mapbox / mbtiles-extracts

Extract parts of MBTiles into separate files using a GeoJSON with polygons.
ISC License
51 stars 14 forks source link

Error running mbtiles-extracts #17

Closed citizenfish closed 4 years ago

citizenfish commented 5 years ago
mbtiles-extracts zoomstack.mbtiles portsmouth.json admin

/usr/local/lib/node_modules/mbtiles-extracts/index.js:162
    return name.toLowerCase().replace(/ /g, '_') + '.mbtiles';
                ^

TypeError: Cannot read property 'toLowerCase' of undefined
    at toFileName (/usr/local/lib/node_modules/mbtiles-extracts/index.js:162:17)
    at result.forEach (/usr/local/lib/node_modules/mbtiles-extracts/index.js:64:37)
    at Array.forEach (<anonymous>)
    at Stream.onData (/usr/local/lib/node_modules/mbtiles-extracts/index.js:63:24)
    at Stream.emit (events.js:182:13)
    at drain (/usr/local/lib/node_modules/mbtiles-extracts/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/usr/local/lib/node_modules/mbtiles-extracts/node_modules/through/index.js:45:5)
    at emit (/usr/local/lib/node_modules/mbtiles-extracts/node_modules/split/index.js:37:14)
    at next (/usr/local/lib/node_modules/mbtiles-extracts/node_modules/split/index.js:49:7)
    at Stream.<anonymous> (/usr/local/lib/node_modules/mbtiles-extracts/node_modules/split/index.js:54:5)
jonahadkins commented 5 years ago

hi 👋 seeing the same result as above - I tried running a few previous versions and got the same error, guessing it might be related to a dependency?

EjaYF commented 4 years ago

Try to use the propertyname 'name' e.g.: mbtiles-extracts [path_to_mbtiles] [path_to_geojson] name

I was also facing this problem and debugged the javascript to find out that in the geojson file should look like this:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "NameOfTheArea"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": []
      }
    }
  ]
}

and that the argument 'property name' to give to mbtiles-extracts is in this case NOT "NameOfTheArea", but the identifier : name.

Hope this helps.

citizenfish commented 4 years ago

The fix was to add the attribute "name" to the GEOJSON and use the command specified by @EjaYF