Select to view content in your preferred language

Dealing with presentation of shapes crossing antimeridian

213
0
05-18-2024 07:51 AM
Labels (3)
MarcHillman
Occasional Contributor

I have a rectangle drawn around Fiji. It crosses the antimeridian. I have successfully used NormalizeCentralMeridian to split it into 2 separate polygons. When I render it (in KML) I naturally end up with 2 vertical edges along the antimeridian. This is not very aesthetically pleasing. I think it would look nicer with the 2 central vertical lines missing.

I've been thinking about how to achieve this. I wish them to remain polygons so I can fill them. Of note, when you render a polygon to KML, it does not need to be a closed polygon. In my situation I have deliberately closed them as I wish to have a continuous boundary. So why not just not close the polygon? Well, if I don't close I only have a 1 in 4 chance of removing the correct line. It would be easy to convert to a linestring, and just leave the vertical lines out, but then I lose the ability to fill the polygon, and click on it for a popup.

The only approach I can think of is to remove a segment from the polygon, and not close it. Trouble is, the removed segment has to be at either the start or the end of the ring. This means I have to 'rotate' the polygon ring until the segment with the vertical element is either at the start or the end of the ring.

Is this a sensible algorithm, or is there a better way? Anyone done this and got a code snippet?

 

fiji.jpg

0 Replies