@basemaps/cli-vector 8.1.0 → 8.3.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 +211 -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 +10 -0
- package/build/generalization/generalization.js +168 -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 +117 -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 +32 -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 +41 -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.d.ts +13 -0
- package/build/modify/layers/water.js +82 -0
- package/build/modify/layers/water.js.map +1 -0
- package/build/modify/modify.d.ts +11 -0
- package/build/modify/modify.js +49 -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 +7 -0
- package/build/modify/shared.js +53 -0
- package/build/modify/shared.js.map +1 -0
- package/build/schema-loader/parser.d.ts +16 -0
- package/build/schema-loader/parser.js +2 -0
- package/build/schema-loader/parser.js.map +1 -1
- package/build/schema-loader/schema.d.ts +21 -5
- package/build/schema-loader/schema.loader.d.ts +3 -1
- package/build/schema-loader/schema.loader.js +18 -6
- 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/nztm.d.ts +4 -0
- package/build/transform/nztm.js +13 -0
- package/build/transform/nztm.js.map +1 -0
- package/build/transform/ogr2ogr.d.ts +9 -0
- package/build/transform/ogr2ogr.js +43 -0
- package/build/transform/ogr2ogr.js.map +1 -0
- package/build/transform/tippecanoe.d.ts +15 -0
- package/build/transform/tippecanoe.js +69 -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 +20809 -9550
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplify.js","sourceRoot":"","sources":["../../src/generalization/simplify.ts"],"names":[],"mappings":"AAEA,mCAAmC;AACnC,SAAS,SAAS,CAAC,EAAS,EAAE,EAAS;IACrC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,4CAA4C;AAC5C,SAAS,YAAY,CAAC,CAAQ,EAAE,EAAS,EAAE,EAAS;IAClD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACd,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACd,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEnB,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,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AC;AACpB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,QAAQ,CAAC,MAAe,EAAE,SAAiB,EAAE,cAAwB;IACnF,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAEtC,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAE1C,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3E,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
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,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@@ -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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S,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAElD,6BAA6B;IAC7B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,IAAY,CAAC;QAEjB,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,GAAG,CAAC,CAAC;QACX,CAAC;aAAM,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7B,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,117 @@
|
|
|
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
|
+
//DATA PROBLEM: We need to store the first feature which have all the propertie values, the duplicate features will only have null values in the properties
|
|
28
|
+
const storedFeature = PlaceLabelsFeatures.get(label);
|
|
29
|
+
if (storedFeature == null) {
|
|
30
|
+
const newFeature = createNewFeature(feature, label, zoomLevel, logger);
|
|
31
|
+
if (newFeature == null)
|
|
32
|
+
return null;
|
|
33
|
+
PlaceLabelsFeatures.set(label, newFeature);
|
|
34
|
+
logger.trace({}, 'HandlePlaceLabels:End');
|
|
35
|
+
return newFeature;
|
|
36
|
+
}
|
|
37
|
+
// update the stored feature's 'minzoom' value
|
|
38
|
+
storedFeature.tippecanoe.minzoom = zoomLevel;
|
|
39
|
+
// update the stored feature's 'maxzoom' value
|
|
40
|
+
storedFeature.tippecanoe.maxzoom = zoomLevel;
|
|
41
|
+
logger.trace({}, 'HandlePlaceLabels:End');
|
|
42
|
+
return storedFeature;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parses a 'place_labels' layer feature into a VectorGeoPlaceLabelsFeature object.
|
|
46
|
+
*
|
|
47
|
+
* @param feature - the feature to process
|
|
48
|
+
* @param label - the feature's 'label' property
|
|
49
|
+
* @param zoomLevel - the feature's 'zoom_level' property
|
|
50
|
+
* @param logger - a logger instance
|
|
51
|
+
* @returns a VectorGeoPlaceLabelsFeature object
|
|
52
|
+
*/
|
|
53
|
+
function createNewFeature(feature, label, zoomLevel, logger) {
|
|
54
|
+
let properties;
|
|
55
|
+
let tippecanoe;
|
|
56
|
+
try {
|
|
57
|
+
properties = zPlaceLabelsProperties.parse({
|
|
58
|
+
label,
|
|
59
|
+
style: feature.properties['style'],
|
|
60
|
+
place: feature.properties['place'],
|
|
61
|
+
adminlevel: feature.properties['adminlevel'],
|
|
62
|
+
natural: feature.properties['natural'],
|
|
63
|
+
water: feature.properties['water'],
|
|
64
|
+
});
|
|
65
|
+
tippecanoe = zPlaceLabelsTippecanoe.parse({
|
|
66
|
+
layer: 'place_labels',
|
|
67
|
+
minzoom: zoomLevel,
|
|
68
|
+
maxzoom: zoomLevel,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
if (e instanceof z.ZodError) {
|
|
73
|
+
logger.trace({ label }, 'Failed to parse expected properties. Discarding feature.');
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new Error('An unexpected error occurred.');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const newFeature = {
|
|
81
|
+
type: feature.type,
|
|
82
|
+
properties: {
|
|
83
|
+
name: properties.label,
|
|
84
|
+
kind: convertStyleToKind(properties.style, tippecanoe.minzoom),
|
|
85
|
+
place: properties.place,
|
|
86
|
+
adminlevel: properties.adminlevel,
|
|
87
|
+
natural: properties.natural,
|
|
88
|
+
water: properties.water,
|
|
89
|
+
},
|
|
90
|
+
geometry: feature.geometry,
|
|
91
|
+
tippecanoe,
|
|
92
|
+
};
|
|
93
|
+
return newFeature;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Determines a feature's 'kind' based on its 'styles' property.
|
|
97
|
+
*
|
|
98
|
+
* @param style - the feature's 'style' property
|
|
99
|
+
*/
|
|
100
|
+
function convertStyleToKind(style, minzoom) {
|
|
101
|
+
if (style.startsWith('ANT'))
|
|
102
|
+
return 'ant';
|
|
103
|
+
if (style.startsWith('GEO'))
|
|
104
|
+
return 'geo';
|
|
105
|
+
if (style.startsWith('TWN')) {
|
|
106
|
+
if (minzoom <= 8)
|
|
107
|
+
return 'city';
|
|
108
|
+
if (style === 'TWN1')
|
|
109
|
+
return 'suburb';
|
|
110
|
+
if (style === 'TWN2')
|
|
111
|
+
return 'town';
|
|
112
|
+
if (style === 'TWN3')
|
|
113
|
+
return 'city';
|
|
114
|
+
}
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
//# 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,E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,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,32 @@
|
|
|
1
|
+
import { getCoordinates, polylabel } from '../shared.js';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a 'pois' layer feature.
|
|
4
|
+
*
|
|
5
|
+
* @param feature - the feature to process
|
|
6
|
+
* @param options - the layer's options
|
|
7
|
+
* @param logger - a logger instance
|
|
8
|
+
* @returns the processed feature
|
|
9
|
+
*/
|
|
10
|
+
export function handleLayerPois(feature, logger) {
|
|
11
|
+
logger.trace({}, 'HandlePois:Start');
|
|
12
|
+
feature = structuredClone(feature);
|
|
13
|
+
if (feature.properties['building'] === 'building') {
|
|
14
|
+
const bldgUse = feature.properties['bldg_use'];
|
|
15
|
+
if (bldgUse == null) {
|
|
16
|
+
// discard the feature
|
|
17
|
+
logger.trace({}, 'HandlePois:End');
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
feature.properties['building'] = bldgUse;
|
|
21
|
+
// Covert the building polygon to a point for 50246-nz-building-polygons-topo-150k
|
|
22
|
+
if (feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') {
|
|
23
|
+
const coordinates = getCoordinates(feature.geometry, logger);
|
|
24
|
+
const inaccessibilityPole = polylabel(coordinates);
|
|
25
|
+
const point = { type: 'Point', coordinates: inaccessibilityPole };
|
|
26
|
+
feature.geometry = point;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
logger.trace({}, 'HandlePois:End');
|
|
30
|
+
return feature;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=pois.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pois.js","sourceRoot":"","sources":["../../../src/modify/layers/pois.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;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,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;QAEzC,kFAAkF;QAClF,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACpF,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC7D,MAAM,mBAAmB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;YAEnD,MAAM,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;YACzE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,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,41 @@
|
|
|
1
|
+
import { getCoordinates, polylabel } from '../shared.js';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a 'public_transport' layer feature.
|
|
4
|
+
*
|
|
5
|
+
* @param feature - the feature to process
|
|
6
|
+
* @param options - the layer's options
|
|
7
|
+
* @param logger - a logger instance
|
|
8
|
+
* @returns the processed feature
|
|
9
|
+
*/
|
|
10
|
+
export function handleLayerPublicTransport(feature, options, logger) {
|
|
11
|
+
logger.trace({}, 'HandlePublicTransport:Start');
|
|
12
|
+
const kind = options.layer.tags['kind'];
|
|
13
|
+
switch (kind) {
|
|
14
|
+
case 'aerodrome':
|
|
15
|
+
feature = handleKindAerodrome(feature, logger);
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
logger.trace({}, 'HandlePublicTransport:End');
|
|
19
|
+
return feature;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Processes a 'public_transport' layer feature with a 'kind' value of 'aerodrome'.
|
|
23
|
+
*
|
|
24
|
+
* @param feature - the feature to process
|
|
25
|
+
* @param logger - a logger instance
|
|
26
|
+
* @returns the processed feature
|
|
27
|
+
*/
|
|
28
|
+
function handleKindAerodrome(feature, logger) {
|
|
29
|
+
logger.trace({}, 'HandleKindAerodrome:Start');
|
|
30
|
+
feature = structuredClone(feature);
|
|
31
|
+
const coordinates = getCoordinates(feature.geometry, logger);
|
|
32
|
+
// REVIEW: the following resource suggests using a precision value of 0.000001 for geo-coords:
|
|
33
|
+
// https://github.com/mapbox/polylabel?tab=readme-ov-file#javascript-usage
|
|
34
|
+
// currently, we use the default value of 1.0
|
|
35
|
+
const inaccessibilityPole = polylabel(coordinates);
|
|
36
|
+
const point = { type: 'Point', coordinates: inaccessibilityPole };
|
|
37
|
+
feature.geometry = point;
|
|
38
|
+
logger.trace({}, 'HandleKindAerodrome:End');
|
|
39
|
+
return feature;
|
|
40
|
+
}
|
|
41
|
+
//# 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":"AAKA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAyB,EACzB,OAA8B,EAC9B,MAAe;IAEf,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,6BAA6B,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAExC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW;YACd,OAAO,GAAG,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC/C,MAAM;IACV,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,OAAyB,EAAE,MAAe;IACrE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAC9C,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAEnC,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7D,8FAA8F;IAC9F,0EAA0E;IAC1E,6CAA6C;IAC7C,MAAM,mBAAmB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IAEnD,MAAM,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACzE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;IAEzB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,yBAAyB,CAAC,CAAC;IAC5C,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 '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;
|