Skip to content
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

add country-coder json [#44] #328

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

add country-coder json [#44] #328

wants to merge 4 commits into from

Conversation

bdon
Copy link
Member

@bdon bdon commented Oct 24, 2024

import org.locationtech.jts.geom.*;
import org.locationtech.jts.index.strtree.STRtree;

public class CountryCoder {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to enhance that to handle (Polygon contains LineString) - looks like Contains only supports Point and Intersects works for all geometries? TBD if it actually matters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that, it seems like country coder should return the country that feature is "most within" so we could sample a few points? Here's the api that prepared geometry exposes when testing geometries: https://locationtech.github.io/jts/javadoc/org/locationtech/jts/geom/prep/PreparedGeometry.html

Copy link

@msbarry
Copy link
Contributor

msbarry commented Oct 24, 2024

FYI I'm planning to add something very similar to planetiler soon to support name abbreviations and other use cases like this: onthegomap/planetiler#14 (comment)

@bdon
Copy link
Member Author

bdon commented Oct 24, 2024

@msbarry great, I could upstream this implementation or merge it with PolygonIndex once it's proven out, unless you see any major things missing? Biggest TBD feels like what happens at boundaries

@msbarry
Copy link
Contributor

msbarry commented Oct 25, 2024

@msbarry great, I could upstream this implementation or merge it with PolygonIndex once it's proven out, unless you see any major things missing? Biggest TBD feels like what happens at boundaries

That would be great! My plan was to eventually have configurable backends that require downloading different data sources (natural earth borders by POV or overture divisions) but the fallback would be to use this country-coder json source bundled in the jar.

@bdon
Copy link
Member Author

bdon commented Oct 25, 2024

There are also some data cleanup needed on the JSON like a separate country code FX for Metropolitan France.
I think country-coder is good enough for Shields since although US states aren't in the JSON the OSM tags may have enough state network information to derive that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants