-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: main
Are you sure you want to change the base?
Conversation
import org.locationtech.jts.geom.*; | ||
import org.locationtech.jts.index.strtree.STRtree; | ||
|
||
public class CountryCoder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use Planetiler's PolygonIndex
, see https://github.com/onthegomap/planetiler/blob/f5fe38a4d4400f3aa30998a1eb3ac551ce3e47d9/planetiler-core/src/main/java/com/onthegomap/planetiler/geo/PolygonIndex.java#L20, cc @msbarry
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Quality Gate passedIssues Measures |
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) |
@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. |
There are also some data cleanup needed on the JSON like a separate country code FX for Metropolitan France. |
@wipfli @nvkelso