@kahwee/sf-map-svg 0.3.0 → 1.1.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/CHANGELOG.md +44 -3
- package/LICENSE +23 -4
- package/README.md +267 -74
- package/SOURCES.md +4 -0
- package/{data → dist/data}/README.md +2 -1
- package/dist/data/bart-stations.json +134 -0
- package/dist/data/catalog.json +4718 -0
- package/dist/data/coast.json +36 -0
- package/dist/data/districts-2002.json +325 -0
- package/dist/data/districts-2012.json +325 -0
- package/dist/data/districts-2022.json +325 -0
- package/dist/data/highways.json +4138 -0
- package/dist/data/index.d.ts +26 -0
- package/{data → dist/data}/index.js +37 -39
- package/dist/data/key-roads.json +12662 -0
- package/dist/data/landmarks.json +167 -0
- package/dist/data/neighborhoods-analysis.json +817 -0
- package/dist/data/neighborhoods-realtor.json +1978 -0
- package/dist/data/neighborhoods.json +2267 -0
- package/dist/data/types.d.ts +117 -0
- package/dist/data/types.js +1 -0
- package/dist/src/data.d.ts +25 -0
- package/{src → dist/src}/data.js +17 -20
- package/dist/src/explorer-layout.d.ts +23 -0
- package/dist/src/explorer-layout.js +72 -0
- package/dist/src/explorer.d.ts +4 -0
- package/dist/src/explorer.js +961 -0
- package/dist/src/geometry.d.ts +5 -0
- package/dist/src/geometry.js +53 -0
- package/dist/src/immutable.d.ts +2 -0
- package/dist/src/immutable.js +9 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.js +125 -0
- package/dist/src/interactive.d.ts +4 -0
- package/dist/src/interactive.js +5 -0
- package/dist/src/layers.d.ts +36 -0
- package/dist/src/layers.js +64 -0
- package/dist/src/navigation.d.ts +6 -0
- package/dist/src/navigation.js +145 -0
- package/dist/src/overlays.d.ts +25 -0
- package/dist/src/overlays.js +15 -0
- package/dist/src/svg.d.ts +4 -0
- package/dist/src/svg.js +7 -0
- package/dist/src/transit.d.ts +3 -0
- package/dist/src/transit.js +105 -0
- package/dist/src/types.d.ts +112 -0
- package/dist/src/types.js +1 -0
- package/dist/src/viewport.d.ts +5 -0
- package/dist/src/viewport.js +27 -0
- package/package.json +40 -25
- package/data/bart-stations.json +0 -134
- package/data/catalog.json +0 -4699
- package/data/coast.json +0 -36
- package/data/districts-2002.json +0 -325
- package/data/districts-2012.json +0 -325
- package/data/districts-2022.json +0 -325
- package/data/highways.json +0 -4138
- package/data/index.d.ts +0 -117
- package/data/landmarks.json +0 -167
- package/data/neighborhoods-analysis.json +0 -817
- package/data/neighborhoods-realtor.json +0 -1978
- package/data/neighborhoods.json +0 -2267
- package/src/geometry.d.ts +0 -8
- package/src/geometry.js +0 -51
- package/src/immutable.js +0 -8
- package/src/index.d.ts +0 -51
- package/src/index.js +0 -122
- package/src/layers.js +0 -54
- package/src/overlays.js +0 -18
- package/src/svg.js +0 -12
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type * from './types.js';
|
|
2
|
+
import type { Catalog, DistrictProperties, Feature, FeatureCollection, KeyRoadProperties, LandmarkProperties, NeighborhoodProperties, NeighborhoodSource } from './types.js';
|
|
3
|
+
export declare const coast: FeatureCollection<{
|
|
4
|
+
readonly name: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const districtMaps: Readonly<Record<2002 | 2012 | 2022, FeatureCollection<DistrictProperties>>>;
|
|
7
|
+
export declare const neighborhoods: FeatureCollection<NeighborhoodProperties>;
|
|
8
|
+
export declare const neighborhoodCollections: Readonly<Record<NeighborhoodSource, FeatureCollection<NeighborhoodProperties>>>;
|
|
9
|
+
export declare const neighborhoodSources: readonly NeighborhoodSource[];
|
|
10
|
+
export declare const highways: FeatureCollection<{
|
|
11
|
+
readonly route: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const landmarks: FeatureCollection<LandmarkProperties>;
|
|
14
|
+
export declare const bartStations: FeatureCollection<{
|
|
15
|
+
readonly name: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const catalog: Catalog;
|
|
18
|
+
/** Exact ID, canonical name, source name, or alias lookup within one definition set. */
|
|
19
|
+
export declare function getNeighborhood(name: string, { source }?: {
|
|
20
|
+
source?: NeighborhoodSource;
|
|
21
|
+
}): Feature<NeighborhoodProperties> | undefined;
|
|
22
|
+
/** Search names across sources; results keep their source identity and omit geometry. */
|
|
23
|
+
export declare function searchNeighborhoods(query?: string, { source }?: {
|
|
24
|
+
source?: NeighborhoodSource;
|
|
25
|
+
}): import("./types.js").NeighborhoodEntry[];
|
|
26
|
+
export declare const keyRoads: FeatureCollection<KeyRoadProperties>;
|
|
@@ -1,69 +1,67 @@
|
|
|
1
|
+
import { deepFreeze } from '../src/immutable.js';
|
|
2
|
+
import stationData from './bart-stations.json' with { type: 'json' };
|
|
3
|
+
import catalogData from './catalog.json' with { type: 'json' };
|
|
1
4
|
import coastData from './coast.json' with { type: 'json' };
|
|
2
5
|
import districts2002 from './districts-2002.json' with { type: 'json' };
|
|
3
6
|
import districts2012 from './districts-2012.json' with { type: 'json' };
|
|
4
7
|
import districts2022 from './districts-2022.json' with { type: 'json' };
|
|
8
|
+
import highwayData from './highways.json' with { type: 'json' };
|
|
9
|
+
import roadData from './key-roads.json' with { type: 'json' };
|
|
10
|
+
import landmarkData from './landmarks.json' with { type: 'json' };
|
|
5
11
|
import sfFind from './neighborhoods.json' with { type: 'json' };
|
|
6
12
|
import analysis from './neighborhoods-analysis.json' with { type: 'json' };
|
|
7
13
|
import realtor from './neighborhoods-realtor.json' with { type: 'json' };
|
|
8
|
-
import highwayData from './highways.json' with { type: 'json' };
|
|
9
|
-
import landmarkData from './landmarks.json' with { type: 'json' };
|
|
10
|
-
import stationData from './bart-stations.json' with { type: 'json' };
|
|
11
|
-
import catalogData from './catalog.json' with { type: 'json' };
|
|
12
|
-
import { deepFreeze } from '../src/immutable.js';
|
|
13
|
-
|
|
14
14
|
export const coast = deepFreeze(coastData);
|
|
15
15
|
export const districtMaps = deepFreeze({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
2002: districts2002,
|
|
17
|
+
2012: districts2012,
|
|
18
|
+
2022: districts2022,
|
|
19
19
|
});
|
|
20
20
|
export const neighborhoods = deepFreeze(realtor);
|
|
21
|
-
export const neighborhoodCollections = deepFreeze({
|
|
21
|
+
export const neighborhoodCollections = deepFreeze({
|
|
22
|
+
'sf-find': sfFind,
|
|
23
|
+
analysis,
|
|
24
|
+
realtor,
|
|
25
|
+
});
|
|
22
26
|
export const neighborhoodSources = Object.freeze(Object.keys(neighborhoodCollections));
|
|
23
27
|
export const highways = deepFreeze(highwayData);
|
|
24
28
|
export const landmarks = deepFreeze(landmarkData);
|
|
25
29
|
export const bartStations = deepFreeze(stationData);
|
|
26
30
|
export const catalog = deepFreeze(catalogData);
|
|
27
|
-
|
|
28
|
-
const normalize = (value) =>
|
|
29
|
-
value
|
|
31
|
+
const normalize = (value) => value
|
|
30
32
|
.normalize('NFKD')
|
|
31
33
|
.toLowerCase()
|
|
32
34
|
.replace(/[\u0300-\u036f'’]/g, '')
|
|
33
35
|
.replace(/[^a-z0-9]+/g, ' ')
|
|
34
36
|
.trim();
|
|
35
37
|
function checkSource(source) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
if (!Object.hasOwn(neighborhoodCollections, source))
|
|
39
|
+
throw new RangeError(`Unknown neighborhood source: ${source}`);
|
|
38
40
|
}
|
|
39
41
|
const names = (feature) => [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
feature.id,
|
|
43
|
+
feature.properties.canonicalName,
|
|
44
|
+
feature.properties.sourceName,
|
|
45
|
+
...feature.properties.aliases,
|
|
44
46
|
];
|
|
45
|
-
|
|
46
47
|
/** Exact ID, canonical name, source name, or alias lookup within one definition set. */
|
|
47
|
-
export function getNeighborhood(name, { source =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
export function getNeighborhood(name, { source = 'realtor' } = {}) {
|
|
49
|
+
checkSource(source);
|
|
50
|
+
if (typeof name !== 'string')
|
|
51
|
+
throw new TypeError('Neighborhood name must be a string.');
|
|
52
|
+
const query = normalize(name);
|
|
53
|
+
if (!query)
|
|
54
|
+
return undefined;
|
|
55
|
+
return neighborhoodCollections[source].features.find((feature) => names(feature).some((value) => normalize(value) === query));
|
|
55
56
|
}
|
|
56
|
-
|
|
57
57
|
/** Search names across sources; results keep their source identity and omit geometry. */
|
|
58
58
|
export function searchNeighborhoods(query = '', { source } = {}) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
normalize(value).includes(term),
|
|
67
|
-
),
|
|
68
|
-
);
|
|
59
|
+
if (source !== undefined)
|
|
60
|
+
checkSource(source);
|
|
61
|
+
if (typeof query !== 'string')
|
|
62
|
+
throw new TypeError('Neighborhood query must be a string.');
|
|
63
|
+
const term = normalize(query);
|
|
64
|
+
return catalog.neighborhoods.filter((entry) => (source === undefined || entry.source === source) &&
|
|
65
|
+
[entry.id, entry.canonicalName, entry.sourceName, ...entry.aliases].some((value) => normalize(value).includes(term)));
|
|
69
66
|
}
|
|
67
|
+
export const keyRoads = deepFreeze(roadData);
|