0.1.4 • Published 7 years ago

geojson-filter v0.1.4

Weekly downloads
12
License
ISC
Repository
github
Last release
7 years ago

geojson-filter

Return a new GeoJson only whit features which pass the filter, this library is a tiny wrapper around feature-filter-geojson.

Go to feature-filter-geojson for complete doc about filter array possibilities.

usage

const gjfilter = require('geojson-filter');

const filter = ["==", "prop0", "value0"];

let geojson = { "type": "FeatureCollection",
    "features": [
      { "type": "Feature",
        "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
            "properties": {
            "prop0": "value0"
        }
        },
      { "type": "Feature",
        "geometry": {
          "type": "LineString",
          "coordinates": [
            [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
            ]
          },
        "properties": {
          "prop0": "value0",
          "prop1": 0.0
          }
        },
      { "type": "Feature",
         "geometry": {
           "type": "Polygon",
           "coordinates": [
             [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
               [100.0, 1.0], [100.0, 0.0] ]
             ]
         },
         "properties": {
           "prop0": "value1",
           "prop1": {"this": "that"}
           }
         }
       ]
     };

console.log(JSON.stringify(gjfilter(geojson, filter)));

The output is:

{ "type": "FeatureCollection",
    "features": [
      { "type": "Feature",
        "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
            "properties": {
            "prop0": "value0"
        }
        },
      { "type": "Feature",
        "geometry": {
          "type": "LineString",
          "coordinates": [
            [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
            ]
          },
        "properties": {
          "prop0": "value0",
          "prop1": 0.0
          }
        }
       ]
     }
0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago