Skip to content

Given latitude and longitude, how to find in what country those coordinates are? #233

@clzola

Description

@clzola

This is more of a question as I need help to figure out...

So as ti title says:

Given latitude and longitude, how to find in what country those coordinates are?

I have geojson file with country borders. Each country is represented with either Polygon or MultiPolygon. If I understand correctly, those coordinates that are inside geojson file are longitude and latitude in EPSG:4236 CRS. Because of that I cannot just check relation between Point (longitude, latitude) and Polygon because it might give error because operation/methods from this library and JTS does not take into account curvature of earth.

So my idea is first to convert all geometries from EPSG:4326 to Google Mercator, and then convert given longitude and latitude, and finally perform contains and intersect operations?

Am I on the right way? Or can I directly use geometries without transformation from one CRS to another (I am willing to tolerate some error, like some near border cases)?

Also for the optimization purposes, I would build quad tree and boundary box checks...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions