-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fit names in territorial bounds #21
Comments
I remember reading a reddit post from the eu4 devs on this a while ago. A modified version of ST_LongestLine might be worth looking into as well. |
Aren't these a bit overkill. For example in google maps the names of the countries are always at the middle point. And they are in similar font sizes on different zoom levels. Wouldn't that be easier and familiar. |
@ataalik you right, using same algorithm is an overkill. Simple names on map would be enough. I check google maps and I spot some interesting facts: |
I believe we concluded on the last call that this would be a frontend task? |
It would be difficult to calculate on frontend
|
That's what I thought as well, I'll try and look into a PostGIS solution |
If we want to add labels using mapbox we should serve labels (text) in MVT. |
@MiklerGM could you link a documentation page or example showing how to serve MVT with text? |
@whirish we are serving cities like this already. |
This is how it works on frontend (MVT Style for cities) Backend Line 243 in 467e63f
|
Ah, so it's rendered on the frontend and just the text is returned in the MVT. I thought the text was being rendered on the backend, got it. |
We can automatically fill the visual center by using P625 Coordinate Location or P5140 Coordinates of Geographic Center from wikidata. |
Nice catch, do we want to add a script in microservices to do that? |
We need to do this only once for whole db, I am not sure we need a microservice for that. Probably I would do it as part of admin interface. |
Next query will set the visual center as a centroid of the largest polygon or point on the surface if the centroid is outside of the polygon UPDATE api_spacetimevolume SET visual_center = foo.visual_center FROM (
SELECT *, CASE WHEN ST_Intersects(geom, centroid) IS true THEN centroid ELSE surface END AS visual_center FROM (
SELECT id, geom, ST_Centroid(geom) as centroid, ST_PointOnSurface(geom) as surface FROM (
SELECT id, geom FROM (
SELECT *,
(MAX(ST_Area(geom)) OVER (PARTITION BY id) = ST_Area(geom)) as sqft
FROM (
SELECT id, (ST_Dump(territory)).geom AS geom
FROM api_spacetimevolume
) as foo
) as foo
WHERE sqft = true
) as foo
) as foo
) as foo
WHERE foo.id = api_spacetimevolume.id; |
Added central point to TE. A label is placed based on that point. |
Right now we have a blind map, country names are available only in balloon with mouse on hover.
The more info we get, the bigger and more unusable that balloon will become. One of obvious proposals is to create an MVT layer with country names (like in Europa Universalis or any paper maps). Same naming can be applied later to different admin_level
Reddit post
Describe the algorithm suitable for generating names with similar behavior.
The text was updated successfully, but these errors were encountered: