-
Notifications
You must be signed in to change notification settings - Fork 687
Expand file tree
/
Copy pathgeoUtils.js
More file actions
26 lines (21 loc) · 808 Bytes
/
geoUtils.js
File metadata and controls
26 lines (21 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import turfHelpers from '@turf/helpers';
export function makePoint(coordinates, properties) {
return turfHelpers.point(coordinates, properties);
}
export function makeLatLngBounds(northEastCoordinates, southWestCoordinates) {
return turfHelpers.featureCollection([
turfHelpers.point(northEastCoordinates),
turfHelpers.point(southWestCoordinates),
]);
}
export function makeFeature(geometry, properties) {
return turfHelpers.feature(geometry, properties);
}
export function makeFeatureCollection(features = []) {
return turfHelpers.featureCollection(features);
}
export function addToFeatureCollection(featureCollection, feature) {
const shallowFeatureCollection = Object.assign({}, featureCollection);
shallowFeatureCollection.features.push(feature);
return featureCollection;
}