Skip to content

Commit

Permalink
docs(readme): geojson module examples
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Sep 24, 2024
1 parent 213e8cb commit da6296e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,45 @@ const { s2 } = require('s2js')
</script>
```

### GeoJSON support

The supplementary `geojson` module provides convenience functions for working with GeoJSON data in S2:

```js
import { geojson } from 's2js'

const s2Polyline = geojson.fromGeoJSON({
type: 'LineString',
coordinates: [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
})
```

The `geojson.RegionCoverer` class supports all geometry types including multi-geometries:

```js
import { geojson } from 's2js'

const coverer = new geojson.RegionCoverer({ maxCells: 30 })

const union = coverer.covering({
type: 'Polygon',
coordinates: [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
})
```

### Contributing

If you'd like to contribute a module please open an Issue to discuss.
Expand Down

0 comments on commit da6296e

Please sign in to comment.