|
Geometry : |
Subject: [geometry] Polygons that cross the international date line
From: Jeremy Fergason (jeremy.fergason_at_[hidden])
Date: 2016-12-17 11:59:33
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
https://polymail.io/
Geometry list run by mateusz at loskot.net