Skip to content

Commit 7f76267

Browse files
committed
docs(readme): geojson module examples
1 parent 213e8cb commit 7f76267

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,43 @@ const { s2 } = require('s2js')
3434
</script>
3535
```
3636

37+
### GeoJSON support
38+
39+
The supplementary `geojson` module provides convenience functions for working with GeoJSON data in S2:
40+
41+
```js
42+
import { geojson } from 's2js'
43+
44+
const s2Polyline = geojson.fromGeoJSON({
45+
type: 'LineString',
46+
coordinates: [
47+
[102.0, 0.0],
48+
[103.0, 1.0],
49+
[104.0, 0.0],
50+
[105.0, 1.0]
51+
]
52+
})
53+
```
54+
55+
The `RegionCoverer` supports all geometry types including multi-geometries:
56+
57+
```js
58+
const coverer = new geojson.RegionCoverer({ maxCells: 30 })
59+
60+
const union = coverer.covering({
61+
type: 'Polygon',
62+
coordinates: [
63+
[
64+
[100.0, 0.0],
65+
[101.0, 0.0],
66+
[101.0, 1.0],
67+
[100.0, 1.0],
68+
[100.0, 0.0]
69+
]
70+
]
71+
})
72+
```
73+
3774
### Contributing
3875

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

0 commit comments

Comments
 (0)