Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid -> Invalid polygons can occur #6

Open
andrewharvey opened this issue Feb 9, 2019 · 1 comment
Open

Valid -> Invalid polygons can occur #6

andrewharvey opened this issue Feb 9, 2019 · 1 comment

Comments

@andrewharvey
Copy link
Contributor

reducing coordinate precision of all coordinates in a polygon can unwittingly create invalid polygons. I'm not sure if it's the place of this program to care about that but it would be nice if no invalid polygons were written out.

@jonjardine
Copy link

Very useful tool, however as mentioned above invalid polygons can be produced, where two points become identical due to the rounding / clipping process. MySQL's geometry calculations will report invalid polygons in these cases.

An example is below:

{
   "type":"Feature",
   "properties":{
      "gml_id":"SSSI_SCOTLAND.902",
      "NAME":"Ness of Cullivoe",
      "PA_CODE":1217,
      "STATUS":"Current",
      "SITE_HA":10.36,
      "TYPE":"GEOLOGICAL",
      "MPA_NET":"N",
      "GEO_LOC":"MIXED"
   },
   "geometry":{
      "type":"Polygon",
      "coordinates":[
         [
            [
               -0.994949049275153,
               60.702545894931433
            ],
            [
               -0.994947414191508,
               60.7025395884272
            ],
            [
               -0.994951217317521,
               60.7025351274714
            ],
            [
               -0.99496215976439,
               60.70253611639918
            ],
            [
               -0.994969392320168,
               60.702539753233921
            ],
            [
               -0.994969280238507,
               60.702543343972998
            ],
            [
               -0.994959982580452,
               60.7025477637278
            ],
            [
               -0.994949049275153,
               60.702545894931433
            ]
         ]
      ]
   }
}

After conversion to 5 decimal places, this produces:

{
      "type":"Feature",
      "properties":{
         "STATUS":"Current",
         "NAME":"Ness of Cullivoe",
         "TYPE":"GEOLOGICAL",
         "SITE_HA":10.36,I'v
         "gml_id":"SSSI_SCOTLAND.902",
         "MPA_NET":"N",
         "GEO_LOC":"MIXED",
         "PA_CODE":1217
      }
   },
   {
      "geometry":{
         "type":"Polygon",
         "coordinates":[
            [
               [
                  -0.99465,
                  60.7026
               ],
               [
                  -0.99467,
                  60.70259
               ],
               [
                  -0.99468,
                  60.70259
               ],
               [
                  -0.99468,
                  60.70259
               ],
               [
                  -0.99466,
                  60.7026
               ],
               [
                  -0.99465,
                  60.7026
               ]
            ]
         ]
      }
    }

The third and fourth points are now identical.

A potentially valid solution would simply be to drop any additional points with the same coordinates when forming the final polygons, although this of course would require additional logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants