mapbox / geojsonhint

IMPORTANT: This repo will be archived. Use @placemarkio/check-geojson instead
ISC License
258 stars 37 forks source link

Right hand rule for polygons + outdated NPM #82

Closed oyvindi closed 3 years ago

oyvindi commented 3 years ago

The current version is not handling RHR correctly, but seems like @rurban made a fix (see #81)

According to RFC 7946, exterior rings are counter-clockwise, and opposite for interiors.

Would be nice to have this merged to master, and publish a new NPM (the latest version there is 2.0.0)

Here is a sample MultiPolygon that should be correct, but fails validation:

{
  "type":"MultiPolygon",
  "coordinates":[
    [
      [
        [
          -149.92383493947585,
          -107.20901451037372
        ],
        [
          -259.59381502763006,
          -109.20301414834012
        ],
        [
          -258.2644819356524,
          -134.460342895915
        ],
        [
          -203.09715861858095,
          -141.77167490179193
        ],
        [
          -140.61850329563254,
          -125.81967779806041
        ],
        [
          -149.92383493947585,
          -107.20901451037372
        ]
      ],
      [
        [
          -254.4534848633285,
          -128.68537469897
        ],
        [
          -252.63985750747375,
          -113.16878509887954
        ],
        [
          -241.1746460656409,
          -113.77221728002854
        ],
        [
          -239.54032744438703,
          -128.88966452662675
        ],
        [
          -254.4534848633285,
          -128.68537469897
        ]
      ],
      [
        [
          -211.55262105541485,
          -114.18079693534207
        ],
        [
          -198.47807208538396,
          -125.41673745646227
        ],
        [
          -222.17569209356486,
          -126.02960693943254
        ],
        [
          -211.55262105541485,
          -114.18079693534207
        ]
      ]
    ],
    [
      [
        [
          -217.05515608434595,
          -92.58635049861982
        ],
        [
          -241.64781828593203,
          -65.33502211307837
        ],
        [
          -263.58181430356285,
          -92.58635049861982
        ],
        [
          -217.05515608434595,
          -92.58635049861982
        ]
      ]
    ],
    [
      [
        [
          -154.57650076139757,
          -62.01168938313447
        ],
        [
          -190.46849424479345,
          -62.67635592912325
        ],
        [
          -190.46849424479345,
          -92.58635049861982
        ],
        [
          -150.58850148546466,
          -95.24501668257506
        ],
        [
          -154.57650076139757,
          -62.01168938313447
        ]
      ],
      [
        [
          -183.15633501112902,
          -68.82845519554763
        ],
        [
          -161.2973234518588,
          -68.82845519554763
        ],
        [
          -160.48016414123182,
          -87.2145396846534
        ],
        [
          -183.36062483878575,
          -87.2145396846534
        ],
        [
          -183.15633501112902,
          -68.82845519554763
        ]
      ]
    ]
  ]
}
sgillies commented 3 years ago

@oyvindi confirmed. Thanks for the example. I will add it to the test suite.