@tmlmobilidade/utils 20250821.16.30 → 20250821.54.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { type FeatureCollection, type Geometry } from 'geojson';
|
|
1
|
+
import { type Feature, type FeatureCollection, type Geometry } from 'geojson';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a base GeoJSON feature collection for the given feature type.
|
|
4
4
|
* @returns A base GeoJSON feature collection with an empty features array.
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function getBaseGeoJsonFeature<T extends Geometry, K>(type: T['type'], properties?: K): Feature<T, K>;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a base GeoJSON feature collection for the given feature type.
|
|
9
|
+
* @returns A base GeoJSON feature collection with an empty features array.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getBaseGeoJsonFeatureCollection<T extends Geometry, K>(): FeatureCollection<T, K>;
|
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
* Creates a base GeoJSON feature collection for the given feature type.
|
|
4
4
|
* @returns A base GeoJSON feature collection with an empty features array.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export function getBaseGeoJsonFeature(type, properties) {
|
|
7
|
+
const emptyGeometries = {
|
|
8
|
+
GeometryCollection: { geometries: [], type: 'GeometryCollection' },
|
|
9
|
+
LineString: { coordinates: [], type: 'LineString' },
|
|
10
|
+
MultiLineString: { coordinates: [], type: 'MultiLineString' },
|
|
11
|
+
MultiPoint: { coordinates: [], type: 'MultiPoint' },
|
|
12
|
+
MultiPolygon: { coordinates: [], type: 'MultiPolygon' },
|
|
13
|
+
Point: { coordinates: [0, 0], type: 'Point' },
|
|
14
|
+
Polygon: { coordinates: [], type: 'Polygon' },
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
geometry: emptyGeometries[type],
|
|
18
|
+
properties: (properties ?? {}),
|
|
19
|
+
type: 'Feature',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a base GeoJSON feature collection for the given feature type.
|
|
24
|
+
* @returns A base GeoJSON feature collection with an empty features array.
|
|
25
|
+
*/
|
|
26
|
+
export function getBaseGeoJsonFeatureCollection() {
|
|
7
27
|
return Object.assign({ features: [], type: 'FeatureCollection' });
|
|
8
|
-
}
|
|
28
|
+
}
|
|
29
|
+
;
|
package/package.json
CHANGED