Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Can anyone point me to a C++ class for representing coordinates that automatically handles projection transforms? What I'm thinking of is something that would allow me to create vars that incorporate a projection and have appropriate geographic operators such that comparisons make sense even when the coordinates are in different projections. Using template notation (though I can't figure out how to template on a projection)

Coord < SRID:1234> point1 (x1, y1); Coord < SRID:5678> point2 (x2, y2);

if (point1.east(point2)) ... // true if point1 is east of point2


point2 = point1 // This operation assigns the coordinates of point1 to point2, 
using the coordinate system of point2 (in this case SRID::5678).
share|improve this question
add comment

2 Answers

Try to look at Proj.4 library.

You can reproject you points to common coordinate system and then perform the comparison.

Try to create some wrapper class that will perform automate reprojection to common CS and then compare coordinates.

share|improve this answer
Not to be overly critical, but this answer is not useful at all. The whole point this question asks is how to write the wrapper class in a clever way. I'm already familiar with the Proj.4 library. The question is how to create a clean C++ wrapper, or better yet, find someone who also already done it. –  Llaves May 16 '12 at 15:44
add comment

If you want to support comparing points on different datums you have a lot of work ahead; there are often multiple "paths" between datums and it is often the case that the correct path is context dependent.

That being said, CS-MAP (C API) will do its best to pick a path between datums - if you aren't picky it will probably do something acceptable.

And many CS-MAP coordinate systems are tagged with EPSG #s, so you could look up the name associated with a given number.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.