Polygons that cross the international date line

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Polygons that cross the international date line

Jeremy Fergason
All,

I am trying to figure out how to handle polygons that cross the international date line.  Take, for example:

POLYGON((90 45,-90 45,-90 -45,90 -45,90 45))

This is a valid polygon using the EPSG:4326 projection, however boost views it as invalid.  The way to make it valid
would be to produce a multi-polygon the splits across the singularity.

MULTIPOLYGON(((180 45,180 -45,90 -45,90 45,180 45)),((-180 45,-90 45,-90 -45,-180 -45,-180 45)))

Right now I have an algorithm that takes the first polygon and checks if any line segments cross the international date line.  If there are, it then mirrors any x-coordinates that are negative by adding 360.  This makes the polygon valid.  Next I create two intersection polygons and intersect my mirrored polygon with them.  I take the results and mirror the results back by checking if a coordinate is greater than 180 and subtracting 360 if it is.  Then I form the above multi-polygon.

This works if the maximum x-extent of the polygon is less than 180 degrees.

Does anyone have any advice on a possibly simpler solution?  Would there be interest in putting this algorithm into the boost::geometry core package?

Thanks!

Jeremy Fergason
Sent from Polymail

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Loading...