Reputation: 14081
I am looking for a free geo data class library. I need to convert different formats of Latitude / Longitude values (e.g as here), get distances between lat/lng values, coordinates in range, etc.
Google shows me several single methods / functions in C++, this is not the issue. Examples
What I am looking for is a more complete / sophisticated class library with some documentation and examples. Any hints?
-- Edit --
LatLong is such a library in Javascript: http://www.movable-type.co.uk/scripts/latlong.html
Will also check (C++): http://geographiclib.sourceforge.net/html/annotated.html
-- Edit 2 --
The transformation approach below is a good starter, however, if there are other great libs please let me know. Thanks to all who have contributed.
Upvotes: 7
Views: 7303
Reputation: 10756
proj4 is what you're looking for. It's a serious mapping tool, mature and well respected projection api. It's predominantly popular for doing forward and backward conversion between geographical coordinates (lat/lng) and planar (x,y). Coordinate geometry with planar coordinates is much simpler than with geographical.
Documentation is not the best. Because it can also be used as a stand-alone program, I'd start off reading the man page to get an introduction. The command-line switches are the same parameters used to initialise the structure when using the api. Then read the api docs - the function calls listed under Basic API functions may very well be all you need.
Edit with what started off as a comment to OP: Projecting to planar coordinates is attractive for many reasons: Coordinate comparisons are then in linear units rather than angular. Distance becomes a trivial hypotenuse calculation. Axis-aligned rectangles are intuitive to work with. Elementary right-angled trigonometry can be used to calculate new points, e.g. midway, offset, etc. This is all provided the extents of the region is not massive, e.g. of continental scale - If your dataset is within say a degree square (that's still large) you'll be fine with this approach.
Upvotes: 7