@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.
Files changed (100) hide show
  1. package/README.md +3 -0
  2. package/base/buildings.ts +124 -0
  3. package/base/composition.ts +119 -0
  4. package/base/index.ts +10 -0
  5. package/base/layers.ts +52 -0
  6. package/base/terrain.ts +33 -0
  7. package/base/theme.ts +118 -0
  8. package/bdc/index.ts +395 -0
  9. package/coverage/index.ts +89 -0
  10. package/hspa/index.ts +20 -0
  11. package/index.ts +12 -0
  12. package/out/base/buildings.d.ts +11 -0
  13. package/out/base/buildings.d.ts.map +1 -0
  14. package/out/base/buildings.js +109 -0
  15. package/out/base/buildings.js.map +1 -0
  16. package/out/base/composition.d.ts +33 -0
  17. package/out/base/composition.d.ts.map +1 -0
  18. package/out/base/composition.js +86 -0
  19. package/out/base/composition.js.map +1 -0
  20. package/out/base/index.d.ts +10 -0
  21. package/out/base/index.d.ts.map +1 -0
  22. package/out/base/index.js +10 -0
  23. package/out/base/index.js.map +1 -0
  24. package/out/base/layers.d.ts +9 -0
  25. package/out/base/layers.d.ts.map +1 -0
  26. package/out/base/layers.js +49 -0
  27. package/out/base/layers.js.map +1 -0
  28. package/out/base/terrain.d.ts +20 -0
  29. package/out/base/terrain.d.ts.map +1 -0
  30. package/out/base/terrain.js +29 -0
  31. package/out/base/terrain.js.map +1 -0
  32. package/out/base/theme.d.ts +20 -0
  33. package/out/base/theme.d.ts.map +1 -0
  34. package/out/base/theme.js +103 -0
  35. package/out/base/theme.js.map +1 -0
  36. package/out/bdc/index.d.ts +27 -0
  37. package/out/bdc/index.d.ts.map +1 -0
  38. package/out/bdc/index.js +344 -0
  39. package/out/bdc/index.js.map +1 -0
  40. package/out/coverage/index.d.ts +58 -0
  41. package/out/coverage/index.d.ts.map +1 -0
  42. package/out/coverage/index.js +77 -0
  43. package/out/coverage/index.js.map +1 -0
  44. package/out/hspa/index.d.ts +12 -0
  45. package/out/hspa/index.d.ts.map +1 -0
  46. package/out/hspa/index.js +18 -0
  47. package/out/hspa/index.js.map +1 -0
  48. package/out/index.d.ts +12 -0
  49. package/out/index.d.ts.map +1 -0
  50. package/out/index.js +12 -0
  51. package/out/index.js.map +1 -0
  52. package/out/race-dots/index.d.ts +61 -0
  53. package/out/race-dots/index.d.ts.map +1 -0
  54. package/out/race-dots/index.js +59 -0
  55. package/out/race-dots/index.js.map +1 -0
  56. package/out/styles/index.d.ts +8 -0
  57. package/out/styles/index.d.ts.map +1 -0
  58. package/out/styles/index.js +8 -0
  59. package/out/styles/index.js.map +1 -0
  60. package/out/styles/layers.d.ts +33 -0
  61. package/out/styles/layers.d.ts.map +1 -0
  62. package/out/styles/layers.js +108 -0
  63. package/out/styles/layers.js.map +1 -0
  64. package/out/styles/sources.d.ts +22 -0
  65. package/out/styles/sources.d.ts.map +1 -0
  66. package/out/styles/sources.js +12 -0
  67. package/out/styles/sources.js.map +1 -0
  68. package/out/tiger/index.d.ts +11 -0
  69. package/out/tiger/index.d.ts.map +1 -0
  70. package/out/tiger/index.js +64 -0
  71. package/out/tiger/index.js.map +1 -0
  72. package/out/tiles/api.d.ts +20 -0
  73. package/out/tiles/api.d.ts.map +1 -0
  74. package/out/tiles/api.js +41 -0
  75. package/out/tiles/api.js.map +1 -0
  76. package/out/tiles/coords.d.ts +16 -0
  77. package/out/tiles/coords.d.ts.map +1 -0
  78. package/out/tiles/coords.js +34 -0
  79. package/out/tiles/coords.js.map +1 -0
  80. package/out/tiles/index.d.ts +9 -0
  81. package/out/tiles/index.d.ts.map +1 -0
  82. package/out/tiles/index.js +9 -0
  83. package/out/tiles/index.js.map +1 -0
  84. package/out/tiles/schema.d.ts +41 -0
  85. package/out/tiles/schema.d.ts.map +1 -0
  86. package/out/tiles/schema.js +7 -0
  87. package/out/tiles/schema.js.map +1 -0
  88. package/out/tsconfig.tsbuildinfo +1 -0
  89. package/package.json +46 -0
  90. package/race-dots/index.ts +68 -0
  91. package/styles/index.ts +8 -0
  92. package/styles/layers.ts +148 -0
  93. package/styles/sources.ts +26 -0
  94. package/tiger/index.ts +71 -0
  95. package/tiles/api.ts +53 -0
  96. package/tiles/coords.ts +46 -0
  97. package/tiles/index.ts +9 -0
  98. package/tiles/schema.ts +42 -0
  99. package/tsconfig.json +22 -0
  100. 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
+ }
@@ -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
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @copyright Sister Software.
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+
7
+ export * from "./api.js"
8
+ export * from "./coords.js"
9
+ export * from "./schema.js"
@@ -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
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": ["../typedoc.base.jsonc"],
3
+ "entryPoints": ["index.ts"]
4
+ }