开发者

Compute differences between Point2D<UCS> and Point2D<GCS>

This is related to the a thread that was posted earlier in this forum.

What are some recommended frameworks for manipulating spatial data in C++?

Do you know of a geometry library that offer generics-based compile-time protection from mixing UCS and GCS coordinates? For example, I'm looking for something that allows me to write code like this:

Point2D<GCS> p1( 1.0, 1.0 );
Point2D<UCS> p2( 1.0, 1.0 );
std::cout << (开发者_StackOverflow社区p1 - p2) << std::endl; // compile-time error: mixing types!

I don't need protection from mixing different UCS's, only mixing GCS and a UCS. Mixing local and global coordinate systems is a completely avoidable error that can be eliminated with proper book-keeping, which should be simplified using C++'s strong type-checking and support of generics. I'd rather use an existing library than re-invent the wheel.


You can write a function to convert UCS to GCS. Then you can perform std::cout<<(p1-p2)<<"\n; when both of them are in GCS.

Then, there will will be no compiler error due to mixing types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜