@dra2020/baseclient 1.0.17 → 1.0.18
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.
- package/dist/baseclient.js +15 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +1 -0
- package/lib/geo/geo.ts +15 -0
- package/package.json +1 -1
package/dist/geo/geo.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare type GeoProperties = geojson.GeoJsonProperties;
|
|
|
4
4
|
export declare type GeoFeature = geojson.Feature;
|
|
5
5
|
export declare type GeoFeatureArray = GeoFeature[];
|
|
6
6
|
export declare type GeoFeatureCollection = geojson.FeatureCollection;
|
|
7
|
+
export declare function geoEnsureID(col: GeoFeatureCollection): void;
|
|
7
8
|
export declare function geoCollectionToMap(col: GeoFeatureCollection): GeoFeatureMap;
|
|
8
9
|
export declare function geoMapToCollection(map: GeoFeatureMap): GeoFeatureCollection;
|
|
9
10
|
export declare function geoCollectionToTopo(col: GeoFeatureCollection): Poly.Topo;
|
package/lib/geo/geo.ts
CHANGED
|
@@ -7,6 +7,21 @@ export type GeoFeature = geojson.Feature;
|
|
|
7
7
|
export type GeoFeatureArray = GeoFeature[];
|
|
8
8
|
export type GeoFeatureCollection = geojson.FeatureCollection;
|
|
9
9
|
|
|
10
|
+
export function geoEnsureID(col: GeoFeatureCollection): void
|
|
11
|
+
{
|
|
12
|
+
let prop: string;
|
|
13
|
+
const props = ['id', 'GEOID', 'GEOID10', 'GEOID20', 'GEOID30' ];
|
|
14
|
+
|
|
15
|
+
if (col && col.features && col.features.length > 0)
|
|
16
|
+
{
|
|
17
|
+
let f = col.features[0];
|
|
18
|
+
if (f.properties.id !== undefined) return;
|
|
19
|
+
props.forEach(p => { if (prop === undefined && f.properties[p] !== undefined) prop = p; });
|
|
20
|
+
if (prop)
|
|
21
|
+
col.features.forEach(f => { f.properties.id = f.properties[prop] });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
10
25
|
export function geoCollectionToMap(col: GeoFeatureCollection): GeoFeatureMap
|
|
11
26
|
{
|
|
12
27
|
if (col == null) return null;
|