max-mapper / geojson-js-utils

JavaScript helper functions for manipulating GeoJSON
BSD 2-Clause "Simplified" License
402 stars 58 forks source link

pointInPolygon crashes on MultiPolygon with no positions #37

Closed tmcw closed 7 years ago

tmcw commented 7 years ago

Including this valid but unusual feature in a FeatureCollection will lead to a crash in geojson-js-utils at https://github.com/maxogden/geojson-js-utils/blob/master/geojson-utils.js#L55 because the code assumes that rings will have positions, but that isn't guaranteed by the GeoJSON specification.

{
  "type": "Feature",
  "id": "4a1a777ddffb28ed6caabd67eabf49bef002bf82",
  "properties": {
    "fill": "#483D8B",
    "fill-opacity": 0.9,
    "stroke": "#000000",
    "stroke-width": 2,
    "stroke-opacity": 0.9,
    "headline": "Winter Weather Advisory issued November 20 at 5:18PM EST until November 21 at 4:00AM EST by NWS Pittsburgh"
  },
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [
      []
    ]
  }
}
tmcw commented 7 years ago

Closing; happy to contribute a fix or even offer maintainership, but otherwise pruning quiet tickets.

Wotuu commented 6 years ago

I just ran into this issue as well. It's still there, for when a maintainer wants to accept this fix.