mapbox / geojsonhint

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

Geometry null #52

Closed fxi closed 8 years ago

fxi commented 8 years ago

Hi,

"geometry: null" should be listed as an error. Turf ( or Mapbox gl) are throwing an error with this.

Thanks !

Maybe something like this :

        if (geom === null) {
            errors.push({
                message: 'geometry could not be null',
                line: geom.__line__
            });
        }

This will fail:

{
  "type": "FeatureCollection",
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
    }
  },
  "features": [
    {
      "type": "Feature",
      "properties": {
        "Label": "Tertiary"
      },
      "geometry": null
    },
    {
      "type": "Feature",
      "properties": {
        "Label": "Secondary"
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            66.599966,
            36.997548
          ],
          [
            66.603196,
            36.99737
          ],
          [
            66.607052,
            36.997655
          ]
        ]
      }
    }
  ]
}
sgillies commented 8 years ago

@fxi "geometry": null means the feature is unlocated and is valid GeoJSON: https://tools.ietf.org/html/rfc7946#section-3.2. It could be useful to print a message that notes a feature is unlocated, but this is not exactly a data error.

@tmcw @perrygeo can geojsonhint print a non-error message?

fxi commented 8 years ago

Thanks for your quick reply !

You are right and I should have checked this before posting something.

Moreover, my example works well in mapbox gl.

http://jsbin.com/dehalawuhe/edit?html,output

Thanks again !

tmcw commented 8 years ago

@fxi can you replicate this error in both mapbox-gl-js and turf? Can you be more specific about both? mapbox-gl-js's GeoJSON processing infrastructure already has a test confirming null geometry support, so it should be able to handle null geometries correctly.

fxi commented 8 years ago

@tmcw Thanks, but I was on the wrong track with the null values, I'm sorry. Both mapbox-gl-js and turf seems to handle this well. I've removed the null geometry but I still get an error when adding a specific file as source in mapbox-gl-js. For your information, I'm trying to do a small experiment with mapbox-gl-js: an app with multiple large files, drag and drop functionality: http://bl.ocks.org/fxi/b7f1af5981432296bfafec70a95fd9b6. And naturally, there is surprises everywhere, this is why I put aside my crystal ball and looked for a smart tool like geojsonhint to do the validation job. But it's maybe not a validation thing, after all.