@collabdt/core 0.12.0 → 0.12.2
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/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +7 -10
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.d.ts +1 -0
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.js +10 -2
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.js.map +1 -1
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.js +13 -14
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +11 -8
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/src/Geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/Geocoder.js +23 -20
- package/dist/core/components/viewers/map/src/Geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js +7 -6
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js +12 -32
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/shareMapTool.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/shareMapTool.js +24 -14
- package/dist/core/components/viewers/map/src/tools/shareMapTool.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.d.ts +1 -0
- package/dist/core/components/viewers/map/utils/geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.js +5 -0
- package/dist/core/components/viewers/map/utils/geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/adapters.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.js +8 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/index.d.ts +3 -0
- package/dist/core/components/viewers/map/utils/geocoding/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/index.js +20 -3
- package/dist/core/components/viewers/map/utils/geocoding/index.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/osm.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.js +32 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/pelias.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.js +30 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.d.ts +17 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.js +26 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts +38 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js +91 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.d.ts +25 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.js +71 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.d.ts +20 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.js +103 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.d.ts +4 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.js +72 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.js.map +1 -0
- package/dist/core/hooks/useShareUrl.d.ts.map +1 -1
- package/dist/core/hooks/useShareUrl.js +5 -9
- package/dist/core/hooks/useShareUrl.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AA+BtC,eAAO,MAAM,mBAAmB,GAAU,MAAM,MAAM,EAAE,aAAa,MAAM,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,EAAE,CAU5G,CAAA;AAED,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,2BAAsC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,KAC9F,OAAO,CAAC,OAAO,EAAE,CAUnB,CAAA;AAcD,4GAA4G;AAC5G,eAAO,MAAM,WAAW,GAAU,OAAO,UAAU,EAAE,MAAM,MAAM,EAAE,UAAS,YAAiB,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAGrH,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { toDisplayString } from "../../../../../utils/utils";
|
|
2
2
|
import { getGeocodingConfig } from "./config";
|
|
3
|
-
import { photonAutocomplete, nominatimReverse } from "./osm";
|
|
4
|
-
import { peliasAutocomplete, peliasReverse } from "./pelias";
|
|
3
|
+
import { photonAutocomplete, nominatimReverse, nominatimSearchPlace } from "./osm";
|
|
4
|
+
import { peliasAutocomplete, peliasReverse, peliasSearchPlace } from "./pelias";
|
|
5
|
+
import { matchesContext } from "./placeSearch";
|
|
5
6
|
let peliasAuthFailed = false;
|
|
6
7
|
const peliasActive = () => getGeocodingConfig().usePelias && !peliasAuthFailed;
|
|
7
8
|
const isAuthError = (error) => {
|
|
@@ -38,8 +39,24 @@ const reverseGeocode = async (latitude, longitude, countryCode, { size = 1, coar
|
|
|
38
39
|
}
|
|
39
40
|
return nominatimReverse(latitude, longitude, { coarse });
|
|
40
41
|
};
|
|
42
|
+
const searchPlaceCandidates = async (level, name, context) => {
|
|
43
|
+
if (peliasActive()) {
|
|
44
|
+
try {
|
|
45
|
+
return await peliasSearchPlace(level, name, context);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
handlePeliasFailure(error, "Nominatim");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return nominatimSearchPlace(level, name, context);
|
|
51
|
+
};
|
|
52
|
+
const searchPlace = async (level, name, context = {}) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const candidates = await searchPlaceCandidates(level, name, context);
|
|
55
|
+
return (_a = candidates.find((feature) => matchesContext(feature.properties, context))) != null ? _a : null;
|
|
56
|
+
};
|
|
41
57
|
export {
|
|
42
58
|
autocompleteGeocode,
|
|
43
|
-
reverseGeocode
|
|
59
|
+
reverseGeocode,
|
|
60
|
+
searchPlace
|
|
44
61
|
};
|
|
45
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { toDisplayString } from '../../../../../utils/utils'\n\nimport { getGeocodingConfig } from './config'\nimport { photonAutocomplete, nominatimReverse } from './osm'\nimport { peliasAutocomplete, peliasReverse } from './pelias'\n\nimport type { Feature } from 'geojson'\n\n// Provider-agnostic entry points. The preferred provider (Geocode Earth or a\n// self-hosted Pelias) is resolved in ./config from runtime-injected values;\n// if it fails we fall back to the free public OSM services so address search\n// keeps working.\n//\n// A bad/expired/origin-restricted key surfaces as a 401/403. Autocomplete fires\n// on every keystroke, so once we see an auth failure we stop retrying the keyed\n// provider for the rest of the session and serve results directly from public OSM.\nlet peliasAuthFailed = false\n\nconst peliasActive = (): boolean => getGeocodingConfig().usePelias && !peliasAuthFailed\n\nconst isAuthError = (error: unknown): boolean => {\n const message = error instanceof Error ? error.message : toDisplayString(error)\n return message.includes('401') || message.includes('403')\n}\n\nconst handlePeliasFailure = (error: unknown, fallbackName: string): void => {\n if (isAuthError(error)) {\n peliasAuthFailed = true\n console.warn(\n `Geocoder: the configured provider rejected the API key (auth error). ` +\n `Falling back to public OSM services (Photon/Nominatim) for the rest of this session.`,\n )\n } else {\n console.warn(`Geocoder: provider request failed; falling back to ${fallbackName}.`, error)\n }\n}\n\nexport const autocompleteGeocode = async (text: string, countryCode: string, size: number): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasAutocomplete(text, countryCode, size)\n }\n catch (error) {\n handlePeliasFailure(error, 'Photon')\n }\n }\n return photonAutocomplete(text, countryCode, size)\n}\n\nexport const reverseGeocode = async (\n latitude: string,\n longitude: string,\n countryCode: string,\n { size = 1, coarse = false, layers }: { size?: number; coarse?: boolean; layers?: string } = {},\n): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasReverse(latitude, longitude, countryCode, { size, coarse, layers })\n }\n catch (error) {\n handlePeliasFailure(error, 'Nominatim')\n }\n }\n return nominatimReverse(latitude, longitude, { coarse })\n}\n"],"mappings":"AAGA,SAAS,uBAAuB;AAEhC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { toDisplayString } from '../../../../../utils/utils'\n\nimport { getGeocodingConfig } from './config'\nimport { photonAutocomplete, nominatimReverse, nominatimSearchPlace } from './osm'\nimport { peliasAutocomplete, peliasReverse, peliasSearchPlace } from './pelias'\n\nimport { matchesContext } from './placeSearch'\n\nimport type { PlaceContext, PlaceLevel } from './placeSearch'\nimport type { Feature } from 'geojson'\n\n// Provider-agnostic entry points. The preferred provider (Geocode Earth or a\n// self-hosted Pelias) is resolved in ./config from runtime-injected values;\n// if it fails we fall back to the free public OSM services so address search\n// keeps working.\n//\n// A bad/expired/origin-restricted key surfaces as a 401/403. Autocomplete fires\n// on every keystroke, so once we see an auth failure we stop retrying the keyed\n// provider for the rest of the session and serve results directly from public OSM.\nlet peliasAuthFailed = false\n\nconst peliasActive = (): boolean => getGeocodingConfig().usePelias && !peliasAuthFailed\n\nconst isAuthError = (error: unknown): boolean => {\n const message = error instanceof Error ? error.message : toDisplayString(error)\n return message.includes('401') || message.includes('403')\n}\n\nconst handlePeliasFailure = (error: unknown, fallbackName: string): void => {\n if (isAuthError(error)) {\n peliasAuthFailed = true\n console.warn(\n `Geocoder: the configured provider rejected the API key (auth error). ` +\n `Falling back to public OSM services (Photon/Nominatim) for the rest of this session.`,\n )\n } else {\n console.warn(`Geocoder: provider request failed; falling back to ${fallbackName}.`, error)\n }\n}\n\nexport const autocompleteGeocode = async (text: string, countryCode: string, size: number): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasAutocomplete(text, countryCode, size)\n }\n catch (error) {\n handlePeliasFailure(error, 'Photon')\n }\n }\n return photonAutocomplete(text, countryCode, size)\n}\n\nexport const reverseGeocode = async (\n latitude: string,\n longitude: string,\n countryCode: string,\n { size = 1, coarse = false, layers }: { size?: number; coarse?: boolean; layers?: string } = {},\n): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasReverse(latitude, longitude, countryCode, { size, coarse, layers })\n }\n catch (error) {\n handlePeliasFailure(error, 'Nominatim')\n }\n }\n return nominatimReverse(latitude, longitude, { coarse })\n}\n\nconst searchPlaceCandidates = async (level: PlaceLevel, name: string, context: PlaceContext): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasSearchPlace(level, name, context)\n }\n catch (error) {\n handlePeliasFailure(error, 'Nominatim')\n }\n }\n return nominatimSearchPlace(level, name, context)\n}\n\n/** First result in `level`'s category that lies inside the parent subdivision, or null to go up a level. */\nexport const searchPlace = async (level: PlaceLevel, name: string, context: PlaceContext = {}): Promise<Feature | null> => {\n const candidates = await searchPlaceCandidates(level, name, context)\n return candidates.find(feature => matchesContext(feature.properties, context)) ?? null\n}\n"],"mappings":"AAGA,SAAS,uBAAuB;AAEhC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB,kBAAkB,4BAA4B;AAC3E,SAAS,oBAAoB,eAAe,yBAAyB;AAErE,SAAS,sBAAsB;AAa/B,IAAI,mBAAmB;AAEvB,MAAM,eA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c,OAAO,OAAmB,MAAc,UAAwB,CAAC,MAA+B;AArF3H;AAsFE,QAAM,aAAa,MAAM,sBAAsB,OAAO,MAAM,OAAO;AACnE,UAAO,gBAAW,KAAK,aAAW,eAAe,QAAQ,YAAY,OAAO,CAAC,MAAtE,YAA2E;AACpF;","names":[]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { PlaceContext, PlaceLevel } from './placeSearch';
|
|
1
2
|
import type { Feature } from 'geojson';
|
|
2
3
|
export declare const photonAutocomplete: (text: string, countryCode: string | undefined, size: number) => Promise<Feature[]>;
|
|
3
4
|
export declare const nominatimReverse: (latitude: string, longitude: string, { coarse }: {
|
|
4
5
|
coarse: boolean;
|
|
5
6
|
}) => Promise<Feature[]>;
|
|
7
|
+
export declare const nominatimSearchPlace: (level: PlaceLevel, name: string, context: PlaceContext) => Promise<Feature[]>;
|
|
6
8
|
//# sourceMappingURL=osm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"osm.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/osm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"osm.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/osm.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,kBAAkB,GAAU,MAAM,MAAM,EAAE,aAAa,MAAM,GAAG,SAAS,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,EAAE,CAsBvH,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,YAAY;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,KAC9B,OAAO,CAAC,OAAO,EAAE,CAiBnB,CAAA;AAmBD,eAAO,MAAM,oBAAoB,GAAU,OAAO,UAAU,EAAE,MAAM,MAAM,EAAE,SAAS,YAAY,KAAG,OAAO,CAAC,OAAO,EAAE,CAoBpH,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { normalizePhotonFeature, normalizeNominatimResult } from "./adapters";
|
|
1
|
+
import { normalizePhotonFeature, normalizeNominatimResult, subdivisionName } from "./adapters";
|
|
2
2
|
import { getGeocodingConfig } from "./config";
|
|
3
|
+
import { isCountryCode, PLACE_CANDIDATES } from "./placeSearch";
|
|
3
4
|
const photonAutocomplete = async (text, countryCode, size) => {
|
|
4
5
|
const { photonUrl } = getGeocodingConfig();
|
|
5
6
|
const params = new URLSearchParams({ q: text, limit: String(size * 2), lang: "en" });
|
|
@@ -33,8 +34,38 @@ const nominatimReverse = async (latitude, longitude, { coarse }) => {
|
|
|
33
34
|
if (!data || data.error || data.lat == null) return [];
|
|
34
35
|
return [normalizeNominatimResult(data)];
|
|
35
36
|
};
|
|
37
|
+
const NOMINATIM_FIELDS = {
|
|
38
|
+
country: "country",
|
|
39
|
+
countrySubdivision: "state",
|
|
40
|
+
municipality: "city",
|
|
41
|
+
address: "street"
|
|
42
|
+
};
|
|
43
|
+
const NOMINATIM_FEATURE_TYPES = {
|
|
44
|
+
country: "country",
|
|
45
|
+
countrySubdivision: "state",
|
|
46
|
+
municipality: "settlement"
|
|
47
|
+
};
|
|
48
|
+
const nominatimSubdivision = (value, country) => isCountryCode(country) && subdivisionName(country, value) || value;
|
|
49
|
+
const nominatimSearchPlace = async (level, name, context) => {
|
|
50
|
+
const { nominatimUrl } = getGeocodingConfig();
|
|
51
|
+
const params = new URLSearchParams({ format: "jsonv2", addressdetails: "1", limit: String(PLACE_CANDIDATES) });
|
|
52
|
+
if (isCountryCode(context.country)) params.set("countrycodes", context.country.toLowerCase());
|
|
53
|
+
else if (context.country) params.set("country", context.country);
|
|
54
|
+
if (context.countrySubdivision) params.set("state", nominatimSubdivision(context.countrySubdivision, context.country));
|
|
55
|
+
if (context.municipality) params.set("city", context.municipality);
|
|
56
|
+
const value = level === "countrySubdivision" ? nominatimSubdivision(name, context.country) : name;
|
|
57
|
+
params.set(NOMINATIM_FIELDS[level], value);
|
|
58
|
+
if (level === "country" && isCountryCode(name)) params.set("countrycodes", name.toLowerCase());
|
|
59
|
+
const featureType = NOMINATIM_FEATURE_TYPES[level];
|
|
60
|
+
if (featureType) params.set("featureType", featureType);
|
|
61
|
+
const response = await fetch(`${nominatimUrl}/search?${params}`);
|
|
62
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
63
|
+
const data = await response.json();
|
|
64
|
+
return Array.isArray(data) ? data.map(normalizeNominatimResult) : [];
|
|
65
|
+
};
|
|
36
66
|
export {
|
|
37
67
|
nominatimReverse,
|
|
68
|
+
nominatimSearchPlace,
|
|
38
69
|
photonAutocomplete
|
|
39
70
|
};
|
|
40
71
|
//# sourceMappingURL=osm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/osm.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { normalizePhotonFeature, normalizeNominatimResult } from './adapters'\nimport { getGeocodingConfig } from './config'\n\nimport type { Feature } from 'geojson'\n\n// Free, no-key public OSM fallbacks. Photon serves autocomplete (it is built for\n// per-keystroke search); Nominatim serves reverse lookups (occasional, single point).\n\nexport const photonAutocomplete = async (text: string, countryCode: string | undefined, size: number): Promise<Feature[]> => {\n const { photonUrl } = getGeocodingConfig()\n\n // Photon has no country filter, so over-fetch and post-filter by country code.\n const params = new URLSearchParams({ q: text, limit: String(size * 2), lang: 'en' })\n\n const response = await fetch(`${photonUrl}/api?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n let features: Feature[] = (data.features || []).map(normalizePhotonFeature)\n\n if (countryCode) {\n const cc = countryCode.toUpperCase()\n const inCountry = features.filter(f => {\n const ca = (f.properties as any)?.country_a\n return !ca || ca === cc\n })\n if (inCountry.length) features = inCountry\n }\n\n return features.slice(0, size)\n}\n\nexport const nominatimReverse = async (\n latitude: string,\n longitude: string,\n { coarse }: { coarse: boolean },\n): Promise<Feature[]> => {\n const { nominatimUrl } = getGeocodingConfig()\n\n const params = new URLSearchParams({\n format: 'jsonv2',\n lat: latitude,\n lon: longitude,\n addressdetails: '1',\n zoom: coarse ? '10' : '18',\n })\n\n const response = await fetch(`${nominatimUrl}/reverse?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n if (!data || data.error || data.lat == null) return []\n return [normalizeNominatimResult(data)]\n}\n"],"mappings":"AAGA,SAAS,wBAAwB,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/osm.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { normalizePhotonFeature, normalizeNominatimResult, subdivisionName } from './adapters'\nimport { getGeocodingConfig } from './config'\nimport { isCountryCode, PLACE_CANDIDATES } from './placeSearch'\n\nimport type { PlaceContext, PlaceLevel } from './placeSearch'\nimport type { Feature } from 'geojson'\n\n// Free, no-key public OSM fallbacks. Photon serves autocomplete (it is built for\n// per-keystroke search); Nominatim serves reverse lookups (occasional, single point).\n\nexport const photonAutocomplete = async (text: string, countryCode: string | undefined, size: number): Promise<Feature[]> => {\n const { photonUrl } = getGeocodingConfig()\n\n // Photon has no country filter, so over-fetch and post-filter by country code.\n const params = new URLSearchParams({ q: text, limit: String(size * 2), lang: 'en' })\n\n const response = await fetch(`${photonUrl}/api?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n let features: Feature[] = (data.features || []).map(normalizePhotonFeature)\n\n if (countryCode) {\n const cc = countryCode.toUpperCase()\n const inCountry = features.filter(f => {\n const ca = (f.properties as any)?.country_a\n return !ca || ca === cc\n })\n if (inCountry.length) features = inCountry\n }\n\n return features.slice(0, size)\n}\n\nexport const nominatimReverse = async (\n latitude: string,\n longitude: string,\n { coarse }: { coarse: boolean },\n): Promise<Feature[]> => {\n const { nominatimUrl } = getGeocodingConfig()\n\n const params = new URLSearchParams({\n format: 'jsonv2',\n lat: latitude,\n lon: longitude,\n addressdetails: '1',\n zoom: coarse ? '10' : '18',\n })\n\n const response = await fetch(`${nominatimUrl}/reverse?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n if (!data || data.error || data.lat == null) return []\n return [normalizeNominatimResult(data)]\n}\n\nconst NOMINATIM_FIELDS: Record<PlaceLevel, string> = {\n country: 'country',\n countrySubdivision: 'state',\n municipality: 'city',\n address: 'street',\n}\n\nconst NOMINATIM_FEATURE_TYPES: Partial<Record<PlaceLevel, string>> = {\n country: 'country',\n countrySubdivision: 'state',\n municipality: 'settlement',\n}\n\n// Nominatim matches `state=Quebec` but not `state=QC`, so known codes are expanded to names.\nconst nominatimSubdivision = (value: string, country?: string): string =>\n (isCountryCode(country) && subdivisionName(country, value)) || value\n\nexport const nominatimSearchPlace = async (level: PlaceLevel, name: string, context: PlaceContext): Promise<Feature[]> => {\n const { nominatimUrl } = getGeocodingConfig()\n\n const params = new URLSearchParams({ format: 'jsonv2', addressdetails: '1', limit: String(PLACE_CANDIDATES) })\n if (isCountryCode(context.country)) params.set('countrycodes', context.country.toLowerCase())\n else if (context.country) params.set('country', context.country)\n if (context.countrySubdivision) params.set('state', nominatimSubdivision(context.countrySubdivision, context.country))\n if (context.municipality) params.set('city', context.municipality)\n\n const value = level === 'countrySubdivision' ? nominatimSubdivision(name, context.country) : name\n params.set(NOMINATIM_FIELDS[level], value)\n if (level === 'country' && isCountryCode(name)) params.set('countrycodes', name.toLowerCase())\n const featureType = NOMINATIM_FEATURE_TYPES[level]\n if (featureType) params.set('featureType', featureType)\n\n const response = await fetch(`${nominatimUrl}/search?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n return Array.isArray(data) ? data.map(normalizeNominatimResult) : []\n}\n"],"mappings":"AAGA,SAAS,wBAAwB,0BAA0B,uBAAuB;AAClF,SAAS,0BAA0B;AACnC,SAAS,eAAe,wBAAwB;AAQzC,MAAM,qBAAqB,OAAO,MAAc,aAAiC,SAAqC;AAC3H,QAAM,EAAE,UAAU,IAAI,mBAAmB;AAGzC,QAAM,SAAS,IAAI,gBAAgB,EAAE,GAAG,MAAM,OAAO,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;AAEnF,QAAM,WAAW,MAAM,MAAM,GAAG,SAAS,QAAQ,MAAM,EAAE;AACzD,MAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAE1E,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,YAAuB,KAAK,YAAY,CAAC,GAAG,IAAI,sBAAsB;AAE1E,MAAI,aAAa;AACf,UAAM,KAAK,YAAY,YAAY;AACnC,UAAM,YAAY,SAAS,OAAO,OAAK;AA3B3C;AA4BM,YAAM,MAAM,OAAE,eAAF,mBAAsB;AAClC,aAAO,CAAC,MAAM,OAAO;AAAA,IACvB,CAAC;AACD,QAAI,UAAU,OAAQ,YAAW;AAAA,EACnC;AAEA,SAAO,SAAS,MAAM,GAAG,IAAI;AAC/B;AAEO,MAAM,mBAAmB,OAC9B,UACA,WACA,EAAE,OAAO,MACc;AACvB,QAAM,EAAE,aAAa,IAAI,mBAAmB;AAE5C,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,MAAM,SAAS,OAAO;AAAA,EACxB,CAAC;AAED,QAAM,WAAW,MAAM,MAAM,GAAG,YAAY,YAAY,MAAM,EAAE;AAChE,MAAI,CAAC,SAAS,GAAI,OA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,GAAG,YAAY,WAAW,MAAM,EAAE;AAC/D,MAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAE1E,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,SAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,wBAAwB,IAAI,CAAC;AACrE;","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PlaceContext, PlaceLevel } from './placeSearch';
|
|
1
2
|
import type { Feature } from 'geojson';
|
|
2
3
|
export declare const peliasAutocomplete: (text: string, countryCode: string | undefined, size: number) => Promise<Feature[]>;
|
|
3
4
|
export declare const peliasReverse: (latitude: string, longitude: string, countryCode: string | undefined, { size, coarse, layers }: {
|
|
@@ -5,4 +6,5 @@ export declare const peliasReverse: (latitude: string, longitude: string, countr
|
|
|
5
6
|
coarse: boolean;
|
|
6
7
|
layers?: string;
|
|
7
8
|
}) => Promise<Feature[]>;
|
|
9
|
+
export declare const peliasSearchPlace: (level: PlaceLevel, name: string, context: PlaceContext) => Promise<Feature[]>;
|
|
8
10
|
//# sourceMappingURL=pelias.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pelias.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/pelias.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pelias.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/pelias.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,kBAAkB,GAAU,MAAM,MAAM,EAAE,aAAa,MAAM,GAAG,SAAS,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,EAAE,CAevH,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,aAAa,MAAM,GAAG,SAAS,EAC/B,0BAA0B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3E,OAAO,CAAC,OAAO,EAAE,CAkBnB,CAAA;AAgBD,eAAO,MAAM,iBAAiB,GAAU,OAAO,UAAU,EAAE,MAAM,MAAM,EAAE,SAAS,YAAY,KAAG,OAAO,CAAC,OAAO,EAAE,CAgBjH,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getGeocodingConfig } from "./config";
|
|
2
|
+
import { isCountryCode, PLACE_CANDIDATES } from "./placeSearch";
|
|
2
3
|
const peliasAutocomplete = async (text, countryCode, size) => {
|
|
3
4
|
var _a;
|
|
4
5
|
const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig();
|
|
@@ -30,8 +31,36 @@ const peliasReverse = async (latitude, longitude, countryCode, { size, coarse, l
|
|
|
30
31
|
const data = await response.json();
|
|
31
32
|
return ((_a = data.features) == null ? void 0 : _a.length) ? data.features : [];
|
|
32
33
|
};
|
|
34
|
+
const PELIAS_LAYERS = {
|
|
35
|
+
country: "country",
|
|
36
|
+
countrySubdivision: "region",
|
|
37
|
+
municipality: "locality,localadmin",
|
|
38
|
+
address: "address"
|
|
39
|
+
};
|
|
40
|
+
const PELIAS_FIELDS = {
|
|
41
|
+
country: "country",
|
|
42
|
+
countrySubdivision: "region",
|
|
43
|
+
municipality: "locality",
|
|
44
|
+
address: "address"
|
|
45
|
+
};
|
|
46
|
+
const peliasSearchPlace = async (level, name, context) => {
|
|
47
|
+
var _a;
|
|
48
|
+
const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig();
|
|
49
|
+
const params = new URLSearchParams({ size: String(PLACE_CANDIDATES), layers: PELIAS_LAYERS[level] });
|
|
50
|
+
if (context.country) params.set("country", context.country);
|
|
51
|
+
if (context.countrySubdivision) params.set("region", context.countrySubdivision);
|
|
52
|
+
if (context.municipality) params.set("locality", context.municipality);
|
|
53
|
+
params.set(PELIAS_FIELDS[level], name);
|
|
54
|
+
if (level !== "country" && isCountryCode(context.country)) params.set("boundary.country", context.country.toUpperCase());
|
|
55
|
+
if (geocodeEarthApiKey) params.set("api_key", geocodeEarthApiKey);
|
|
56
|
+
const response = await fetch(`${peliasBase}/v1/search/structured?${params}`);
|
|
57
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
58
|
+
const data = await response.json();
|
|
59
|
+
return (_a = data.features) != null ? _a : [];
|
|
60
|
+
};
|
|
33
61
|
export {
|
|
34
62
|
peliasAutocomplete,
|
|
35
|
-
peliasReverse
|
|
63
|
+
peliasReverse,
|
|
64
|
+
peliasSearchPlace
|
|
36
65
|
};
|
|
37
66
|
//# sourceMappingURL=pelias.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/pelias.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { getGeocodingConfig } from './config'\n\nimport type { Feature } from 'geojson'\n\n// Geocode Earth and self-hosted Pelias share this dialect; only the base URL and\n// the (optional) api_key differ. Responses already match the shape the app expects.\n\nexport const peliasAutocomplete = async (text: string, countryCode: string | undefined, size: number): Promise<Feature[]> => {\n const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig()\n\n const params = new URLSearchParams({\n 'text': text,\n 'size': String(size),\n })\n if (countryCode) params.set('boundary.country', countryCode.toUpperCase())\n if (geocodeEarthApiKey) params.set('api_key', geocodeEarthApiKey)\n\n const response = await fetch(`${peliasBase}/v1/autocomplete?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const geojson = await response.json()\n return geojson.features?.length ? geojson.features : []\n}\n\nexport const peliasReverse = async (\n latitude: string,\n longitude: string,\n countryCode: string | undefined,\n { size, coarse, layers }: { size: number; coarse: boolean; layers?: string },\n): Promise<Feature[]> => {\n const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig()\n\n const params = new URLSearchParams({\n 'point.lat': latitude,\n 'point.lon': longitude,\n 'size': String(size),\n })\n if (countryCode) params.set('boundary.country', countryCode.toUpperCase())\n if (coarse) params.set('layers', 'coarse')\n else if (layers) params.set('layers', layers)\n if (geocodeEarthApiKey) params.set('api_key', geocodeEarthApiKey)\n\n const response = await fetch(`${peliasBase}/v1/reverse?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n return data.features?.length ? data.features : []\n}\n"],"mappings":"AAGA,SAAS,0BAA0B;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/pelias.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { getGeocodingConfig } from './config'\nimport { isCountryCode, PLACE_CANDIDATES } from './placeSearch'\n\nimport type { PlaceContext, PlaceLevel } from './placeSearch'\nimport type { Feature } from 'geojson'\n\n// Geocode Earth and self-hosted Pelias share this dialect; only the base URL and\n// the (optional) api_key differ. Responses already match the shape the app expects.\n\nexport const peliasAutocomplete = async (text: string, countryCode: string | undefined, size: number): Promise<Feature[]> => {\n const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig()\n\n const params = new URLSearchParams({\n 'text': text,\n 'size': String(size),\n })\n if (countryCode) params.set('boundary.country', countryCode.toUpperCase())\n if (geocodeEarthApiKey) params.set('api_key', geocodeEarthApiKey)\n\n const response = await fetch(`${peliasBase}/v1/autocomplete?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const geojson = await response.json()\n return geojson.features?.length ? geojson.features : []\n}\n\nexport const peliasReverse = async (\n latitude: string,\n longitude: string,\n countryCode: string | undefined,\n { size, coarse, layers }: { size: number; coarse: boolean; layers?: string },\n): Promise<Feature[]> => {\n const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig()\n\n const params = new URLSearchParams({\n 'point.lat': latitude,\n 'point.lon': longitude,\n 'size': String(size),\n })\n if (countryCode) params.set('boundary.country', countryCode.toUpperCase())\n if (coarse) params.set('layers', 'coarse')\n else if (layers) params.set('layers', layers)\n if (geocodeEarthApiKey) params.set('api_key', geocodeEarthApiKey)\n\n const response = await fetch(`${peliasBase}/v1/reverse?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n return data.features?.length ? data.features : []\n}\n\nconst PELIAS_LAYERS: Record<PlaceLevel, string> = {\n country: 'country',\n countrySubdivision: 'region',\n municipality: 'locality,localadmin',\n address: 'address',\n}\n\nconst PELIAS_FIELDS: Record<PlaceLevel, string> = {\n country: 'country',\n countrySubdivision: 'region',\n municipality: 'locality',\n address: 'address',\n}\n\nexport const peliasSearchPlace = async (level: PlaceLevel, name: string, context: PlaceContext): Promise<Feature[]> => {\n const { geocodeEarthApiKey, peliasBase } = getGeocodingConfig()\n\n const params = new URLSearchParams({ size: String(PLACE_CANDIDATES), layers: PELIAS_LAYERS[level] })\n if (context.country) params.set('country', context.country)\n if (context.countrySubdivision) params.set('region', context.countrySubdivision)\n if (context.municipality) params.set('locality', context.municipality)\n params.set(PELIAS_FIELDS[level], name)\n if (level !== 'country' && isCountryCode(context.country)) params.set('boundary.country', context.country.toUpperCase())\n if (geocodeEarthApiKey) params.set('api_key', geocodeEarthApiKey)\n\n const response = await fetch(`${peliasBase}/v1/search/structured?${params}`)\n if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)\n\n const data = await response.json()\n return data.features ?? []\n}\n"],"mappings":"AAGA,SAAS,0BAA0B;AACnC,SAAS,eAAe,wBAAwB;AAQzC,MAAM,qBAAqB,OAAO,MAAc,aAAiC,SAAqC;AAZ7H;AAaE,QAAM,EAAE,oBAAoB,WAAW,IAAI,mBAAmB;AAE9D,QAAM,SAAS,IAAI,gBAAgB;AAAA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AAAA,EACpB,cAAc;AAAA,EACd,SAAS;AACX;AAEO,MAAM,oBAAoB,OAAO,OAAmB,MAAc,YAA8C;AApEvH;AAqEE,QAAM,EAAE,oBAAoB,WAAW,IAAI,mBAAmB;AAE9D,QAAM,SAAS,IAAI,gBAAgB,EAAE,MAAM,OAAO,gBAAgB,GAAG,QAAQ,cAAc,KAAK,EAAE,CAAC;AACnG,MAAI,QAAQ,QAAS,QAAO,IAAI,WAAW,QAAQ,OAAO;AAC1D,MAAI,QAAQ,mBAAoB,QAAO,IAAI,UAAU,QAAQ,kBAAkB;AAC/E,MAAI,QAAQ,aAAc,QAAO,IAAI,YAAY,QAAQ,YAAY;AACrE,SAAO,IAAI,cAAc,KAAK,GAAG,IAAI;AACrC,MAAI,UAAU,aAAa,cAAc,QAAQ,OAAO,EAAG,QAAO,IAAI,oBAAoB,QAAQ,QAAQ,YAAY,CAAC;AACvH,MAAI,mBAAoB,QAAO,IAAI,WAAW,kBAAkB;AAEhE,QAAM,WAAW,MAAM,MAAM,GAAG,UAAU,yBAAyB,MAAM,EAAE;AAC3E,MAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAE1E,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAO,UAAK,aAAL,YAAiB,CAAC;AAC3B;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PlaceLevel = 'country' | 'countrySubdivision' | 'municipality' | 'address';
|
|
2
|
+
/** Parent names that disambiguate a place search; each is optional. */
|
|
3
|
+
export interface PlaceContext {
|
|
4
|
+
country?: string;
|
|
5
|
+
countrySubdivision?: string;
|
|
6
|
+
municipality?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const isCountryCode: (value?: string) => value is string;
|
|
9
|
+
/** `CA-ON` (camera tracking) and `ON` (geocoder) both name Ontario; queries want the bare code. */
|
|
10
|
+
export declare const normalizeSubdivision: (value?: string | null) => string;
|
|
11
|
+
/** The country an ISO 3166-2 code names: `CA-ON` → `CA`, or '' for a bare code. */
|
|
12
|
+
export declare const subdivisionCountry: (value?: string | null) => string;
|
|
13
|
+
/** Candidates fetched per search, so the first one inside the parent subdivision can win. */
|
|
14
|
+
export declare const PLACE_CANDIDATES = 5;
|
|
15
|
+
/** False only when the feature names a subdivision other than the one asked for; missing data passes. */
|
|
16
|
+
export declare function matchesContext(properties: Record<string, unknown> | null | undefined, context: PlaceContext): boolean;
|
|
17
|
+
//# sourceMappingURL=placeSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placeSearch.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/placeSearch.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,oBAAoB,GAAG,cAAc,GAAG,SAAS,CAAA;AAEtF,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAID,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,KAAG,KAAK,IAAI,MAAuC,CAAA;AAE/F,mGAAmG;AACnG,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,GAAG,IAAI,KAAG,MAI5D,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,GAAG,IAAI,KAAG,MACU,CAAA;AAErE,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,IAAI,CAAA;AAIjC,yGAAyG;AACzG,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAIrH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const ALPHA2 = /^[a-z]{2}$/i;
|
|
2
|
+
const isCountryCode = (value) => !!value && ALPHA2.test(value);
|
|
3
|
+
const normalizeSubdivision = (value) => {
|
|
4
|
+
const trimmed = (value != null ? value : "").trim();
|
|
5
|
+
const match = /^[a-z]{2}-(.+)$/i.exec(trimmed);
|
|
6
|
+
return match ? match[1] : trimmed;
|
|
7
|
+
};
|
|
8
|
+
const subdivisionCountry = (value) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
return (_b = (_a = /^([a-z]{2})-/i.exec((value != null ? value : "").trim())) == null ? void 0 : _a[1].toUpperCase()) != null ? _b : "";
|
|
11
|
+
};
|
|
12
|
+
const PLACE_CANDIDATES = 5;
|
|
13
|
+
const fold = (value) => (typeof value === "string" ? value : "").normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").trim().toLowerCase();
|
|
14
|
+
function matchesContext(properties, context) {
|
|
15
|
+
const wanted = fold(context.countrySubdivision);
|
|
16
|
+
const regions = [properties == null ? void 0 : properties.region_a, properties == null ? void 0 : properties.region].map(fold).filter(Boolean);
|
|
17
|
+
return !wanted || regions.length === 0 || regions.includes(wanted);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
PLACE_CANDIDATES,
|
|
21
|
+
isCountryCode,
|
|
22
|
+
matchesContext,
|
|
23
|
+
normalizeSubdivision,
|
|
24
|
+
subdivisionCountry
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=placeSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/placeSearch.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nexport type PlaceLevel = 'country' | 'countrySubdivision' | 'municipality' | 'address'\n\n/** Parent names that disambiguate a place search; each is optional. */\nexport interface PlaceContext {\n country?: string\n countrySubdivision?: string\n municipality?: string\n}\n\nconst ALPHA2 = /^[a-z]{2}$/i\n\nexport const isCountryCode = (value?: string): value is string => !!value && ALPHA2.test(value)\n\n/** `CA-ON` (camera tracking) and `ON` (geocoder) both name Ontario; queries want the bare code. */\nexport const normalizeSubdivision = (value?: string | null): string => {\n const trimmed = (value ?? '').trim()\n const match = /^[a-z]{2}-(.+)$/i.exec(trimmed)\n return match ? match[1] : trimmed\n}\n\n/** The country an ISO 3166-2 code names: `CA-ON` → `CA`, or '' for a bare code. */\nexport const subdivisionCountry = (value?: string | null): string =>\n /^([a-z]{2})-/i.exec((value ?? '').trim())?.[1].toUpperCase() ?? ''\n\n/** Candidates fetched per search, so the first one inside the parent subdivision can win. */\nexport const PLACE_CANDIDATES = 5\n\nconst fold = (value: unknown) => (typeof value === 'string' ? value : '').normalize('NFD').replace(/\\p{Diacritic}/gu, '').trim().toLowerCase()\n\n/** False only when the feature names a subdivision other than the one asked for; missing data passes. */\nexport function matchesContext(properties: Record<string, unknown> | null | undefined, context: PlaceContext): boolean {\n const wanted = fold(context.countrySubdivision)\n const regions = [properties?.region_a, properties?.region].map(fold).filter(Boolean)\n return !wanted || regions.length === 0 || regions.includes(wanted)\n}\n"],"mappings":"AAYA,MAAM,SAAS;AAER,MAAM,gBAAgB,CAAC,UAAoC,CAAC,CAAC,SAAS,OAAO,KAAK,KAAK;AAGvF,MAAM,uBAAuB,CAAC,UAAkC;AACrE,QAAM,WAAW,wBAAS,IAAI,KAAK;AACnC,QAAM,QAAQ,mBAAmB,KAAK,OAAO;AAC7C,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;AAGO,MAAM,qBAAqB,CAAC,UAA+B;AAxBlE;AAyBE,qCAAgB,MAAM,wBAAS,IAAI,KAAK,CAAC,MAAzC,mBAA6C,GAAG,kBAAhD,YAAiE;AAAA;AAG5D,MAAM,mBAAmB;AAEhC,MAAM,OAAO,CAAC,WAAoB,OAAO,UAAU,WAAW,QAAQ,IAAI,UAAU,KAAK,EAAE,QAAQ,WAAC,kBAAc,IAAE,GAAE,EAAE,EAAE,KAAK,EAAE,YAAY;AAGtI,SAAS,eAAe,YAAwD,SAAgC;AACrH,QAAM,SAAS,KAAK,QAAQ,kBAAkB;AAC9C,QAAM,UAAU,CAAC,yCAAY,UAAU,yCAAY,MAAM,EAAE,IAAI,IAAI,EAAE,OAAO,OAAO;AACnF,SAAO,CAAC,UAAU,QAAQ,WAAW,KAAK,QAAQ,SAAS,MAAM;AACnE;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Bbox, CameraTarget, LocationLevel } from './locationTarget';
|
|
2
|
+
import type { Map as MapLibreMap } from 'maplibre-gl';
|
|
3
|
+
export declare const LABEL_KEYS: readonly ["country", "countrySubdivision", "municipality", "site", "address", "buildingId"];
|
|
4
|
+
export type LabelKey = typeof LABEL_KEYS[number];
|
|
5
|
+
export type LocationLabels = Partial<Record<LabelKey, string>>;
|
|
6
|
+
export interface CameraSnapshot {
|
|
7
|
+
lat: number;
|
|
8
|
+
lng: number;
|
|
9
|
+
zoom: number;
|
|
10
|
+
bearing: number;
|
|
11
|
+
pitch: number;
|
|
12
|
+
bounds: Bbox;
|
|
13
|
+
}
|
|
14
|
+
interface PlaceProperties {
|
|
15
|
+
country_a?: string;
|
|
16
|
+
region_a?: string;
|
|
17
|
+
region?: string;
|
|
18
|
+
locality?: string;
|
|
19
|
+
neighbourhood?: string;
|
|
20
|
+
county?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function labelsFromParams(params: URLSearchParams): LocationLabels;
|
|
23
|
+
export declare function labelsFromPlace(properties: PlaceProperties | null | undefined, address?: string): LocationLabels;
|
|
24
|
+
/** Labels finer than `level` describe somewhere else once the map has flown there, so they are dropped. */
|
|
25
|
+
export declare function clearFinerLabels(labels: LocationLabels, level: LocationLevel): LocationLabels;
|
|
26
|
+
export declare function withLocationParams(params: URLSearchParams, camera: CameraSnapshot, labels: LocationLabels): URLSearchParams;
|
|
27
|
+
export declare function cameraSnapshot(map: MapLibreMap): CameraSnapshot;
|
|
28
|
+
/** `URLSearchParams` escapes commas, which are legal in a query; keep them readable so `bbox=w,s,e,n` stays legible. */
|
|
29
|
+
export declare const toQueryString: (params: URLSearchParams) => string;
|
|
30
|
+
/** Rewrites the live URL's params in place: no server round trip, and Next's router adopts the result. */
|
|
31
|
+
export declare function replaceUrlParams(update: (params: URLSearchParams) => URLSearchParams): void;
|
|
32
|
+
/** Writes the map's current camera plus `labels` into the address bar without a navigation. */
|
|
33
|
+
export declare function writeLocationParams(map: MapLibreMap, labels: LocationLabels): CameraSnapshot;
|
|
34
|
+
export declare function flyToCamera(map: MapLibreMap, target: CameraTarget): void;
|
|
35
|
+
/** Flies to `target` and, once the camera settles, rewrites the URL with every location value. */
|
|
36
|
+
export declare function flyAndSyncUrl(map: MapLibreMap, target: CameraTarget, labels: LocationLabels): Promise<CameraSnapshot>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=locationParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locationParams.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/locationParams.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,UAAU,6FAA8F,CAAA;AAErH,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;AAEhD,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;AAK9D,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,IAAI,CAAA;CACb;AA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LEVELS } from "./locationTarget";
|
|
2
|
+
const LABEL_KEYS = ["country", "countrySubdivision", "municipality", "site", "address", "buildingId"];
|
|
3
|
+
const MAP_LABEL_KEYS = ["country", "countrySubdivision", "municipality", "address"];
|
|
4
|
+
function labelsFromParams(params) {
|
|
5
|
+
var _a;
|
|
6
|
+
const labels = {};
|
|
7
|
+
for (const key of LABEL_KEYS) {
|
|
8
|
+
const value = (_a = params.get(key)) == null ? void 0 : _a.trim();
|
|
9
|
+
if (value) labels[key] = value;
|
|
10
|
+
}
|
|
11
|
+
return labels;
|
|
12
|
+
}
|
|
13
|
+
function labelsFromPlace(properties, address) {
|
|
14
|
+
var _a;
|
|
15
|
+
const p = properties != null ? properties : {};
|
|
16
|
+
return {
|
|
17
|
+
country: ((_a = p.country_a) == null ? void 0 : _a.length) === 2 ? p.country_a : void 0,
|
|
18
|
+
countrySubdivision: p.region_a || p.region || void 0,
|
|
19
|
+
municipality: p.locality || p.neighbourhood || p.county || void 0,
|
|
20
|
+
address: address || void 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function clearFinerLabels(labels, level) {
|
|
24
|
+
const depth = LOCATION_LEVELS.indexOf(level);
|
|
25
|
+
return Object.fromEntries(
|
|
26
|
+
Object.entries(labels).filter(([key]) => LOCATION_LEVELS.indexOf(key) <= depth)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const round = (value, digits) => String(Number(value.toFixed(digits)));
|
|
30
|
+
function withLocationParams(params, camera, labels) {
|
|
31
|
+
const next = new URLSearchParams(params.toString());
|
|
32
|
+
next.set("lat", round(camera.lat, 7));
|
|
33
|
+
next.set("lng", round(camera.lng, 7));
|
|
34
|
+
next.set("zoom", round(camera.zoom, 2));
|
|
35
|
+
next.set("bearing", round(camera.bearing, 1));
|
|
36
|
+
next.set("pitch", round(camera.pitch, 1));
|
|
37
|
+
next.set("bbox", camera.bounds.map((value) => round(value, 6)).join(","));
|
|
38
|
+
for (const key of MAP_LABEL_KEYS) {
|
|
39
|
+
const value = labels[key];
|
|
40
|
+
if (value) next.set(key, value);
|
|
41
|
+
else next.delete(key);
|
|
42
|
+
}
|
|
43
|
+
return next;
|
|
44
|
+
}
|
|
45
|
+
function cameraSnapshot(map) {
|
|
46
|
+
const center = map.getCenter();
|
|
47
|
+
const bounds = map.getBounds();
|
|
48
|
+
return {
|
|
49
|
+
lat: center.lat,
|
|
50
|
+
lng: center.lng,
|
|
51
|
+
zoom: map.getZoom(),
|
|
52
|
+
bearing: map.getBearing(),
|
|
53
|
+
pitch: map.getPitch(),
|
|
54
|
+
bounds: [bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth()]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const toQueryString = (params) => params.toString().replace(/%2C/gi, ",");
|
|
58
|
+
function replaceUrlParams(update) {
|
|
59
|
+
const url = new URL(window.location.href);
|
|
60
|
+
url.search = toQueryString(update(url.searchParams));
|
|
61
|
+
window.history.replaceState({}, "", url.toString());
|
|
62
|
+
}
|
|
63
|
+
function writeLocationParams(map, labels) {
|
|
64
|
+
const camera = cameraSnapshot(map);
|
|
65
|
+
replaceUrlParams((params) => withLocationParams(params, camera, labels));
|
|
66
|
+
return camera;
|
|
67
|
+
}
|
|
68
|
+
function flyToCamera(map, target) {
|
|
69
|
+
if ("bounds" in target) map.fitBounds(target.bounds, { speed: 2 });
|
|
70
|
+
else map.flyTo({ center: target.center, zoom: target.zoom, speed: 2, essential: true });
|
|
71
|
+
}
|
|
72
|
+
function flyAndSyncUrl(map, target, labels) {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
map.once("moveend", () => resolve(writeLocationParams(map, labels)));
|
|
75
|
+
flyToCamera(map, target);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
LABEL_KEYS,
|
|
80
|
+
cameraSnapshot,
|
|
81
|
+
clearFinerLabels,
|
|
82
|
+
flyAndSyncUrl,
|
|
83
|
+
flyToCamera,
|
|
84
|
+
labelsFromParams,
|
|
85
|
+
labelsFromPlace,
|
|
86
|
+
replaceUrlParams,
|
|
87
|
+
toQueryString,
|
|
88
|
+
withLocationParams,
|
|
89
|
+
writeLocationParams
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=locationParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/locationParams.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { LOCATION_LEVELS } from './locationTarget'\n\nimport type { Bbox, CameraTarget, LocationLevel } from './locationTarget'\nimport type { Map as MapLibreMap } from 'maplibre-gl'\n\nexport const LABEL_KEYS = ['country', 'countrySubdivision', 'municipality', 'site', 'address', 'buildingId'] as const\n\nexport type LabelKey = typeof LABEL_KEYS[number]\n\nexport type LocationLabels = Partial<Record<LabelKey, string>>\n\n/** Place names the map owns in the URL. `site`, `buildingId` and every other param are read but never rewritten. */\nconst MAP_LABEL_KEYS = ['country', 'countrySubdivision', 'municipality', 'address'] as const\n\nexport interface CameraSnapshot {\n lat: number\n lng: number\n zoom: number\n bearing: number\n pitch: number\n bounds: Bbox\n}\n\ninterface PlaceProperties {\n country_a?: string\n region_a?: string\n region?: string\n locality?: string\n neighbourhood?: string\n county?: string\n}\n\nexport function labelsFromParams(params: URLSearchParams): LocationLabels {\n const labels: LocationLabels = {}\n for (const key of LABEL_KEYS) {\n const value = params.get(key)?.trim()\n if (value) labels[key] = value\n }\n return labels\n}\n\nexport function labelsFromPlace(properties: PlaceProperties | null | undefined, address?: string): LocationLabels {\n const p = properties ?? {}\n return {\n country: p.country_a?.length === 2 ? p.country_a : undefined,\n countrySubdivision: p.region_a || p.region || undefined,\n municipality: p.locality || p.neighbourhood || p.county || undefined,\n address: address || undefined,\n }\n}\n\n/** Labels finer than `level` describe somewhere else once the map has flown there, so they are dropped. */\nexport function clearFinerLabels(labels: LocationLabels, level: LocationLevel): LocationLabels {\n const depth = LOCATION_LEVELS.indexOf(level)\n return Object.fromEntries(\n Object.entries(labels).filter(([key]) => LOCATION_LEVELS.indexOf(key as LocationLevel) <= depth),\n )\n}\n\nconst round = (value: number, digits: number) => String(Number(value.toFixed(digits)))\n\nexport function withLocationParams(params: URLSearchParams, camera: CameraSnapshot, labels: LocationLabels) {\n const next = new URLSearchParams(params.toString())\n next.set('lat', round(camera.lat, 7))\n next.set('lng', round(camera.lng, 7))\n next.set('zoom', round(camera.zoom, 2))\n next.set('bearing', round(camera.bearing, 1))\n next.set('pitch', round(camera.pitch, 1))\n next.set('bbox', camera.bounds.map(value => round(value, 6)).join(','))\n for (const key of MAP_LABEL_KEYS) {\n const value = labels[key]\n if (value) next.set(key, value)\n else next.delete(key)\n }\n return next\n}\n\nexport function cameraSnapshot(map: MapLibreMap): CameraSnapshot {\n const center = map.getCenter()\n const bounds = map.getBounds()\n return {\n lat: center.lat,\n lng: center.lng,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n bounds: [bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth()],\n }\n}\n\n/** `URLSearchParams` escapes commas, which are legal in a query; keep them readable so `bbox=w,s,e,n` stays legible. */\nexport const toQueryString = (params: URLSearchParams) => params.toString().replace(/%2C/gi, ',')\n\n/** Rewrites the live URL's params in place: no server round trip, and Next's router adopts the result. */\nexport function replaceUrlParams(update: (params: URLSearchParams) => URLSearchParams) {\n const url = new URL(window.location.href)\n url.search = toQueryString(update(url.searchParams))\n // Forwarding history.state would carry Next's __NA marker, and Next then skips syncing its router to this URL.\n window.history.replaceState({}, '', url.toString())\n}\n\n/** Writes the map's current camera plus `labels` into the address bar without a navigation. */\nexport function writeLocationParams(map: MapLibreMap, labels: LocationLabels): CameraSnapshot {\n const camera = cameraSnapshot(map)\n replaceUrlParams(params => withLocationParams(params, camera, labels))\n return camera\n}\n\nexport function flyToCamera(map: MapLibreMap, target: CameraTarget) {\n if ('bounds' in target) map.fitBounds(target.bounds, { speed: 2 })\n else map.flyTo({ center: target.center, zoom: target.zoom, speed: 2, essential: true })\n}\n\n/** Flies to `target` and, once the camera settles, rewrites the URL with every location value. */\nexport function flyAndSyncUrl(map: MapLibreMap, target: CameraTarget, labels: LocationLabels): Promise<CameraSnapshot> {\n return new Promise(resolve => {\n map.once('moveend', () => resolve(writeLocationParams(map, labels)))\n flyToCamera(map, target)\n })\n}\n"],"mappings":"AAGA,SAAS,uBAAuB;AAKzB,MAAM,aAAa,CAAC,WAAW,sBAAsB,gBAAgB,QAAQ,WAAW,YAAY;AAO3G,MAAM,iBAAiB,CAAC,WAAW,sBAAsB,gBAAgB,SAAS;AAoB3E,SAAS,iBAAiB,QAAyC;AAnC1E;AAoCE,QAAM,SAAyB,CAAC;AAChC,aAAW,OAAO,YAAY;AAC5B,UAAM,SAAQ,YAAO,IAAI,GAAG,MAAd,mBAAiB;AAC/B,QAAI,MAAO,QAAO,GAAG,IAAI;AAAA,EAC3B;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB,YAAgD,SAAkC;AA5ClH;AA6CE,QAAM,IAAI,kCAAc,CAAC;AACzB,SAAO;AAAA,IACL,WAAS,OAAE,cAAF,mBAAa,YAAW,IAAI,EAAE,YAAY;AAAA,IACnD,oBAAoB,EAAE,YAAY,EAAE,UAAU;AAAA,IAC9C,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU;AAAA,IAC3D,SAAS,WAAW;AAAA,EACtB;AACF;AAGO,SAAS,iBAAiB,QAAwB,OAAsC;AAC7F,QAAM,QAAQ,gBAAgB,QAAQ,KAAK;AAC3C,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,gBAAgB,QAAQ,GAAoB,KAAK,KAAK;AAAA,EACjG;AACF;AAEA,MAAM,QAAQ,CAAC,OAAe,WAAmB,OAAO,OAAO,MAAM,QAAQ,MAAM,CAAC,CAA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S,CAAC;AACpD;AAGO,SAAS,oBAAoB,KAAkB,QAAwC;AAC5F,QAAM,SAAS,eAAe,GAAG;AACjC,mBAAiB,YAAU,mBAAmB,QAAQ,QAAQ,MAAM,CAAC;AACrE,SAAO;AACT;AAEO,SAAS,YAAY,KAAkB,QAAsB;AAClE,MAAI,YAAY,OAAQ,KAAI,UAAU,OAAO,QAAQ,EAAE,OAAO,EAAE,CAAC;AAAA,MAC5D,KAAI,MAAM,EAAE,QAAQ,OAAO,QAAQ,MAAM,OAAO,MAAM,OAAO,GAAG,WAAW,KAAK,CAAC;AACxF;AAGO,SAAS,cAAc,KAAkB,QAAsB,QAAiD;AACrH,SAAO,IAAI,QAAQ,aAAW;AAC5B,QAAI,KAAK,WAAW,MAAM,QAAQ,oBAAoB,KAAK,MAAM,CAAC,CAAC;AACnE,gBAAY,KAAK,MAAM;AAAA,EACzB,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Coarse to fine. The map flies to the finest level the URL carries, falling back up on failure. */
|
|
2
|
+
export declare const LOCATION_LEVELS: readonly ["country", "countrySubdivision", "municipality", "site", "address", "buildingId", "asset", "bbox", "latlng"];
|
|
3
|
+
export type LocationLevel = typeof LOCATION_LEVELS[number];
|
|
4
|
+
export type Bbox = [west: number, south: number, east: number, north: number];
|
|
5
|
+
export type CameraTarget = {
|
|
6
|
+
center: [lng: number, lat: number];
|
|
7
|
+
zoom: number;
|
|
8
|
+
} | {
|
|
9
|
+
bounds: Bbox;
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_LEVEL_ZOOM: {
|
|
12
|
+
readonly country: 4;
|
|
13
|
+
readonly countrySubdivision: 6;
|
|
14
|
+
readonly municipality: 12;
|
|
15
|
+
readonly site: 16;
|
|
16
|
+
readonly address: 18;
|
|
17
|
+
readonly buildingId: 18;
|
|
18
|
+
readonly latlng: 14;
|
|
19
|
+
};
|
|
20
|
+
export declare function parseBbox(value: string | null): Bbox | null;
|
|
21
|
+
export declare function parseLngLat(params: URLSearchParams): [number, number] | null;
|
|
22
|
+
export declare function parseZoom(params: URLSearchParams): number | undefined;
|
|
23
|
+
/** Every valid level in the URL, finest first: the order to try them in. */
|
|
24
|
+
export declare function presentLevels(params: URLSearchParams): LocationLevel[];
|
|
25
|
+
//# sourceMappingURL=locationTarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locationTarget.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/locationTarget.ts"],"names":[],"mappings":"AAGA,qGAAqG;AACrG,eAAO,MAAM,eAAe,wHAUlB,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAE1D,MAAM,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AAE7E,MAAM,MAAM,YAAY,GACpB;IAAE,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,CAAA;AAEpB,eAAO,MAAM,kBAAkB;;;;;;;;CAQrB,CAAA;AAMV,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAK3D;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAM5E;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAGrE;AAaD,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,EAAE,CAEtE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const LOCATION_LEVELS = [
|
|
2
|
+
"country",
|
|
3
|
+
"countrySubdivision",
|
|
4
|
+
"municipality",
|
|
5
|
+
"site",
|
|
6
|
+
"address",
|
|
7
|
+
"buildingId",
|
|
8
|
+
"asset",
|
|
9
|
+
"bbox",
|
|
10
|
+
"latlng"
|
|
11
|
+
];
|
|
12
|
+
const DEFAULT_LEVEL_ZOOM = {
|
|
13
|
+
country: 4,
|
|
14
|
+
countrySubdivision: 6,
|
|
15
|
+
municipality: 12,
|
|
16
|
+
site: 16,
|
|
17
|
+
address: 18,
|
|
18
|
+
buildingId: 18,
|
|
19
|
+
latlng: 14
|
|
20
|
+
};
|
|
21
|
+
const trimmed = (params, key) => {
|
|
22
|
+
var _a;
|
|
23
|
+
return ((_a = params.get(key)) != null ? _a : "").trim();
|
|
24
|
+
};
|
|
25
|
+
const isNumericId = (value) => /^\d+$/.test(value);
|
|
26
|
+
function parseBbox(value) {
|
|
27
|
+
const parts = (value != null ? value : "").split(",").map((part) => Number.parseFloat(part));
|
|
28
|
+
if (parts.length !== 4 || !parts.every(Number.isFinite)) return null;
|
|
29
|
+
const [west, south, east, north] = parts;
|
|
30
|
+
return west < east && south < north ? [west, south, east, north] : null;
|
|
31
|
+
}
|
|
32
|
+
function parseLngLat(params) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const lat = Number.parseFloat((_a = params.get("lat")) != null ? _a : "");
|
|
35
|
+
const lng = Number.parseFloat((_b = params.get("lng")) != null ? _b : "");
|
|
36
|
+
if (!Number.isFinite(lat) || !Number.isFinite(lng)) return null;
|
|
37
|
+
if (lat === 0 && lng === 0) return null;
|
|
38
|
+
return Math.abs(lat) <= 90 && Math.abs(lng) <= 180 ? [lng, lat] : null;
|
|
39
|
+
}
|
|
40
|
+
function parseZoom(params) {
|
|
41
|
+
var _a;
|
|
42
|
+
const zoom = Number.parseFloat((_a = params.get("zoom")) != null ? _a : "");
|
|
43
|
+
return Number.isFinite(zoom) ? zoom : void 0;
|
|
44
|
+
}
|
|
45
|
+
function hasLevel(level, params) {
|
|
46
|
+
switch (level) {
|
|
47
|
+
case "latlng":
|
|
48
|
+
return parseLngLat(params) !== null;
|
|
49
|
+
case "bbox":
|
|
50
|
+
return parseBbox(params.get("bbox")) !== null;
|
|
51
|
+
case "asset":
|
|
52
|
+
return false;
|
|
53
|
+
case "site":
|
|
54
|
+
case "buildingId":
|
|
55
|
+
return isNumericId(trimmed(params, level));
|
|
56
|
+
default:
|
|
57
|
+
return trimmed(params, level) !== "";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function presentLevels(params) {
|
|
61
|
+
return [...LOCATION_LEVELS].reverse().filter((level) => hasLevel(level, params));
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
DEFAULT_LEVEL_ZOOM,
|
|
65
|
+
LOCATION_LEVELS,
|
|
66
|
+
parseBbox,
|
|
67
|
+
parseLngLat,
|
|
68
|
+
parseZoom,
|
|
69
|
+
presentLevels
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=locationTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/locationTarget.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n/** Coarse to fine. The map flies to the finest level the URL carries, falling back up on failure. */\nexport const LOCATION_LEVELS = [\n 'country',\n 'countrySubdivision',\n 'municipality',\n 'site',\n 'address',\n 'buildingId',\n 'asset',\n 'bbox',\n 'latlng',\n] as const\n\nexport type LocationLevel = typeof LOCATION_LEVELS[number]\n\nexport type Bbox = [west: number, south: number, east: number, north: number]\n\nexport type CameraTarget =\n | { center: [lng: number, lat: number]; zoom: number }\n | { bounds: Bbox }\n\nexport const DEFAULT_LEVEL_ZOOM = {\n country: 4,\n countrySubdivision: 6,\n municipality: 12,\n site: 16,\n address: 18,\n buildingId: 18,\n latlng: 14,\n} as const\n\nconst trimmed = (params: URLSearchParams, key: string) => (params.get(key) ?? '').trim()\n\nconst isNumericId = (value: string) => /^\\d+$/.test(value)\n\nexport function parseBbox(value: string | null): Bbox | null {\n const parts = (value ?? '').split(',').map(part => Number.parseFloat(part))\n if (parts.length !== 4 || !parts.every(Number.isFinite)) return null\n const [west, south, east, north] = parts\n return west < east && south < north ? [west, south, east, north] : null\n}\n\nexport function parseLngLat(params: URLSearchParams): [number, number] | null {\n const lat = Number.parseFloat(params.get('lat') ?? '')\n const lng = Number.parseFloat(params.get('lng') ?? '')\n if (!Number.isFinite(lat) || !Number.isFinite(lng)) return null\n if (lat === 0 && lng === 0) return null\n return Math.abs(lat) <= 90 && Math.abs(lng) <= 180 ? [lng, lat] : null\n}\n\nexport function parseZoom(params: URLSearchParams): number | undefined {\n const zoom = Number.parseFloat(params.get('zoom') ?? '')\n return Number.isFinite(zoom) ? zoom : undefined\n}\n\nfunction hasLevel(level: LocationLevel, params: URLSearchParams): boolean {\n switch (level) {\n case 'latlng': return parseLngLat(params) !== null\n case 'bbox': return parseBbox(params.get('bbox')) !== null\n case 'asset': return false\n case 'site':\n case 'buildingId': return isNumericId(trimmed(params, level))\n default: return trimmed(params, level) !== ''\n }\n}\n\n/** Every valid level in the URL, finest first: the order to try them in. */\nexport function presentLevels(params: URLSearchParams): LocationLevel[] {\n return [...LOCATION_LEVELS].reverse().filter(level => hasLevel(level, params))\n}\n"],"mappings":"AAIO,MAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,qBAAqB;AAAA,EAChC,SAAS;AAAA,EACT,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AACV;AAEA,MAAM,UAAU,CAAC,QAAyB,QAAa;AAlCvD;AAkC2D,uBAAO,IAAI,GAAG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,IAC5D;AAAS,aAAO,QAAQ,QAAQ,KAAK,MAAM;AAAA,EAC7C;AACF;AAGO,SAAS,cAAc,QAA0C;AACtE,SAAO,CAAC,GAAG,eAAe,EAAE,QAAQ,EAAE,OAAO,WAAS,SAAS,OAAO,MAAM,CAAC;AAC/E;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LocationLabels } from './locationParams';
|
|
2
|
+
import type { CameraTarget, LocationLevel } from './locationTarget';
|
|
3
|
+
import type { Building, Site } from '../../../../../types/dbTypes';
|
|
4
|
+
import type { PlaceContext, PlaceLevel } from '../geocoding/placeSearch';
|
|
5
|
+
import type { Feature } from 'geojson';
|
|
6
|
+
export interface ResolvedLocation {
|
|
7
|
+
level: LocationLevel;
|
|
8
|
+
target: CameraTarget;
|
|
9
|
+
labels: LocationLabels;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolveDeps {
|
|
12
|
+
searchPlace: (level: PlaceLevel, name: string, context: PlaceContext) => Promise<Feature | null>;
|
|
13
|
+
site?: Site | null;
|
|
14
|
+
building?: Building | null;
|
|
15
|
+
/** Used when the URL carries no `country`. */
|
|
16
|
+
countryCode?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Resolves the finest level in `params`, walking up the hierarchy until one lands. Null leaves the map where it is. */
|
|
19
|
+
export declare function resolveLocationTarget(params: URLSearchParams, deps: ResolveDeps): Promise<ResolvedLocation | null>;
|
|
20
|
+
//# sourceMappingURL=resolveLocationTarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveLocationTarget.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,CAAA;IACpB,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,cAAc,CAAA;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAChG,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AA0ED,wHAAwH;AACxH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAWxH"}
|