@mailwoman/cartographer 1.0.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/README.md +3 -0
- package/base/buildings.ts +124 -0
- package/base/composition.ts +119 -0
- package/base/index.ts +10 -0
- package/base/layers.ts +52 -0
- package/base/terrain.ts +33 -0
- package/base/theme.ts +118 -0
- package/bdc/index.ts +395 -0
- package/coverage/index.ts +89 -0
- package/hspa/index.ts +20 -0
- package/index.ts +12 -0
- package/out/base/buildings.d.ts +11 -0
- package/out/base/buildings.d.ts.map +1 -0
- package/out/base/buildings.js +109 -0
- package/out/base/buildings.js.map +1 -0
- package/out/base/composition.d.ts +33 -0
- package/out/base/composition.d.ts.map +1 -0
- package/out/base/composition.js +86 -0
- package/out/base/composition.js.map +1 -0
- package/out/base/index.d.ts +10 -0
- package/out/base/index.d.ts.map +1 -0
- package/out/base/index.js +10 -0
- package/out/base/index.js.map +1 -0
- package/out/base/layers.d.ts +9 -0
- package/out/base/layers.d.ts.map +1 -0
- package/out/base/layers.js +49 -0
- package/out/base/layers.js.map +1 -0
- package/out/base/terrain.d.ts +20 -0
- package/out/base/terrain.d.ts.map +1 -0
- package/out/base/terrain.js +29 -0
- package/out/base/terrain.js.map +1 -0
- package/out/base/theme.d.ts +20 -0
- package/out/base/theme.d.ts.map +1 -0
- package/out/base/theme.js +103 -0
- package/out/base/theme.js.map +1 -0
- package/out/bdc/index.d.ts +27 -0
- package/out/bdc/index.d.ts.map +1 -0
- package/out/bdc/index.js +344 -0
- package/out/bdc/index.js.map +1 -0
- package/out/coverage/index.d.ts +58 -0
- package/out/coverage/index.d.ts.map +1 -0
- package/out/coverage/index.js +77 -0
- package/out/coverage/index.js.map +1 -0
- package/out/hspa/index.d.ts +12 -0
- package/out/hspa/index.d.ts.map +1 -0
- package/out/hspa/index.js +18 -0
- package/out/hspa/index.js.map +1 -0
- package/out/index.d.ts +12 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +12 -0
- package/out/index.js.map +1 -0
- package/out/race-dots/index.d.ts +61 -0
- package/out/race-dots/index.d.ts.map +1 -0
- package/out/race-dots/index.js +59 -0
- package/out/race-dots/index.js.map +1 -0
- package/out/styles/index.d.ts +8 -0
- package/out/styles/index.d.ts.map +1 -0
- package/out/styles/index.js +8 -0
- package/out/styles/index.js.map +1 -0
- package/out/styles/layers.d.ts +33 -0
- package/out/styles/layers.d.ts.map +1 -0
- package/out/styles/layers.js +108 -0
- package/out/styles/layers.js.map +1 -0
- package/out/styles/sources.d.ts +22 -0
- package/out/styles/sources.d.ts.map +1 -0
- package/out/styles/sources.js +12 -0
- package/out/styles/sources.js.map +1 -0
- package/out/tiger/index.d.ts +11 -0
- package/out/tiger/index.d.ts.map +1 -0
- package/out/tiger/index.js +64 -0
- package/out/tiger/index.js.map +1 -0
- package/out/tiles/api.d.ts +20 -0
- package/out/tiles/api.d.ts.map +1 -0
- package/out/tiles/api.js +41 -0
- package/out/tiles/api.js.map +1 -0
- package/out/tiles/coords.d.ts +16 -0
- package/out/tiles/coords.d.ts.map +1 -0
- package/out/tiles/coords.js +34 -0
- package/out/tiles/coords.js.map +1 -0
- package/out/tiles/index.d.ts +9 -0
- package/out/tiles/index.d.ts.map +1 -0
- package/out/tiles/index.js +9 -0
- package/out/tiles/index.js.map +1 -0
- package/out/tiles/schema.d.ts +41 -0
- package/out/tiles/schema.d.ts.map +1 -0
- package/out/tiles/schema.js +7 -0
- package/out/tiles/schema.js.map +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +46 -0
- package/race-dots/index.ts +68 -0
- package/styles/index.ts +8 -0
- package/styles/layers.ts +148 -0
- package/styles/sources.ts +26 -0
- package/tiger/index.ts +71 -0
- package/tiles/api.ts +53 -0
- package/tiles/coords.ts +46 -0
- package/tiles/index.ts +9 -0
- package/tiles/schema.ts +42 -0
- package/tsconfig.json +22 -0
- package/typedoc.json +4 -0
package/tiger/index.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { HillsLayerID } from "../base/layers.js"
|
|
8
|
+
import type { LayerSpecificationListInput } from "../styles/layers.js"
|
|
9
|
+
import { TileSetSourceID } from "../styles/sources.js"
|
|
10
|
+
|
|
11
|
+
export const TIGERTractsTileSetID = TileSetSourceID("tiger-tracts")
|
|
12
|
+
export const TIGERBlocksTileSetID = TileSetSourceID("tiger-blocks")
|
|
13
|
+
|
|
14
|
+
export const TIGERLayers: LayerSpecificationListInput[] = [
|
|
15
|
+
{
|
|
16
|
+
afterID: HillsLayerID,
|
|
17
|
+
metadata: {
|
|
18
|
+
queryable: false,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
id: "boundary-tracts",
|
|
22
|
+
"source-layer": "tracts",
|
|
23
|
+
source: TIGERTractsTileSetID,
|
|
24
|
+
type: "line",
|
|
25
|
+
filter: [">=", ["get", "ALAND"], 0],
|
|
26
|
+
maxzoom: 9,
|
|
27
|
+
paint: {
|
|
28
|
+
"line-color": "white",
|
|
29
|
+
"line-width": 1,
|
|
30
|
+
|
|
31
|
+
"line-opacity": [
|
|
32
|
+
// We fade out the outline at higher zoom levels
|
|
33
|
+
"interpolate",
|
|
34
|
+
["linear"],
|
|
35
|
+
["zoom"],
|
|
36
|
+
5,
|
|
37
|
+
0.01,
|
|
38
|
+
10,
|
|
39
|
+
0.25,
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
beforeID: "water",
|
|
46
|
+
metadata: {
|
|
47
|
+
queryable: false,
|
|
48
|
+
},
|
|
49
|
+
id: "boundary-blocks",
|
|
50
|
+
"source-layer": "blocks",
|
|
51
|
+
source: TIGERBlocksTileSetID,
|
|
52
|
+
type: "line",
|
|
53
|
+
filter: [">=", ["get", "ALAND"], 0],
|
|
54
|
+
minzoom: 9,
|
|
55
|
+
paint: {
|
|
56
|
+
"line-color": "orange",
|
|
57
|
+
"line-width": 1,
|
|
58
|
+
|
|
59
|
+
"line-opacity": [
|
|
60
|
+
// We fade out the outline at higher zoom levels
|
|
61
|
+
"interpolate",
|
|
62
|
+
["linear"],
|
|
63
|
+
["zoom"],
|
|
64
|
+
9,
|
|
65
|
+
0.01,
|
|
66
|
+
16,
|
|
67
|
+
0.5,
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
]
|
package/tiles/api.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { APIClient, pluckResponseData } from "@mailwoman/core/api"
|
|
8
|
+
import type { VectorSourceSpecification } from "maplibre-gl"
|
|
9
|
+
import type { TileSetSourceID, TileSetSourceRecord } from "../styles/sources.js"
|
|
10
|
+
import type { TileJSON } from "./schema.js"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* API Client for fetching Protomap tile data.
|
|
14
|
+
*/
|
|
15
|
+
export const TileAPI = new APIClient({
|
|
16
|
+
displayName: "TileAPI",
|
|
17
|
+
axios: {
|
|
18
|
+
baseURL: "https://tiles.sister.software",
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export function fetchTileSetSourceSpec(
|
|
23
|
+
tileSetID: TileSetSourceID
|
|
24
|
+
): Promise<[TileSetSourceID, VectorSourceSpecification]> {
|
|
25
|
+
return TileAPI.fetch<TileJSON>({ url: `/${tileSetID}.json` })
|
|
26
|
+
.then(pluckResponseData)
|
|
27
|
+
.then((metadata) => {
|
|
28
|
+
const sourceSpec: VectorSourceSpecification = {
|
|
29
|
+
type: "vector",
|
|
30
|
+
scheme: metadata.scheme,
|
|
31
|
+
tiles: metadata.tiles,
|
|
32
|
+
minzoom: metadata.minzoom,
|
|
33
|
+
maxzoom: metadata.maxzoom,
|
|
34
|
+
attribution: metadata.attribution || "Sister Software. et al.",
|
|
35
|
+
bounds: metadata.bounds,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return [tileSetID, sourceSpec] as const
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function fetchTileSetSources(tileSetIDs: TileSetSourceID[]): Promise<TileSetSourceRecord> {
|
|
43
|
+
const tileSetPromises = tileSetIDs.map(fetchTileSetSourceSpec)
|
|
44
|
+
|
|
45
|
+
const tileSetPairs = await Promise.all(tileSetPromises)
|
|
46
|
+
const tileSetSources: TileSetSourceRecord = {}
|
|
47
|
+
|
|
48
|
+
for (const [tileSetID, sourceSpec] of tileSetPairs) {
|
|
49
|
+
tileSetSources[tileSetID] = sourceSpec
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return tileSetSources
|
|
53
|
+
}
|
package/tiles/coords.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Literal type for a tile coord array.
|
|
9
|
+
*/
|
|
10
|
+
export type TileCoords = [zoom: number, xCoord: number, yCoord: number]
|
|
11
|
+
|
|
12
|
+
export function parseTileCoordParams({ z, x, y }: Record<string, string | undefined>): TileCoords | null {
|
|
13
|
+
const coords = [z, x, y].map((n) => parseInt(n!, 10)).filter((n) => !isNaN(n))
|
|
14
|
+
|
|
15
|
+
if (coords.length !== 3) return null
|
|
16
|
+
|
|
17
|
+
return coords as TileCoords
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Get the precise fractional tile location for a point at a zoom level
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export function pointToTileFraction(zoom: number, longitude: number, latitude: number): TileCoords {
|
|
25
|
+
const sin = Math.sin((latitude * Math.PI) / 180)
|
|
26
|
+
const z2 = Math.pow(2, zoom)
|
|
27
|
+
let x = z2 * (longitude / 360 + 0.5)
|
|
28
|
+
|
|
29
|
+
const y = z2 * (0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI)
|
|
30
|
+
|
|
31
|
+
// Wrap Tile X
|
|
32
|
+
x = x % z2
|
|
33
|
+
|
|
34
|
+
if (x < 0) x = x + z2
|
|
35
|
+
|
|
36
|
+
return [zoom, x, y]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get the tile for a point at a specified zoom level
|
|
41
|
+
*/
|
|
42
|
+
export function pointToTile(zoom: number, longitude: number, latitude: number): TileCoords {
|
|
43
|
+
const [, x, y] = pointToTileFraction(zoom, longitude, latitude)
|
|
44
|
+
|
|
45
|
+
return [zoom, Math.floor(x), Math.floor(y)]
|
|
46
|
+
}
|
package/tiles/index.ts
ADDED
package/tiles/schema.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TileJSON is an open standard for representing map metadata.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://github.com/mapbox/tilejson-spec TileJSON Specification}
|
|
11
|
+
*/
|
|
12
|
+
export interface TileJSON {
|
|
13
|
+
/**
|
|
14
|
+
* The version of the TileJSON spec that is implemented by this JSON object.
|
|
15
|
+
*
|
|
16
|
+
* @default "3.0.0"
|
|
17
|
+
*/
|
|
18
|
+
tilejson: string
|
|
19
|
+
scheme: "xyz"
|
|
20
|
+
tiles: string[]
|
|
21
|
+
vector_layers: TileJSONVectorLayer[]
|
|
22
|
+
attribution?: string
|
|
23
|
+
description?: string
|
|
24
|
+
name: string
|
|
25
|
+
version: string
|
|
26
|
+
bounds: [minLon: number, minLat: number, maxLon: number, maxLat: number]
|
|
27
|
+
center: [centerLon: number, centerLat: number, centerZoom: number]
|
|
28
|
+
minzoom: number
|
|
29
|
+
maxzoom: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A vector layer definition for a TileJSON object.
|
|
34
|
+
*/
|
|
35
|
+
export interface TileJSONVectorLayer {
|
|
36
|
+
description?: string
|
|
37
|
+
id: string
|
|
38
|
+
fields: Record<string, string>
|
|
39
|
+
source: string
|
|
40
|
+
minzoom?: number
|
|
41
|
+
maxzoom?: number
|
|
42
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@sister.software/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"emitDeclarationOnly": false,
|
|
5
|
+
"allowImportingTsExtensions": false,
|
|
6
|
+
"allowSyntheticDefaultImports": true,
|
|
7
|
+
"emitDecoratorMetadata": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"paths": {
|
|
10
|
+
"@mailwoman/mailwoman/sdk": ["./sdk/index"],
|
|
11
|
+
"@mailwoman/mailwoman/sdk/*": ["./sdk/*"]
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"exclude": ["./out/**/*"],
|
|
15
|
+
"references": [
|
|
16
|
+
// ---
|
|
17
|
+
{ "path": "../core" },
|
|
18
|
+
{ "path": "../spatial" },
|
|
19
|
+
{ "path": "../tiger" },
|
|
20
|
+
{ "path": "../mailwoman" }
|
|
21
|
+
]
|
|
22
|
+
}
|
package/typedoc.json
ADDED