@basemaps/cli-vector 8.0.0 → 8.2.0
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/build/bin.js +2 -2
- package/build/cli/cli.analyse.d.ts +34 -0
- package/build/cli/cli.analyse.js +152 -0
- package/build/cli/cli.analyse.js.map +1 -0
- package/build/cli/cli.create.d.ts +39 -0
- package/build/cli/cli.create.js +207 -0
- package/build/cli/cli.create.js.map +1 -0
- package/build/cli/cli.extract.d.ts +8 -17
- package/build/cli/cli.extract.js +43 -33
- package/build/cli/cli.extract.js.map +1 -1
- package/build/cli/cli.join.d.ts +44 -0
- package/build/cli/cli.join.js +149 -0
- package/build/cli/cli.join.js.map +1 -0
- package/build/extract.js.map +1 -0
- package/build/generalization/generalization.d.ts +9 -0
- package/build/generalization/generalization.js +159 -0
- package/build/generalization/generalization.js.map +1 -0
- package/build/generalization/simplify.d.ts +2 -0
- package/build/generalization/simplify.js +80 -0
- package/build/generalization/simplify.js.map +1 -0
- package/build/index.d.ts +83 -5
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/modify/consts.d.ts +1 -0
- package/build/modify/consts.js +23 -0
- package/build/modify/consts.js.map +1 -0
- package/build/modify/layers/__test__/contours.test.d.ts +1 -0
- package/build/modify/layers/__test__/contours.test.js +59 -0
- package/build/modify/layers/__test__/contours.test.js.map +1 -0
- package/build/modify/layers/contours.d.ts +28 -0
- package/build/modify/layers/contours.js +90 -0
- package/build/modify/layers/contours.js.map +1 -0
- package/build/modify/layers/place_labels.d.ts +18 -0
- package/build/modify/layers/place_labels.js +122 -0
- package/build/modify/layers/place_labels.js.map +1 -0
- package/build/modify/layers/pois.d.ts +11 -0
- package/build/modify/layers/pois.js +27 -0
- package/build/modify/layers/pois.js.map +1 -0
- package/build/modify/layers/public_transport.d.ts +12 -0
- package/build/modify/layers/public_transport.js +53 -0
- package/build/modify/layers/public_transport.js.map +1 -0
- package/build/modify/layers/street_labels.d.ts +12 -0
- package/build/modify/layers/street_labels.js +34 -0
- package/build/modify/layers/street_labels.js.map +1 -0
- package/build/modify/layers/streets.d.ts +12 -0
- package/build/modify/layers/streets.js +72 -0
- package/build/modify/layers/streets.js.map +1 -0
- package/build/modify/layers/water_polygons.d.ts +13 -0
- package/build/modify/layers/water_polygons.js +85 -0
- package/build/modify/layers/water_polygons.js.map +1 -0
- package/build/modify/modify.d.ts +11 -0
- package/build/modify/modify.js +48 -0
- package/build/modify/modify.js.map +1 -0
- package/build/modify/parser.d.ts +47 -0
- package/build/modify/parser.js +24 -0
- package/build/modify/parser.js.map +1 -0
- package/build/modify/schema.d.ts +17 -0
- package/build/modify/schema.js +2 -0
- package/build/modify/schema.js.map +1 -0
- package/build/modify/shared.d.ts +4 -0
- package/build/modify/shared.js +38 -0
- package/build/modify/shared.js.map +1 -0
- package/build/schema-loader/parser.d.ts +8 -0
- package/build/schema-loader/parser.js +1 -0
- package/build/schema-loader/parser.js.map +1 -1
- package/build/schema-loader/schema.d.ts +19 -5
- package/build/schema-loader/schema.loader.js +10 -5
- package/build/schema-loader/schema.loader.js.map +1 -1
- package/build/stac.d.ts +41 -0
- package/build/stac.js +185 -0
- package/build/stac.js.map +1 -0
- package/build/transform/covt.d.ts +5 -0
- package/build/transform/covt.js +23 -0
- package/build/transform/covt.js.map +1 -0
- package/build/transform/mbtiles.to.ttiles.d.ts +14 -0
- package/build/transform/mbtiles.to.ttiles.js +60 -0
- package/build/transform/mbtiles.to.ttiles.js.map +1 -0
- package/build/transform/ogr2ogr.d.ts +7 -0
- package/build/transform/ogr2ogr.js +20 -0
- package/build/transform/ogr2ogr.js.map +1 -0
- package/build/transform/tippecanoe.d.ts +14 -0
- package/build/transform/tippecanoe.js +68 -0
- package/build/transform/tippecanoe.js.map +1 -0
- package/build/types/VectorGeoFeature.d.ts +9 -0
- package/build/types/VectorGeoFeature.js +2 -0
- package/build/types/VectorGeoFeature.js.map +1 -0
- package/build/util.d.ts +35 -0
- package/build/util.js +43 -0
- package/build/util.js.map +1 -0
- package/dist/index.cjs +20753 -9551
- package/package.json +23 -8
- package/build/extract/extract.js.map +0 -1
- /package/build/{extract/extract.d.ts → extract.d.ts} +0 -0
- /package/build/{extract/extract.js → extract.js} +0 -0
package/build/index.d.ts
CHANGED
|
@@ -1,29 +1,107 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const VectorCli: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
|
|
2
2
|
parse(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
|
|
3
|
+
command: "join";
|
|
4
|
+
args: {
|
|
5
|
+
fromFile: URL[];
|
|
6
|
+
filename: string;
|
|
7
|
+
tileMatrix: string;
|
|
8
|
+
title: string;
|
|
9
|
+
target: URL | undefined;
|
|
10
|
+
verbose: boolean;
|
|
11
|
+
extraVerbose: boolean;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
3
14
|
command: "extract";
|
|
4
15
|
args: {
|
|
5
|
-
|
|
16
|
+
schema: URL;
|
|
6
17
|
cache: string;
|
|
7
|
-
|
|
18
|
+
tileMatrix: string;
|
|
19
|
+
verbose: boolean;
|
|
20
|
+
extraVerbose: boolean;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
command: "create";
|
|
24
|
+
args: {
|
|
25
|
+
path: URL[];
|
|
26
|
+
fromFile: URL[] | undefined;
|
|
27
|
+
concurrency: number;
|
|
28
|
+
join: boolean;
|
|
29
|
+
verbose: boolean;
|
|
30
|
+
extraVerbose: boolean;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
command: "analyse";
|
|
34
|
+
args: {
|
|
35
|
+
path: URL;
|
|
36
|
+
template: string;
|
|
37
|
+
target: URL;
|
|
8
38
|
verbose: boolean;
|
|
9
39
|
extraVerbose: boolean;
|
|
10
40
|
};
|
|
11
41
|
}>>;
|
|
12
42
|
} & import("cmd-ts/dist/cjs/helpdoc.js").Named & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Descriptive & import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/helpdoc.js").PrintHelp & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/argparser.js").Register & import("cmd-ts/dist/cjs/runner.js").Handling<{
|
|
43
|
+
command: "join";
|
|
44
|
+
args: {
|
|
45
|
+
fromFile: URL[];
|
|
46
|
+
filename: string;
|
|
47
|
+
tileMatrix: string;
|
|
48
|
+
title: string;
|
|
49
|
+
target: URL | undefined;
|
|
50
|
+
verbose: boolean;
|
|
51
|
+
extraVerbose: boolean;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
13
54
|
command: "extract";
|
|
14
55
|
args: {
|
|
15
|
-
|
|
56
|
+
schema: URL;
|
|
16
57
|
cache: string;
|
|
17
|
-
|
|
58
|
+
tileMatrix: string;
|
|
59
|
+
verbose: boolean;
|
|
60
|
+
extraVerbose: boolean;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
command: "create";
|
|
64
|
+
args: {
|
|
65
|
+
path: URL[];
|
|
66
|
+
fromFile: URL[] | undefined;
|
|
67
|
+
concurrency: number;
|
|
68
|
+
join: boolean;
|
|
69
|
+
verbose: boolean;
|
|
70
|
+
extraVerbose: boolean;
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
command: "analyse";
|
|
74
|
+
args: {
|
|
75
|
+
path: URL;
|
|
76
|
+
template: string;
|
|
77
|
+
target: URL;
|
|
18
78
|
verbose: boolean;
|
|
19
79
|
extraVerbose: boolean;
|
|
20
80
|
};
|
|
21
81
|
}, {
|
|
82
|
+
command: "join";
|
|
83
|
+
value: Promise<void>;
|
|
84
|
+
} | {
|
|
22
85
|
command: "extract";
|
|
23
86
|
value: Promise<void>;
|
|
87
|
+
} | {
|
|
88
|
+
command: "create";
|
|
89
|
+
value: Promise<void>;
|
|
90
|
+
} | {
|
|
91
|
+
command: "analyse";
|
|
92
|
+
value: Promise<void>;
|
|
24
93
|
}> & {
|
|
25
94
|
run(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
|
|
95
|
+
command: "join";
|
|
96
|
+
value: Promise<void>;
|
|
97
|
+
} | {
|
|
26
98
|
command: "extract";
|
|
27
99
|
value: Promise<void>;
|
|
100
|
+
} | {
|
|
101
|
+
command: "create";
|
|
102
|
+
value: Promise<void>;
|
|
103
|
+
} | {
|
|
104
|
+
command: "analyse";
|
|
105
|
+
value: Promise<void>;
|
|
28
106
|
}>>;
|
|
29
107
|
};
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// eslint-disable-next-line simple-import-sort/imports
|
|
2
2
|
import { subcommands } from 'cmd-ts';
|
|
3
3
|
import { ExtractCommand } from './cli/cli.extract.js';
|
|
4
|
-
|
|
4
|
+
import { CreateCommand } from './cli/cli.create.js';
|
|
5
|
+
import { JoinCommand } from './cli/cli.join.js';
|
|
6
|
+
import { AnalyseCommand } from './cli/cli.analyse.js';
|
|
7
|
+
export const VectorCli = subcommands({
|
|
5
8
|
name: 'vector',
|
|
6
9
|
cmds: {
|
|
7
10
|
extract: ExtractCommand,
|
|
11
|
+
create: CreateCommand,
|
|
12
|
+
join: JoinCommand,
|
|
13
|
+
analyse: AnalyseCommand,
|
|
8
14
|
},
|
|
9
15
|
});
|
|
10
16
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;IACnC,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE;QACJ,OAAO,EAAE,cAAc;KACxB;CACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;IACnC,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE;QACJ,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;KACxB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MajorHighWays: Readonly<Set<string>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const MajorHighWays = new Set([
|
|
2
|
+
'1',
|
|
3
|
+
'1B',
|
|
4
|
+
'2',
|
|
5
|
+
'3',
|
|
6
|
+
'3A',
|
|
7
|
+
'4',
|
|
8
|
+
'5',
|
|
9
|
+
'6',
|
|
10
|
+
'6A',
|
|
11
|
+
'7',
|
|
12
|
+
'8',
|
|
13
|
+
'8A',
|
|
14
|
+
'18',
|
|
15
|
+
'20',
|
|
16
|
+
'51',
|
|
17
|
+
'76',
|
|
18
|
+
'73',
|
|
19
|
+
'1,3',
|
|
20
|
+
'6,94',
|
|
21
|
+
'6,96',
|
|
22
|
+
]);
|
|
23
|
+
//# sourceMappingURL=consts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/modify/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAA0B,IAAI,GAAG,CAAC;IAC1D,GAAG;IACH,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;CACP,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { strictEqual } from 'assert';
|
|
4
|
+
import { handleKindContours, handleKindPeak } from '../contours.js';
|
|
5
|
+
describe('HandleLayerContours', () => {
|
|
6
|
+
const Logger = LogConfig.get();
|
|
7
|
+
const FakeFeature = {
|
|
8
|
+
type: 'Feature',
|
|
9
|
+
properties: {},
|
|
10
|
+
tippecanoe: {
|
|
11
|
+
layer: 'contours',
|
|
12
|
+
minzoom: -1,
|
|
13
|
+
maxzoom: -1,
|
|
14
|
+
},
|
|
15
|
+
geometry: {
|
|
16
|
+
type: 'MultiLineString',
|
|
17
|
+
coordinates: [
|
|
18
|
+
[
|
|
19
|
+
[-1, -1, -1],
|
|
20
|
+
[-1, -1, -1],
|
|
21
|
+
],
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
describe('handleKindContours', () => {
|
|
26
|
+
it('should assign a feature a type of index', () => {
|
|
27
|
+
const feature = structuredClone(FakeFeature);
|
|
28
|
+
feature.properties['elevation'] = 100;
|
|
29
|
+
const modifiedFeature = handleKindContours(feature, Logger);
|
|
30
|
+
strictEqual(modifiedFeature.properties['type'], 'index');
|
|
31
|
+
strictEqual(modifiedFeature.tippecanoe.minzoom, FakeFeature.tippecanoe.minzoom);
|
|
32
|
+
});
|
|
33
|
+
it("should override a feature's minzoom, but not assign it a type", () => {
|
|
34
|
+
const feature = structuredClone(FakeFeature);
|
|
35
|
+
feature.properties['elevation'] = 105;
|
|
36
|
+
const modifiedFeature = handleKindContours(feature, Logger);
|
|
37
|
+
strictEqual(modifiedFeature.properties['type'], undefined);
|
|
38
|
+
strictEqual(modifiedFeature.tippecanoe.minzoom, 14);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('handleKindPeak', () => {
|
|
42
|
+
it('should assign a feature a rank from 1-5', () => {
|
|
43
|
+
const cases = [
|
|
44
|
+
{ elevation: 2000, rank: 1 },
|
|
45
|
+
{ elevation: 1500, rank: 2 },
|
|
46
|
+
{ elevation: 1000, rank: 3 },
|
|
47
|
+
{ elevation: 500, rank: 4 },
|
|
48
|
+
{ elevation: 0, rank: 5 },
|
|
49
|
+
];
|
|
50
|
+
for (const { elevation, rank } of cases) {
|
|
51
|
+
const feature = structuredClone(FakeFeature);
|
|
52
|
+
feature.properties['elevation'] = elevation;
|
|
53
|
+
const modifiedFeature = handleKindPeak(feature, Logger);
|
|
54
|
+
strictEqual(modifiedFeature.properties['rank'], rank);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=contours.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contours.test.js","sourceRoot":"","sources":["../../../../src/modify/layers/__test__/contours.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpE,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,MAAM,GAAG,SAAS,CAAC,GA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AAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACjD,MAAM,KAAK,GAAG;gBACZ,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE;gBAC5B,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE;gBAC5B,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE;gBAC5B,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE;gBAC3B,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;aAC1B,CAAC;YAEF,KAAK,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;gBACxC,MAAM,OAAO,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;gBAC7C,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;gBAE5C,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAExD,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LogType } from '@basemaps/shared';
|
|
2
|
+
import { VectorCreationOptions } from '../../stac.js';
|
|
3
|
+
import { VectorGeoFeature } from '../../types/VectorGeoFeature.js';
|
|
4
|
+
/**
|
|
5
|
+
* Processes a 'contours' layer feature.
|
|
6
|
+
*
|
|
7
|
+
* @param feature - the feature to process
|
|
8
|
+
* @param options - the layer's options
|
|
9
|
+
* @param logger - a logger instance
|
|
10
|
+
* @returns the processed feature
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleLayerContours(feature: VectorGeoFeature, options: VectorCreationOptions, logger: LogType): VectorGeoFeature;
|
|
13
|
+
/**
|
|
14
|
+
* Processes a 'contours' layer feature with a 'kind' value of 'contours'.
|
|
15
|
+
*
|
|
16
|
+
* @param feature - the feature to process
|
|
17
|
+
* @param logger - a logger instance
|
|
18
|
+
* @returns the processed feature
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleKindContours(feature: VectorGeoFeature, logger: LogType): VectorGeoFeature;
|
|
21
|
+
/**
|
|
22
|
+
* Processes a 'contours' layer feature with a 'kind' value of 'peak'.
|
|
23
|
+
*
|
|
24
|
+
* @param feature - the feature to process
|
|
25
|
+
* @param logger - a logger instance
|
|
26
|
+
* @returns the processed feature
|
|
27
|
+
*/
|
|
28
|
+
export declare function handleKindPeak(feature: VectorGeoFeature, logger: LogType): VectorGeoFeature;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processes a 'contours' layer feature.
|
|
3
|
+
*
|
|
4
|
+
* @param feature - the feature to process
|
|
5
|
+
* @param options - the layer's options
|
|
6
|
+
* @param logger - a logger instance
|
|
7
|
+
* @returns the processed feature
|
|
8
|
+
*/
|
|
9
|
+
export function handleLayerContours(feature, options, logger) {
|
|
10
|
+
logger.trace({}, 'HandleContours:Start');
|
|
11
|
+
const kind = options.layer.tags['kind'];
|
|
12
|
+
switch (kind) {
|
|
13
|
+
case 'contours':
|
|
14
|
+
feature = handleKindContours(feature, logger);
|
|
15
|
+
break;
|
|
16
|
+
case 'peak':
|
|
17
|
+
feature = handleKindPeak(feature, logger);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
logger.trace({}, 'HandleContours:End');
|
|
21
|
+
return feature;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Processes a 'contours' layer feature with a 'kind' value of 'contours'.
|
|
25
|
+
*
|
|
26
|
+
* @param feature - the feature to process
|
|
27
|
+
* @param logger - a logger instance
|
|
28
|
+
* @returns the processed feature
|
|
29
|
+
*/
|
|
30
|
+
export function handleKindContours(feature, logger) {
|
|
31
|
+
logger?.trace({}, 'HandleKindContours:Start');
|
|
32
|
+
feature = structuredClone(feature);
|
|
33
|
+
// read the 'elevation' property
|
|
34
|
+
const elevation = feature.properties['elevation'];
|
|
35
|
+
if (typeof elevation !== 'number')
|
|
36
|
+
throw new Error('Elevation is not a number');
|
|
37
|
+
// if 'elevation' is divisble by 100 with no remainder
|
|
38
|
+
if (elevation % 100 === 0) {
|
|
39
|
+
// append 'type' property
|
|
40
|
+
const type = 'index';
|
|
41
|
+
feature.properties['type'] = type;
|
|
42
|
+
logger?.trace({ type }, 'new/overidden tags');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// override 'minzoom'
|
|
46
|
+
const minzoom = 14;
|
|
47
|
+
feature.tippecanoe.minzoom = minzoom;
|
|
48
|
+
logger?.trace({ minzoom }, 'overidden styles');
|
|
49
|
+
}
|
|
50
|
+
logger?.trace({}, 'HandleKindContours:End');
|
|
51
|
+
return feature;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Processes a 'contours' layer feature with a 'kind' value of 'peak'.
|
|
55
|
+
*
|
|
56
|
+
* @param feature - the feature to process
|
|
57
|
+
* @param logger - a logger instance
|
|
58
|
+
* @returns the processed feature
|
|
59
|
+
*/
|
|
60
|
+
export function handleKindPeak(feature, logger) {
|
|
61
|
+
logger?.trace({}, 'HandleKindPeak:Start');
|
|
62
|
+
feature = structuredClone(feature);
|
|
63
|
+
// read the 'elevation' property
|
|
64
|
+
const elevation = feature.properties['elevation'];
|
|
65
|
+
// if 'elevation' is a number
|
|
66
|
+
if (typeof elevation === 'number') {
|
|
67
|
+
let rank;
|
|
68
|
+
if (elevation >= 2000) {
|
|
69
|
+
rank = 1;
|
|
70
|
+
}
|
|
71
|
+
else if (elevation >= 1500) {
|
|
72
|
+
rank = 2;
|
|
73
|
+
}
|
|
74
|
+
else if (elevation >= 1000) {
|
|
75
|
+
rank = 3;
|
|
76
|
+
}
|
|
77
|
+
else if (elevation >= 500) {
|
|
78
|
+
rank = 4;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
rank = 5;
|
|
82
|
+
}
|
|
83
|
+
// append 'rank' property
|
|
84
|
+
feature.properties['rank'] = rank;
|
|
85
|
+
logger?.trace({ rank }, 'new/overidden tags');
|
|
86
|
+
}
|
|
87
|
+
logger?.trace({}, 'HandleKindPeak:End');
|
|
88
|
+
return feature;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=contours.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contours.js","sourceRoot":"","sources":["../../../src/modify/layers/contours.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAyB,EACzB,OAA8B,EAC9B,MAAe;IAEf,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAExC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU;YACb,OAAO,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC9C,MAAM;QACR,KAAK,MAAM;YACT,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC1C,MAAM;IACV,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAyB,EAAE,MAAe;IAC3E,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,0BAA0B,CAAC,CAAC;IAC9C,OAAO,GAAG,eAAe,CAAC,OAAO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,IAAI,GAAG,CAAC,CAAC;QACX,CAAC;aAAM,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,CAAC;QACX,CAAC;aAAM,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;YAC5B,IAAI,GAAG,CAAC,CAAC;QACX,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,CAAC,CAAC;QACX,CAAC;QAED,yBAAyB;QACzB,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QAClC,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,oBAAoB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LogType } from '@basemaps/shared';
|
|
2
|
+
import { VectorGeoFeature } from '../../types/VectorGeoFeature.js';
|
|
3
|
+
import { VectorGeoPlaceLabelsFeature } from '../schema.js';
|
|
4
|
+
export declare const PlaceLabelsFeatures: Map<string, VectorGeoPlaceLabelsFeature>;
|
|
5
|
+
/**
|
|
6
|
+
* Processes a 'place_labels' layer feature. Specifically, features of the gazatteer dataset.
|
|
7
|
+
*
|
|
8
|
+
* The gazatteer dataset contains multiple features that technically describe the same feature, such that:
|
|
9
|
+
* - 1. One feature will contain all of the expected properties.
|
|
10
|
+
* - 2. The other features will have 'null' values for all expected properties, except `label` and `zoom_level`.
|
|
11
|
+
* - 3. All of the features describing the same feature will have the same `label` value, but different `zoom_level` values.
|
|
12
|
+
*
|
|
13
|
+
* @param feature - the feature to process
|
|
14
|
+
* @param options - the layer's options
|
|
15
|
+
* @param logger - a logger instance
|
|
16
|
+
* @returns the processed feature
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleLayerPlaceLabels(feature: VectorGeoFeature, logger: LogType): VectorGeoFeature | null;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zPlaceLabelsProperties, zPlaceLabelsTippecanoe, } from '../parser.js';
|
|
3
|
+
export const PlaceLabelsFeatures = new Map();
|
|
4
|
+
/**
|
|
5
|
+
* Processes a 'place_labels' layer feature. Specifically, features of the gazatteer dataset.
|
|
6
|
+
*
|
|
7
|
+
* The gazatteer dataset contains multiple features that technically describe the same feature, such that:
|
|
8
|
+
* - 1. One feature will contain all of the expected properties.
|
|
9
|
+
* - 2. The other features will have 'null' values for all expected properties, except `label` and `zoom_level`.
|
|
10
|
+
* - 3. All of the features describing the same feature will have the same `label` value, but different `zoom_level` values.
|
|
11
|
+
*
|
|
12
|
+
* @param feature - the feature to process
|
|
13
|
+
* @param options - the layer's options
|
|
14
|
+
* @param logger - a logger instance
|
|
15
|
+
* @returns the processed feature
|
|
16
|
+
*/
|
|
17
|
+
export function handleLayerPlaceLabels(feature, logger) {
|
|
18
|
+
logger.trace({}, 'HandlePlaceLabels:Start');
|
|
19
|
+
feature = structuredClone(feature);
|
|
20
|
+
// read the 'label' and 'zoom_level' properties (required)
|
|
21
|
+
const label = feature.properties['label'];
|
|
22
|
+
if (typeof label !== 'string')
|
|
23
|
+
throw new Error('Label property is not a string');
|
|
24
|
+
const zoomLevel = feature.properties['zoom_level'];
|
|
25
|
+
if (typeof zoomLevel !== 'number')
|
|
26
|
+
throw new Error('Zoom level is not a number');
|
|
27
|
+
const storedFeature = PlaceLabelsFeatures.get(label);
|
|
28
|
+
if (storedFeature == null) {
|
|
29
|
+
const newFeature = createNewFeature(feature, label, zoomLevel, logger);
|
|
30
|
+
if (newFeature == null)
|
|
31
|
+
return null;
|
|
32
|
+
PlaceLabelsFeatures.set(label, newFeature);
|
|
33
|
+
logger.trace({}, 'HandlePlaceLabels:End');
|
|
34
|
+
return newFeature;
|
|
35
|
+
}
|
|
36
|
+
// update the stored feature's 'minzoom' value
|
|
37
|
+
if (zoomLevel < storedFeature.tippecanoe.minzoom) {
|
|
38
|
+
storedFeature.tippecanoe.minzoom = zoomLevel;
|
|
39
|
+
PlaceLabelsFeatures.set(label, storedFeature);
|
|
40
|
+
}
|
|
41
|
+
// update the stored feature's 'maxzoom' value
|
|
42
|
+
if (zoomLevel > storedFeature.tippecanoe.maxzoom) {
|
|
43
|
+
storedFeature.tippecanoe.maxzoom = zoomLevel;
|
|
44
|
+
PlaceLabelsFeatures.set(label, storedFeature);
|
|
45
|
+
}
|
|
46
|
+
logger.trace({}, 'HandlePlaceLabels:End');
|
|
47
|
+
return storedFeature;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parses a 'place_labels' layer feature into a VectorGeoPlaceLabelsFeature object.
|
|
51
|
+
*
|
|
52
|
+
* @param feature - the feature to process
|
|
53
|
+
* @param label - the feature's 'label' property
|
|
54
|
+
* @param zoomLevel - the feature's 'zoom_level' property
|
|
55
|
+
* @param logger - a logger instance
|
|
56
|
+
* @returns a VectorGeoPlaceLabelsFeature object
|
|
57
|
+
*/
|
|
58
|
+
function createNewFeature(feature, label, zoomLevel, logger) {
|
|
59
|
+
let properties;
|
|
60
|
+
let tippecanoe;
|
|
61
|
+
try {
|
|
62
|
+
properties = zPlaceLabelsProperties.parse({
|
|
63
|
+
label,
|
|
64
|
+
style: feature.properties['style'],
|
|
65
|
+
place: feature.properties['place'],
|
|
66
|
+
adminlevel: feature.properties['adminlevel'],
|
|
67
|
+
natural: feature.properties['natural'],
|
|
68
|
+
water: feature.properties['water'],
|
|
69
|
+
});
|
|
70
|
+
tippecanoe = zPlaceLabelsTippecanoe.parse({
|
|
71
|
+
layer: 'place_labels',
|
|
72
|
+
minzoom: zoomLevel,
|
|
73
|
+
maxzoom: zoomLevel,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
if (e instanceof z.ZodError) {
|
|
78
|
+
logger.trace({ label }, 'Failed to parse expected properties. Discarding feature.');
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new Error('An unexpected error occurred.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const newFeature = {
|
|
86
|
+
type: feature.type,
|
|
87
|
+
properties: {
|
|
88
|
+
name: properties.label,
|
|
89
|
+
kind: convertStyleToKind(properties.style, tippecanoe.minzoom),
|
|
90
|
+
place: properties.place,
|
|
91
|
+
adminlevel: properties.adminlevel,
|
|
92
|
+
natural: properties.natural,
|
|
93
|
+
water: properties.water,
|
|
94
|
+
},
|
|
95
|
+
geometry: feature.geometry,
|
|
96
|
+
tippecanoe,
|
|
97
|
+
};
|
|
98
|
+
return newFeature;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Determines a feature's 'kind' based on its 'styles' property.
|
|
102
|
+
*
|
|
103
|
+
* @param style - the feature's 'style' property
|
|
104
|
+
*/
|
|
105
|
+
function convertStyleToKind(style, minzoom) {
|
|
106
|
+
if (style.startsWith('ANT'))
|
|
107
|
+
return 'ant';
|
|
108
|
+
if (style.startsWith('GEO'))
|
|
109
|
+
return 'geo';
|
|
110
|
+
if (style.startsWith('TWN')) {
|
|
111
|
+
if (minzoom <= 8)
|
|
112
|
+
return 'city';
|
|
113
|
+
if (style === 'TWN1')
|
|
114
|
+
return 'suburb';
|
|
115
|
+
if (style === 'TWN2')
|
|
116
|
+
return 'town';
|
|
117
|
+
if (style === 'TWN3')
|
|
118
|
+
return 'city';
|
|
119
|
+
}
|
|
120
|
+
return '';
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=place_labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place_labels.js","sourceRoot":"","sources":["../../../src/modify/layers/place_labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,cAAc,CAAC;AAGtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,IA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IAAI;QAClB,UAAU,EAAE;YACV,IAAI,EAAE,UAAU,CAAC,KAAK;YACtB,IAAI,EAAE,kBAAkB,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;YAC9D,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;SACxB;QACD,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU;KACX,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,KAAa,EAAE,OAAe;IACxD,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,IAAI,OAAO,IAAI,CAAC;YAAE,OAAO,MAAM,CAAC;QAChC,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,QAAQ,CAAC;QACtC,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,MAAM,CAAC;QACpC,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,MAAM,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LogType } from '@basemaps/shared';
|
|
2
|
+
import { VectorGeoFeature } from '../../types/VectorGeoFeature.js';
|
|
3
|
+
/**
|
|
4
|
+
* Processes a 'pois' layer feature.
|
|
5
|
+
*
|
|
6
|
+
* @param feature - the feature to process
|
|
7
|
+
* @param options - the layer's options
|
|
8
|
+
* @param logger - a logger instance
|
|
9
|
+
* @returns the processed feature
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleLayerPois(feature: VectorGeoFeature, logger: LogType): VectorGeoFeature | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processes a 'pois' layer feature.
|
|
3
|
+
*
|
|
4
|
+
* @param feature - the feature to process
|
|
5
|
+
* @param options - the layer's options
|
|
6
|
+
* @param logger - a logger instance
|
|
7
|
+
* @returns the processed feature
|
|
8
|
+
*/
|
|
9
|
+
export function handleLayerPois(feature, logger) {
|
|
10
|
+
logger.trace({}, 'HandlePois:Start');
|
|
11
|
+
feature = structuredClone(feature);
|
|
12
|
+
// REVIEW: We don't have any use for this criteria as we don't include the following layers:
|
|
13
|
+
// 1. 50245-nz-building-points-topo-150k
|
|
14
|
+
// 2. 50246-nz-building-polygons-topo-150k
|
|
15
|
+
if (feature.properties['building'] === 'building') {
|
|
16
|
+
const bldgUse = feature.properties['bldg_use'];
|
|
17
|
+
if (bldgUse == null) {
|
|
18
|
+
// discard the feature
|
|
19
|
+
logger.trace({}, 'HandlePois:End');
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
feature.properties['building'] = bldgUse;
|
|
23
|
+
}
|
|
24
|
+
logger.trace({}, 'HandlePois:End');
|
|
25
|
+
return feature;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=pois.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pois.js","sourceRoot":"","sources":["../../../src/modify/layers/pois.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,OAAyB,EAAE,MAAe;IACxE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACrC,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAEnC,4FAA4F;IAC5F,wCAAwC;IACxC,0CAA0C;IAC1C,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,UAAU,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAE/C,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,sBAAsB;YACtB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IACnC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LogType } from '@basemaps/shared';
|
|
2
|
+
import { VectorCreationOptions } from '../../stac.js';
|
|
3
|
+
import { VectorGeoFeature } from '../../types/VectorGeoFeature.js';
|
|
4
|
+
/**
|
|
5
|
+
* Processes a 'public_transport' layer feature.
|
|
6
|
+
*
|
|
7
|
+
* @param feature - the feature to process
|
|
8
|
+
* @param options - the layer's options
|
|
9
|
+
* @param logger - a logger instance
|
|
10
|
+
* @returns the processed feature
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleLayerPublicTransport(feature: VectorGeoFeature, options: VectorCreationOptions, logger: LogType): VectorGeoFeature;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as poly from 'polylabel';
|
|
2
|
+
const polylabel = poly.default;
|
|
3
|
+
/**
|
|
4
|
+
* Processes a 'public_transport' layer feature.
|
|
5
|
+
*
|
|
6
|
+
* @param feature - the feature to process
|
|
7
|
+
* @param options - the layer's options
|
|
8
|
+
* @param logger - a logger instance
|
|
9
|
+
* @returns the processed feature
|
|
10
|
+
*/
|
|
11
|
+
export function handleLayerPublicTransport(feature, options, logger) {
|
|
12
|
+
logger.trace({}, 'HandlePublicTransport:Start');
|
|
13
|
+
const kind = options.layer.tags['kind'];
|
|
14
|
+
switch (kind) {
|
|
15
|
+
case 'aerodrome':
|
|
16
|
+
feature = handleKindAerodrome(feature, logger);
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
logger.trace({}, 'HandlePublicTransport:End');
|
|
20
|
+
return feature;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Processes a 'public_transport' layer feature with a 'kind' value of 'aerodrome'.
|
|
24
|
+
*
|
|
25
|
+
* @param feature - the feature to process
|
|
26
|
+
* @param logger - a logger instance
|
|
27
|
+
* @returns the processed feature
|
|
28
|
+
*/
|
|
29
|
+
function handleKindAerodrome(feature, logger) {
|
|
30
|
+
logger.trace({}, 'HandleKindAerodrome:Start');
|
|
31
|
+
feature = structuredClone(feature);
|
|
32
|
+
const coordinates = getCoordinates(feature.geometry, logger);
|
|
33
|
+
// REVIEW: the following resource suggests using a precision value of 0.000001 for geo-coords:
|
|
34
|
+
// https://github.com/mapbox/polylabel?tab=readme-ov-file#javascript-usage
|
|
35
|
+
// currently, we use the default value of 1.0
|
|
36
|
+
const inaccessibilityPole = polylabel(coordinates);
|
|
37
|
+
const point = { type: 'Point', coordinates: inaccessibilityPole };
|
|
38
|
+
feature.geometry = point;
|
|
39
|
+
logger.trace({}, 'HandleKindAerodrome:End');
|
|
40
|
+
return feature;
|
|
41
|
+
}
|
|
42
|
+
function getCoordinates(geometry, logger) {
|
|
43
|
+
switch (geometry.type) {
|
|
44
|
+
case 'MultiPolygon':
|
|
45
|
+
// TODO: Worth to try create a point for each polygon and see how it looks line.
|
|
46
|
+
return geometry.coordinates[0];
|
|
47
|
+
case 'Polygon':
|
|
48
|
+
return geometry.coordinates;
|
|
49
|
+
}
|
|
50
|
+
logger.error({ type: geometry.type }, 'Unsupported geometry type');
|
|
51
|
+
throw new Error('Unsupported geometry type');
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=public_transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_transport.js","sourceRoot":"","sources":["../../../src/modify/layers/public_transport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,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AgF;YAChF,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjC,KAAK,SAAS;YACZ,OAAO,QAAQ,CAAC,WAAW,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE,2BAA2B,CAAC,CAAC;IACnE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LogType } from '@basemaps/shared';
|
|
2
|
+
import { VectorCreationOptions } from '../../stac.js';
|
|
3
|
+
import { VectorGeoFeature } from '../../types/VectorGeoFeature.js';
|
|
4
|
+
/**
|
|
5
|
+
* Processes a 'street_labels' layer feature.
|
|
6
|
+
*
|
|
7
|
+
* @param feature - the feature to process
|
|
8
|
+
* @param options - the layer's options
|
|
9
|
+
* @param logger - a logger instance
|
|
10
|
+
* @returns the processed feature
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleLayerStreetLabels(feature: VectorGeoFeature, options: VectorCreationOptions, logger: LogType): VectorGeoFeature;
|