venue-js 1.1.1 → 1.2.0-next.1
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/index.d.mts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +83 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/data/index.ts","../src/data/constant.ts","../src/data/api/delivery-project.ts","../src/data/getDataClient.ts","../src/data/populator/index.ts","../src/data/utils/match-filters.ts","../src/IndoorMap/IndoorMap.ts","../../../node_modules/@turf/helpers/index.ts","../../../node_modules/@turf/meta/index.js","../../../node_modules/@turf/bbox/index.ts","../src/IndoorMap/constants.ts","../src/IndoorMap/utils/createElements.js","../src/IndoorMap/object3d/Billboard.js","../src/IndoorMap/object3d/GroundLabel.ts","../src/IndoorMap/object3d/SpriteMarker.ts","../src/IndoorMap/object3d/NavigationPath.ts","../src/IndoorMap/utils/geometry.ts","../src/IndoorMap/utils/svg.ts","../src/IndoorMap/utils/math.ts","../src/IndoorMap/utils/createHighlightElement.ts","../src/IndoorMap/camera/CameraManager.ts","../src/IndoorMap/renderer/RendererManager.ts","../src/IndoorMap/renderer/3d/Element3DRenderer.ts","../src/IndoorMap/renderer/3d/element3DRendererOptions.ts","../src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts","../src/IndoorMap/renderer/utils/interpolateStops.ts","../src/IndoorMap/renderer/2d/Element2DRenderer.ts","../src/IndoorMap/renderer/2d/element2DRendererOptions.ts","../src/IndoorMap/renderer/2d/Marker2DRenderer.ts","../src/IndoorMap/renderer/3d/Marker3DRenderer.ts","../src/IndoorMap/renderer/utils/svg2material.ts","../src/IndoorMap/renderer/utils/angleBetweenLineString.ts"],"sourcesContent":["// Data Module: Get geojson from service\nexport * from \"./data\"\nexport * from \"./IndoorMap\"\n","export { QueryObserver } from \"@tanstack/query-core\"\n\nexport * from \"./types\"\nexport * from \"./constant\"\nexport * from \"./api/delivery-project\"\nexport * from \"./getDataClient\"\n","import { FeatureQueryOptions } from \"./types\"\nimport { FeatureType } from \"./types/feature-api\"\n\nexport const DEFAULT_BASE_URL = \"https://service.venue.in.th/api\"\n\nexport const IMDF_FEATURE_TYPES: FeatureType[] = [\n \"address\",\n \"amenity\",\n \"anchor\",\n \"building\",\n \"detail\",\n \"fixture\",\n \"footprint\",\n \"geofence\",\n \"kiosk\",\n \"level\",\n \"occupant\",\n \"opening\",\n \"relationship\",\n \"section\",\n \"unit\",\n \"venue\",\n]\n\nexport const NONIMDF_FEATURE_TYPES: FeatureType[] = [\n \"taxonomy\",\n \"event\",\n \"promotion\",\n \"label\",\n \"privilege\",\n]\n\nexport const GEOJSON_FEATURE_TYPES: FeatureType[] = [\n ...IMDF_FEATURE_TYPES,\n ...NONIMDF_FEATURE_TYPES,\n]\n\nexport const ALL_FEATURE_TYPES: FeatureType[] = [\n ...GEOJSON_FEATURE_TYPES,\n \"sponsored-content\",\n \"element\",\n]\n\nexport const defaultFeatureQueryOptionsMap: Record<\n FeatureType,\n FeatureQueryOptions\n> = {\n // IMDF\n address: {},\n amenity: {},\n anchor: {},\n building: {},\n detail: { enabled: false },\n fixture: {},\n footprint: {},\n geofence: { enabled: false },\n kiosk: {},\n level: {},\n occupant: {\n refetchInterval: 5 * 60 * 1000, // refresh every 5 min\n staleTime: 5 * 60 * 1000,\n },\n opening: {},\n relationship: {},\n section: {},\n unit: {},\n venue: {},\n\n // OTHERS GEOJSON\n taxonomy: {},\n privilege: {},\n event: {},\n promotion: {\n refetchInterval: 0.5 * 60 * 1000, // refresh every 5 min\n staleTime: 0.5 * 60 * 1000,\n },\n label: {},\n\n // NON GEOJSON\n \"sponsored-content\": {\n refetchInterval: 1 * 60 * 1000, // refresh every 5 min\n },\n element: {},\n page: {},\n}\n","import type {\n FeatureResponseMap,\n FeatureType,\n SponsoredContentStrapiV4ApiResponse,\n} from \"../types/feature-api\"\nimport { DEFAULT_BASE_URL } from \"../constant\"\n\nexport async function fetchFeature<T extends FeatureType = FeatureType>(\n projectId: string,\n apiKey: string,\n featureType: FeatureType,\n baseUrl: string = DEFAULT_BASE_URL\n): Promise<FeatureResponseMap[T][]> {\n // TODO: Update Label Endpoint to match other endpoints\n switch (featureType) {\n case \"label\":\n case \"element\": {\n const pluralFeatureType = `${featureType}s`\n const res = await fetch(\n `${baseUrl}/delivery/projects/${projectId}/${pluralFeatureType}.geojson?api-key=${apiKey}`\n )\n if (res.status !== 200) return []\n const items = await res.json()\n return items\n }\n\n case \"sponsored-content\": {\n const res = await fetch(\n `${baseUrl}/delivery/projects/${projectId}/sponsored-content.json?api-key=${apiKey}`\n )\n if (res.status !== 200) return []\n const jsonRes = await res.json()\n const items = jsonRes.data as SponsoredContentStrapiV4ApiResponse[]\n return items.map((item) => ({\n id: item.id,\n ...item.attributes,\n })) as FeatureResponseMap[T][]\n }\n\n default: {\n const res = await fetch(\n `${baseUrl}/delivery/projects/${projectId}/imdf/${featureType}.geojson?api-key=${apiKey}`\n )\n if (res.status !== 200) return []\n const collections = await res.json()\n return collections.features\n }\n }\n}\n\nexport const safeFetchFeature = async <T extends FeatureType = FeatureType>(\n projectId: string,\n apiKey: string,\n featureType: FeatureType,\n baseUrl: string = DEFAULT_BASE_URL\n): Promise<FeatureResponseMap[T][]> => {\n try {\n const result = await fetchFeature<T>(\n projectId,\n apiKey,\n featureType,\n baseUrl\n )\n return result ?? []\n } catch (e) {\n // Suppress error and return []\n return Promise.resolve([])\n }\n}\n","import { safeFetchFeature } from \"./api/delivery-project\"\nimport { FeatureResponseMap, FeatureType } from \"./types/feature-api\"\nimport {\n EnsureQueryDataOptions,\n QueryClient,\n QueryObserver,\n} from \"@tanstack/query-core\"\nimport {\n FeatureQueryOptions,\n FilterParams,\n FindParams,\n InternalFilterByType,\n InternalFindById,\n PopulatedParams,\n VenueClientOptions,\n VenueDataClient,\n} from \"./types/VenueDataClient\"\nimport { createPopulator } from \"./populator\"\nimport { FeaturePopulatedResponseMap } from \"./types\"\nimport { matchFilters } from \"./utils/match-filters\"\n\nexport const getDataClient = (options: VenueClientOptions): VenueDataClient => {\n const observers = new Map<\n FeatureType,\n { observer: QueryObserver<any, any>, unsubscribe: () => void }\n >()\n\n const queryClient = options.queryClient ?? new QueryClient()\n const { projectId, apiKey, baseUrl } = options\n\n if (!projectId)\n throw new Error(\n \"Cannot create VenueDataClient. Reason: `projectId` is missing\"\n )\n if (!apiKey)\n throw new Error(\n \"Cannot create VenueDataClient. Reason: `apiKey` is missing\"\n )\n\n const createDeliveryApiQueryOptions = <T extends FeatureType = FeatureType>(\n featureType: T\n ) => ({\n queryKey: [\"_deliveryapi\", featureType] as const,\n queryFn: () => safeFetchFeature<T>(projectId, apiKey, featureType, baseUrl),\n })\n\n /**\n * Internal Functions\n * ***********************************/\n const internalFilterByType: InternalFilterByType = async <T extends FeatureType = FeatureType>(\n featureType: T\n ) => {\n try {\n const features = await queryClient.ensureQueryData<\n FeatureResponseMap[T][],\n unknown,\n FeatureResponseMap[T][]\n >(createDeliveryApiQueryOptions(featureType))\n return features\n } catch (error) {\n throw error\n }\n }\n\n const internalFindById: InternalFindById = async <T extends FeatureType = FeatureType>(\n id: string\n ) => {\n if (id === null) return null\n const featureType = id.slice(0, id.lastIndexOf(\"-\")) as FeatureType\n const feature = await queryClient.ensureQueryData<FeatureResponseMap[T]>({\n queryKey: [\"_deliveryapi\", featureType, id],\n queryFn: async () => {\n const features = await internalFilterByType(featureType)\n const feature = features.find(\n (f) => f.id === id\n ) as FeatureResponseMap[T]\n return feature ?? null\n },\n })\n return feature\n }\n\n // Create `Feature Populator` with internal functions\n const populator = createPopulator({ internalFindById, internalFilterByType })\n\n /**\n * Public Functions\n * ***********************************/\n const registerObserver = (\n featureType: FeatureType,\n refetchInterval: number\n ) => {\n if (observers.has(featureType)) {\n console.warn(`Observer for ${featureType} already exists`)\n const record = observers.get(featureType)\n return record.observer\n }\n \n const options = createDeliveryApiQueryOptions(featureType)\n const observer = new QueryObserver(queryClient, {\n ...options,\n refetchInterval,\n })\n const unsubscribe = observer.subscribe(() => {\n console.log(`[venue-js] Listening to ${featureType} changes (interval = ${refetchInterval}ms)`)\n // TODO: add logs or what to do after subscribe\n })\n observers.set(featureType, { observer, unsubscribe })\n\n return observer\n }\n\n const destroyObserver = (featureType: FeatureType) => {\n const record = observers.get(featureType)\n if (!record) return\n\n record.unsubscribe()\n observers.delete(featureType)\n }\n\n const destroyObservers = () => {\n observers.forEach(({ observer, unsubscribe }) => {\n unsubscribe()\n observer.destroy()\n })\n observers.clear()\n }\n\n const createFilterByTypeQueryOptions = <T extends FeatureType = FeatureType>(\n featureType: T,\n params: FilterParams = {},\n options: FeatureQueryOptions = {}\n ): EnsureQueryDataOptions<FeatureResponseMap[T][] | FeaturePopulatedResponseMap[T][]> => ({\n queryKey: [featureType, \"list\", params] as const,\n queryFn: async () => {\n const features = await internalFilterByType<T>(featureType)\n \n // Filter \n const filters = params.filters ?? {}\n let result = features\n if (params.filters) {\n result = features.filter(f => matchFilters(f, filters))\n }\n\n // Populate\n return params.populate === true\n ? await Promise.all(result.map((f) => populator[featureType](f)))\n : result\n },\n ...(options ?? {}),\n })\n\n const createFindByIdQueryOptions = <T extends FeatureType = FeatureType>(\n featureType: T,\n id: string,\n params: FindParams = {},\n options: FeatureQueryOptions = {}\n ): EnsureQueryDataOptions<FeatureResponseMap[T] | FeaturePopulatedResponseMap[T]> => ({\n queryKey: [featureType, \"detail\", id, params] as const,\n queryFn: async () => {\n const feature = await internalFindById<T>(id)\n return params.populate === true\n ? await populator[featureType](feature)\n : Promise.resolve(feature)\n },\n ...(options ?? {}),\n })\n\n async function filterByType<T extends FeatureType>(featureType: T, params: FilterParams & PopulatedParams): Promise<FeaturePopulatedResponseMap[T][]>\n async function filterByType<T extends FeatureType>(featureType: T, params?: FilterParams): Promise<FeatureResponseMap[T][]>\n async function filterByType<T extends FeatureType>(featureType: T, params?: FilterParams) {\n const filterQueryOptions = createFilterByTypeQueryOptions<T>(\n featureType,\n params\n )\n const features = await queryClient.ensureQueryData(filterQueryOptions)\n return (params?.populate === true) ? features as FeaturePopulatedResponseMap[T][] : features as FeatureResponseMap[T][]\n }\n\n async function findById<T extends FeatureType>(featureType: T, id: string, params: FindParams & PopulatedParams): Promise<FeaturePopulatedResponseMap[T]>\n async function findById<T extends FeatureType>(featureType: T, id: string, params?: FindParams): Promise<FeatureResponseMap[T]>\n async function findById<T extends FeatureType>( featureType: T, id: string, params?: FindParams) {\n const findQueryOptions = createFindByIdQueryOptions<T>(\n featureType,\n id,\n params\n )\n const feature = await queryClient.ensureQueryData(findQueryOptions)\n return feature\n }\n\n return {\n projectId,\n queryClient,\n registerObserver,\n destroyObserver,\n destroyObservers,\n createFilterByTypeQueryOptions,\n createFindByIdQueryOptions,\n filterByType,\n findById,\n }\n}\n","import {\n FeatureResponseMap,\n FeaturePopulatedResponseMap,\n InternalFindById,\n InternalFilterByType,\n SectionFeature,\n} from \"../types\"\n\nimport { booleanWithin } from \"@turf/boolean-within\"\n\ntype CreatePopulatorOptions = {\n internalFindById: InternalFindById\n internalFilterByType: InternalFilterByType\n}\n\ntype PopulatableFeatureType = Extract<\n keyof FeatureResponseMap,\n keyof FeaturePopulatedResponseMap\n>\ntype PopulatorFn<T extends PopulatableFeatureType> = (\n f: FeatureResponseMap[T]\n) => Promise<FeaturePopulatedResponseMap[T]>\n\nexport type Populator = {\n [K in PopulatableFeatureType]?: PopulatorFn<K>\n}\n\nexport const createPopulator = ({\n internalFindById,\n internalFilterByType,\n}: CreatePopulatorOptions): Populator => {\n const populateAddress: PopulatorFn<\"address\"> = (address) =>\n Promise.resolve(address)\n const populateBuilding: PopulatorFn<\"building\"> = (building) =>\n Promise.resolve(building)\n const populateDetail: PopulatorFn<\"detail\"> = (detail) =>\n Promise.resolve(detail)\n const populateFootprint: PopulatorFn<\"footprint\"> = (footprint) =>\n Promise.resolve(footprint)\n const populateGeofence: PopulatorFn<\"geofence\"> = (geofence) =>\n Promise.resolve(geofence)\n const populateRelationship: PopulatorFn<\"relationship\"> = (relationship) =>\n Promise.resolve(relationship)\n const populatePrivilege: PopulatorFn<\"privilege\"> = (privilege) =>\n Promise.resolve(privilege)\n const populateEvent: PopulatorFn<\"event\"> = (event) => Promise.resolve(event)\n\n const populatePromotion: PopulatorFn<\"promotion\"> = async (promotion) => {\n const venue = await internalFindById<\"venue\">(promotion.properties.venue_id)\n return {\n ...promotion,\n properties: {\n ...promotion.properties,\n venue,\n },\n }\n }\n\n const populateAmenity: PopulatorFn<\"amenity\"> = async (amenity) => {\n const units = await Promise.all(\n amenity.properties.unit_ids.map(internalFindById<\"unit\">)\n )\n\n const populatedUnits = await Promise.all(units.map(populateUnit))\n\n const venue = await internalFindById<\"venue\">(amenity.properties.venue_id)\n\n const defaultLevel = populatedUnits[0].properties.level\n\n const kiosks = await internalFilterByType<\"kiosk\">(\"kiosk\")\n const ordinalKiosks = kiosks.filter(\n (kiosk) => kiosk.properties.level_id === defaultLevel.id\n )\n const kiosk = ordinalKiosks.find((kiosk) => booleanWithin(amenity, kiosk))\n return {\n ...amenity,\n properties: {\n ...amenity.properties,\n\n ordinal: defaultLevel.properties.ordinal,\n level_name: defaultLevel.properties.name.en,\n units: populatedUnits,\n venue,\n\n _experimental_kiosk: kiosk ? await populateKiosk(kiosk) : null,\n },\n }\n }\n\n const populateAnchor: PopulatorFn<\"anchor\"> = async (anchor) => {\n const unit = await internalFindById<\"unit\">(anchor.properties.unit_id)\n const level = await internalFindById<\"level\">(unit.properties.level_id)\n\n const sections = await internalFilterByType<\"section\">(\"section\")\n const section = sections.find((section) => booleanWithin(anchor, section))\n\n return {\n ...anchor,\n properties: {\n ...anchor.properties,\n level: await populateLevel(level),\n unit: await populateUnit(unit),\n section: section ? await populateSection(section) : null,\n },\n }\n }\n\n const populateFixture: PopulatorFn<\"fixture\"> = async (fixture) => {\n const level = await internalFindById<\"level\">(fixture.properties.level_id)\n const venue = await internalFindById<\"venue\">(fixture.properties.venue_id)\n const anchor = await internalFindById<\"anchor\">(fixture.properties.anchor_id)\n\n return {\n ...fixture,\n properties: {\n ...fixture.properties,\n anchor: anchor ? await populateAnchor(anchor) : null,\n level: await populateLevel(level),\n venue: await populateVenue(venue),\n ordinal: level.properties.ordinal,\n }\n }\n }\n\n const populateKiosk: PopulatorFn<\"kiosk\"> = async (kiosk) => {\n const level = await internalFindById<\"level\">(kiosk.properties.level_id)\n const venue = await internalFindById<\"venue\">(kiosk.properties.venue_id)\n const anchor = await internalFindById<\"anchor\">(kiosk.properties.anchor_id)\n\n // Find Kiosk's Unit\n const units = await internalFilterByType<\"unit\">(\"unit\")\n const unit = units.find(\n (unit) =>\n unit.properties.category === \"walkway\" &&\n unit.properties.level_id === kiosk.properties.level_id &&\n booleanWithin(kiosk, unit)\n )\n\n let section: SectionFeature | null = null\n\n if (anchor) {\n const sections = await internalFilterByType<\"section\">(\"section\")\n section = sections.find((section) => booleanWithin(anchor, section))\n }\n\n return {\n ...kiosk,\n properties: {\n ...kiosk.properties,\n anchor: anchor ? await populateAnchor(anchor) : null,\n level: await populateLevel(level),\n venue: await populateVenue(venue),\n ordinal: level.properties.ordinal,\n\n unit: unit ? await populateUnit(unit) : null,\n section: section ? await populateSection(section) : null,\n },\n }\n }\n\n const populateLevel: PopulatorFn<\"level\"> = async (level) => {\n const venue = await internalFindById<\"venue\">(level.properties.venue_id)\n return {\n ...level,\n properties: {\n ...level.properties,\n venue,\n },\n }\n }\n\n const populateOccupant: PopulatorFn<\"occupant\"> = async (occupant) => {\n const {\n anchor_id,\n venue_id,\n local_category_ids,\n promotion_ids,\n privilege_ids,\n kiosk_id,\n unit_id,\n kiosk_ids = [],\n unit_ids = [],\n } = occupant.properties\n const anchor = await internalFindById<\"anchor\">(anchor_id)\n const venue = await internalFindById<\"venue\">(venue_id)\n\n const localCategories = await Promise.all(\n local_category_ids.map(internalFindById<\"taxonomy\">)\n )\n const promotions = await Promise.all(\n promotion_ids.map(internalFindById<\"promotion\">)\n )\n const privileges = await Promise.all(\n privilege_ids.map(internalFindById<\"privilege\">)\n )\n const kiosk = await internalFindById<\"kiosk\">(kiosk_id)\n const unit = await internalFindById<\"unit\">(unit_id)\n\n const kiosks = await Promise.all(kiosk_ids.map(internalFindById<\"kiosk\">))\n const units = await Promise.all(unit_ids.map(internalFindById<\"unit\">))\n return {\n ...occupant,\n properties: {\n ...occupant.properties,\n anchor: anchor ? await populateAnchor(anchor) : null,\n local_categories: await Promise.all(\n localCategories.map(populateTaxonomy)\n ),\n venue,\n promotions,\n privileges,\n\n kiosk,\n unit,\n kiosks: await Promise.all(kiosks.map(populateKiosk)),\n units: await Promise.all(units.map(populateUnit)),\n },\n }\n }\n\n const populateOpening: PopulatorFn<\"opening\"> = async (opening) => {\n const venue = await internalFindById<\"venue\">(opening.properties.venue_id)\n const level = await internalFindById<\"level\">(opening.properties.level_id)\n return {\n ...opening,\n properties: {\n venue,\n level: await populateLevel(level),\n ordinal: level.properties.ordinal,\n }\n }\n }\n\n const populateSection: PopulatorFn<\"section\"> = async (section) => {\n const venue = await internalFindById<\"venue\">(section.properties.venue_id)\n const level = await internalFindById<\"level\">(section.properties.level_id)\n return {\n ...section,\n properties: {\n ...section.properties,\n venue,\n level: await populateLevel(level),\n ordinal: level.properties.ordinal,\n },\n }\n }\n\n const populateUnit: PopulatorFn<\"unit\"> = async (unit) => {\n const venue = await internalFindById<\"venue\">(unit.properties.venue_id)\n const level = await internalFindById<\"level\">(unit.properties.level_id)\n\n const sections = await internalFilterByType<\"section\">(\"section\")\n try {\n const section = unit.geometry.type !== 'MultiPolygon' ? sections.find((section) => booleanWithin(unit, section)) : null\n return {\n ...unit,\n properties: {\n ...unit.properties,\n venue,\n ordinal: level.properties.ordinal,\n level: await populateLevel(level),\n section: section ? await populateSection(section) : null,\n },\n }\n } catch (err) {\n console.log(`error finding section `, { unit, sections })\n }\n }\n\n const populateVenue: PopulatorFn<\"venue\"> = (venue) => {\n return Promise.resolve(venue)\n }\n\n const populateTaxonomy: PopulatorFn<\"taxonomy\"> = async (taxonomy) => {\n const venue = await internalFindById<\"venue\">(taxonomy.properties.venue_id)\n return {\n ...taxonomy,\n properties: {\n ...taxonomy.properties,\n venue: venue ? await populateVenue(venue) : null,\n },\n }\n }\n\n const populateFeature = (feature) => Promise.resolve(feature)\n\n return {\n address: populateAddress,\n building: populateBuilding,\n detail: populateDetail,\n fixture: populateFixture,\n footprint: populateFootprint,\n geofence: populateGeofence,\n opening: populateOpening,\n relationship: populateRelationship,\n privilege: populatePrivilege,\n promotion: populatePromotion,\n event: populateEvent,\n label: populateFeature,\n element: populateFeature,\n page: populateFeature,\n\n amenity: populateAmenity,\n anchor: populateAnchor,\n kiosk: populateKiosk,\n level: populateLevel,\n occupant: populateOccupant,\n section: populateSection,\n unit: populateUnit,\n venue: populateVenue,\n\n taxonomy: populateTaxonomy,\n }\n}\n","import type { Value, InFilter, Filter, Filters } from '../types/match-filters'\n\nfunction isInFilter(filter: Filter): filter is InFilter {\n return (\n typeof filter === \"object\" &&\n filter !== null &&\n \"$in\" in filter &&\n Array.isArray((filter as any).$in)\n );\n}\n\nconst someIntersect = (a: Value[], b: Value[]) => a.some(v => b.includes(v));\n\nexport function matchFilter(value: Value | Value[], filter: Filter) {\n\n if (Array.isArray(value)) {\n if (isInFilter(filter)) return someIntersect(value, filter.$in);\n \n // Equal\n return value.includes(filter as Value);\n \n } else {\n if (isInFilter(filter)) return filter.$in.includes(value);\n \n // Equal\n return value === filter;\n }\n}\n\nexport function matchFilters<T extends Record<string, any>>(item: T, filters: Filters): boolean {\n return Object.entries(filters).every(([key, filter]) => {\n return matchFilter(item.properties[key], filter)\n });\n}","import {\n ui,\n Map,\n TileLayer,\n VectorLayer,\n Extent,\n LineString,\n Geometry,\n Marker,\n Coordinate,\n OverlayLayer,\n} from \"maptalks-gl\"\n\nimport { GeoJsonProperties, LineString as LineStringType, Feature } from \"geojson\"\nimport TWEEN from \"@tweenjs/tween.js\"\nimport _ from \"lodash\"\nimport {\n feature as turfFeature,\n lineString,\n point,\n} from \"@turf/helpers\"\nimport turfDistance from \"@turf/distance\"\nimport turfCenter from \"@turf/center\"\nimport bbox from \"@turf/bbox\"\nimport scale from \"@turf/transform-scale\"\nimport bboxPolygon from \"@turf/bbox-polygon\"\nimport { featureCollection } from '@turf/helpers';\n\nimport { PerspectiveCamera } from \"three\"\nimport { ThreeLayer } from \"maptalks.three\"\n\nimport {\n LAYERS,\n LAYER_OPTIONS,\n LAYER_FEATURE_TYPE_OBJ,\n HIGHLIGHT_LAYER_NAME,\n USER_LOCATION_LAYER_NAME,\n ORIGIN_MARKER_ID,\n DESTINATION_MARKER_ID,\n DEFAULT_HIGHLIGHT_OPTIONS,\n DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,\n USER_LOCATION_ELEMENT_ID,\n LAST_USER_LOCATION_ELEMENT_ID_PREFIX,\n ALWAYS_VISIBLE_FEATURE_TYPES,\n LOCALE_SYMBOL_KEY,\n DEFAULT_LOCALE,\n VENUE_EVENTS,\n} from \"./constants\"\n\nimport {\n styledFeatureGenerator,\n getExtrudeConfigByFeature,\n} from \"./utils/createElements\"\n\nimport { getBearingBetweenPoints } from \"./utils/math\"\n\nimport {\n NavigationPath,\n Billboard,\n SpriteMarker,\n GroundLabel,\n} from \"./object3d\"\nimport {\n createHighlighExtrudeObjectController,\n createHighlighBillboardController,\n} from \"./utils/createHighlightElement\"\nimport {\n IMapConfig,\n IndoorMapOptions,\n ISetHighlightElementIdsOptions,\n} from \"./types\"\n\nimport { CameraManager } from \"./camera/CameraManager\"\nimport { RendererManager } from \"./renderer\"\nimport { VenueDataClient } from \"../data\"\n\ntype MapPaddingType = {\n paddingLeft: number;\n paddingRight: number;\n paddingTop: number;\n paddingBottom: number;\n}\n\nconst INITIAL_CENTER = [100.5017051, 13.7572619] // just placeholder\nconst INITIAL_ZOOM = 18.5\nconst CLICK_TOLERANCE = 20\n\nconst defaultOptions: Partial<IndoorMapOptions> = {\n pixelRatio: 1,\n locale: DEFAULT_LOCALE,\n}\n\n\nexport class IndoorMap extends EventTarget {\n //TODO: refac functions; let them do only 1 thing in a function\n\n /** Note: \"#\" means private variables */\n #styler = null\n #featuresInitted = false\n #elementsLoaded = false\n #elements: Record<string, any> = {}\n #features = []\n #markers = []\n #venues = []\n #venueInView: string | null = null\n #ordinals = []\n #mapTheme = {}\n #billboards = []\n #billboardObjects = []\n #spriteMarkerObjects = []\n #mapDecorations = []\n #groundLabels = []\n #groundObjects = []\n #navigationGeometries: Record<string, NavigationPath> = {}\n #venueObjects = []\n #glbObjects = []\n #objects = []\n #object3ds = []\n #isClicked = false\n #highlightElementIds = []\n #highlightObjectIds = []\n #highlightObjectControllers = []\n #userLocationGeometry = null\n #userLocationElement = null\n #mapConfig: IMapConfig = {}\n #locale: string = defaultOptions.locale\n #lastUserLocationGeometries = []\n #lastUserLocationElements = []\n\n #isLayersFadingOnZoom = false\n\n #touchStartTarget = null\n #touchStartPoint = null\n\n #onClickElement = (e) => {}\n #animationsToRun = []\n\n map: Map | null = null\n #dataClient: VenueDataClient\n camera: CameraManager\n rendererManager: RendererManager\n\n showVenueObject = false\n threeLayer: ThreeLayer | null = null\n\n onMapReady = () => {}\n onMapLoading = () => {}\n\n constructor(elementId, options: IndoorMapOptions) {\n super()\n const {\n onMapReady,\n onMapLoading,\n pixelRatio,\n locale,\n } = _.merge({}, defaultOptions, options)\n\n this.map = new Map(elementId, {\n attribution: false,\n center: INITIAL_CENTER,\n zoom: INITIAL_ZOOM,\n clickTimeThreshold: 600,\n centerCross: (options.centerCross ?? false),\n baseLayer: new TileLayer(\"base\", {\n urlTemplate:\n \"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png\",\n subdomains: [\"a\", \"b\", \"c\", \"d\"],\n opacity: 1.0,\n attribution: \"\",\n hitDetect: false,\n decodeImageInWorker: true,\n errorUrl: \"/assets/img/tile-placeholder.png\",\n }),\n layers: [],\n })\n\n /** Manage create elements from imdf features */\n this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer)\n\n /** Manage zoom, bearing, pitch, flyTo, moveCamera to position */\n this.camera = new CameraManager(this.map)\n \n this.locale = locale\n this.pixelRatio = pixelRatio\n\n this.onMapReady = onMapReady\n this.onMapLoading = onMapLoading\n this.showVenueObject = false\n\n // Bind events\n // @ts-expect-error\n this.map.on(\"click\", this.handleMapClick)\n\n this.dataClient = options.dataClient\n }\n\n set dataClient(value) {\n this.#dataClient = value\n \n // Get center from dataClient and move map to center\n this.#dataClient.filterByType(\"venue\")\n .then(venues => {\n /** Find Venue's center */\n const venueCenters = turfCenter(featureCollection(venues));\n const [x, y] = venueCenters.geometry.coordinates\n const center = new Coordinate(x, y)\n\n /** Move Map to center */\n this.camera.setView({ center, pitch: 60, zoom: 19 })\n })\n }\n\n on(eventName: string, handler) {\n this.map.on(eventName, handler)\n }\n\n /**\n * Events\n */\n handleMapClick = ({ coordinate }) => {\n const { x, y } = coordinate\n console.log(\n `[Coordinates]: x: ${_.round(x, 8)} y: ${_.round(\n y,\n 8\n )}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`\n )\n }\n\n handleMapTouchEnd = ({ containerPoint }) => {\n const { x, y } = containerPoint\n const { x: touchStartX, y: touchStartY } = this.#touchStartPoint\n\n const dis = Math.hypot(x - touchStartX, y - touchStartY)\n // @ts-expect-error \n this.map.off(\"touchend\", this.handleMapTouchEnd)\n\n if (dis > 0 && dis < CLICK_TOLERANCE) {\n console.log(\"Forgiving click\", this.#touchStartTarget.properties.id)\n this.handleClickElement({ target: this.#touchStartTarget })\n }\n\n this.#touchStartTarget = null\n this.#touchStartPoint = null\n }\n\n /**\n * Getters & Setters\n */\n get elementsLoaded() {\n return this.#elementsLoaded\n }\n\n get pixelRatio() {\n return this.map.getDevicePixelRatio()\n }\n\n get locale() {\n return this.#locale\n }\n\n set mapTheme(value) {\n this.#mapTheme = value\n this.#styler = styledFeatureGenerator(this.#mapTheme)\n }\n\n get venues() {\n return this.#venues || []\n }\n\n #findAndSetVenueInView = () => {\n const venueInViewWithDistance = this.findVenueInView()\n if (\n venueInViewWithDistance &&\n (!this.#venueInView ||\n venueInViewWithDistance.venueId !== this.#venueInView)\n ) {\n this.#venueInView = venueInViewWithDistance.venueId\n this.map.fire(VENUE_EVENTS.VENUE_MOVEINTOVIEW, venueInViewWithDistance)\n }\n }\n\n set detectVenueInView(value) {\n if (value) {\n // Set initial venueInView\n this.#findAndSetVenueInView()\n this.map.on(\"moveend\", this.#findAndSetVenueInView)\n } else {\n this.map.off(\"moveend\", this.#findAndSetVenueInView)\n }\n }\n\n get ordinals() {\n return this.#ordinals || []\n }\n\n set ordinals(value) {\n if (!Array.isArray(value)) throw new Error(\"ordinals must be Array\")\n this.#ordinals = value\n }\n\n set billboards(value) {\n this.#billboards = value\n }\n\n set mapConfig(value: IMapConfig) {\n this.#mapConfig = value\n }\n\n set mapDecorations(value) {\n this.#mapDecorations = value\n }\n\n set maxZoom(value: number) {\n this.map.setMaxZoom(value)\n const spatialReference = {\n projection: \"EPSG:3857\",\n resolutions: (function () {\n const resolutions = []\n const d = 2 * 6378137 * Math.PI\n for (let i = 0; i < value; i++) {\n resolutions[i] = d / (256 * Math.pow(2, i))\n }\n return resolutions\n })(),\n }\n this.map.setSpatialReference(spatialReference)\n }\n\n set minZoom(value: number) {\n this.map.setMinZoom(value)\n }\n\n set groundLabels(value) {\n this.#groundLabels = value\n }\n\n set pixelRatio(value: number) {\n this.map.setDevicePixelRatio(value)\n }\n\n set onClickElement(func) {\n this.#onClickElement = func\n }\n\n set locale(value: string) {\n this.#locale = value || defaultOptions.locale\n\n // Update elements affected by locale changes.\n this.updateUserLocationSymbolByLocale(this.#locale)\n }\n\n /**\n * Private internal methods\n */\n\n #clearElements() {\n LAYERS.forEach((layerKey) => {\n this.#clearAllElementOnLayerByName(layerKey)\n })\n const scene = this.threeLayer.getScene()\n if (scene) {\n scene.children = scene.children.filter(\n (children) => children instanceof PerspectiveCamera\n )\n }\n }\n\n handleClickElement = (e) => {\n if (this.#isClicked) return\n this.#isClicked = true\n const onClickElement = this.#onClickElement\n if (!_.isFunction(onClickElement)) return\n this.#onClickElement(e)\n this.#isClicked = false\n }\n\n setCenter(center: Coordinate, padding?: MapPaddingType) {\n this.map.setCenter(center, padding)\n }\n\n async #legacy_createElements() {\n const {\n // 2D\n createVenue,\n createOpening,\n createSection,\n createFixture,\n createOccupant,\n createDecoration,\n // 3D\n create3DFootprint,\n create3DGroundLabel,\n create3DBillboard,\n createVenue3DModel,\n createExtrudedUnit,\n create3DFixture,\n create3DAmenityMarker,\n create3DOccupantAmenityMarker,\n create3DOpeningMarker,\n createOccupantGroundLabel,\n // Light\n createAmbientLight,\n createDirectionalLight,\n } = this.#styler\n\n let elements = {}\n let object3ds = []\n\n const scene = this.threeLayer.getScene()\n if (scene) {\n const {\n ambientLight: ambientLightConfig = {},\n directionalLight: directionalLightConfig = {},\n } = _.get(this.#mapConfig, \"light\", {\n ambientLight: {},\n directionalLight: {},\n })\n\n const ambientLight = createAmbientLight(ambientLightConfig)\n scene.add(ambientLight)\n\n const light = createDirectionalLight(directionalLightConfig)\n scene.add(light)\n }\n for (const feature of this.#features) {\n try {\n const { feature_type: featureType, properties, id } = feature\n const layerName = _.get(\n LAYER_FEATURE_TYPE_OBJ,\n featureType,\n featureType\n )\n const layer = this.map.getLayer(layerName)\n let geometry\n const category = _.get(feature, \"properties.category\")\n\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n const textMarkerType = _.get(\n this.#mapConfig,\n \"text_marker_type\",\n \"ui-marker\"\n )\n const featureExtrudeConfig = getExtrudeConfigByFeature(\n extrudeConfig,\n feature\n )\n\n switch (featureType) {\n case \"venue\": {\n geometry = createVenue(feature).addTo(layer)\n // Add 3D Model\n const models = await createVenue3DModel(feature, this.threeLayer)\n models.forEach((model) => {\n model.on(\"click\", this.handleClickElement)\n object3ds.push(model)\n this.#venueObjects.push(model)\n })\n break\n }\n case \"amenity\": {\n if (feature.properties.is_featured) {\n const billboardObj = create3DBillboard(feature, this.threeLayer)\n billboardObj?.on(\"click\", this.handleClickElement)\n this.#billboardObjects.push(billboardObj)\n this.#spriteMarkerObjects.push(billboardObj)\n object3ds.push(billboardObj)\n break\n }\n const marker3d = create3DAmenityMarker(\n feature,\n this.threeLayer,\n extrudeConfig\n )\n marker3d?.on(\"click\", this.handleClickElement)\n this.#spriteMarkerObjects.push(marker3d)\n object3ds.push(marker3d)\n break\n }\n case \"opening\": {\n switch (category) {\n case \"emergencyexit\":\n const { geometry } = turfCenter(feature)\n const markerFeature = {\n ...feature,\n geometry,\n }\n const marker3d = create3DOpeningMarker(\n markerFeature,\n this.threeLayer,\n extrudeConfig\n )?.on(\"click\", this.handleClickElement)\n object3ds.push(marker3d)\n break\n default:\n }\n geometry = createOpening(feature)\n ?.on(\"click\", this.handleClickElement)\n .addTo(layer)\n break\n }\n case \"section\": {\n geometry = createSection(feature)?.addTo(layer)\n break\n }\n case \"occupant\": {\n switch (category) {\n // Create only marker if it is amenity occupant\n case \"currencyexchange\":\n case \"donationcenter\":\n case \"postoffice\":\n const markerFeature = {\n ...feature,\n geometry: feature.properties?.anchor?.geometry,\n }\n const marker3d = create3DOccupantAmenityMarker(\n markerFeature,\n this.threeLayer,\n extrudeConfig\n )?.on(\"click\", this.handleClickElement)\n object3ds.push(marker3d)\n break\n default: {\n // Main Location\n const { kiosk, anchor } = feature.properties\n const { unit } = anchor.properties\n let mainLocation = kiosk || unit || null\n\n // Get related locations excluding current ordinal\n const relatedLocations = [\n ...feature.properties.units,\n ...feature.properties.kiosks,\n ].filter((f) => f.properties.ordinal !== properties.ordinal)\n\n // Combine all locations to process in single loop\n const occupantLocations = [mainLocation, ...relatedLocations]\n const renderType = feature.properties.render_type\n\n occupantLocations.forEach((location, index) => {\n const isMainLocation = index === 0\n\n // Handle 3D elements (currently only ground labels)\n if (renderType === \"Label\") {\n const occupantGroundLabel = createOccupantGroundLabel(\n feature,\n location,\n { textMarkerType, extrudeConfig },\n this.threeLayer\n )\n\n // Add 3D ground label to object3ds\n if (occupantGroundLabel instanceof GroundLabel) {\n occupantGroundLabel.on(\"click\", this.handleClickElement)\n occupantGroundLabel.addTo(this.threeLayer)\n object3ds.push(occupantGroundLabel)\n this.#groundObjects.push(occupantGroundLabel)\n }\n } else {\n // Handle 2D markers (UIMarker or regular Marker)\n const occupantMarker = createOccupant(feature, location, {\n textMarkerType,\n extrudeConfig,\n })\n /**\n * !Temporary condition; can be removed later if we implement all markers (logo, logo + name, name) to UIMarker.\n * UIMarker Can only be added to the map after rc.29\n * https://github.com/maptalks/maptalks.js/releases/tag/v1.0.0-rc.29\n */\n\n // Add marker to map based on type\n if (occupantMarker instanceof ui.UIMarker) {\n occupantMarker.addTo(this.map)\n } else {\n occupantMarker?.on(\"click\", this.handleClickElement)\n occupantMarker?.addTo(layer)\n }\n\n if (isMainLocation) {\n // Set main location add to elements (so it can be show/hide by ordinal)\n geometry = occupantMarker\n } else {\n // For related location add to elements (so it can be show/hide by ordinal)\n elements[`${feature.id}_${index}`] = {\n geometry: occupantMarker,\n properties: location.properties,\n featureType: \"occupant\",\n feature,\n }\n }\n }\n })\n }\n }\n break\n }\n case \"fixture\": {\n const models = await create3DFixture(feature, this.threeLayer)\n models.forEach((model) => {\n model.on(\"click\", this.handleClickElement)\n object3ds.push(model)\n this.#glbObjects.push(model)\n })\n if (!featureExtrudeConfig) {\n geometry = createFixture(feature)?.addTo(layer)\n } else {\n const locatedLevel = feature?.properties?.level\n const levelExtrudeConfig = getExtrudeConfigByFeature(\n extrudeConfig,\n locatedLevel\n )\n const levelHeight = _.get(levelExtrudeConfig, \"height\", 0)\n const option = { ...featureExtrudeConfig, altitude: levelHeight }\n\n const extrudedFixture = createExtrudedUnit(\n feature,\n this.threeLayer,\n option\n )\n object3ds.push(extrudedFixture)\n }\n break\n }\n \n case \"footprint\": {\n // Added 3D Footprint\n const objects = await create3DFootprint(\n feature,\n this.threeLayer,\n featureExtrudeConfig\n )\n objects.forEach((object) => {\n object.on(\"click\", () => {\n const {\n geometry: { coordinates },\n } = turfCenter(feature)\n this.camera.flyToAndZoomIn(coordinates, { pitch: 45 })\n })\n object3ds.push(object)\n this.#objects.push(object)\n })\n\n // Add Footprint Marker\n if (feature.properties.logo) {\n const footprintMarker = create3DBillboard(\n feature,\n this.threeLayer\n )\n object3ds.push(footprintMarker)\n this.#billboardObjects.push(footprintMarker)\n }\n\n break\n }\n default:\n break\n }\n if (!id) throw new Error(`Property is missing ID, ${id}`)\n elements[id] = { geometry, properties, featureType, feature }\n } catch (err) {\n console.warn(`Cannot create ${feature.id}: ${err.message}`)\n }\n }\n\n this.#groundLabels.forEach((label) => {\n const text = label.properties.name\n try {\n const groundLabel = create3DGroundLabel(label, this.threeLayer)\n object3ds.push(groundLabel)\n this.#groundObjects.push(groundLabel)\n } catch (error) {\n console.log(\"error creating ground label for \", text)\n }\n })\n\n this.#mapDecorations.forEach((decoration) => {\n const { id, geometry, properties } = decoration\n const geometryType = decoration?.geometry?.type\n try {\n switch (geometryType) {\n case \"Point\":\n const createdBillboard = create3DBillboard(\n decoration,\n this.threeLayer\n )\n this.#billboardObjects.push(createdBillboard)\n object3ds.push(createdBillboard)\n break\n default:\n const decorationLayer = this.map.getLayer(`base`)\n const createdDecoration = createDecoration(geometry, {\n id,\n ...properties,\n }).addTo(decorationLayer)\n elements[id] = {\n geometry: createdDecoration,\n properties,\n featureType: \"decoration\",\n }\n break\n }\n } catch (error) {\n console.log(\n \"error creating decoration for \",\n decoration.properties.name\n )\n }\n })\n\n // Initiate Canvas render\n this.#elements = elements\n this.#elementsLoaded = true\n this.#featuresInitted = true\n this.#object3ds = object3ds\n if (typeof this.onMapReady === \"function\") this.onMapReady()\n }\n\n #clearAllElementOnLayerByName = (layerName: string) => {\n const layer = this.map.getLayer(layerName) as VectorLayer\n if (layer) layer.clear()\n }\n\n\n /**\n * Change Level & animate to path / geometry / view / etc.\n * ================================== */\n changeLevelByOrdinal(ordinal: null | number | number[]): void {\n // this.#showGeometriesByOrdinal(ordinal) // show / hide geometry on the ordinal\n // this.#showThreeObjectByOrdinal(ordinal)\n this.rendererManager.changeLevelByOrdinal(ordinal)\n }\n\n getFeatureExtent = (feature, scaleFactor = 1) => {\n const [minX, minY, maxX, maxY] = bbox(\n scale(bboxPolygon(bbox(feature)), scaleFactor)\n )\n return new Extent(minX, minY, maxX, maxY)\n }\n\n getExtentCenter = (extent: Extent) => {\n return extent.getCenter()\n }\n\n getExtentZoom = (\n extent: Extent,\n options: { isFraction?: boolean; padding?: MapPaddingType } = {\n isFraction: false,\n padding: {\n paddingLeft: 0,\n paddingRight: 0,\n paddingTop: 0,\n paddingBottom: 0,\n },\n }\n ) => {\n const { isFraction = false, padding } = options\n return this.map.getFitZoom(extent, isFraction, padding)\n }\n\n findVenueInView = (): { venueId: string; distance: number } => {\n const mapCenter = this.map.getCenter()\n const result = this.#venues.reduce<{\n venueId: string\n distance: number\n } | null>((closest, venue) => {\n const { display_point: displayPoint } = venue.properties\n const distance = turfDistance(displayPoint, [mapCenter.x, mapCenter.y])\n if (!closest || distance < closest.distance) {\n return { venueId: venue.id, distance }\n }\n return closest\n }, null)\n return result\n }\n\n flyTo = (center, options) => {\n this.camera.flyTo(center, options)\n }\n\n getLineStringBearing = (feature) => {\n const { geometry } = feature\n const path = new LineString(geometry.coordinates)\n return getBearingBetweenPoints(\n path.getFirstCoordinate(),\n path.getLastCoordinate()\n )\n }\n\n //map animation\n addAnimations(animation: { id: string; callback: () => void }) {\n this.#animationsToRun.push(animation)\n }\n\n removeAnimationById(id: string) {\n this.#animationsToRun = this.#animationsToRun.filter(\n (animation) => animation.id !== id\n )\n }\n\n clearAnimations() {\n this.#animationsToRun = []\n }\n\n /**\n * Hilighting Elements\n * ========================================= */\n // TODO: To consider if we should use setter `set hilightElementIds` instead?\n setHighlightElementIds(\n targetElementIds,\n options: ISetHighlightElementIdsOptions = {}\n ) {\n const highlight3DOptions = _.merge(\n {},\n DEFAULT_HIGHLIGHT_OPTIONS,\n _.get(options, \"highlight3DOptions\", {})\n )\n const highlight2DOptions = _.merge(\n {},\n DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,\n _.get(options, \"highlight2DOptions\", {})\n )\n\n this.setHighlightedObject(targetElementIds, highlight3DOptions)\n return this.setHighlight2DElementIds(targetElementIds, highlight2DOptions)\n }\n setHighlight2DElementIds(targetElementIds, options = {}) {\n const { defaultMarker, symbolSet } = _.merge(\n {},\n DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,\n options\n )\n const {\n createMarker,\n createHighlightOccupantMarker,\n getElementSymbol,\n getHilighPolygonalSymbol,\n getHighlightMarkerSymbol,\n } = this.#styler\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n /**\n * Hilight new elements\n */\n const elementToHilights = targetElementIds\n .map(\n (elemId) =>\n this.#elements[elemId] ||\n this.#elements[`${LAST_USER_LOCATION_ELEMENT_ID_PREFIX}${elemId}`]\n )\n .filter((elem) => elem)\n\n elementToHilights.forEach((elem) => {\n const { feature, geometry } = elem\n if (!geometry || !feature) return\n\n const hilightLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME)\n if (!hilightLayer) return\n\n const defaultSymbol = getHilighPolygonalSymbol(geometry.type)\n const definedSymbol = symbolSet ? getElementSymbol(symbolSet) : null\n const symbol = _.isEmpty(definedSymbol) ? defaultSymbol : definedSymbol\n\n switch (geometry.type) {\n case \"MultiPolygon\":\n case \"Polygon\": {\n geometry?.updateSymbol(symbol)\n break\n }\n default:\n break\n }\n\n switch (feature.feature_type) {\n case \"amenity\":\n const highlightedAmenityMarker =\n definedSymbol || getHighlightMarkerSymbol()\n geometry?.updateSymbol(highlightedAmenityMarker)\n break\n case \"occupant\": {\n switch (feature.properties.category) {\n case \"currencyexchange\":\n case \"donationcenter\":\n case \"postoffice\":\n const highlightedAmenityMarker =\n definedSymbol || getHighlightMarkerSymbol()\n geometry?.updateSymbol(highlightedAmenityMarker)\n break\n default:\n if (feature.properties.render_type === \"Logo\") {\n this.hideGeometryByElementId(feature.id)\n }\n createHighlightOccupantMarker(feature, {\n extrudeConfig,\n symbol: definedSymbol,\n })\n .on(\"click\", this.handleClickElement)\n .addTo(hilightLayer)\n break\n }\n break\n }\n case \"opening\":\n break\n default:\n if (defaultMarker) createMarker(feature).addTo(hilightLayer)\n break\n }\n\n /* Hide the occupant marker before display the highlight marker */\n // const occupantId = IndexedOccupantMarkers[feature.id]\n // if (occupantId) {\n // hideOccupantMarker(occupantId)\n // }\n })\n\n // Store new hilightIds to prev ref.\n this.#highlightElementIds = targetElementIds\n\n if (elementToHilights.length === 0) return\n return featureCollection(\n elementToHilights.map(({ feature }) => {\n const { geometry } = feature\n if (feature.feature_type === \"occupant\")\n return turfFeature(feature?.properties?.anchor?.geometry)\n return turfFeature(geometry)\n })\n )\n }\n\n clearHighlightElements() {\n /**\n * Clear previous hilights\n */\n this.#clearAllElementOnLayerByName(HIGHLIGHT_LAYER_NAME)\n\n //Return geometry to defaultSymbol\n _(this.#highlightElementIds)\n .map((elemId) => this.#elements[elemId]?.geometry)\n .compact()\n .forEach((geometry) => {\n if (geometry instanceof ui.UIMarker) return\n\n if (geometry instanceof Marker) {\n this.showGeometryByElementId(geometry.properties.id)\n return\n }\n\n try {\n const defaultSymbol = geometry.options.defaultSymbol\n geometry.updateSymbol(defaultSymbol)\n } catch (err) {\n console.log(\n `error cannot return to defaultSymbol, check if \"defaultSymbol\" exists in element creation function`\n )\n }\n })\n this.#highlightElementIds = []\n }\n\n setHighlightedObject(targetObjectIds, options = {}) {\n const { symbolSet } = _.merge({}, DEFAULT_HIGHLIGHT_OPTIONS, options)\n const {\n getElementSymbol,\n getHilighPolygonalSymbol,\n createHighlight2DAmenityMarkerFrom3DMarker,\n } = this.#styler\n const objects = this.threeLayer?.getBaseObjects()\n const objectsToHighlight = objects.filter(({ properties }) =>\n targetObjectIds.includes(properties?.id)\n )\n\n const defaultSymbol = getHilighPolygonalSymbol(\"Polygon\")\n const targetSymbol = symbolSet ? getElementSymbol(symbolSet) : null\n const { polygonFill: color } = _.isEmpty(targetSymbol)\n ? defaultSymbol\n : targetSymbol\n\n const amenityHighlightMode = _.get(\n this.#mapConfig,\n \"amenity_highlight_mode\",\n \"\"\n )\n objectsToHighlight.forEach((obj) => {\n //highlight extruded polygon\n if (obj.type === \"ExtrudePolygon\") {\n const newController = createHighlighExtrudeObjectController(obj, {\n color,\n })\n newController.start()\n this.#highlightObjectControllers.push(newController)\n }\n //highlight amenity marker\n if (obj instanceof SpriteMarker) {\n if (amenityHighlightMode === \"2DMarker\") {\n const hilight2DLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME)\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n obj.hide()\n const { properties: featureProperties } = obj\n createHighlight2DAmenityMarkerFrom3DMarker(\n featureProperties,\n extrudeConfig\n )\n .on(\"click\", this.handleClickElement)\n .addTo(hilight2DLayer)\n } else {\n obj.highlight()\n }\n }\n\n if (obj instanceof Billboard) {\n const newController = createHighlighBillboardController(obj)\n newController.start()\n this.#highlightObjectControllers.push(newController)\n }\n })\n\n this.#highlightObjectIds = targetObjectIds\n }\n\n clearHighlightObject() {\n this.#highlightObjectControllers.forEach((controller) => {\n if (_.isFunction(controller?.clear)) controller.clear()\n })\n this.#highlightObjectIds.forEach((objIds) => {\n const objects = this.threeLayer?.getBaseObjects()\n const objectToResetHighlight = objects.find(({ properties }) =>\n objIds.includes(properties?.id)\n )\n if (objectToResetHighlight instanceof SpriteMarker) {\n objectToResetHighlight.show()\n objectToResetHighlight.removeHighlight()\n }\n })\n // Clear the highlight object controllers\n this.#highlightObjectControllers = []\n this.#highlightObjectIds = []\n }\n\n /**\n * User Location\n ****************************/\n // TODO: To consider if we should use setter `set userLocation` instead?\n\n addUserLocation(value) {\n const { createUserLocationMarker } = this.#styler\n\n this.#userLocationGeometry = value\n\n const { properties, feature_type } = value\n\n // If UserLocationGeometry not exists, create one.\n\n const markerLayer = this.map.getLayer(USER_LOCATION_LAYER_NAME)\n\n if (!this.#userLocationElement?.geometry && markerLayer) {\n const geometry = createUserLocationMarker(value)\n geometry.addTo(markerLayer)\n\n // Add marker to this.#elements\n const element = {\n geometry,\n properties,\n featureType: feature_type,\n feature: value,\n }\n this.#elements[USER_LOCATION_ELEMENT_ID] = element\n this.#userLocationElement = element\n\n this.updateUserLocationSymbolByLocale(this.locale)\n }\n }\n\n updateUserLocationSymbolByLocale(locale: string) {\n const userLocationGeometry = _.get(\n this.#elements,\n `${USER_LOCATION_ELEMENT_ID}.geometry`\n )\n\n if (!userLocationGeometry) return\n\n const currentSymbol = userLocationGeometry.getSymbol()\n\n /**\n * Localized user location marker example.\n * Supports locale-based marker files.\n *\n * Example:\n * {\n * \"markerFile\": \"logo_url\", // Default marker\n * \"locale_symbol\": { \"th\": { \"markerFile\": \"logo_url\" }, \"default\": { \"markerFile\": \"logo_url\" } }\n * }\n */\n const localeSymbolToUpdate = currentSymbol.map((symbol) => {\n const localeSymbol =\n _.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) ||\n _.get(symbol, `${LOCALE_SYMBOL_KEY}.default`)\n if (!_.isPlainObject(localeSymbol)) return symbol\n\n return {\n ...symbol,\n ...localeSymbol,\n }\n })\n userLocationGeometry?.updateSymbol(localeSymbolToUpdate)\n }\n\n removeUserLocation() {\n this.#userLocationGeometry = null\n if (this.#userLocationElement) {\n const { geometry } = this.#userLocationElement\n if (geometry) geometry.remove()\n\n this.#userLocationElement = null\n this.#elements[USER_LOCATION_ELEMENT_ID] = null\n }\n }\n\n showUserLocationMarker() {\n this.#userLocationElement?.geometry.show()\n }\n\n hideUserLocationMarker() {\n this.#userLocationElement?.geometry.hide()\n }\n\n addLastUserLocation(value) {\n const newLastLocationId = value?.id\n // If the last location ID is undefined or exists, no new marker will be added.\n const isExists =\n this.#lastUserLocationGeometries.findIndex(\n ({ feature }) => feature?.id === newLastLocationId\n ) >= 0\n\n if (!newLastLocationId || isExists) return\n\n const { createLastUserLocationMarker } = this.#styler\n\n this.#lastUserLocationGeometries = [\n ...this.#lastUserLocationGeometries,\n value,\n ]\n\n const { properties, feature_type, id } = value\n\n const markerLayer = this.map.getLayer(USER_LOCATION_LAYER_NAME)\n\n const geometry = createLastUserLocationMarker(value)\n if (!geometry) return\n geometry.addTo(markerLayer)\n\n // Add marker to this.#elements\n const element = {\n geometry,\n properties,\n featureType: feature_type,\n feature: value,\n }\n this.#elements[`${LAST_USER_LOCATION_ELEMENT_ID_PREFIX}${id}`] = element\n this.#lastUserLocationElements = [\n ...this.#lastUserLocationElements,\n element,\n ]\n }\n\n removeLastUserLocation() {\n this.#lastUserLocationGeometries = []\n if (\n this.#lastUserLocationElements &&\n this.#lastUserLocationElements.length > 0\n ) {\n for (const lastUserLocationElem of this.#lastUserLocationElements) {\n const { geometry, properties = {} } = lastUserLocationElem\n if (geometry) {\n geometry.remove()\n delete this.#elements[`last_user_location-${properties?.id}`]\n }\n }\n this.#lastUserLocationElements = []\n }\n }\n\n hideLastUserLocationMarker() {\n for (const lastUserLocationElem of this.#lastUserLocationElements) {\n const { geometry } = lastUserLocationElem\n if (geometry) geometry.hide()\n }\n }\n\n /**\n * END of User Location\n ****************************/\n\n showGeometryByElementId = (elementId): void => {\n const geometry: Geometry | undefined = _.get(\n this.#elements,\n `${elementId}.geometry`\n )\n if (geometry) geometry.show()\n }\n\n hideGeometryByElementId = (elementId): void => {\n const geometry: Geometry = _.get(this.#elements, `${elementId}.geometry`)\n if (geometry) geometry.hide()\n }\n\n setSpriteMarkersOpacity = (opacity: number = 1): void => {\n const spriteMarkerObjects = this.#spriteMarkerObjects\n spriteMarkerObjects?.forEach((baseObject) => {\n baseObject.getObject3d().traverse((child) => {\n if (child.isLine || child.isSprite) {\n child.material.opacity = opacity\n }\n })\n })\n }\n\n setFeatureObject3DsOpacity = (opacity: number = 1): void => {\n const objects = this.#object3ds\n objects?.forEach((baseObject) => {\n if (baseObject instanceof NavigationPath) return\n baseObject.getObject3d().traverse((child) => {\n if (child.isMesh === true) {\n child.material.opacity = opacity\n }\n })\n })\n }\n\n /*\n * Enable or disable the fading effect based on the zoom level for all layers except the Venue Model.\n * This function applies when extruded units exceed the edges of the Venue Model while zooming out.\n * It can be enabled only when the Venue Model is present.\n */\n disableLayersFadingOnZoom = (): void => {\n this.#isLayersFadingOnZoom = false\n }\n\n enableLayersFadingOnZoom = (): void => {\n this.#isLayersFadingOnZoom = this.#venueObjects.length !== 0\n }\n\n /**\n * Navigation\n ****************************/\n combineNearbyLineStrings(\n lineStrings: Feature<LineStringType, GeoJsonProperties>[],\n options: {\n properties?: GeoJsonProperties\n distance?: number\n } = { properties: {}, distance: 0.0003 }\n // 0.0003 = 30cm\n ) {\n const { properties = {}, distance = 0.0003 } = options || {}\n const combinedLineStrings = []\n const accLine = []\n if (lineStrings.length === 1) return lineStrings\n\n for (let i = 0; i < lineStrings.length; i++) {\n const line = lineStrings[i]\n const coords = line.geometry.coordinates\n const prevLine = lineStrings[i - 1]\n const firstCoord = _.first(coords)\n const isFirstLine = i === 0\n\n if (isFirstLine) {\n accLine.push(...coords)\n continue\n }\n\n const prevLastCoord = _.last(prevLine.geometry.coordinates)\n const isNearby =\n turfDistance(point(firstCoord), point(prevLastCoord)) < distance\n\n if (!isNearby) {\n const remainingLines = lineStrings.slice(i)\n const res = this.combineNearbyLineStrings(remainingLines, properties)\n combinedLineStrings.push(...res)\n break\n }\n accLine.push(...coords)\n }\n combinedLineStrings.push(lineString(accLine, properties))\n return combinedLineStrings\n }\n\n createNavigationGeometries = (stepGeometries, destinationFeature) => {\n const {\n createOriginMarker,\n createDestinationPinMarker,\n createDestinationLogoMarker,\n create3DStepPath,\n } = this.#styler\n const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME)\n\n const linesByOrdinal = _(stepGeometries)\n .filter(({ geometry }) => geometry.type === \"LineString\")\n .groupBy(\"properties.ordinal\")\n .value()\n\n const joinedLines = _(linesByOrdinal).reduce((acc, lines, key) => {\n const joined = this.combineNearbyLineStrings(lines, {\n properties: { ordinal: +key },\n })\n return [...acc, ...joined]\n }, [])\n\n joinedLines.forEach((line, index) => {\n try {\n const navPath: NavigationPath = create3DStepPath(line, this.threeLayer)\n this.threeLayer.addMesh([navPath])\n this.#navigationGeometries[`line-${index}`] = navPath\n this.#object3ds.push(navPath)\n } catch (err) {\n console.log(err)\n }\n })\n\n stepGeometries.forEach((stepGeometry) => {\n const { geometry, properties, feature_type = null } = stepGeometry\n let stepElement\n try {\n switch (geometry.type) {\n // Create a destination marker and route path\n case \"Point\":\n switch (feature_type) {\n case \"origin-marker\":\n stepElement =\n createOriginMarker(stepGeometry).addTo(routeMarkerLayer)\n break\n case \"destination-marker\":\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n if (destinationFeature.feature_type === \"occupant\") {\n const stepId = _.get(stepGeometry, \"id\")\n // !Update step ID to occupant destination feature ID to prevent unexpected clearing of occupant element from map\n const normalizedDestinationFeature = {\n ...destinationFeature,\n id: stepId,\n }\n const logoUrl = _.get(\n normalizedDestinationFeature,\n \"properties.logo.url\"\n )\n const createOccupantDestinationMarkerFn = logoUrl\n ? createDestinationLogoMarker\n : createDestinationPinMarker\n stepElement = createOccupantDestinationMarkerFn(\n normalizedDestinationFeature,\n { extrudeConfig }\n ).addTo(routeMarkerLayer)\n break\n }\n stepElement = createDestinationPinMarker(destinationFeature, {\n extrudeConfig,\n }).addTo(routeMarkerLayer)\n break\n default:\n this.#navigationGeometries[stepGeometry.id] = stepElement\n break\n }\n break\n default:\n break\n }\n if (stepElement) {\n const { id, feature_type: featureType } = stepGeometry\n // Add tot Elements object\n this.#elements[id] = {\n geometry: stepElement,\n featureType,\n properties: { ...stepGeometry, ...properties },\n }\n //\n }\n } catch (err) {\n // console.log(err, {\n // index: index,\n // stepGeometries,\n // })\n // throw err;\n console.log(err)\n }\n })\n }\n\n createOverviewStepPathByOrdinal = (stepGeometries, viewingOrdinal) => {\n const { createLineStringFromGeometries } = this.#styler\n const initialStepGeometries = stepGeometries\n .filter(({ properties }) => properties.ordinal === viewingOrdinal)\n .map(({ geometry }) => geometry)\n return createLineStringFromGeometries(initialStepGeometries)\n }\n\n clearNavigationGeometries(): void {\n // Remove origin and destination markers from the highlight layer\n const routeMarkerLayer = this.map.getLayer(\n HIGHLIGHT_LAYER_NAME\n ) as OverlayLayer\n const originMarkerGeometry = _.get(\n this.#elements,\n `${ORIGIN_MARKER_ID}.geometry`\n )\n const destinationMarkerGeometry = _.get(\n this.#elements,\n `${DESTINATION_MARKER_ID}.geometry`\n )\n const geometriesToRemove = _.compact([\n originMarkerGeometry,\n destinationMarkerGeometry,\n ])\n\n routeMarkerLayer.removeGeometry(geometriesToRemove)\n\n this.#elements[ORIGIN_MARKER_ID] = null\n this.#elements[DESTINATION_MARKER_ID] = null\n\n // Filter out NavigationPath objects from the global this.#object3ds list\n this.#object3ds = this.#object3ds.filter(\n (obj) => !(obj instanceof NavigationPath)\n )\n\n // Remove related navigation geometry objects\n const objects = this.#navigationGeometries || {}\n _.forEach(objects, (obj) => {\n if (!obj) return\n this.#navigationGeometries[obj.properties.id] = null\n obj.remove()\n })\n }\n /**\n * END of Navigation\n ****************************/\n\n /**\n * hide/show venue 3dmodel\n **/\n\n hideVenueObjects = () => {\n this.showVenueObject = false\n }\n showVenueObjects = () => {\n this.showVenueObject = true\n }\n\n /**\n * Other functions\n */\n\n enableClick = () => this.map.config({ geometryEvents: true })\n disableClick = () => this.map.config({ geometryEvents: false })\n\n freeze = () => this.map.config({ zoomable: false, draggable: false })\n unfreeze = () => this.map.config({ zoomable: true, draggable: true })\n\n /**\n * render (frame)\n */\n getTargetViewCenter = (\n targetView,\n options = { offset: { top: 0, left: 0, right: 0, bottom: 0 } }\n ) => {\n // Extend the input targetView with default values from the current view if not provided\n const map = this.map\n const { offset } = options\n const { top = 0, left = 0, right = 0, bottom = 0 } = offset\n // Temporarily set the map to the target view to calculate the extent.\n // This approach requires that the map view can be adjusted without triggering a visible change.\n const originalState = {\n bearing: map.getBearing(),\n center: map.getCenter(),\n pitch: map.getPitch(),\n zoom: map.getZoom(),\n }\n\n const finalView = {\n bearing: _.isNil(targetView.bearing)\n ? map.getBearing()\n : targetView.bearing,\n center: _.isNil(targetView.center) ? map.getCenter() : targetView.center,\n pitch: _.isNil(targetView.pitch) ? map.getPitch() : targetView.pitch,\n zoom: _.isNil(targetView.zoom) ? map.getZoom() : targetView.zoom,\n }\n\n map.setView(finalView)\n\n // Calculate the visible extent at this state\n const projectedTargetCenter = map\n .coordinateToContainerPoint(finalView.center)\n .add(right / 2 - left / 2, bottom / 2 - top / 2)\n const adjustedTargetCenter = map.containerPointToCoordinate(\n projectedTargetCenter\n )\n // Reset the map to its original state to avoid any visible changes\n map.setView(originalState)\n return adjustedTargetCenter\n }\n\n setMaxExtent(extent: Extent) {\n return this.map.setMaxExtent(extent)\n }\n\n render() {\n // TODO: Update User Location marker position\n const view = this.map.getView()\n const currBearing = view.bearing\n this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate\n if (this.threeLayer._needsUpdate) {\n // @ts-ignore\n this.threeLayer.redraw()\n }\n\n if (this.threeLayer) {\n const objectOpacity = _.clamp(38 - 2 * this.camera.getZoom(), 0, 1)\n\n this.#objects.forEach((object) => {\n object.getObject3d().traverse((child) => {\n if (child.isMesh) child.material.opacity = objectOpacity\n //TODO: recheck this line if it actually works\n /** set Mesh visible = false when opacity is 0\n * and true when opacity > 0\n */\n child.visible = !!objectOpacity\n })\n object.getObject3d().visible = !!objectOpacity\n })\n\n if (this.#billboardObjects) {\n this.#billboardObjects.forEach((object) => {\n const objectScale = _.clamp(\n 20 - 1 * this.camera.getZoom(),\n 1,\n 1.05\n )\n object.getObject3d().scale.set(objectScale, objectScale, 1)\n })\n }\n\n /*\n * The layer appears while zooming in and disappears when zooming out,\n * fully vanishing when the Venue Model is visible (opacity: 1).\n */\n if (this.#isLayersFadingOnZoom) {\n const layerOpacity = _.clamp(1 - objectOpacity, 0, 1)\n // Fading 2D layers.\n LAYERS.forEach((layerKey) => {\n const layer = this.map.getLayer(layerKey)\n if (layer) layer.setOpacity(layerOpacity)\n })\n\n // Fading 3D units, such as extruded units.\n this.setFeatureObject3DsOpacity(layerOpacity)\n\n // Fading sprite markers, such as billboards and amenity markers.\n this.setSpriteMarkersOpacity(layerOpacity)\n }\n\n this.#venueObjects.forEach((object) => {\n object.getObject3d().traverse((child) => {\n if (child.isMesh) child.material.opacity = objectOpacity\n /** set Mesh visible = false when opacity is 0\n * and true when opacity > 0\n */\n child.visible = this.showVenueObject && objectOpacity > 0.4\n })\n })\n\n // Update bearing to each GroundLabel to determine if text should flip or not\n this.#groundObjects.forEach((gLabel) => {\n gLabel.bearing = currBearing\n })\n }\n\n this.#animationsToRun.forEach(({ callback }) => callback(this))\n\n //update TWEEN.js animaton\n TWEEN.update()\n\n requestAnimationFrame(this.render.bind(this))\n }\n}\n","import {\n BBox,\n Feature,\n FeatureCollection,\n Geometry,\n GeometryCollection,\n GeometryObject,\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n Position,\n GeoJsonProperties,\n} from \"geojson\";\n\nimport { Id } from \"./lib/geojson.js\";\nexport * from \"./lib/geojson.js\";\n\n/**\n * @module helpers\n */\n\n// TurfJS Combined Types\nexport type Coord = Feature<Point> | Point | Position;\n\n/**\n * Linear measurement units.\n *\n * ⚠️ Warning. Be aware of the implications of using radian or degree units to\n * measure distance. The distance represented by a degree of longitude *varies*\n * depending on latitude.\n *\n * See https://www.thoughtco.com/degree-of-latitude-and-longitude-distance-4070616\n * for an illustration of this behaviour.\n *\n * @typedef\n */\nexport type Units =\n | \"meters\"\n | \"metres\"\n | \"millimeters\"\n | \"millimetres\"\n | \"centimeters\"\n | \"centimetres\"\n | \"kilometers\"\n | \"kilometres\"\n | \"miles\"\n | \"nauticalmiles\"\n | \"inches\"\n | \"yards\"\n | \"feet\"\n | \"radians\"\n | \"degrees\";\n\n/**\n * Area measurement units.\n *\n * @typedef\n */\nexport type AreaUnits =\n | Exclude<Units, \"radians\" | \"degrees\">\n | \"acres\"\n | \"hectares\";\n\n/**\n * Grid types.\n *\n * @typedef\n */\nexport type Grid = \"point\" | \"square\" | \"hex\" | \"triangle\";\n\n/**\n * Shorthand corner identifiers.\n *\n * @typedef\n */\nexport type Corners = \"sw\" | \"se\" | \"nw\" | \"ne\" | \"center\" | \"centroid\";\n\n/**\n * Geometries made up of lines i.e. lines and polygons.\n *\n * @typedef\n */\nexport type Lines = LineString | MultiLineString | Polygon | MultiPolygon;\n\n/**\n * Convenience type for all possible GeoJSON.\n *\n * @typedef\n */\nexport type AllGeoJSON =\n | Feature\n | FeatureCollection\n | Geometry\n | GeometryCollection;\n\n/**\n * The Earth radius in meters. Used by Turf modules that model the Earth as a sphere. The {@link https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius mean radius} was selected because it is {@link https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended recommended } by the Haversine formula (used by turf/distance) to reduce error.\n *\n * @constant\n */\nexport const earthRadius = 6371008.8;\n\n/**\n * Unit of measurement factors based on earthRadius.\n *\n * Keys are the name of the unit, values are the number of that unit in a single radian\n *\n * @constant\n */\nexport const factors: Record<Units, number> = {\n centimeters: earthRadius * 100,\n centimetres: earthRadius * 100,\n degrees: 360 / (2 * Math.PI),\n feet: earthRadius * 3.28084,\n inches: earthRadius * 39.37,\n kilometers: earthRadius / 1000,\n kilometres: earthRadius / 1000,\n meters: earthRadius,\n metres: earthRadius,\n miles: earthRadius / 1609.344,\n millimeters: earthRadius * 1000,\n millimetres: earthRadius * 1000,\n nauticalmiles: earthRadius / 1852,\n radians: 1,\n yards: earthRadius * 1.0936,\n};\n\n/**\n\n * Area of measurement factors based on 1 square meter.\n *\n * @constant\n */\nexport const areaFactors: Record<AreaUnits, number> = {\n acres: 0.000247105,\n centimeters: 10000,\n centimetres: 10000,\n feet: 10.763910417,\n hectares: 0.0001,\n inches: 1550.003100006,\n kilometers: 0.000001,\n kilometres: 0.000001,\n meters: 1,\n metres: 1,\n miles: 3.86e-7,\n nauticalmiles: 2.9155334959812285e-7,\n millimeters: 1000000,\n millimetres: 1000000,\n yards: 1.195990046,\n};\n\n/**\n * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.\n *\n * @function\n * @param {GeometryObject} geometry input geometry\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<GeometryObject, GeoJsonProperties>} a GeoJSON Feature\n * @example\n * var geometry = {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * };\n *\n * var feature = turf.feature(geometry);\n *\n * //=feature\n */\nexport function feature<\n G extends GeometryObject = Geometry,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n geom: G | null,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<G, P> {\n const feat: any = { type: \"Feature\" };\n if (options.id === 0 || options.id) {\n feat.id = options.id;\n }\n if (options.bbox) {\n feat.bbox = options.bbox;\n }\n feat.properties = properties || {};\n feat.geometry = geom;\n return feat;\n}\n\n/**\n * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.\n * For GeometryCollection type use `helpers.geometryCollection`\n *\n * @function\n * @param {(\"Point\" | \"LineString\" | \"Polygon\" | \"MultiPoint\" | \"MultiLineString\" | \"MultiPolygon\")} type Geometry Type\n * @param {Array<any>} coordinates Coordinates\n * @param {Object} [options={}] Optional Parameters\n * @returns {Geometry} a GeoJSON Geometry\n * @example\n * var type = \"Point\";\n * var coordinates = [110, 50];\n * var geometry = turf.geometry(type, coordinates);\n * // => geometry\n */\nexport function geometry(\n type:\n | \"Point\"\n | \"LineString\"\n | \"Polygon\"\n | \"MultiPoint\"\n | \"MultiLineString\"\n | \"MultiPolygon\",\n coordinates: any[],\n _options: Record<string, never> = {}\n) {\n switch (type) {\n case \"Point\":\n return point(coordinates).geometry;\n case \"LineString\":\n return lineString(coordinates).geometry;\n case \"Polygon\":\n return polygon(coordinates).geometry;\n case \"MultiPoint\":\n return multiPoint(coordinates).geometry;\n case \"MultiLineString\":\n return multiLineString(coordinates).geometry;\n case \"MultiPolygon\":\n return multiPolygon(coordinates).geometry;\n default:\n throw new Error(type + \" is invalid\");\n }\n}\n\n/**\n * Creates a {@link Point} {@link Feature} from a Position.\n *\n * @function\n * @param {Position} coordinates longitude, latitude position (each in decimal degrees)\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<Point, GeoJsonProperties>} a Point feature\n * @example\n * var point = turf.point([-75.343, 39.984]);\n *\n * //=point\n */\nexport function point<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<Point, P> {\n if (!coordinates) {\n throw new Error(\"coordinates is required\");\n }\n if (!Array.isArray(coordinates)) {\n throw new Error(\"coordinates must be an Array\");\n }\n if (coordinates.length < 2) {\n throw new Error(\"coordinates must be at least 2 numbers long\");\n }\n if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {\n throw new Error(\"coordinates must contain numbers\");\n }\n\n const geom: Point = {\n type: \"Point\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.\n *\n * @function\n * @param {Position[]} coordinates an array of Points\n * @param {GeoJsonProperties} [properties={}] Translate these properties to each Feature\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north]\n * associated with the FeatureCollection\n * @param {Id} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<Point>} Point Feature\n * @example\n * var points = turf.points([\n * [-75, 39],\n * [-80, 45],\n * [-78, 50]\n * ]);\n *\n * //=points\n */\nexport function points<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<Point, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return point(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.\n *\n * @function\n * @param {Position[][]} coordinates an array of LinearRings\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<Polygon, GeoJsonProperties>} Polygon Feature\n * @example\n * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });\n *\n * //=polygon\n */\nexport function polygon<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<Polygon, P> {\n for (const ring of coordinates) {\n if (ring.length < 4) {\n throw new Error(\n \"Each LinearRing of a Polygon must have 4 or more Positions.\"\n );\n }\n\n if (ring[ring.length - 1].length !== ring[0].length) {\n throw new Error(\"First and last Position are not equivalent.\");\n }\n\n for (let j = 0; j < ring[ring.length - 1].length; j++) {\n // Check if first point of Polygon contains two numbers\n if (ring[ring.length - 1][j] !== ring[0][j]) {\n throw new Error(\"First and last Position are not equivalent.\");\n }\n }\n }\n const geom: Polygon = {\n type: \"Polygon\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.\n *\n * @function\n * @param {Position[][][]} coordinates an array of Polygon coordinates\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<Polygon, GeoJsonProperties>} Polygon FeatureCollection\n * @example\n * var polygons = turf.polygons([\n * [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],\n * [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],\n * ]);\n *\n * //=polygons\n */\nexport function polygons<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<Polygon, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return polygon(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Creates a {@link LineString} {@link Feature} from an Array of Positions.\n *\n * @function\n * @param {Position[]} coordinates an array of Positions\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<LineString, GeoJsonProperties>} LineString Feature\n * @example\n * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});\n * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});\n *\n * //=linestring1\n * //=linestring2\n */\nexport function lineString<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<LineString, P> {\n if (coordinates.length < 2) {\n throw new Error(\"coordinates must be an array of two or more positions\");\n }\n const geom: LineString = {\n type: \"LineString\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.\n *\n * @function\n * @param {Position[][]} coordinates an array of LinearRings\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north]\n * associated with the FeatureCollection\n * @param {Id} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<LineString, GeoJsonProperties>} LineString FeatureCollection\n * @example\n * var linestrings = turf.lineStrings([\n * [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],\n * [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]\n * ]);\n *\n * //=linestrings\n */\nexport function lineStrings<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<LineString, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return lineString(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.\n *\n * @function\n * @param {Array<Feature<GeometryObject, GeoJsonProperties>>} features input features\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {FeatureCollection<GeometryObject, GeoJsonProperties>} FeatureCollection of Features\n * @example\n * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});\n * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});\n * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});\n *\n * var collection = turf.featureCollection([\n * locationA,\n * locationB,\n * locationC\n * ]);\n *\n * //=collection\n */\nexport function featureCollection<\n G extends GeometryObject = Geometry,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n features: Array<Feature<G, P>>,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<G, P> {\n const fc: any = { type: \"FeatureCollection\" };\n if (options.id) {\n fc.id = options.id;\n }\n if (options.bbox) {\n fc.bbox = options.bbox;\n }\n fc.features = features;\n return fc;\n}\n\n/**\n * Creates a {@link Feature}<{@link MultiLineString}> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Position[][]} coordinates an array of LineStrings\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiLineString, GeoJsonProperties>} a MultiLineString feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);\n *\n * //=multiLine\n */\nexport function multiLineString<\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiLineString, P> {\n const geom: MultiLineString = {\n type: \"MultiLineString\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature}<{@link MultiPoint}> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Position[]} coordinates an array of Positions\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiPoint, GeoJsonProperties>} a MultiPoint feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiPt = turf.multiPoint([[0,0],[10,10]]);\n *\n * //=multiPt\n */\nexport function multiPoint<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiPoint, P> {\n const geom: MultiPoint = {\n type: \"MultiPoint\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature}<{@link MultiPolygon}> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Position[][][]} coordinates an array of Polygons\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiPolygon, GeoJsonProperties>} a multipolygon feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);\n *\n * //=multiPoly\n *\n */\nexport function multiPolygon<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiPolygon, P> {\n const geom: MultiPolygon = {\n type: \"MultiPolygon\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a Feature<GeometryCollection> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>} geometries an array of GeoJSON Geometries\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<GeometryCollection, GeoJsonProperties>} a GeoJSON GeometryCollection Feature\n * @example\n * var pt = turf.geometry(\"Point\", [100, 0]);\n * var line = turf.geometry(\"LineString\", [[101, 0], [102, 1]]);\n * var collection = turf.geometryCollection([pt, line]);\n *\n * // => collection\n */\nexport function geometryCollection<\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n geometries: Array<\n Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon\n >,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<GeometryCollection, P> {\n const geom: GeometryCollection = {\n type: \"GeometryCollection\",\n geometries,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Round number to precision\n *\n * @function\n * @param {number} num Number\n * @param {number} [precision=0] Precision\n * @returns {number} rounded number\n * @example\n * turf.round(120.4321)\n * //=120\n *\n * turf.round(120.4321, 2)\n * //=120.43\n */\nexport function round(num: number, precision = 0): number {\n if (precision && !(precision >= 0)) {\n throw new Error(\"precision must be a positive number\");\n }\n const multiplier = Math.pow(10, precision || 0);\n return Math.round(num * multiplier) / multiplier;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @function\n * @param {number} radians in radians across the sphere\n * @param {Units} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} distance\n */\nexport function radiansToLength(\n radians: number,\n units: Units = \"kilometers\"\n): number {\n const factor = factors[units];\n if (!factor) {\n throw new Error(units + \" units is invalid\");\n }\n return radians * factor;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @function\n * @param {number} distance in real units\n * @param {Units} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} radians\n */\nexport function lengthToRadians(\n distance: number,\n units: Units = \"kilometers\"\n): number {\n const factor = factors[units];\n if (!factor) {\n throw new Error(units + \" units is invalid\");\n }\n return distance / factor;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet\n *\n * @function\n * @param {number} distance in real units\n * @param {Units} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} degrees\n */\nexport function lengthToDegrees(distance: number, units?: Units): number {\n return radiansToDegrees(lengthToRadians(distance, units));\n}\n\n/**\n * Converts any bearing angle from the north line direction (positive clockwise)\n * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line\n *\n * @function\n * @param {number} bearing angle, between -180 and +180 degrees\n * @returns {number} angle between 0 and 360 degrees\n */\nexport function bearingToAzimuth(bearing: number): number {\n let angle = bearing % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\n\n/**\n * Converts any azimuth angle from the north line direction (positive clockwise)\n * and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line\n *\n * @function\n * @param {number} angle between 0 and 360 degrees\n * @returns {number} bearing between -180 and +180 degrees\n */\nexport function azimuthToBearing(angle: number): number {\n // Ignore full revolutions (multiples of 360)\n angle = angle % 360;\n\n if (angle > 180) {\n return angle - 360;\n } else if (angle < -180) {\n return angle + 360;\n }\n\n return angle;\n}\n\n/**\n * Converts an angle in radians to degrees\n *\n * @function\n * @param {number} radians angle in radians\n * @returns {number} degrees between 0 and 360 degrees\n */\nexport function radiansToDegrees(radians: number): number {\n // % (2 * Math.PI) radians in case someone passes value > 2π\n const normalisedRadians = radians % (2 * Math.PI);\n return (normalisedRadians * 180) / Math.PI;\n}\n\n/**\n * Converts an angle in degrees to radians\n *\n * @function\n * @param {number} degrees angle between 0 and 360 degrees\n * @returns {number} angle in radians\n */\nexport function degreesToRadians(degrees: number): number {\n // % 360 degrees in case someone passes value > 360\n const normalisedDegrees = degrees % 360;\n return (normalisedDegrees * Math.PI) / 180;\n}\n\n/**\n * Converts a length from one unit to another.\n *\n * @function\n * @param {number} length Length to be converted\n * @param {Units} [originalUnit=\"kilometers\"] Input length unit\n * @param {Units} [finalUnit=\"kilometers\"] Returned length unit\n * @returns {number} The converted length\n */\nexport function convertLength(\n length: number,\n originalUnit: Units = \"kilometers\",\n finalUnit: Units = \"kilometers\"\n): number {\n if (!(length >= 0)) {\n throw new Error(\"length must be a positive number\");\n }\n return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);\n}\n\n/**\n * Converts an area from one unit to another.\n *\n * @function\n * @param {number} area Area to be converted\n * @param {AreaUnits} [originalUnit=\"meters\"] Input area unit\n * @param {AreaUnits} [finalUnit=\"kilometers\"] Returned area unit\n * @returns {number} The converted length\n */\nexport function convertArea(\n area: number,\n originalUnit: AreaUnits = \"meters\",\n finalUnit: AreaUnits = \"kilometers\"\n): number {\n if (!(area >= 0)) {\n throw new Error(\"area must be a positive number\");\n }\n\n const startFactor = areaFactors[originalUnit];\n if (!startFactor) {\n throw new Error(\"invalid original units\");\n }\n\n const finalFactor = areaFactors[finalUnit];\n if (!finalFactor) {\n throw new Error(\"invalid final units\");\n }\n\n return (area / startFactor) * finalFactor;\n}\n\n/**\n * isNumber\n *\n * @function\n * @param {any} num Number to validate\n * @returns {boolean} true/false\n * @example\n * turf.isNumber(123)\n * //=true\n * turf.isNumber('foo')\n * //=false\n */\nexport function isNumber(num: any): boolean {\n return !isNaN(num) && num !== null && !Array.isArray(num);\n}\n\n/**\n * isObject\n *\n * @function\n * @param {any} input variable to validate\n * @returns {boolean} true/false, including false for Arrays and Functions\n * @example\n * turf.isObject({elevation: 10})\n * //=true\n * turf.isObject('foo')\n * //=false\n */\nexport function isObject(input: any): boolean {\n return input !== null && typeof input === \"object\" && !Array.isArray(input);\n}\n\n/**\n * Validate BBox\n *\n * @private\n * @param {any} bbox BBox to validate\n * @returns {void}\n * @throws {Error} if BBox is not valid\n * @example\n * validateBBox([-180, -40, 110, 50])\n * //=OK\n * validateBBox([-180, -40])\n * //=Error\n * validateBBox('Foo')\n * //=Error\n * validateBBox(5)\n * //=Error\n * validateBBox(null)\n * //=Error\n * validateBBox(undefined)\n * //=Error\n */\nexport function validateBBox(bbox: any): void {\n if (!bbox) {\n throw new Error(\"bbox is required\");\n }\n if (!Array.isArray(bbox)) {\n throw new Error(\"bbox must be an Array\");\n }\n if (bbox.length !== 4 && bbox.length !== 6) {\n throw new Error(\"bbox must be an Array of 4 or 6 numbers\");\n }\n bbox.forEach((num) => {\n if (!isNumber(num)) {\n throw new Error(\"bbox must only contain numbers\");\n }\n });\n}\n\n/**\n * Validate Id\n *\n * @private\n * @param {any} id Id to validate\n * @returns {void}\n * @throws {Error} if Id is not valid\n * @example\n * validateId([-180, -40, 110, 50])\n * //=Error\n * validateId([-180, -40])\n * //=Error\n * validateId('Foo')\n * //=OK\n * validateId(5)\n * //=OK\n * validateId(null)\n * //=Error\n * validateId(undefined)\n * //=Error\n */\nexport function validateId(id: any): void {\n if (!id) {\n throw new Error(\"id is required\");\n }\n if ([\"string\", \"number\"].indexOf(typeof id) === -1) {\n throw new Error(\"id must be a number or a string\");\n }\n}\n","import { feature, point, lineString, isObject } from \"@turf/helpers\";\n\n/**\n * Callback for coordEach\n *\n * @callback coordEachCallback\n * @param {number[]} currentCoord The current coordinate being processed.\n * @param {number} coordIndex The current index of the coordinate being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over coordinates in any GeoJSON object, similar to Array.forEach()\n *\n * @function\n * @param {AllGeoJSON} geojson any GeoJSON object\n * @param {coordEachCallback} callback a method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)\n * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {\"foo\": \"bar\"}),\n * turf.point([36, 53], {\"hello\": \"world\"})\n * ]);\n *\n * turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=currentCoord\n * //=coordIndex\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * });\n */\nfunction coordEach(geojson, callback, excludeWrapCoord) {\n // Handles null Geometry -- Skips this GeoJSON\n if (geojson === null) return;\n var j,\n k,\n l,\n geometry,\n stopG,\n coords,\n geometryMaybeCollection,\n wrapShrink = 0,\n coordIndex = 0,\n isGeometryCollection,\n type = geojson.type,\n isFeatureCollection = type === \"FeatureCollection\",\n isFeature = type === \"Feature\",\n stop = isFeatureCollection ? geojson.features.length : 1;\n\n // This logic may look a little weird. The reason why it is that way\n // is because it's trying to be fast. GeoJSON supports multiple kinds\n // of objects at its root: FeatureCollection, Features, Geometries.\n // This function has the responsibility of handling all of them, and that\n // means that some of the `for` loops you see below actually just don't apply\n // to certain inputs. For instance, if you give this just a\n // Point geometry, then both loops are short-circuited and all we do\n // is gradually rename the input until it's called 'geometry'.\n //\n // This also aims to allocate as few resources as possible: just a\n // few numbers and booleans, rather than any temporary arrays as would\n // be required with the normalization approach.\n for (var featureIndex = 0; featureIndex < stop; featureIndex++) {\n geometryMaybeCollection = isFeatureCollection\n ? geojson.features[featureIndex].geometry\n : isFeature\n ? geojson.geometry\n : geojson;\n isGeometryCollection = geometryMaybeCollection\n ? geometryMaybeCollection.type === \"GeometryCollection\"\n : false;\n stopG = isGeometryCollection\n ? geometryMaybeCollection.geometries.length\n : 1;\n\n for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {\n var multiFeatureIndex = 0;\n var geometryIndex = 0;\n geometry = isGeometryCollection\n ? geometryMaybeCollection.geometries[geomIndex]\n : geometryMaybeCollection;\n\n // Handles null Geometry -- Skips this geometry\n if (geometry === null) continue;\n coords = geometry.coordinates;\n var geomType = geometry.type;\n\n wrapShrink =\n excludeWrapCoord &&\n (geomType === \"Polygon\" || geomType === \"MultiPolygon\")\n ? 1\n : 0;\n\n switch (geomType) {\n case null:\n break;\n case \"Point\":\n if (\n callback(\n coords,\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n multiFeatureIndex++;\n break;\n case \"LineString\":\n case \"MultiPoint\":\n for (j = 0; j < coords.length; j++) {\n if (\n callback(\n coords[j],\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n if (geomType === \"MultiPoint\") multiFeatureIndex++;\n }\n if (geomType === \"LineString\") multiFeatureIndex++;\n break;\n case \"Polygon\":\n case \"MultiLineString\":\n for (j = 0; j < coords.length; j++) {\n for (k = 0; k < coords[j].length - wrapShrink; k++) {\n if (\n callback(\n coords[j][k],\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n }\n if (geomType === \"MultiLineString\") multiFeatureIndex++;\n if (geomType === \"Polygon\") geometryIndex++;\n }\n if (geomType === \"Polygon\") multiFeatureIndex++;\n break;\n case \"MultiPolygon\":\n for (j = 0; j < coords.length; j++) {\n geometryIndex = 0;\n for (k = 0; k < coords[j].length; k++) {\n for (l = 0; l < coords[j][k].length - wrapShrink; l++) {\n if (\n callback(\n coords[j][k][l],\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n }\n geometryIndex++;\n }\n multiFeatureIndex++;\n }\n break;\n case \"GeometryCollection\":\n for (j = 0; j < geometry.geometries.length; j++)\n if (\n coordEach(geometry.geometries[j], callback, excludeWrapCoord) ===\n false\n )\n return false;\n break;\n default:\n throw new Error(\"Unknown Geometry Type\");\n }\n }\n }\n}\n\n/**\n * Callback for coordReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback coordReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {number[]} currentCoord The current coordinate being processed.\n * @param {number} coordIndex The current index of the coordinate being processed.\n * Starts at index 0, if an initialValue is provided, and at index 1 otherwise.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce coordinates in any GeoJSON object, similar to Array.reduce()\n *\n * @function\n * @param {AllGeoJSON} geojson any GeoJSON object\n * @param {coordReduceCallback} callback a method that takes (previousValue, currentCoord, coordIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {\"foo\": \"bar\"}),\n * turf.point([36, 53], {\"hello\": \"world\"})\n * ]);\n *\n * turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=previousValue\n * //=currentCoord\n * //=coordIndex\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * return currentCoord;\n * });\n */\nfunction coordReduce(geojson, callback, initialValue, excludeWrapCoord) {\n var previousValue = initialValue;\n coordEach(\n geojson,\n function (\n currentCoord,\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) {\n if (coordIndex === 0 && initialValue === undefined)\n previousValue = currentCoord;\n else\n previousValue = callback(\n previousValue,\n currentCoord,\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n );\n },\n excludeWrapCoord\n );\n return previousValue;\n}\n\n/**\n * Callback for propEach\n *\n * @callback propEachCallback\n * @param {GeoJsonProperties} currentProperties The current Properties being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over properties in any GeoJSON object, similar to Array.forEach()\n *\n * @function\n * @param {FeatureCollection|Feature} geojson any GeoJSON object\n * @param {propEachCallback} callback a method that takes (currentProperties, featureIndex)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.propEach(features, function (currentProperties, featureIndex) {\n * //=currentProperties\n * //=featureIndex\n * });\n */\nfunction propEach(geojson, callback) {\n var i;\n switch (geojson.type) {\n case \"FeatureCollection\":\n for (i = 0; i < geojson.features.length; i++) {\n if (callback(geojson.features[i].properties, i) === false) break;\n }\n break;\n case \"Feature\":\n callback(geojson.properties, 0);\n break;\n }\n}\n\n/**\n * Callback for propReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback propReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {GeoJsonProperties} currentProperties The current Properties being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce properties in any GeoJSON object into a single value,\n * similar to how Array.reduce works. However, in this case we lazily run\n * the reduction, so an array of all properties is unnecessary.\n *\n * @function\n * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object\n * @param {propReduceCallback} callback a method that takes (previousValue, currentProperties, featureIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {\n * //=previousValue\n * //=currentProperties\n * //=featureIndex\n * return currentProperties\n * });\n */\nfunction propReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n propEach(geojson, function (currentProperties, featureIndex) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentProperties;\n else\n previousValue = callback(previousValue, currentProperties, featureIndex);\n });\n return previousValue;\n}\n\n/**\n * Callback for featureEach\n *\n * @callback featureEachCallback\n * @param {Feature<any>} currentFeature The current Feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over features in any GeoJSON object, similar to\n * Array.forEach.\n *\n * @function\n * @param {FeatureCollection|Feature|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {featureEachCallback} callback a method that takes (currentFeature, featureIndex)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.featureEach(features, function (currentFeature, featureIndex) {\n * //=currentFeature\n * //=featureIndex\n * });\n */\nfunction featureEach(geojson, callback) {\n if (geojson.type === \"Feature\") {\n callback(geojson, 0);\n } else if (geojson.type === \"FeatureCollection\") {\n for (var i = 0; i < geojson.features.length; i++) {\n if (callback(geojson.features[i], i) === false) break;\n }\n }\n}\n\n/**\n * Callback for featureReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback featureReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature} currentFeature The current Feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce features in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection|Feature|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {featureReduceCallback} callback a method that takes (previousValue, currentFeature, featureIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {\"foo\": \"bar\"}),\n * turf.point([36, 53], {\"hello\": \"world\"})\n * ]);\n *\n * turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {\n * //=previousValue\n * //=currentFeature\n * //=featureIndex\n * return currentFeature\n * });\n */\nfunction featureReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n featureEach(geojson, function (currentFeature, featureIndex) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentFeature;\n else previousValue = callback(previousValue, currentFeature, featureIndex);\n });\n return previousValue;\n}\n\n/**\n * Get all coordinates from any GeoJSON object.\n *\n * @function\n * @param {AllGeoJSON} geojson any GeoJSON object\n * @returns {Array<Array<number>>} coordinate position array\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * var coords = turf.coordAll(features);\n * //= [[26, 37], [36, 53]]\n */\nfunction coordAll(geojson) {\n var coords = [];\n coordEach(geojson, function (coord) {\n coords.push(coord);\n });\n return coords;\n}\n\n/**\n * Callback for geomEach\n *\n * @callback geomEachCallback\n * @param {GeometryObject} currentGeometry The current Geometry being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {GeoJsonProperties} featureProperties The current Feature Properties being processed.\n * @param {BBox} featureBBox The current Feature BBox being processed.\n * @param {Id} featureId The current Feature Id being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over each geometry in any GeoJSON object, similar to Array.forEach()\n *\n * @function\n * @param {FeatureCollection|Feature|Geometry|GeometryObject|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {geomEachCallback} callback a method that takes (currentGeometry, featureIndex, featureProperties, featureBBox, featureId)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.geomEach(features, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {\n * //=currentGeometry\n * //=featureIndex\n * //=featureProperties\n * //=featureBBox\n * //=featureId\n * });\n */\nfunction geomEach(geojson, callback) {\n var i,\n j,\n g,\n geometry,\n stopG,\n geometryMaybeCollection,\n isGeometryCollection,\n featureProperties,\n featureBBox,\n featureId,\n featureIndex = 0,\n isFeatureCollection = geojson.type === \"FeatureCollection\",\n isFeature = geojson.type === \"Feature\",\n stop = isFeatureCollection ? geojson.features.length : 1;\n\n // This logic may look a little weird. The reason why it is that way\n // is because it's trying to be fast. GeoJSON supports multiple kinds\n // of objects at its root: FeatureCollection, Features, Geometries.\n // This function has the responsibility of handling all of them, and that\n // means that some of the `for` loops you see below actually just don't apply\n // to certain inputs. For instance, if you give this just a\n // Point geometry, then both loops are short-circuited and all we do\n // is gradually rename the input until it's called 'geometry'.\n //\n // This also aims to allocate as few resources as possible: just a\n // few numbers and booleans, rather than any temporary arrays as would\n // be required with the normalization approach.\n for (i = 0; i < stop; i++) {\n geometryMaybeCollection = isFeatureCollection\n ? geojson.features[i].geometry\n : isFeature\n ? geojson.geometry\n : geojson;\n featureProperties = isFeatureCollection\n ? geojson.features[i].properties\n : isFeature\n ? geojson.properties\n : {};\n featureBBox = isFeatureCollection\n ? geojson.features[i].bbox\n : isFeature\n ? geojson.bbox\n : undefined;\n featureId = isFeatureCollection\n ? geojson.features[i].id\n : isFeature\n ? geojson.id\n : undefined;\n isGeometryCollection = geometryMaybeCollection\n ? geometryMaybeCollection.type === \"GeometryCollection\"\n : false;\n stopG = isGeometryCollection\n ? geometryMaybeCollection.geometries.length\n : 1;\n\n for (g = 0; g < stopG; g++) {\n geometry = isGeometryCollection\n ? geometryMaybeCollection.geometries[g]\n : geometryMaybeCollection;\n\n // Handle null Geometry\n if (geometry === null) {\n if (\n callback(\n null,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) === false\n )\n return false;\n continue;\n }\n switch (geometry.type) {\n case \"Point\":\n case \"LineString\":\n case \"MultiPoint\":\n case \"Polygon\":\n case \"MultiLineString\":\n case \"MultiPolygon\": {\n if (\n callback(\n geometry,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) === false\n )\n return false;\n break;\n }\n case \"GeometryCollection\": {\n for (j = 0; j < geometry.geometries.length; j++) {\n if (\n callback(\n geometry.geometries[j],\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) === false\n )\n return false;\n }\n break;\n }\n default:\n throw new Error(\"Unknown Geometry Type\");\n }\n }\n // Only increase `featureIndex` per each feature\n featureIndex++;\n }\n}\n\n/**\n * Callback for geomReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback geomReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {GeometryObject} currentGeometry The current Geometry being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {GeoJsonProperties} featureProperties The current Feature Properties being processed.\n * @param {BBox} featureBBox The current Feature BBox being processed.\n * @param {Id} featureId The current Feature Id being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce geometry in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection|Feature|GeometryObject|GeometryCollection|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {geomReduceCallback} callback a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {\n * //=previousValue\n * //=currentGeometry\n * //=featureIndex\n * //=featureProperties\n * //=featureBBox\n * //=featureId\n * return currentGeometry\n * });\n */\nfunction geomReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n geomEach(\n geojson,\n function (\n currentGeometry,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentGeometry;\n else\n previousValue = callback(\n previousValue,\n currentGeometry,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n );\n }\n );\n return previousValue;\n}\n\n/**\n * Callback for flattenEach\n *\n * @callback flattenEachCallback\n * @param {Feature} currentFeature The current flattened feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over flattened features in any GeoJSON object, similar to\n * Array.forEach.\n *\n * @function\n * @param {FeatureCollection|Feature|GeometryObject|GeometryCollection|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {flattenEachCallback} callback a method that takes (currentFeature, featureIndex, multiFeatureIndex)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})\n * ]);\n *\n * turf.flattenEach(features, function (currentFeature, featureIndex, multiFeatureIndex) {\n * //=currentFeature\n * //=featureIndex\n * //=multiFeatureIndex\n * });\n */\nfunction flattenEach(geojson, callback) {\n geomEach(geojson, function (geometry, featureIndex, properties, bbox, id) {\n // Callback for single geometry\n var type = geometry === null ? null : geometry.type;\n switch (type) {\n case null:\n case \"Point\":\n case \"LineString\":\n case \"Polygon\":\n if (\n callback(\n feature(geometry, properties, { bbox: bbox, id: id }),\n featureIndex,\n 0\n ) === false\n )\n return false;\n return;\n }\n\n var geomType;\n\n // Callback for multi-geometry\n switch (type) {\n case \"MultiPoint\":\n geomType = \"Point\";\n break;\n case \"MultiLineString\":\n geomType = \"LineString\";\n break;\n case \"MultiPolygon\":\n geomType = \"Polygon\";\n break;\n }\n\n for (\n var multiFeatureIndex = 0;\n multiFeatureIndex < geometry.coordinates.length;\n multiFeatureIndex++\n ) {\n var coordinate = geometry.coordinates[multiFeatureIndex];\n var geom = {\n type: geomType,\n coordinates: coordinate,\n };\n if (\n callback(feature(geom, properties), featureIndex, multiFeatureIndex) ===\n false\n )\n return false;\n }\n });\n}\n\n/**\n * Callback for flattenReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback flattenReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature} currentFeature The current Feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce flattened features in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection|Feature|GeometryObject|GeometryCollection|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {flattenReduceCallback} callback a method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})\n * ]);\n *\n * turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, multiFeatureIndex) {\n * //=previousValue\n * //=currentFeature\n * //=featureIndex\n * //=multiFeatureIndex\n * return currentFeature\n * });\n */\nfunction flattenReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n flattenEach(\n geojson,\n function (currentFeature, featureIndex, multiFeatureIndex) {\n if (\n featureIndex === 0 &&\n multiFeatureIndex === 0 &&\n initialValue === undefined\n )\n previousValue = currentFeature;\n else\n previousValue = callback(\n previousValue,\n currentFeature,\n featureIndex,\n multiFeatureIndex\n );\n }\n );\n return previousValue;\n}\n\n/**\n * Callback for segmentEach\n *\n * @callback segmentEachCallback\n * @param {Feature<LineString>} currentSegment The current Segment being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @param {number} segmentIndex The current index of the Segment being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()\n * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.\n *\n * @param {AllGeoJSON} geojson any GeoJSON\n * @param {segmentEachCallback} callback a method that takes (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex)\n * @returns {void}\n * @example\n * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);\n *\n * // Iterate over GeoJSON by 2-vertex segments\n * turf.segmentEach(polygon, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {\n * //=currentSegment\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * //=segmentIndex\n * });\n *\n * // Calculate the total number of segments\n * var total = 0;\n * turf.segmentEach(polygon, function () {\n * total++;\n * });\n */\nfunction segmentEach(geojson, callback) {\n flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {\n var segmentIndex = 0;\n\n // Exclude null Geometries\n if (!feature.geometry) return;\n // (Multi)Point geometries do not contain segments therefore they are ignored during this operation.\n var type = feature.geometry.type;\n if (type === \"Point\" || type === \"MultiPoint\") return;\n\n // Generate 2-vertex line segments\n var previousCoords;\n var previousFeatureIndex = 0;\n var previousMultiIndex = 0;\n var prevGeomIndex = 0;\n if (\n coordEach(\n feature,\n function (\n currentCoord,\n coordIndex,\n featureIndexCoord,\n multiPartIndexCoord,\n geometryIndex\n ) {\n // Simulating a meta.coordReduce() since `reduce` operations cannot be stopped by returning `false`\n if (\n previousCoords === undefined ||\n featureIndex > previousFeatureIndex ||\n multiPartIndexCoord > previousMultiIndex ||\n geometryIndex > prevGeomIndex\n ) {\n previousCoords = currentCoord;\n previousFeatureIndex = featureIndex;\n previousMultiIndex = multiPartIndexCoord;\n prevGeomIndex = geometryIndex;\n segmentIndex = 0;\n return;\n }\n var currentSegment = lineString(\n [previousCoords, currentCoord],\n feature.properties\n );\n if (\n callback(\n currentSegment,\n featureIndex,\n multiFeatureIndex,\n geometryIndex,\n segmentIndex\n ) === false\n )\n return false;\n segmentIndex++;\n previousCoords = currentCoord;\n }\n ) === false\n )\n return false;\n });\n}\n\n/**\n * Callback for segmentReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback segmentReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature<LineString>} currentSegment The current Segment being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @param {number} segmentIndex The current index of the Segment being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()\n * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.\n *\n * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON\n * @param {segmentReduceCallback} callback a method that takes (previousValue, currentSegment, currentIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer}\n * @example\n * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);\n *\n * // Iterate over GeoJSON by 2-vertex segments\n * turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {\n * //= previousSegment\n * //= currentSegment\n * //= featureIndex\n * //= multiFeatureIndex\n * //= geometryIndex\n * //= segmentIndex\n * return currentSegment\n * });\n *\n * // Calculate the total number of segments\n * var initialValue = 0\n * var total = turf.segmentReduce(polygon, function (previousValue) {\n * previousValue++;\n * return previousValue;\n * }, initialValue);\n */\nfunction segmentReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n var started = false;\n segmentEach(\n geojson,\n function (\n currentSegment,\n featureIndex,\n multiFeatureIndex,\n geometryIndex,\n segmentIndex\n ) {\n if (started === false && initialValue === undefined)\n previousValue = currentSegment;\n else\n previousValue = callback(\n previousValue,\n currentSegment,\n featureIndex,\n multiFeatureIndex,\n geometryIndex,\n segmentIndex\n );\n started = true;\n }\n );\n return previousValue;\n}\n\n/**\n * Callback for lineEach\n *\n * @callback lineEachCallback\n * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed\n * @param {number} featureIndex The current index of the Feature being processed\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed\n * @param {number} geometryIndex The current index of the Geometry being processed\n * @returns {void}\n */\n\n/**\n * Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,\n * similar to Array.forEach.\n *\n * @function\n * @param {FeatureCollection<Lines>|Feature<Lines>|Lines|Feature<GeometryCollection>|GeometryCollection} geojson object\n * @param {lineEachCallback} callback a method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex)\n * @returns {void}\n * @example\n * var multiLine = turf.multiLineString([\n * [[26, 37], [35, 45]],\n * [[36, 53], [38, 50], [41, 55]]\n * ]);\n *\n * turf.lineEach(multiLine, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=currentLine\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * });\n */\nfunction lineEach(geojson, callback) {\n // validation\n if (!geojson) throw new Error(\"geojson is required\");\n\n flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {\n if (feature.geometry === null) return;\n var type = feature.geometry.type;\n var coords = feature.geometry.coordinates;\n switch (type) {\n case \"LineString\":\n if (callback(feature, featureIndex, multiFeatureIndex, 0, 0) === false)\n return false;\n break;\n case \"Polygon\":\n for (\n var geometryIndex = 0;\n geometryIndex < coords.length;\n geometryIndex++\n ) {\n if (\n callback(\n lineString(coords[geometryIndex], feature.properties),\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n }\n break;\n }\n });\n}\n\n/**\n * Callback for lineReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback lineReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed.\n * @param {number} featureIndex The current index of the Feature being processed\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed\n * @param {number} geometryIndex The current index of the Geometry being processed\n * @returns {Reducer}\n */\n\n/**\n * Reduce features in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection<Lines>|Feature<Lines>|Lines|Feature<GeometryCollection>|GeometryCollection} geojson object\n * @param {Function} callback a method that takes (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var multiPoly = turf.multiPolygon([\n * turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),\n * turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])\n * ]);\n *\n * turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=previousValue\n * //=currentLine\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * return currentLine\n * });\n */\nfunction lineReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n lineEach(\n geojson,\n function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentLine;\n else\n previousValue = callback(\n previousValue,\n currentLine,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n );\n }\n );\n return previousValue;\n}\n\n/**\n * Finds a particular 2-vertex LineString Segment from a GeoJSON using `@turf/meta` indexes.\n *\n * Negative indexes are permitted.\n * Point & MultiPoint will always return null.\n *\n * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.featureIndex=0] Feature Index\n * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index\n * @param {number} [options.geometryIndex=0] Geometry Index\n * @param {number} [options.segmentIndex=0] Segment Index\n * @param {Object} [options.properties={}] Translate Properties to output LineString\n * @param {BBox} [options.bbox={}] Translate BBox to output LineString\n * @param {number|string} [options.id={}] Translate Id to output LineString\n * @returns {Feature<LineString>} 2-vertex GeoJSON Feature LineString\n * @example\n * var multiLine = turf.multiLineString([\n * [[10, 10], [50, 30], [30, 40]],\n * [[-10, -10], [-50, -30], [-30, -40]]\n * ]);\n *\n * // First Segment (defaults are 0)\n * turf.findSegment(multiLine);\n * // => Feature<LineString<[[10, 10], [50, 30]]>>\n *\n * // First Segment of 2nd Multi Feature\n * turf.findSegment(multiLine, {multiFeatureIndex: 1});\n * // => Feature<LineString<[[-10, -10], [-50, -30]]>>\n *\n * // Last Segment of Last Multi Feature\n * turf.findSegment(multiLine, {multiFeatureIndex: -1, segmentIndex: -1});\n * // => Feature<LineString<[[-50, -30], [-30, -40]]>>\n */\nfunction findSegment(geojson, options) {\n // Optional Parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var featureIndex = options.featureIndex || 0;\n var multiFeatureIndex = options.multiFeatureIndex || 0;\n var geometryIndex = options.geometryIndex || 0;\n var segmentIndex = options.segmentIndex || 0;\n\n // Find FeatureIndex\n var properties = options.properties;\n var geometry;\n\n switch (geojson.type) {\n case \"FeatureCollection\":\n if (featureIndex < 0)\n featureIndex = geojson.features.length + featureIndex;\n properties = properties || geojson.features[featureIndex].properties;\n geometry = geojson.features[featureIndex].geometry;\n break;\n case \"Feature\":\n properties = properties || geojson.properties;\n geometry = geojson.geometry;\n break;\n case \"Point\":\n case \"MultiPoint\":\n return null;\n case \"LineString\":\n case \"Polygon\":\n case \"MultiLineString\":\n case \"MultiPolygon\":\n geometry = geojson;\n break;\n default:\n throw new Error(\"geojson is invalid\");\n }\n\n // Find SegmentIndex\n if (geometry === null) return null;\n var coords = geometry.coordinates;\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\":\n return null;\n case \"LineString\":\n if (segmentIndex < 0) segmentIndex = coords.length + segmentIndex - 1;\n return lineString(\n [coords[segmentIndex], coords[segmentIndex + 1]],\n properties,\n options\n );\n case \"Polygon\":\n if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;\n if (segmentIndex < 0)\n segmentIndex = coords[geometryIndex].length + segmentIndex - 1;\n return lineString(\n [\n coords[geometryIndex][segmentIndex],\n coords[geometryIndex][segmentIndex + 1],\n ],\n properties,\n options\n );\n case \"MultiLineString\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (segmentIndex < 0)\n segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;\n return lineString(\n [\n coords[multiFeatureIndex][segmentIndex],\n coords[multiFeatureIndex][segmentIndex + 1],\n ],\n properties,\n options\n );\n case \"MultiPolygon\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (geometryIndex < 0)\n geometryIndex = coords[multiFeatureIndex].length + geometryIndex;\n if (segmentIndex < 0)\n segmentIndex =\n coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;\n return lineString(\n [\n coords[multiFeatureIndex][geometryIndex][segmentIndex],\n coords[multiFeatureIndex][geometryIndex][segmentIndex + 1],\n ],\n properties,\n options\n );\n }\n throw new Error(\"geojson is invalid\");\n}\n\n/**\n * Finds a particular Point from a GeoJSON using `@turf/meta` indexes.\n *\n * Negative indexes are permitted.\n *\n * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.featureIndex=0] Feature Index\n * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index\n * @param {number} [options.geometryIndex=0] Geometry Index\n * @param {number} [options.coordIndex=0] Coord Index\n * @param {Object} [options.properties={}] Translate Properties to output Point\n * @param {BBox} [options.bbox={}] Translate BBox to output Point\n * @param {number|string} [options.id={}] Translate Id to output Point\n * @returns {Feature<Point>} 2-vertex GeoJSON Feature Point\n * @example\n * var multiLine = turf.multiLineString([\n * [[10, 10], [50, 30], [30, 40]],\n * [[-10, -10], [-50, -30], [-30, -40]]\n * ]);\n *\n * // First Segment (defaults are 0)\n * turf.findPoint(multiLine);\n * // => Feature<Point<[10, 10]>>\n *\n * // First Segment of the 2nd Multi-Feature\n * turf.findPoint(multiLine, {multiFeatureIndex: 1});\n * // => Feature<Point<[-10, -10]>>\n *\n * // Last Segment of last Multi-Feature\n * turf.findPoint(multiLine, {multiFeatureIndex: -1, coordIndex: -1});\n * // => Feature<Point<[-30, -40]>>\n */\nfunction findPoint(geojson, options) {\n // Optional Parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var featureIndex = options.featureIndex || 0;\n var multiFeatureIndex = options.multiFeatureIndex || 0;\n var geometryIndex = options.geometryIndex || 0;\n var coordIndex = options.coordIndex || 0;\n\n // Find FeatureIndex\n var properties = options.properties;\n var geometry;\n\n switch (geojson.type) {\n case \"FeatureCollection\":\n if (featureIndex < 0)\n featureIndex = geojson.features.length + featureIndex;\n properties = properties || geojson.features[featureIndex].properties;\n geometry = geojson.features[featureIndex].geometry;\n break;\n case \"Feature\":\n properties = properties || geojson.properties;\n geometry = geojson.geometry;\n break;\n case \"Point\":\n case \"MultiPoint\":\n return null;\n case \"LineString\":\n case \"Polygon\":\n case \"MultiLineString\":\n case \"MultiPolygon\":\n geometry = geojson;\n break;\n default:\n throw new Error(\"geojson is invalid\");\n }\n\n // Find Coord Index\n if (geometry === null) return null;\n var coords = geometry.coordinates;\n switch (geometry.type) {\n case \"Point\":\n return point(coords, properties, options);\n case \"MultiPoint\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n return point(coords[multiFeatureIndex], properties, options);\n case \"LineString\":\n if (coordIndex < 0) coordIndex = coords.length + coordIndex;\n return point(coords[coordIndex], properties, options);\n case \"Polygon\":\n if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;\n if (coordIndex < 0)\n coordIndex = coords[geometryIndex].length + coordIndex;\n return point(coords[geometryIndex][coordIndex], properties, options);\n case \"MultiLineString\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (coordIndex < 0)\n coordIndex = coords[multiFeatureIndex].length + coordIndex;\n return point(coords[multiFeatureIndex][coordIndex], properties, options);\n case \"MultiPolygon\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (geometryIndex < 0)\n geometryIndex = coords[multiFeatureIndex].length + geometryIndex;\n if (coordIndex < 0)\n coordIndex =\n coords[multiFeatureIndex][geometryIndex].length - coordIndex;\n return point(\n coords[multiFeatureIndex][geometryIndex][coordIndex],\n properties,\n options\n );\n }\n throw new Error(\"geojson is invalid\");\n}\n\nexport {\n coordReduce,\n coordEach,\n propEach,\n propReduce,\n featureReduce,\n featureEach,\n coordAll,\n geomReduce,\n geomEach,\n flattenReduce,\n flattenEach,\n segmentReduce,\n segmentEach,\n lineReduce,\n lineEach,\n findSegment,\n findPoint,\n};\n","import { BBox } from \"geojson\";\nimport { AllGeoJSON } from \"@turf/helpers\";\nimport { coordEach } from \"@turf/meta\";\n\n/**\n * Calculates the bounding box for any GeoJSON object, including FeatureCollection.\n * Uses geojson.bbox if available and options.recompute is not set.\n *\n * @function\n * @param {GeoJSON} geojson any GeoJSON object\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson\n * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order\n * @example\n * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);\n * var bbox = turf.bbox(line);\n * var bboxPolygon = turf.bboxPolygon(bbox);\n *\n * //addToMap\n * var addToMap = [line, bboxPolygon]\n */\nfunction bbox(\n geojson: AllGeoJSON,\n options: {\n recompute?: boolean;\n } = {}\n): BBox {\n if (geojson.bbox != null && true !== options.recompute) {\n return geojson.bbox;\n }\n const result: BBox = [Infinity, Infinity, -Infinity, -Infinity];\n coordEach(geojson, (coord) => {\n if (result[0] > coord[0]) {\n result[0] = coord[0];\n }\n if (result[1] > coord[1]) {\n result[1] = coord[1];\n }\n if (result[2] < coord[0]) {\n result[2] = coord[0];\n }\n if (result[3] < coord[1]) {\n result[3] = coord[1];\n }\n });\n return result;\n}\n\nexport { bbox };\nexport default bbox;\n","import { IHighlightOptions, ISetHighlight2DElementIdsOptions } from \"./types\"\n\nconst defaultLayerOption = { enableAltitude: true }\n\nconst VENUE = \"venue\"\nconst LEVEL = \"level\"\nconst UNIT = \"unit\"\nconst FIXTURE = \"fixture\"\nconst KIOSK = \"kiosk\"\nconst OPENING = \"opening\"\nconst SECTION = \"section\"\nconst FOOTPRINT = \"footprint\"\n\nconst AMENITY = \"amenity\"\nconst OCCUPANT = \"occupant\"\n\nconst GEOLOCATION = \"geolocation\"\nconst ORIGIN_MARKER = \"origin-marker\"\nconst DESTINATION_MARKER = \"destination-marker\"\n\nconst DECORATION = \"decoration\"\n\nexport const ALWAYS_VISIBLE_FEATURE_TYPES = [VENUE, FOOTPRINT]\nexport const BASE_LAYER_NAME = \"base\"\nexport const POI_MARKER_LAYER_NAME = \"poi\"\nexport const MARKER_LAYER_NAME = \"marker\"\nexport const HIGHLIGHT_LAYER_NAME = \"highlight\"\nexport const USER_LOCATION_LAYER_NAME = \"user_location\"\n\nexport const ORIGIN_MARKER_ID = \"master-origin-marker\"\nexport const DESTINATION_MARKER_ID = \"master-destination-marker\"\nexport const USER_LOCATION_ELEMENT_ID = \"user_location\"\nexport const LAST_USER_LOCATION_ELEMENT_ID_PREFIX = \"last_user_location-\"\n\nexport const LOCALE_SYMBOL_KEY = \"locale_symbol\"\nexport const DEFAULT_LOCALE = \"en\"\n\nexport const DEFAULT_HIGHLIGHT_OPTIONS: IHighlightOptions = {\n symbolSet: null,\n}\nexport const DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS: ISetHighlight2DElementIdsOptions =\n {\n symbolSet: null,\n defaultMarker: false,\n }\n\nexport const LAYERS = [\n BASE_LAYER_NAME,\n POI_MARKER_LAYER_NAME,\n HIGHLIGHT_LAYER_NAME,\n USER_LOCATION_LAYER_NAME,\n]\n\nexport const LAYER_OPTIONS = {\n [BASE_LAYER_NAME]: {\n ...defaultLayerOption,\n forceRenderOnMoving: true,\n forceRenderOnRotating: true,\n forceRenderOnZooming: true,\n },\n [POI_MARKER_LAYER_NAME]: {\n ...defaultLayerOption,\n forceRenderOnMoving: true,\n forceRenderOnRotating: true,\n forceRenderOnZooming: true,\n zIndex: 10,\n collision: true,\n collisionDelay: 1200,\n },\n [MARKER_LAYER_NAME]: { ...defaultLayerOption },\n [HIGHLIGHT_LAYER_NAME]: { ...defaultLayerOption, zIndex: 98 },\n [USER_LOCATION_LAYER_NAME]: { ...defaultLayerOption, zIndex: 99 },\n}\n\nexport const LAYER_FEATURE_TYPE_OBJ = {\n [VENUE]: BASE_LAYER_NAME,\n [LEVEL]: BASE_LAYER_NAME,\n [UNIT]: BASE_LAYER_NAME,\n [FIXTURE]: BASE_LAYER_NAME,\n [KIOSK]: BASE_LAYER_NAME,\n [OPENING]: BASE_LAYER_NAME,\n [SECTION]: BASE_LAYER_NAME,\n [FOOTPRINT]: BASE_LAYER_NAME,\n [AMENITY]: MARKER_LAYER_NAME,\n [OCCUPANT]: POI_MARKER_LAYER_NAME,\n [GEOLOCATION]: USER_LOCATION_LAYER_NAME,\n [ORIGIN_MARKER]: HIGHLIGHT_LAYER_NAME,\n [DESTINATION_MARKER]: HIGHLIGHT_LAYER_NAME,\n [DECORATION]: BASE_LAYER_NAME,\n}\n\n/** Custom Venue Platform Events. Prefix with \"venue:\" to avoid collision */\nexport const VENUE_EVENTS = {\n VENUE_MOVEINTOVIEW: \"venue:venuemoveintoview\", // When a map is moved and a venue moved into a viewport\n}\n","import _ from \"lodash\"\nimport {\n Polygon,\n MultiPolygon,\n LineString,\n Marker,\n Coordinate,\n MultiLineString,\n ui,\n} from \"maptalks\"\nimport turfCenter from \"@turf/center\"\nimport turfBuffer from \"@turf/buffer\"\n\nimport {\n TextureLoader,\n SpriteMaterial,\n MeshLambertMaterial,\n AmbientLight,\n DirectionalLight,\n} from \"three\"\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\"\n\nimport {\n GroundLabel,\n SpriteMarker,\n Billboard,\n NavigationPath,\n} from \"../object3d\"\nimport { getCenterFromGeometry, createPolygonFromLineString } from \"./geometry\"\nimport { createSVGPathFromMarkerSymbol, svgToPng } from \"./svg\"\n\nconst GeometryType = {\n Polygon,\n MultiPolygon,\n}\n\nconst ORDINAL_HEIGHT = 0 // in version 3D change ORDINAL_HEIGHT for set altitude of geometry\n\nconst VENUE_Z_INDEX = 0\n\nconst LEVEL_Z_INDEX = 2\nconst UNIT_Z_INDEX = 3\nconst FIXTURE_Z_INDEX = 4\nconst DECORATION_Z_INDEX = 4\nconst KIOSK_Z_INDEX = 5\nconst OPENING_Z_INDEX = 3\nconst SECTION_Z_INDEX = 6\nconst USER_LOCATION_Z_INDEX = 99\nconst LAST_LOCATION_Z_INDEX = USER_LOCATION_Z_INDEX - 1\n\nconst PREFIX_HIGHLIGHTED_SYMBOL_KEY = \"highlighted\"\nconst SPRITE_MARKER_FEATURE = [\n \"amenity-atm\",\n \"amenity-babychanging\",\n \"amenity-strollerrental\",\n \"amenity-boardinggate.ferry\",\n \"amenity-elevator\",\n \"amenity-escalator\",\n \"amenity-stairs\",\n \"amenity-information\",\n \"amenity-information.transit\",\n \"amenity-wheelchair\",\n \"amenity-restroom\",\n \"amenity-restroom.male\",\n \"amenity-restroom.female\",\n \"amenity-restroom.wheelchair\",\n \"amenity-restroom.family\",\n \"amenity-restroom.unisex\",\n \"amenity-taxi\",\n \"amenity-groundtransportation\",\n \"amenity-bus\",\n \"amenity-bus.muni\",\n \"amenity-shuttle\",\n \"amenity-parking\",\n \"amenity-parking.shortterm\",\n \"amenity-parking.longterm\",\n \"amenity-parking.waitingarea\",\n \"amenity-parking.compact\",\n \"amenity-parking.ev\",\n \"amenity-parking.bicycle\",\n \"amenity-parking.motorcycle\",\n \"amenity-privatelounge\",\n \"amenity-rideshare\",\n \"amenity-valet\",\n \"amenity-landmark\",\n \"amenity-rail.muni\",\n \"amenity-service\",\n \"amenity-smokingarea\",\n \"amenity-ticketing\",\n \"amenity-meetingpoint\",\n \"amenity-prayerroom\",\n \"amenity-firstaid\",\n \"amenity-ticketing.rail\",\n \"amenity-exhibit\",\n \"amenity-mothersroom\",\n \"amenity-checkin.desk\",\n \"amenity-baggagestorage\",\n \"amenity-baggagecarts\",\n \"amenity-library\",\n \"amenity-coinlocker\",\n \"amenity-powerchargingstation\",\n \"amenity-wheelchairassit\",\n \"amenity-lostandfound\",\n \"amenity-foodservice\",\n \"amenity-businesscenter\",\n \"amenity-guestservices\",\n \"amenity-emergencyshelter\",\n \"amenity-prayerroom.buddhism\",\n \"amenity-defibrillator\",\n \"amenity-drinkingfountain\",\n \"amenity-handsanitizerstation\",\n \"amenity-unspecified\",\n \"amenity-entry\",\n \"amenity-fireextinguisher\",\n \"amenity-security\",\n \"amenity-seating\",\n \"amenity-copymachine\",\n \"amenity-fieldofplay\",\n \"amenity-fieldofplay.soccer\",\n \"amenity-amphitheater\",\n \"amenity-hoteling\",\n \"occupant-currencyexchange\",\n \"occupant-donationcenter\",\n \"occupant-bank\",\n \"occupant-books\",\n \"occupant-postoffice\",\n \"opening-emergencyexit\",\n]\n\nconst SPRITE_HIGHLIGHT_MARKER_FEATURE = SPRITE_MARKER_FEATURE.map(\n (featCate) =>\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${featCate.split(\"-\").join(\".\")}`\n)\n\nconst OCCUPANT_TEXT_MARKER_CLASSNAME = \"mtk-occupant-text-marker\"\n\nconst getAltitude = (properties) =>\n Math.max(0, properties.ordinal * ORDINAL_HEIGHT || 0)\n\nconst createRoomUnit = (feature, style, options) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n })\n}\nconst createAmenityUnit = (feature, style, options = {}) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n const area = new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n })\n return area\n}\n\nconst createNonpublicUnit = (feature, style, options = {}) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: {\n ...style,\n },\n })\n}\nconst createWalkwayUnit = (feature, style, options) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: {\n ...symbolStyle,\n },\n })\n}\n\nconst createWaterFixture = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, inheritFillColorToLine, zIndex } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: {\n ...style,\n },\n zIndex,\n })\n}\n\nconst createVegetationFixture = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, inheritFillColorToLine, zIndex } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: {\n ...symbolStyle,\n },\n zIndex,\n })\n}\n\nconst createObstructionalFixture = (feature, style = {}, options = {}) => {\n const { geometry, properties = {} } = feature\n const { model3d } = properties\n const { allowOverride, inheritFillColorToLine, zIndex } = options\n const symbolStyle = { ...style }\n if (!_.isEmpty(model3d)) return\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n //create polygon with line-offset if geometry is lineString\n if (geometry.type === \"LineString\") {\n const polygon = createPolygonFromLineString(geometry)\n return new GeometryType[\"Polygon\"](polygon, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n zIndex,\n })\n }\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n zIndex,\n })\n}\n\nconst createVegetationSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n}\n\nconst creatingSeatingSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n}\n\nconst creatingDefaultSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n try {\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n } catch (error) {\n console.warn(`Error creatingDefaultSection`, geometry.type)\n }\n}\n\nconst createEatingDrinkingSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n}\n\nconst createPrincipalOpening = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, zIndex } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n try {\n return new LineString(geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n zIndex,\n })\n } catch (error) {\n console.log(`error creating pedestrian principal opening:`, feature)\n }\n}\n\nconst createEmergencyExitOpening = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, zIndex } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n try {\n return new LineString(geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n zIndex,\n })\n } catch (error) {\n console.log(`error creating emergency exit opening:`, feature)\n }\n}\nconst createPedestrianOpening = (feature, style, options = {}) => {\n const { geometry, properties, id } = feature\n const { allowOverride, zIndex } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n try {\n return new LineString(geometry.coordinates, {\n properties: {\n id,\n feature_type: \"opening\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n zIndex,\n })\n } catch (error) {\n console.log(`error creating pedestrian opening:`, feature)\n }\n}\n\nconst loadModel3d = (model3d, coordinate, threeLayer) => {\n return new Promise((resolve, reject) => {\n const loader = new GLTFLoader()\n const { url, properties: modelProperties } = model3d\n loader.load(\n url,\n (gltf) => {\n const object3d = gltf.scene\n // จัดขนาด + scale ที่เหมาะสม\n object3d.rotation.x = _.get(modelProperties, \"rotation.x\")\n object3d.rotation.y = _.get(modelProperties, \"rotation.y\")\n object3d.scale.set(...(_.get(modelProperties, \"scale\") || []))\n\n const object = threeLayer.toModel(object3d, {\n coordinate,\n })\n\n object.getObject3d().traverse((child) => {\n if (child.isMesh === true) {\n child.material.transparent = true\n child.material.metalness = 0.1 // set to near 0 because metal requires environment to reflect light to, if there's nothing then metal will become black.\n }\n })\n\n resolve(object)\n },\n (xhr) => {},\n (error) => {\n reject(error)\n }\n )\n })\n}\n\nconst create3DModels = async (\n models,\n defaultCoordinate,\n properties,\n threeLayer\n) => {\n let modelObjs = []\n for (let j = 0; j < models.length; j++) {\n const model = models[j]\n const positionCoord = _.get(model, \"properties.position\")\n const coord = positionCoord || defaultCoordinate\n const object = await loadModel3d(model, coord, threeLayer)\n object.properties = properties\n modelObjs.push(object)\n }\n\n return modelObjs\n}\n\nconst createExtrudePolygon = (\n geometry,\n threeLayer,\n material,\n height,\n properties = {},\n options\n) => {\n const { offset = 0, altitude = 0 } = options\n const offsetGeometry = turfBuffer(geometry, offset, { units: \"meters\" })\n const object = threeLayer.toExtrudePolygon(\n offsetGeometry,\n { height, async: true, altitude },\n material\n )\n object.properties = properties\n return object\n}\n\nconst create3DMarker = (\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n) => {\n return new SpriteMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n}\n\n/**\n * Retrieves the extrude configuration for a feature.\n *\n * @param {Object} baseExtrudeConfig - The default extrude configuration defined in the map settings within the app config content type.\n * @param {Object} feature - The target feature object for which the extrude value is required.\n * @returns {Object|undefined} - The extrude value from the feature's `properties` field, or the base extrude configuration as a fallback if not defined.\n */\nexport const getExtrudeConfigByFeature = (baseExtrudeConfig, feature = {}) => {\n const { feature_type: featureType } = feature\n // Retrieve extrude configuration from the extrude field in the feature's properties\n const featureExtrudeConfig = _.get(feature, \"properties.extrude\")\n\n // Retrieve extrude configuration from the base extrude settings. (Map Config)\n const featureCategory = _.get(feature, \"properties.category\")\n const baseFeatureExtrudeConfig = _.get(\n baseExtrudeConfig,\n `${featureType}.${featureCategory || featureType}`\n )\n\n // Fallback to base extrude configuration if the feature's extrude field is not defined.\n return featureExtrudeConfig ?? baseFeatureExtrudeConfig\n}\n\nconst getFeatureMarkerConfig = (feature, mapConfig = {}) => {\n const { textMarkerType, extrudeConfig = {}, symbol } = mapConfig\n\n const location = getLocationByFeature(feature)\n const featureExtrudeConfig = getExtrudeConfigByFeature(\n extrudeConfig,\n location\n )\n\n return {\n markerSymbol: symbol,\n textMarkerType,\n featureExtrudeConfig,\n }\n}\n\nexport const createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {\n const material = new SpriteMaterial()\n try {\n const [base, icon] = labelSymbol\n const { markerWidth: baseWidth = 24 } = base\n const { markerWidth: iconWidth = 24 } = icon\n const viewBoxDimension = Math.max(baseWidth, iconWidth)\n\n const baseSVG = createSVGPathFromMarkerSymbol(base)\n const iconSVG = createSVGPathFromMarkerSymbol(icon)\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${viewBoxDimension}\" height=\"${viewBoxDimension}\">${baseSVG}${iconSVG}</svg>`\n const textureLoader = new TextureLoader()\n const scaleFactor = 200 / 24 // Scale factor to upscale from 24px to 200px to ensure the resolution is high enough\n\n svgToPng(svg, scaleFactor).then((png) => {\n const texture = textureLoader.load(png, () => {\n material.map = texture\n material.needsUpdate = true\n })\n })\n } catch (error) {\n console.warn(`Error createSpriteMaterialByLabelSymbol: `, labelSymbol)\n }\n return material\n}\n\nexport const createStyledUIMarkerElement = ({\n style,\n textContent,\n className,\n}) => {\n const element = document.createElement(\"div\")\n for (const key in style) {\n element.style[key] = style[key]\n }\n element.className = className\n element.textContent = textContent\n //! Use outerHTML to return HTML string instead of element object to avoid DOM event warnings from Maptalks.js.\n return element.outerHTML\n}\n\nexport const styledFeatureGenerator = (mapTheme) => {\n const getElementSymbol = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.geometry.symbol`)\n if (featureType === key) return featureTypeTheme\n const categoryTheme = _.get(mapTheme, `${key}.geometry.symbol`)\n return _.merge({}, featureTypeTheme, categoryTheme)\n }\n\n const getLabelSymbol = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.label`)\n const categoryTheme = _.get(mapTheme, `${key}.label`)\n const mergedSymbol = _.merge({}, featureTypeTheme, categoryTheme)\n let symbols = _.values(_.map(mergedSymbol, \"symbol\"))\n const markerIndexToMove = symbols.findIndex(\n ({ elementType }) => elementType === \"label.marker\"\n )\n\n // Move the label.marker symbol to the last of array\n if (markerIndexToMove >= 0) {\n const markerSymbolToMove = _.pullAt(symbols, markerIndexToMove)[0]\n symbols.push(markerSymbolToMove)\n }\n\n return symbols\n }\n\n const getUIMarkerSymbol = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.ui.marker`)\n const categoryTheme = _.get(mapTheme, `${key}.ui.marker`)\n const mergedSymbol = _.merge({}, featureTypeTheme, categoryTheme)\n const symbol = _.get(mergedSymbol, \"symbol\")\n return symbol\n }\n const getUIMarkerOptions = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.ui.marker`)\n const categoryTheme = _.get(mapTheme, `${key}.ui.marker`)\n const mergedSymbol = _.merge({}, featureTypeTheme, categoryTheme)\n const options = _.get(mergedSymbol, \"options\")\n return options\n }\n\n const getLabelOptions = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeSymbol = _.get(mapTheme, `${featureType}.label`)\n const categorySymbol = _.get(mapTheme, `${key}.label`)\n const mergedSymbol = _.merge({}, featureTypeSymbol, categorySymbol)\n return _.reduce(\n mergedSymbol,\n (acc, symbol) => ({ ...acc, ..._.get(symbol, \"options\", {}) }),\n {}\n )\n }\n\n const generateSpriteMarkerMaterial = () => {\n return SPRITE_MARKER_FEATURE.reduce((acc, featCate) => {\n const [featureType, category] = featCate.split(\"-\")\n const key = `${featureType}.${category}`\n const labelSymbol = getLabelSymbol(key)\n const material = createSpriteMaterialByLabelSymbol(labelSymbol)\n return { ...acc, [key]: material }\n }, {})\n }\n\n const generateSpriteHighlightMarkerOption = () => {\n return SPRITE_HIGHLIGHT_MARKER_FEATURE.reduce((acc, featCate) => {\n const categoryKey = _.last(featCate.split(\"-\")) // Example: highlighted-amenity.atm -> amenity.atm\n const defaultLabelSymbol = getLabelSymbol(categoryKey)\n const highlightLabelSymbol = getLabelSymbol(featCate)\n const [defaultBase, defaultIcon] = defaultLabelSymbol\n const [highlightBase, highlightIcon] = highlightLabelSymbol\n const base = _.merge({}, defaultBase, highlightBase)\n const icon = _.merge({}, defaultIcon, highlightIcon)\n\n const material = createSpriteMaterialByLabelSymbol([base, icon])\n const options = getLabelOptions(featCate)\n return { ...acc, [featCate]: { material, options } }\n }, {})\n }\n\n const spriteMarkerMaterialObj = generateSpriteMarkerMaterial()\n const spriteHighlightMarkerOptionObj = generateSpriteHighlightMarkerOption()\n\n const getElementOptions = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeOptions = _.get(\n mapTheme,\n `${featureType}.geometry.options`\n )\n\n const categoryOptions = _.get(mapTheme, `${key}.geometry.options`)\n\n return _.merge({}, featureTypeOptions, categoryOptions)\n }\n\n const createOccupantMarker = (feature, locatedFeature, mapConfig) => {\n const { textMarkerType, featureExtrudeConfig } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\", 0)\n const { properties, id, feature_type } = feature\n if (!properties.anchor) return\n\n /**\n * Prepare geometry for occupant marker positioning:\n * - Use anchor coordinates if the location feature is the main location\n * - Otherwise, use the center of the location feature\n */\n const mainLocationId =\n _.get(properties, \"unit.id\") || _.get(properties, \"kiosk.id\")\n const isMainLocationFeature = mainLocationId === locatedFeature?.id\n const { geometry: mainLocationGeometry } = properties?.anchor\n const geometry = isMainLocationFeature\n ? mainLocationGeometry\n : turfCenter(locatedFeature)?.geometry\n\n const baseProperties = {\n id,\n feature_type,\n category: properties.category,\n altitude: getAltitude(properties),\n }\n const occupantName = _.isEmpty(properties.short_name)\n ? properties.name\n : properties.short_name\n\n if (locatedFeature) {\n const { feature_type, properties } = locatedFeature\n const { category } = properties\n const locatedLabelOption =\n feature_type === \"kiosk\"\n ? getLabelOptions(`${feature_type}`)\n : getLabelOptions(`${feature_type}.${category}`)\n const { hidden = false } = locatedLabelOption || {}\n if (hidden) return\n }\n\n const getValidatedRenderType = (requestedType, logoUrl) => {\n // If requestType is \"Logo\" or \"Logo + Name\" and no logo, fallback to \"Name\"\n if (requestedType === \"Logo\" || requestedType === \"Logo + Name\") {\n return logoUrl ? requestedType : \"Name\"\n }\n return requestedType\n }\n\n const logoUrl = _.get(properties, \"logo.url\")\n const requestedRenderType = _.get(properties, \"render_type\", \"Name\")\n const renderType = getValidatedRenderType(requestedRenderType, logoUrl)\n if (renderType === \"Label\") return null\n\n const renderPriority = properties.render_priority || 3\n const labelSymbol = getLabelSymbol(`occupant-${_.toLower(renderType)}`)\n const markerSymbol = _.last(labelSymbol)\n\n const coordinates = _.get(geometry, \"coordinates\")\n\n const priorityLabelSymbol = getLabelSymbol(\n `occupant-${_.toLower(renderType)}-${renderPriority}`\n )\n const priorityMarkerSymbol = _.last(priorityLabelSymbol) || {}\n\n switch (renderType) {\n case \"Logo\":\n _.set(priorityMarkerSymbol, \"markerFile\", logoUrl)\n\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties) + markerHeight,\n ...baseProperties,\n },\n symbol: priorityLabelSymbol,\n })\n\n case \"Logo + Name\":\n return new Marker(coordinates, {\n properties: {\n name: occupantName.en,\n altitude: getAltitude(properties) + markerHeight,\n ...baseProperties,\n },\n symbol: {\n textName: \"{name}\",\n markerFile: logoUrl,\n textHaloRadius: {\n stops: [\n [20, 1],\n [21, 2],\n ],\n },\n ...markerSymbol,\n ...priorityMarkerSymbol,\n },\n })\n case \"None\":\n return new ui.UIMarker(coordinates, {\n properties: { ...baseProperties },\n content: createStyledUIMarkerElement({\n style: { display: \"none\" },\n textContent: occupantName.en,\n }),\n altitude: getAltitude(properties) + markerHeight,\n })\n case \"Name\":\n default:\n if (textMarkerType === \"marker\") {\n return new Marker(coordinates, {\n properties: {\n name: occupantName.en,\n altitude: getAltitude(properties) + markerHeight,\n ...baseProperties,\n },\n symbol: {\n textName: \"{name}\",\n //TODO:: implement symbol scaler later\n textHaloRadius: {\n stops: [\n [20, 1],\n [21, 2],\n ],\n },\n ...markerSymbol,\n ...priorityMarkerSymbol,\n },\n })\n }\n\n const uiMarkerSymbol = getUIMarkerSymbol(\n `occupant-${_.toLower(renderType)}`\n )\n const uiMarkerPrioritySymbol = getUIMarkerSymbol(\n `occupant-${_.toLower(renderType)}-${renderPriority}`\n )\n const uiMarkerPriorityOptions = getUIMarkerOptions(\n `occupant-${_.toLower(renderType)}-${renderPriority}`\n )\n\n const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol }\n return new ui.UIMarker(coordinates, {\n properties: { ...baseProperties },\n content: createStyledUIMarkerElement({\n style,\n textContent: occupantName.en,\n className: OCCUPANT_TEXT_MARKER_CLASSNAME,\n }),\n collision: true,\n collisionFadeIn: true,\n altitude: getAltitude(properties) + markerHeight,\n ...uiMarkerPriorityOptions,\n })\n }\n }\n\n const getFeatureProperties = (feature) => {\n const { id, feature_type, properties } = feature\n const { category, ordinal, style = {} } = properties\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n const { allowOverride } = getElementOptions(`${feature_type}.${category}`)\n if (allowOverride) _.merge(elementStyle, style)\n const { polygonFill: color } = elementStyle\n const featureProperty = {\n id,\n feature_type,\n category: category || feature_type,\n ordinal,\n defaultColor: color,\n }\n return featureProperty\n }\n\n return {\n getElementSymbol,\n getHilighPolygonalSymbol: (type) => {\n switch (type) {\n case \"MultiPolygon\":\n case \"Polygon\": {\n return getElementSymbol(\"hilight-polygonal\")\n }\n case \"Point\": {\n return getElementSymbol(\"hilight-marker\")\n }\n default:\n break\n }\n },\n getHighlightMarkerSymbol: () => {\n return getElementSymbol(\"highlighted-marker\")\n },\n createVenue: (feature) => {\n const { geometry, feature_type } = feature\n const symbolStyle = getElementSymbol(feature_type)\n return new GeometryType[geometry.type](geometry.coordinates, {\n symbol: {\n ...symbolStyle,\n },\n zIndex: VENUE_Z_INDEX,\n })\n },\n\n createLevel: (feature) => {\n const { geometry, properties, feature_type } = feature\n const { category } = properties\n\n const style = getElementSymbol(`${feature_type}.${category}`)\n // const options = getElementOptions(`${feature_type}.${category}`)\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: {\n ...style,\n },\n zIndex: LEVEL_Z_INDEX,\n })\n },\n\n\n createMarker: (feature) => {\n try {\n const { geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const markerSymbol = getElementSymbol(\"pin-marker\")\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: markerSymbol,\n })\n } catch (err) {\n console.log(`error creating marker:`, feature)\n }\n },\n createOriginMarker: (feature) => {\n const { id, geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const markerSymbol = getElementSymbol(\"origin-marker\")\n try {\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n id,\n symbol: markerSymbol,\n })\n } catch (error) {\n console.log(`error creating origin marker:`, feature)\n }\n },\n createDestinationPinMarker: (feature, mapConfig) => {\n const { featureExtrudeConfig } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\")\n // Get Label from located unit / kiosk\n const { id, properties } = feature\n const geometry =\n _.get(feature, \"geometry\") ||\n _.get(feature, \"properties.anchor.geometry\")\n const coordinates = getCenterFromGeometry(geometry)\n const symbol = getElementSymbol(\"pin-marker\")\n try {\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties) + markerHeight,\n },\n id,\n symbol,\n })\n } catch (error) {\n console.log(`error creating destination marker:`, feature)\n }\n },\n createDestinationLogoMarker: (feature, mapConfig = {}) => {\n const { featureExtrudeConfig } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\", 0)\n\n // Get Label from located unit / kiosk\n const { properties, id } = feature\n const { geometry } = properties.anchor\n const logoUrl = _.get(properties, \"logo.url\")\n const coordinates = getCenterFromGeometry(geometry)\n const [markerBase, markerLabel] = getLabelSymbol(\n \"highlighted-logo-marker\"\n )\n try {\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties) + markerHeight,\n },\n id,\n symbol: [markerBase, { ...markerLabel, markerFile: logoUrl }],\n })\n } catch (error) {\n console.log(`error creating destination marker:`, feature)\n }\n },\n\n createUserLocationMarker: (feature) => {\n try {\n const { geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const symbolStyle = getElementSymbol(\"user-location\") || {}\n const marker = new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties),\n ordinal: properties.ordinal !== null ? properties.ordinal : null,\n },\n symbol: symbolStyle.start,\n zIndex: USER_LOCATION_Z_INDEX,\n })\n\n marker.animate(\n {\n symbol: symbolStyle.end,\n },\n {\n repeat: true,\n easing: \"upAndDown\",\n duration: 1500,\n }\n )\n return marker\n } catch (err) {\n console.log(`error creating marker:`, feature)\n }\n },\n\n createLastUserLocationMarker: (feature) => {\n try {\n const { geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const symbolStyle = getElementSymbol(\"last-user-location\") || {}\n const options = getElementOptions(\"last-user-location\") || {}\n const marker = new Marker(coordinates, {\n properties: {\n ...options,\n altitude: getAltitude(properties),\n ordinal: properties.ordinal !== null ? properties.ordinal : null,\n },\n symbol: symbolStyle,\n zIndex: LAST_LOCATION_Z_INDEX,\n })\n\n return marker\n } catch (err) {\n console.log(`error creating marker:`, feature)\n }\n },\n\n createHighlightOccupantMarker: (feature, mapConfig) => {\n const { featureExtrudeConfig, markerSymbol } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\")\n const { id, feature_type, properties } = feature\n\n if (!properties.anchor) return\n\n const markerProperties = {\n ...properties,\n id,\n feature_type,\n altitude: getAltitude(properties) + markerHeight,\n }\n\n const { geometry } = properties?.anchor\n const coordinates = _.get(geometry, \"coordinates\")\n const logoUrl = _.get(properties, \"logo.url\")\n\n // If the symbol option is defined, create a marker.\n if (markerSymbol) {\n return new Marker(coordinates, {\n properties: markerProperties,\n symbol: markerSymbol,\n })\n }\n\n //use pin-marker if no logo\n if (!logoUrl) {\n const symbol = getElementSymbol(\"pin-marker\")\n return new Marker(coordinates, {\n properties: markerProperties,\n symbol,\n })\n }\n\n const labelSymbol = getLabelSymbol(\"highlight-occupant-logo\")\n const priorityMarkerSymbol = _.last(labelSymbol) || {}\n _.set(priorityMarkerSymbol, \"markerFile\", logoUrl)\n return new Marker(coordinates, {\n properties: markerProperties,\n symbol: labelSymbol,\n })\n },\n createHighlight2DAmenityMarkerFrom3DMarker: (feature, mapConfig) => {\n const { coordinates, units, kiosk } = feature\n const amenityLocatedUnit = _.first(units)\n\n const unitConfig = getExtrudeConfigByFeature(\n mapConfig,\n amenityLocatedUnit\n )\n const unitHeight = _.get(unitConfig, \"height\", 0)\n const kioskConfig = getExtrudeConfigByFeature(mapConfig, kiosk)\n const kioskHeight = _.get(kioskConfig, \"height\", 0)\n\n const markerHeight = unitHeight + kioskHeight\n\n const symbol = getElementSymbol(\"highlight-amenity-marker\")\n return new Marker(coordinates, {\n properties: {\n ...feature,\n altitude: markerHeight,\n },\n symbol,\n })\n },\n\n createSection: (feature) => {\n const { properties, feature_type } = feature\n const { category } = properties\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n switch (category) {\n case \"eatingdrinking\":\n return createEatingDrinkingSection(feature, elementStyle)\n case \"vegetation\":\n return createVegetationSection(feature, elementStyle)\n case \"seating\":\n return creatingSeatingSection(feature, elementStyle)\n default:\n return creatingDefaultSection(feature, elementStyle)\n }\n },\n\n createOccupant: (feature, location, mapConfig) => {\n return createOccupantMarker(feature, location, mapConfig)\n },\n\n createOpening: (feature) => {\n const {\n feature_type,\n properties: { category },\n } = feature\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n const options = {\n ...getElementOptions(`${feature_type}.${category}`),\n zIndex: OPENING_Z_INDEX,\n }\n switch (feature.properties.category) {\n case \"pedestrian\":\n return createPedestrianOpening(feature, elementStyle, options)\n case \"pedestrian.principal\":\n return createPrincipalOpening(feature, elementStyle, options)\n case \"emergencyexit\":\n return createEmergencyExitOpening(feature, elementStyle, options)\n default:\n break\n }\n },\n\n createFixture: (feature) => {\n const {\n feature_type,\n properties: { category },\n } = feature\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n const options = {\n ...getElementOptions(`${feature_type}.${category}`),\n zIndex: FIXTURE_Z_INDEX,\n }\n switch (feature.properties.category) {\n case \"water\":\n return createWaterFixture(feature, elementStyle, options)\n case \"vegetation\":\n return createVegetationFixture(feature, elementStyle, options)\n case \"equipment\":\n case \"obstruction\":\n case \"stage\":\n case \"desk\":\n case \"wall\":\n return createObstructionalFixture(feature, elementStyle, options)\n default:\n break\n }\n },\n\n createLineStringFromGeometries: (geometries) => {\n const mergedCoordinates = _(geometries)\n .map((geometry) => {\n switch (geometry.type) {\n case \"Point\":\n return [\n geometry?.getCoordinates\n ? geometry?.getCoordinates()\n : new Coordinate(geometry.coordinates),\n ]\n case \"Polygon\":\n return [\n geometry?.getCenter\n ? geometry?.getCenter()\n : new Polygon(geometry.coordinates).getCenter(),\n ]\n case \"MultiPolygon\":\n return [\n geometry?.getCenter\n ? geometry?.getCenter()\n : new MultiPolygon(geometry.coordinates).getCenter(),\n ]\n case \"LineString\":\n default:\n return geometry?.getCoordinates\n ? geometry?.getCoordinates()\n : new LineString(geometry.coordinates).getCoordinates()\n }\n })\n .flatten()\n .value()\n const stepPathLineSymbol = getElementSymbol(\"navigation-path\")\n const startPathSymbolMarker = getElementSymbol(\"navigation-path-start\")\n\n const line = new LineString(mergedCoordinates, {\n smoothness: 0.5,\n symbol: [...stepPathLineSymbol, startPathSymbolMarker],\n })\n\n return line\n },\n create3DStepPath: (feature, threeLayer, option = {}) => {\n const stepPathLineSymbol = getElementSymbol(\"navigation-path\")\n const pathLineSymbol = stepPathLineSymbol[1]\n const pathLineEffect = stepPathLineSymbol[0]\n const lineOptions = {\n color: pathLineSymbol?.lineColor,\n opacity: pathLineSymbol?.lineOpacity,\n }\n const outlineOptions = {\n color: pathLineEffect?.lineColor,\n opacity: pathLineEffect?.lineOpacity,\n }\n\n return new NavigationPath(\n feature,\n threeLayer,\n getFeatureProperties(feature),\n option,\n lineOptions,\n outlineOptions\n )\n },\n\n createDecoration: (decoration, options) => {\n const { type, coordinates } = decoration\n const { id, ordinal, symbol } = options\n const formattedProperties = {\n properties: {\n id,\n altitude: getAltitude(options),\n ordinal,\n },\n symbol,\n zIndex: DECORATION_Z_INDEX,\n }\n switch (type) {\n case \"Polygon\":\n return new Polygon(coordinates, formattedProperties)\n case \"MultiPolygon\":\n return new MultiPolygon(coordinates, formattedProperties)\n case \"LineString\":\n return new LineString(coordinates, formattedProperties)\n case \"MultiLineString\":\n return new MultiLineString(coordinates, formattedProperties)\n default:\n return null\n }\n },\n\n /** Three JS */\n create3DFootprint: async (feature, threeLayer, options) => {\n const objects = []\n const extrudeHeight = _.get(options, \"height\")\n if (!extrudeHeight) return objects\n\n const { properties } = feature\n const footprintProperties = getFeatureProperties(feature)\n\n // Use properties.model3d if exists\n const hasModel3ds =\n Array.isArray(properties.model3d) && properties.model3d.length > 0\n if (hasModel3ds) {\n const models = properties.model3d\n const center = turfCenter(feature)\n const coordinate = _.get(center, \"geometry.coordinates\")\n for (const model of models) {\n const object = await loadModel3d(model, coordinate, threeLayer)\n object.properties = footprintProperties\n objects.push(object)\n }\n } else {\n const color = footprintProperties.defaultColor\n //skip create extrude polygon if color === \"transparent\" because js can't convert color:\"transparent\" to material color\n if (color === \"transparent\") return\n const material = new MeshLambertMaterial({\n color,\n transparent: true,\n })\n const object = createExtrudePolygon(\n feature.geometry,\n threeLayer,\n material,\n extrudeHeight,\n footprintProperties,\n {}\n )\n objects.push(object)\n }\n\n return objects\n },\n create3DGroundLabel: (label, threeLayer) => {\n const text = label.properties.name\n const bound = label.geometry.coordinates[0]\n if (_.isNil(bound)) throw new Error(\"Invalid coordinates\")\n\n // Retrieve label symbol from map theme\n const groundLabelSymbol = getElementSymbol(\"ground-label\")\n\n // Retrieve label symbol from label feature properties\n const featureSymbol = _.get(label, \"properties\", {})\n\n // Apply default style from map theme if not defined in label feature\n const groundLabelOptions = _.merge(\n {},\n { text },\n groundLabelSymbol,\n featureSymbol\n )\n\n return new GroundLabel(bound, groundLabelOptions, threeLayer)\n },\n\n createOccupantGroundLabel: (feature, location, mapConfig, threeLayer) => {\n const text = feature.properties.name.en\n const bound = location.geometry.coordinates[0]\n if (_.isNil(bound)) throw new Error(\"Invalid coordinates\")\n\n const groundLabelSymbol = getElementSymbol(\"occupant-flat-label\")\n const groundLabelOptions = getElementOptions(\"occupant-flat-label\")\n\n const baseAltitude = getAltitude(location.properties)\n const extrudeHeight = _.get(\n mapConfig,\n \"extrudeConfig.unit.room.height\",\n 0\n )\n const totalAltitude = baseAltitude + extrudeHeight + 0.05\n\n const customAngle = _.get(feature, \"properties.style.angle\")\n const offsetX = _.get(feature, \"properties.style.offsetX\", 0)\n const offsetY = _.get(feature, \"properties.style.offsetY\", 0)\n\n const featureSymbol = {\n name: text,\n ordinal: location.properties.ordinal,\n venue_id: feature.properties.venue_id,\n }\n\n // symbol, options and custom properties\n const mergedGroundLabelOptions = _.merge(\n {},\n { text },\n groundLabelSymbol,\n groundLabelOptions,\n featureSymbol,\n {\n altitude: totalAltitude,\n offsetX,\n offsetY,\n // set custom angle\n ...(!_.isNil(customAngle) ? { angle: customAngle } : {}),\n }\n )\n\n const groundLabel = new GroundLabel(\n bound,\n mergedGroundLabelOptions,\n threeLayer\n )\n return groundLabel\n },\n\n create3DBillboard: (billboard, threeLayer) => {\n const { id, feature_type, properties } = billboard\n const {\n logo,\n altitude,\n scale,\n alphaTest,\n legColor,\n showLeg,\n is_clickable,\n } = properties\n const coordinates = getCenterFromGeometry(billboard.geometry)\n const billboardProperties = {\n ...billboard.properties,\n id,\n feature_type,\n }\n\n const options = {\n altitude,\n scale,\n alphaTest,\n legColor,\n showLeg,\n interactive: is_clickable,\n }\n\n return new Billboard(\n coordinates,\n options,\n logo?.url,\n threeLayer,\n billboardProperties\n )\n },\n create3DAmenityMarker: (feature, threeLayer, config) => {\n const { geometry, properties, feature_type, id } = feature\n const { category, units, kiosk, is_clickable } = properties\n const amenityLocatedUnit = _.first(units)\n const isLocatedUnitModel3dAvailable = !_.isEmpty(\n amenityLocatedUnit?.properties?.model3d\n )\n const isLocatedKioskModel3dAvailable = !_.isEmpty(\n kiosk?.properties?.model3d\n )\n\n const unitConfig = getExtrudeConfigByFeature(config, amenityLocatedUnit)\n const unitHeight = isLocatedUnitModel3dAvailable\n ? 0\n : _.get(unitConfig, \"height\", 0)\n const kioskConfig = getExtrudeConfigByFeature(config, kiosk)\n const kioskHeight = isLocatedKioskModel3dAvailable\n ? 0\n : _.get(kioskConfig, \"height\", 0)\n\n const coordinates = _.get(geometry, \"coordinates\")\n\n const markerProperties = {\n ...properties,\n coordinates,\n id,\n feature_type,\n }\n\n const material = _.get(\n spriteMarkerMaterialObj,\n `${feature_type}.${category}`\n )\n\n const highlightOptions = _.get(\n spriteHighlightMarkerOptionObj,\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`\n )\n\n const options = {\n scale: 0.05,\n altitude: unitHeight + kioskHeight,\n highlight: highlightOptions,\n interactive: is_clickable,\n }\n\n return create3DMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n },\n\n create3DOccupantAmenityMarker: (feature, threeLayer, config) => {\n const { geometry, properties, feature_type, id } = feature\n const { category, unit, kiosk } = properties\n const amenityLocation = kiosk || unit\n const locationConfig = getExtrudeConfigByFeature(config, amenityLocation)\n const coordinates = _.get(geometry, \"coordinates\")\n\n const markerProperties = {\n ...properties,\n coordinates,\n id,\n feature_type,\n }\n\n const material = _.get(\n spriteMarkerMaterialObj,\n `${feature_type}.${category}`\n )\n\n const highlightOptions = _.get(\n spriteHighlightMarkerOptionObj,\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`\n )\n\n const options = {\n scale: 0.05,\n altitude: _.get(locationConfig, \"height\", 0),\n highlight: highlightOptions,\n }\n\n return create3DMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n },\n create3DOpeningMarker: (feature, threeLayer, config) => {\n const { geometry, properties, feature_type, id } = feature\n const { category, unit, kiosk } = properties\n const amenityLocation = kiosk || unit\n const locationConfig = getExtrudeConfigByFeature(config, amenityLocation)\n const coordinates = _.get(geometry, \"coordinates\")\n\n const markerProperties = {\n ...properties,\n coordinates,\n id,\n feature_type,\n }\n\n const material = _.get(\n spriteMarkerMaterialObj,\n `${feature_type}.${category}`\n )\n\n const highlightOptions = _.get(\n spriteHighlightMarkerOptionObj,\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`\n )\n\n const options = {\n scale: 0.05,\n altitude: _.get(locationConfig, \"height\", 0),\n highlight: highlightOptions,\n }\n\n return create3DMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n },\n\n\n createVenue3DModel: async (venue, threeLayer) => {\n const { id, feature_type, properties } = venue\n const { category, model3d } = properties\n const modelProperty = {\n id,\n feature_type,\n category,\n }\n const center = turfCenter(venue)\n const centerCoord = _.get(center, \"geometry.coordinates\")\n const modelPosition = _.get(model3d, \"properties.position\", centerCoord)\n const models = await create3DModels(\n model3d,\n modelPosition,\n modelProperty,\n threeLayer\n )\n return models\n },\n\n create3DFixture: async (fixture, threeLayer) => {\n const { id, feature_type, properties } = fixture\n const { category, ordinal, model3d } = properties\n\n const modelProperty = {\n id,\n feature_type,\n category,\n ordinal,\n }\n\n const center = turfCenter(fixture)\n const coordinate = _.get(center, \"geometry.coordinates\")\n const models = await create3DModels(\n model3d,\n coordinate,\n modelProperty,\n threeLayer\n )\n return models\n },\n createExtrudedUnit: (unit, threeLayer, options) => {\n const extrudeHeight = _.get(options, \"height\")\n if (!extrudeHeight) return\n //NOTE: this is temporary condition that only extrude when the unit is \"room\"\n const unitProperty = getFeatureProperties(unit)\n //NOTE: offset will be dynamic in future improvement\n const options3d = {\n // TODO: Move to extrude config later\n offset: -0.1,\n altitude: _.get(options, \"altitude\", 0),\n }\n const color = unitProperty.defaultColor\n if (color === \"transparent\") return\n const material = new MeshLambertMaterial({\n color,\n transparent: true,\n })\n //create polygon with line-offset if geometry is lineString\n if (unit.geometry.type === \"LineString\") {\n const polygon = createPolygonFromLineString(unit.geometry)\n const geometry = {\n type: \"Polygon\",\n coordinates: polygon,\n }\n return createExtrudePolygon(\n geometry,\n threeLayer,\n material,\n extrudeHeight,\n unitProperty,\n options3d\n )\n }\n const object = createExtrudePolygon(\n unit.geometry,\n threeLayer,\n material,\n extrudeHeight,\n unitProperty,\n options3d\n )\n return object\n },\n \n createAmbientLight: (config) => {\n const { color: colorString = \"0xffffff\", intensity = 1 } = config\n const color = parseInt(colorString, 16)\n const ambientLight = new AmbientLight(color, intensity)\n return ambientLight\n },\n createDirectionalLight: (config) => {\n const {\n color: colorString = \"0xffffff\",\n intensity = 1,\n position: positionString = [0, 0, 0],\n } = config\n const color = parseInt(colorString, 16)\n const [x, y, z] = positionString\n const light = new DirectionalLight(color, intensity)\n light.position.set(x, y, z).normalize()\n return light\n },\n }\n}\n\nconst EXCEPT_AMENITY_LOCATION_CATEGORIES = [\n \"walkway\",\n \"nonpublic\",\n \"parking\",\n \"opentobelow\",\n \"unspecified\",\n]\nexport const getLocationByAmenity = (feature) => {\n const unit = _.get(feature, \"properties.units[0]\", null)\n const unitCategory = _.get(unit, \"properties.category\")\n if (!unit) return feature.id\n return EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory)\n ? feature\n : unit\n}\n\nexport const getLocationByOccupant = (feature) => {\n const kiosk = _.get(feature, \"properties.kiosk\", null)\n const unit = _.get(feature, \"properties.anchor.properties.unit\", null)\n return kiosk || unit\n}\n\nexport const getLocationIdByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"kiosk\":\n case \"unit\":\n case \"opening\":\n return feature.id\n case \"amenity\":\n return getLocationByAmenity(feature)?.id\n case \"occupant\":\n return getLocationByOccupant(feature)?.id\n case \"promotion\":\n case \"event\":\n return feature.properties?.feature_id\n default:\n return\n }\n}\n\nexport const getFeatureByLocationId = (id, features = []) => {\n return features?.find((f) => {\n const mainLocationId = getLocationIdByFeature(f)\n const relatedLocationIds = getRelatedLocationIdsByFeature(f)\n return mainLocationId === id || relatedLocationIds.includes(id)\n })\n}\n\nexport const isClickableFeature = (feature) => {\n const isClickable = _.get(feature, \"properties.is_clickable\")\n switch (feature?.feature_type) {\n case \"amenity\":\n return _.isNull(isClickable) ? true : isClickable\n case \"occupant\":\n return true\n default:\n return\n }\n}\n\nexport const getLocationByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"amenity\":\n return getLocationByAmenity(feature)\n case \"occupant\":\n return getLocationByOccupant(feature)\n default:\n return\n }\n}\n\n/*\n * Utility functions to retrieve related locations for amenities and occupants.\n * - Used for highlighting on the floor plan.\n * - Displays location details.\n */\n\nexport const getRelatedLocationsByOccupant = (feature) => {\n const kiosks = _.get(feature, \"properties.kiosks\", [])\n const units = _.get(feature, \"properties.units\", [])\n return [...kiosks, ...units]\n}\n\nexport const getRelatedLocationsByAmenity = (feature) => {\n const units = _.get(feature, \"properties.units\", [])\n\n if (units.length === 0) return [feature]\n\n return units.filter((unit) => {\n const unitCategory = _.get(unit, \"properties.category\")\n return !EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory)\n })\n}\n\nexport const getRelatedLocationIdsByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"amenity\":\n return getRelatedLocationsByAmenity(feature).map((v) => v?.id)\n case \"occupant\":\n return getRelatedLocationsByOccupant(feature).map((v) => v?.id)\n default:\n return []\n }\n}\n\nexport const getRelatedLocationsByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"amenity\":\n return getRelatedLocationsByAmenity(feature)\n case \"occupant\":\n return getRelatedLocationsByOccupant(feature)\n default:\n return []\n }\n}\n\nexport const getOrdinalByLocationId = (locationId, feature) => {\n if (!feature) return null\n\n const mainUnit = _.get(feature, \"properties.unit\")\n const mainKiosk = _.get(feature, \"properties.kiosk\")\n const relatedLocations = getRelatedLocationsByFeature(feature)\n\n const allLocations = [mainUnit, mainKiosk, ...relatedLocations].filter(\n Boolean\n )\n const targetLocation = allLocations.find(\n (location) => location.id === locationId\n )\n\n return targetLocation\n ? _.get(targetLocation, \"properties.level.properties.ordinal\") ||\n _.get(targetLocation, \"properties.ordinal\")\n : null\n}\n","import * as maptalks from \"maptalks\"\nimport { BaseObject } from \"maptalks.three\"\nimport {\n LineBasicMaterial,\n BufferGeometry,\n Float32BufferAttribute,\n Line,\n TextureLoader,\n SpriteMaterial,\n Sprite,\n} from \"three\"\nimport _ from \"lodash\"\n\nconst OPTIONS = {\n altitude: 25,\n scale: 0.00015,\n alphaTest: 0.3,\n legColor: \"#ff0400\",\n showLeg: true,\n}\n\nconst getImgDimension = async (url) => {\n const img = new Image()\n img.src = url\n await img.decode()\n return { naturalWidth: img.naturalWidth, naturalHeight: img.naturalHeight }\n}\n\nexport class Billboard extends BaseObject {\n #layer = null\n constructor(coordinate, options, src, layer, properties) {\n options = maptalks.Util.extend({}, OPTIONS, options, {\n layer,\n coordinate,\n })\n super()\n //Initialize internal configuration\n this.#layer = layer\n this._initOptions(options)\n const {\n altitude = OPTIONS.altitude,\n scale = OPTIONS.scale,\n alphaTest = OPTIONS.alphaTest,\n legColor = OPTIONS.legColor,\n showLeg = OPTIONS.showLeg,\n } = options\n this.properties = { ...properties }\n this._createGroup()\n\n // Screen size / base mobile screen size ratio => 375\n const divider = _.clamp(window.innerWidth / 375 / 1.75, 1, 1.7)\n // Leg\n if (showLeg) {\n const lineMaterial = new LineBasicMaterial({\n color: legColor,\n transparent: true,\n })\n const lineHeight = layer.altitudeToVector3(altitude, altitude).x\n const lineGeometry = new BufferGeometry()\n const positions = [0, 0, 0, 0, 0, -lineHeight]\n lineGeometry.setAttribute(\n \"position\",\n new Float32BufferAttribute(positions, 3)\n )\n const line = new Line(lineGeometry, lineMaterial)\n this.getObject3d().add(line)\n }\n\n getImgDimension(src).then(({ naturalWidth, naturalHeight }) => {\n // Image\n const map = new TextureLoader().load(src)\n const material = new SpriteMaterial({\n map: map,\n color: 0xffffff,\n alphaTest: alphaTest,\n })\n material.needsUpdate = true\n const sprite = new Sprite(material)\n sprite.material.sizeAttenuation = false\n sprite.scale.set(\n (scale * naturalWidth) / divider,\n (scale * naturalHeight) / divider,\n 1\n )\n this.getObject3d().add(sprite)\n })\n\n // set object3d position\n const z = layer.altitudeToVector3(altitude, altitude).x\n const position = layer.coordinateToVector3(coordinate, z)\n _.set(this.properties, \"default.position\", position)\n _.set(this.properties, \"default.altitude\", altitude)\n _.set(this.properties, \"default.scale\", scale)\n this.getObject3d().position.copy(position)\n }\n\n setLineHeight(altitude) {\n const lineHeight = this.#layer.altitudeToVector3(altitude, altitude).x\n const geometry = this.getObject3d().children[0].geometry\n const positionAttribute = geometry.getAttribute(\"position\")\n positionAttribute.setZ(1, -lineHeight)\n positionAttribute.needsUpdate = true\n\n this.getObject3d().position.z = lineHeight\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { BaseObject } from \"maptalks.three\"\nimport {\n Texture,\n Mesh,\n MeshPhongMaterial,\n PlaneGeometry,\n Material,\n} from \"three\"\nimport { largestRect } from \"d3plus-shape\"\nimport { max, merge, isNumber, isArray, range } from \"lodash-es\"\n\nconst OPTIONS = {\n // Allowing click through and prevent interaction\n interactive: false,\n altitude: 0,\n}\n\nconst defaultFlatLabelOptions = {\n fontSize: 14,\n fontFamily: \"Manrope\",\n fontWeight: 600,\n margin: 0,\n scaleMin: 0.5,\n lineHeight: 1.05,\n scaleStep: 0.05,\n textAlign: \"center\",\n textBaseline: \"middle\",\n fillStyle: \"#000\",\n}\n\nconst defaultRectAngleToCalc = range(-90, 92, 2)\n\nexport const getMaterial = (text, flatLabelOptions) => {\n const options = merge({}, defaultFlatLabelOptions, flatLabelOptions)\n\n const {\n fontSize: initialFontSize,\n fontFamily,\n fontWeight,\n margin,\n scaleMin,\n scaleStep,\n fillStyle,\n lineHeight,\n textAlign,\n strokeStyle,\n lineWidth,\n textBaseline,\n } = options\n\n const pixelMultiplier = 4\n const SIZE = 100 * pixelMultiplier\n const fontSize = initialFontSize * (pixelMultiplier * 1.25)\n const canvas = document.createElement(\"canvas\")\n canvas.width = canvas.height = SIZE\n const ctx = canvas.getContext(\"2d\")\n\n ctx.font = `${fontWeight} ${fontSize}px \"${fontFamily}\", Arial`\n ctx.textAlign = textAlign\n ctx.textBaseline = textBaseline\n ctx.fillStyle = fillStyle\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n\n // Function to wrap text automatically\n const wrapText = (ctx, text, maxWidth) => {\n const words = text.trim().split(/\\s+/)\n if (words.length <= 1) return [text]\n\n const lines = []\n const MAX_LINES = 3\n let currentLine = words[0]\n\n for (let i = 1; i < words.length; i++) {\n const lineToMeasure = currentLine + \" \" + words[i]\n if (ctx.measureText(lineToMeasure).width > maxWidth) {\n lines.push(currentLine)\n currentLine = words[i]\n } else {\n currentLine = lineToMeasure\n }\n }\n lines.push(currentLine)\n return lines.slice(0, MAX_LINES) // Limit to 3 lines\n }\n\n /** Check if text contains manual line breaks */\n const hasManualBreaks = text.includes(\"\\n\")\n let texts\n\n if (hasManualBreaks) {\n // Use manual line breaks\n texts = text.split(/\\n/g)\n } else {\n // Auto-wrap text\n const maxWidth = SIZE - 2 * margin\n texts = wrapText(ctx, text, maxWidth)\n }\n\n /** Automatically recalculate font size to fit the bound */\n let textWidth: number = max(texts.map((text) => ctx.measureText(text).width))\n let scale = 1\n while (scale > 0 && textWidth + 2 * margin > SIZE) {\n scale -= scaleStep\n ctx.font = `${fontWeight} ${scale * fontSize}px \"${fontFamily}\", Arial`\n textWidth = max(texts.map((text) => ctx.measureText(text).width))\n }\n\n // If the text is larger than scaleMin, then render it\n const center = { x: 0.5 * SIZE, y: 0.5 * SIZE }\n\n if (scale > scaleMin) {\n const totalHeight = texts.length * (fontSize * scale * lineHeight)\n const startY =\n center.y - totalHeight / 2 + fontSize * scale * lineHeight * 0.5 // Adjust startY when offset multi text line\n\n texts.forEach((text, index) => {\n const yOffset = startY + index * (fontSize * scale * lineHeight)\n if (strokeStyle && lineWidth) {\n ctx.strokeText(text, center.x, yOffset) // Draw outlined text\n }\n ctx.fillText(text, center.x, yOffset)\n })\n }\n\n const texture = new Texture(canvas)\n texture.needsUpdate = true\n\n const material = new MeshPhongMaterial({\n map: texture,\n transparent: true,\n // @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest\n alphaTest: 0.3,\n })\n return material\n}\n\nexport class GroundLabel extends BaseObject {\n #angle = 0\n #bearing = 0\n #text = \"\"\n #offsetX = 0\n #offsetY = 0\n #originalPosition = null\n #layer = null\n\n constructor(bound, options, layer) {\n options = maptalks.Util.extend({}, OPTIONS, options, {\n layer,\n coordinate: bound,\n })\n\n const {\n altitude,\n text,\n fontSize,\n fillStyle,\n textAlign,\n fontFamily,\n textBaseline,\n strokeStyle,\n lineWidth,\n angle = defaultRectAngleToCalc,\n maxFontScale,\n offsetX = 0,\n offsetY = 0,\n ...properties\n } = options\n\n super()\n this._initOptions(options)\n this.properties = properties\n\n this.#offsetX = offsetX\n this.#offsetY = offsetY\n this.#layer = layer\n\n const material = getMaterial(text, {\n fillStyle,\n fontSize,\n textAlign,\n textBaseline,\n fontFamily,\n strokeStyle,\n lineWidth,\n })\n\n // Convert angle to array if it's a single number\n const rectAngles = isArray(angle) ? angle : [angle]\n\n material.needsUpdate = true\n\n const rect = largestRect(bound, {\n cache: true,\n /**\n * Black magic here:\n * For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.\n * So we remove -90 and 90 from choices, and use -85 & 85 instead.\n */\n angle: rectAngles,\n })\n\n const { cx, cy, width, angle: calculatedAngle } = rect\n this.#text = text\n this.#angle = calculatedAngle // Always use calculated angle from largestRect\n\n const geometry = new PlaneGeometry(1, 1)\n this._createMesh(geometry, material)\n\n // set object3d position\n const z = layer.altitudeToVector3(altitude, altitude).x\n const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z)\n\n this.#originalPosition = basePosition.clone()\n const finalPosition = this.#calculateFinalPosition(basePosition)\n\n const scale = width / 0.0006456122659\n // check if it has maxFontScaleLimit from option use maxFontScale\n const finalScale =\n maxFontScale && scale > maxFontScale ? maxFontScale : scale\n this.getObject3d().scale.set(finalScale, finalScale, finalScale)\n this.getObject3d().position.copy(finalPosition)\n this.getObject3d().rotation.z = (Math.PI / 180) * this.#angle\n }\n\n #calculateFinalPosition(basePosition) {\n if (this.#offsetX === 0 && this.#offsetY === 0) {\n return basePosition\n }\n\n const offsetCoordinate = {\n x: this.#offsetX,\n y: this.#offsetY,\n }\n\n const z = this.#layer.altitudeToVector3(0, 0).x\n const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z)\n const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z)\n\n const worldOffsetX = offsetVector.x - zeroVector.x\n const worldOffsetY = offsetVector.y - zeroVector.y\n\n return {\n x: basePosition.x + worldOffsetX,\n y: basePosition.y + worldOffsetY,\n z: basePosition.z,\n }\n }\n\n #updatePosition() {\n if (this.#originalPosition && this.#layer) {\n const finalPosition = this.#calculateFinalPosition(this.#originalPosition)\n this.getObject3d().position.copy(finalPosition)\n }\n }\n\n set bearing(value) {\n this.#bearing = value\n const degree = this.#angle + this.#bearing\n const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle\n this.getObject3d().rotation.z = (Math.PI / 180) * angle\n }\n\n get angle() {\n return this.#angle\n }\n\n get currentAngle() {\n return this.#angle\n }\n\n get text() {\n return this.#text\n }\n\n get offsetX() {\n return this.#offsetX\n }\n\n get offsetY() {\n return this.#offsetY\n }\n\n get offset() {\n return { x: this.#offsetX, y: this.#offsetY }\n }\n\n set offsetX(value) {\n if (isNumber(value)) {\n this.#offsetX = value\n this.#updatePosition()\n }\n }\n\n set offsetY(value) {\n if (isNumber(value)) {\n this.#offsetY = value\n this.#updatePosition()\n }\n }\n\n set angle(newAngle) {\n if (isNumber(newAngle)) {\n this.#angle = newAngle\n this.getObject3d().rotation.z = (Math.PI / 180) * this.#angle\n }\n }\n\n setOffset(offsetX, offsetY) {\n if (isNumber(offsetX) && isNumber(offsetY)) {\n this.#offsetX = offsetX\n this.#offsetY = offsetY\n this.#updatePosition()\n }\n }\n\n addOffset(deltaX, deltaY) {\n if (isNumber(deltaX) && isNumber(deltaY)) {\n this.#offsetX += deltaX\n this.#offsetY += deltaY\n this.#updatePosition()\n }\n }\n\n resetOffset() {\n this.#offsetX = 0\n this.#offsetY = 0\n this.#updatePosition()\n }\n\n moveToPosition(targetX, targetY) {\n if (this.#originalPosition && this.#layer) {\n const currentCenter = this.#layer.vector3ToCoordinate(\n this.#originalPosition\n )\n this.#offsetX = targetX - currentCenter.x\n this.#offsetY = targetY - currentCenter.y\n this.#updatePosition()\n }\n }\n\n updateText(newText, options: Record<string, unknown> = {}) {\n this.#text = newText\n\n const materialOptions = {\n fillStyle: options.fillStyle || this.properties.fillStyle,\n fontSize: options.fontSize || this.properties.fontSize,\n textAlign: options.textAlign || this.properties.textAlign,\n textBaseline: options.textBaseline || this.properties.textBaseline,\n fontFamily: options.fontFamily || this.properties.fontFamily,\n strokeStyle: options.strokeStyle || this.properties.strokeStyle,\n lineWidth: options.lineWidth || this.properties.lineWidth,\n }\n\n const newMaterial = getMaterial(newText, materialOptions) as Material\n ;(this.getObject3d() as Mesh).material = newMaterial\n newMaterial.needsUpdate = true\n }\n}\n","import { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport { Sprite, SpriteMaterial } from \"three\"\nimport _ from \"lodash\"\n\nconst DEFAULT_SCALE = 0.05\nconst DEFAULT_ALTITUDE = 0\nconst DEFAULT_ALPHATEST = 0.3\nconst DEFAULT_OPTIONS = {\n scale: DEFAULT_SCALE,\n altitude: DEFAULT_ALTITUDE,\n alphaTest: DEFAULT_ALPHATEST,\n highlight: {\n options: {\n scale: DEFAULT_SCALE * 1.25,\n },\n material: null,\n },\n}\n\ninterface IOptions {\n scale: number\n altitude: number\n alphaTest?: number\n highlight?: {\n options: {\n altitude?: number\n scale?: number\n }\n material?: SpriteMaterial\n }\n}\n\nexport class SpriteMarker extends BaseObject {\n #default = null\n #highlight = null\n constructor(\n coordinate,\n options: IOptions,\n material: SpriteMaterial,\n layer: ThreeLayer,\n properties: object\n ) {\n super()\n //Initialize internal configuration\n this._initOptions(options)\n this._createGroup()\n const {\n altitude = DEFAULT_OPTIONS.altitude,\n scale = DEFAULT_OPTIONS.scale,\n highlight = DEFAULT_OPTIONS.highlight,\n alphaTest = DEFAULT_OPTIONS.alphaTest,\n } = options\n this.properties = { ...properties }\n\n const modifiedAltitude = altitude + 2\n\n this.#default = { options: { scale, altitude: modifiedAltitude }, material }\n this.#highlight = _.merge({}, DEFAULT_OPTIONS.highlight, highlight)\n\n /**\n * Add alphaTest to render only non-transparent pixels in PNG images.\n * [@Doc](https://threejs.org/docs/#api/en/materials/Material.alphaTest)\n */\n if (material && material instanceof SpriteMaterial)\n material.alphaTest = alphaTest\n\n const sprite = new Sprite(material)\n sprite.scale.set(scale, scale, scale) // Set sprite scale\n\n const obj3d = this.getObject3d()\n obj3d.add(sprite)\n // set object3d position\n const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x\n const position = layer.coordinateToVector3(coordinate, z)\n _.set(this.properties, \"default.position\", position)\n this.getObject3d().position.copy(position)\n }\n\n // Different objects need to implement their own methods\n setSymbol(material: SpriteMaterial) {\n if (material && material instanceof SpriteMaterial) {\n const sprite = (this.getObject3d() as any).children[0]\n\n if (!sprite) return this\n\n sprite.material = material\n sprite.material.needsUpdate = true\n }\n return this\n }\n\n setScale(scaleX: number, scaleY: number = scaleX, scaleZ: number = scaleX) {\n const sprite = (this.getObject3d() as any).children[0]\n if (!sprite) return this\n\n sprite.scale.set(scaleX, scaleY, scaleZ)\n\n return this\n }\n\n // Different objects need to implement their own methods\n getSymbol(): SpriteMaterial {\n return (this.getObject3d() as any)?.children[0]?.material\n }\n\n highlight() {\n const { material, options } = this.#highlight\n if (material) this.setSymbol(material)\n if (options.scale) this.setScale(options.scale)\n if (options.altitude) this.setAltitude(options.altitude)\n return this\n }\n\n removeHighlight() {\n const { material, options } = this.#default\n if (material) this.setSymbol(material)\n if (options.scale) this.setScale(options.scale)\n if (options.altitude) this.setAltitude(options.altitude)\n return this\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { BaseObject } from \"maptalks.three\"\nimport { MeshBasicMaterial, ShaderMaterial, Color } from \"three\"\n\nconst OPTIONS = {\n altitude: 0,\n}\n\nconst DEFAULT_LINE_OPTION = {\n color: \"#000\",\n opacity: 1,\n}\nconst DEFAULT_LINE_EFFECT_OPTION = {\n color: \"#000\",\n opacity: 1,\n}\n\n// In case we want to open/close this animation per project.\nconst ENABLE_ANIMATED_PATH = true\n\nexport class NavigationPath extends BaseObject {\n constructor(\n feature,\n layer,\n properties,\n options,\n lineOptions = DEFAULT_LINE_OPTION,\n outlineOption = DEFAULT_LINE_EFFECT_OPTION\n ) {\n options = maptalks.Util.extend({}, OPTIONS, options, {\n layer,\n })\n super()\n //Initialize internal configuration\n this._initOptions(options)\n const { altitude = OPTIONS.altitude } = options\n this.properties = { ...properties }\n this._createGroup()\n\n const { color: lineColor, opacity: lineOpacity } =\n lineOptions || DEFAULT_LINE_OPTION\n\n const staticMaterial = new MeshBasicMaterial({\n transparent: true,\n color: lineColor || \"#fff\",\n opacity: lineOpacity || 1,\n depthWrite: false,\n })\n\n const uniforms = {\n time: { value: 0 },\n color: { value: new Color(lineColor || \"#fff\") },\n opacity: { value: lineOpacity || 1 },\n }\n this._uniforms = uniforms\n this._t = 0 // Start time = 0\n\n /**\n * Animation formula\n * float dash = smoothstep(0.3, 0.7, abs(sin(vUv.x * 1.0 - time * 0.1)));\n * | vUv.x * 1.0 | controls dash length & frequency\n * | - time * 1.0 | animates motion to the right\n */\n const animatedMaterial = new ShaderMaterial({\n uniforms,\n transparent: true,\n depthWrite: false,\n vertexShader: `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: `\n uniform float time;\n uniform vec3 color;\n uniform float opacity;\n varying vec2 vUv;\n\n void main() {\n float dash = smoothstep(0.3, 0.7, abs(sin(vUv.x * 1.0 - time * 0.1)));\n gl_FragColor = vec4(color, opacity * dash);\n }\n `,\n })\n\n const pathGeometry = maptalks.GeoJSON.toGeometry(feature)\n const line = layer.toPath(\n pathGeometry,\n {\n interactive: false,\n cornerRadius: 2,\n width: 0.5,\n },\n ENABLE_ANIMATED_PATH ? animatedMaterial : staticMaterial\n )\n\n const { color: outlineColor, opacity: outlineOpacity } = outlineOption || {}\n const outlineMaterial = new MeshBasicMaterial({\n transparent: true,\n color: outlineColor || \"#fff\",\n opacity: outlineOpacity || 1,\n })\n\n const lineOutLine = layer.toPath(\n pathGeometry,\n {\n interactive: false,\n cornerRadius: 2,\n width: 1,\n },\n outlineMaterial\n )\n this.getObject3d().add(lineOutLine.getObject3d())\n this.getObject3d().add(line.getObject3d())\n\n // set object3d position\n const z = layer.altitudeToVector3(altitude + 0.25, altitude + 0.25).x\n const pos = this.getObject3d().position\n\n const position = layer.coordinateToVector3([pos.x, pos.y], z)\n // _.set(this.properties, \"default.position\", position)\n\n this.getObject3d().position.copy(position)\n }\n\n _animation() {\n this._t = this._t + 1\n this._uniforms.time.value = this._t\n }\n}\n","import center from \"@turf/center\"\nimport { Polygon, MultiPolygon, Point, LineString } from \"geojson\"\nimport _ from \"lodash\"\nimport turfLineOffset from \"@turf/line-offset\"\nimport { lineString as turfLineString } from \"@turf/helpers\"\n\n// Calculates the center point of a GeoJSON geometry and Return as a Coordinates.\nexport const getCenterFromGeometry = (geometry?: Polygon | MultiPolygon | Point | LineString): number[] | null => {\n try {\n const { type = null, coordinates = null } = geometry\n if (!type || !coordinates) return null\n const centerPoint = center(geometry)\n return _.get(centerPoint, \"geometry.coordinates\") // Coordinates\n } catch (error) {\n return null\n }\n}\n\nexport const createPolygonFromLineString = (geometry) => {\n const line = turfLineString(geometry.coordinates)\n const left = turfLineOffset(line, 0.3, { units: \"meters\" })\n const right = turfLineOffset(line, -0.3, { units: \"meters\" })\n const leftCoords = left.geometry.coordinates\n const rightCoords = right.geometry.coordinates.reverse()\n const polygon = [...leftCoords, ...rightCoords, leftCoords[0]]\n return [polygon]\n}\n","export const svgToPng = (svgString: string, scaleFactor: number = 1) => {\n const svgBlob = new Blob([svgString], { type: \"image/svg+xml\" })\n const url = URL.createObjectURL(svgBlob)\n const img = new Image()\n return new Promise((resolve, reject) => {\n img.onload = function () {\n // Calculate the new dimensions\n const newWidth = img.width * scaleFactor\n const newHeight = img.height * scaleFactor\n\n // Create a canvas with the new dimensions\n const canvas = document.createElement(\"canvas\")\n canvas.width = newWidth\n canvas.height = newHeight\n const ctx = canvas.getContext(\"2d\")\n\n // Draw the SVG image onto the canvas with the scaled dimensions\n ctx.drawImage(img, 0, 0, newWidth, newHeight)\n\n // Convert canvas to PNG\n const pngDataUrl = canvas.toDataURL(\"image/png\")\n\n // Resolve the Promise with the PNG data URL\n resolve(pngDataUrl)\n }\n\n // Handle image load errors\n img.onerror = function (error) {\n reject(error)\n }\n\n img.src = url\n })\n}\n\nexport const createSVGPathFromMarkerSymbol = (style) => {\n const {\n markerWidth = 24,\n markerDx = 0,\n markerDy = 0,\n markerFill,\n markerPath,\n } = style\n const scale = markerWidth / 24\n return `<path d=\"${markerPath}\" style=\"transform:translate(${markerDx}px, ${markerDy}px) scale(${scale})\" fill=\"${markerFill}\"/>`\n}\n","interface ICoordinate {\n x: number\n y: number\n z?: number\n}\n\ntype RadToDegree = (rad: number) => number\n\ntype GetBearingBetweenPoints = (\n origin: ICoordinate,\n destination: ICoordinate\n) => number\n\ntype GetSuitablyValueBetweenBearings = (\n newBearing: number,\n currentBearing: number\n) => number\n\nconst radToDegree: RadToDegree = (rad) => rad * (180 / Math.PI)\n\nexport const getBearingBetweenPoints: GetBearingBetweenPoints = (\n origin,\n destination\n) => {\n const twoPI = Math.PI * 2\n\n if (origin.x === destination.x && origin.y === destination.y) return\n let theta = Math.atan2(destination.x - origin.x, destination.y - origin.y)\n\n if (theta < 0.0) theta += twoPI\n\n return Math.floor(radToDegree(theta))\n}\n\nexport const getSuitablyValueBetweenBearings: GetSuitablyValueBetweenBearings =\n (newBearing, currentBearing) => {\n const difference = Math.abs(newBearing - currentBearing)\n\n // Adjust newBearing to ensure the shortest direction\n if (difference > 180)\n return newBearing > 0 ? newBearing - 360 : newBearing + 360\n\n return newBearing // Return as is if the difference is within limits\n }\n","import { Color } from \"three\"\nimport _ from \"lodash\"\nimport TWEEN from \"@tweenjs/tween.js\"\n\nimport { BaseObject } from \"maptalks.three\"\nimport { Billboard } from \"../object3d\"\n\n//TODO:: refactor this option logic later\nconst DEFAULT_ALTITUDE_FACTOR = 0.5\nexport const createHighlighBillboardController = (\n obj: Billboard,\n { altitudeFactor = DEFAULT_ALTITUDE_FACTOR } = {}\n) => {\n const controller = { start: () => {}, clear: () => {} }\n if (!(obj instanceof Billboard)) return controller\n\n const altitude = obj.properties.default.altitude\n\n const newAltitude = _.clamp(altitude * altitudeFactor, 0, altitude)\n const tween = new TWEEN.Tween({ altitude })\n .to({ altitude: newAltitude }, 800)\n .easing(TWEEN.Easing.Quartic.Out)\n .onUpdate((newUpdate) => {\n obj.setLineHeight(newUpdate.altitude)\n })\n\n controller.start = () => {\n tween.start()\n }\n\n controller.clear = () => {\n tween.stop().to({ altitude }, 1600).startFromCurrentValues()\n }\n\n return controller\n}\n\nexport const createHighlighExtrudeObjectController = (\n obj: BaseObject,\n { color }\n) => {\n const controller = { start: () => {}, clear: () => {} }\n if (\n obj?.type !== \"ExtrudePolygon\" ||\n _.isNil(obj?.object3d?.material?.color) ||\n _.isNil(color)\n )\n return controller\n\n controller.start = () => {\n obj.object3d.material.color = new Color(color)\n }\n\n controller.clear = () => {\n const objectDefaultColor = _.get(obj, \"properties.defaultColor\")\n obj.object3d.material.color = new Color(objectDefaultColor)\n }\n\n return controller\n}\n","import { Map } from \"maptalks-gl\"\nimport { MapAnimationOptionsType, MapViewType } from \"maptalks/dist/map/Map\"\n\nexport interface CameraManagerOptions {\n defaultView?: MapViewType\n}\n\nexport const ZOOM_OUT_LEVEL = 21\nexport const ZOOM_IN_LEVEL = 24\n\nexport class CameraManager {\n map: Map\n\n constructor(map: Map, options?: CameraManagerOptions) {\n this.map = map\n\n if (options?.defaultView) {\n this.setView(options?.defaultView)\n }\n }\n\n /** Private method */\n #animateflyTo(viewOptions = {}, options = {}, callbackOption = () => {}) {\n const { start, end } = {\n start: (frame) => {},\n end: (frame) => {},\n ...callbackOption,\n }\n this.map.flyTo(viewOptions, options, (frame) => {\n if (frame.state.playState === \"running\" && frame.state.progress === 0)\n start(frame)\n if (frame.state.playState === \"finished\") end(frame)\n })\n }\n\n /** Public methods */\n getView = (): MapViewType => {\n return this.map.getView()\n }\n\n getZoom = (): number => {\n return this.map.getView().zoom\n }\n\n setView = (value: MapViewType) => {\n this.map.setView(value)\n }\n\n flyTo = (center, options: MapAnimationOptionsType & MapViewType = {}) => {\n const currentView = this.getView()\n const {\n zoom = ZOOM_OUT_LEVEL,\n pitch = 60,\n duration = 600,\n easing = \"out\",\n bearing = currentView.bearing,\n } = options\n this.#animateflyTo(\n {\n center,\n zoom,\n pitch,\n bearing,\n },\n { duration, easing }\n )\n }\n\n flyToAndZoomIn = (\n centerPoint,\n options: MapAnimationOptionsType & MapViewType = {}\n ) => {\n const {\n zoom = ZOOM_IN_LEVEL,\n pitch = 60,\n duration = 600,\n easing = \"out\",\n } = options\n this.#animateflyTo(\n {\n center: centerPoint,\n zoom,\n pitch,\n },\n { duration, easing }\n )\n }\n}\n","import * as maptalks from \"maptalks\"\nimport _min from \"lodash/min\"\nimport _partition from \"lodash/partition\"\nimport { center as turfCenter } from \"@turf/center\"\nimport { Position } from \"geojson\"\nimport { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport * as THREE from \"three\"\n\nimport type { RendererManagerOptions } from \"./types\"\nimport { Element3DRenderer } from \"./3d/Element3DRenderer\"\nimport { Element2DRenderer } from \"./2d/Element2DRenderer\"\nimport { Marker2DRenderer } from \"./2d/Marker2DRenderer\"\nimport { Marker3DRenderer } from \"./3d/Marker3DRenderer\"\n\nimport {\n KioskFeaturePopulated,\n OpeningFeaturePopulated,\n UnitFeaturePopulated,\n VenueDataClient,\n} from \"../../data\"\nimport { angleBetweenLineStrings } from \"./utils/angleBetweenLineString\"\n\nexport class RendererManager extends EventTarget {\n map: maptalks.Map\n\n options: RendererManagerOptions\n\n // Client for fetching data\n #dataClient: VenueDataClient\n\n /** Elements: Responsible for converting feature info elements and add to map */\n private elementRenderer: Element2DRenderer | Element3DRenderer\n private markerRenderer: Marker2DRenderer | Marker3DRenderer\n\n private elementsMap: Map<string, maptalks.Geometry | BaseObject>\n private elementsByOrdinal: Map<\n number,\n Array<maptalks.Geometry> | Array<BaseObject>\n >\n\n private currentOrdinals: number | number[] | null\n\n private markersMap: Map<string, maptalks.ui.UIMarker | BaseObject>\n private markersByOrdinal: Map<\n number,\n Array<maptalks.ui.UIMarker> | Array<BaseObject>\n >\n\n constructor(map: maptalks.Map, dataClient: VenueDataClient, options: RendererManagerOptions) {\n super()\n this.map = map\n this.options = options\n this.elementsMap = new Map()\n this.elementsByOrdinal = new Map()\n\n this.markersMap = new Map()\n this.markersByOrdinal = new Map()\n\n this.#dataClient = dataClient\n\n if (options.type === \"3D\") {\n // ElementLayer as ThreeLayer\n const threeLayer = new ThreeLayer(\"elements\", {\n forceRenderOnMoving: true,\n forceRenderOnRotating: true,\n })\n \n const _this = this\n\n threeLayer.prepareToDraw = function (gl, scene, camera) {\n \n const ambientLight = new THREE.AmbientLight(0xffffff, 0.3)\n scene.add(ambientLight)\n \n const dirColor = 0xffffff\n const dllight = new THREE.DirectionalLight(dirColor, 0.8)\n dllight.position.set(0, -10, 10).normalize()\n scene.add(dllight)\n \n // nice optional fill\n const hemi = new THREE.HemisphereLight(0xffffff, 0x444444, 0.4)\n scene.add(hemi)\n\n // Element renderer creates and owns the ThreeLayer\n _this.elementRenderer = new Element3DRenderer(map, options.elements, threeLayer)\n\n // Get the ThreeLayer from element renderer to share with marker renderer\n _this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer)\n\n if (typeof options.onRendererReady === 'function') {\n options.onRendererReady()\n }\n\n _this.#createElements()\n }\n\n threeLayer.addTo(this.map)\n \n \n } else {\n // 2D doesn't need shared layer\n this.elementRenderer = new Element2DRenderer(map, options.elements)\n this.markerRenderer = new Marker2DRenderer(map)\n\n this.#createElements()\n }\n }\n\n getElementsByOrdinal = (ordinal: number) => {\n const exist = this.elementsByOrdinal.get(ordinal)\n if (!exist) this.elementsByOrdinal.set(ordinal, [])\n return this.elementsByOrdinal.get(ordinal)\n }\n\n getMarkersByOrdinal = (ordinal: number) => {\n const exist = this.markersByOrdinal.get(ordinal)\n if (!exist) this.markersByOrdinal.set(ordinal, [])\n return this.markersByOrdinal.get(ordinal)\n }\n\n addElementsToManager = (id, elements, ordinal) => {\n this.elementsMap.set(id, elements)\n elements.forEach((el) => {\n this.getElementsByOrdinal(ordinal).push(el)\n })\n\n const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals\n if (inOrdinal) {\n this.elementRenderer.showElements(elements as any, ordinal)\n } else {\n this.elementRenderer.hideElements(elements as any, ordinal)\n }\n }\n\n addMarkersToManager = (id, markers, ordinal) => {\n this.markersMap.set(id, markers)\n markers.forEach((el) => {\n this.getMarkersByOrdinal(ordinal).push(el)\n })\n\n const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals\n if (inOrdinal) {\n this.markerRenderer.showMarkers(markers, ordinal)\n } else {\n this.markerRenderer.hideMarkers(markers, ordinal)\n }\n }\n async #createElements() {\n /** Levels */\n const levels = await this.#dataClient.filterByType(\"level\", {\n populate: true,\n })\n\n const relationships = await this.#dataClient.filterByType('relationship')\n\n /** Fixtures */\n const fixtures = (await this.#dataClient.filterByType(\"fixture\", { populate: true }))\n fixtures\n .forEach((fixture) => {\n const element = this.elementRenderer.createGeometry(fixture)\n if (element) {\n const _elements = Array.isArray(element) ? element : [element]\n this.addElementsToManager(fixture.id, _elements, fixture.properties.level.properties.ordinal)\n }\n })\n\n /** Units */\n const units = (await this.#dataClient.filterByType<\"unit\">(\"unit\", {\n populate: true,\n })) as UnitFeaturePopulated[]\n\n units\n .filter(\n (u) => ![\"opentobelow\", \"escalator\"].includes(u.properties.category)\n )\n .forEach((unit) => {\n const element = this.elementRenderer.createGeometry(unit)\n if (element) {\n const _elements = Array.isArray(element) ? element : [element]\n this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal)\n }\n })\n\n /** Kiosks */\n const kiosks = (await this.#dataClient.filterByType<\"kiosk\">(\"kiosk\", {\n populate: true,\n })) as KioskFeaturePopulated[]\n kiosks.forEach((kiosk) => {\n const element = this.elementRenderer.createGeometry(kiosk)\n if (element) {\n const _elements = Array.isArray(element) ? element : [element]\n this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal)\n }\n })\n\n /**\n * Escalators\n */\n const escalators = units.filter(u => u.properties.category === 'escalator')\n for (const escalator of escalators) {\n try {\n const escalatorRelationships = relationships.filter(r => (r.properties?.intermediary || []).some(inter => inter.id === escalator.id))\n if (escalatorRelationships.length === 0) {\n throw new Error('Cannot find escalator relationship')\n }\n if (escalatorRelationships.length > 1) {\n throw new Error('Found more than one relationship')\n }\n const thisOrdinal = escalator.properties.ordinal\n const relationship = escalatorRelationships[0]\n const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id]\n const bothOpenings = await Promise.all(\n bothOpeningIds.map(id => this.#dataClient.findById('opening', id, { populate: true }))\n ) as OpeningFeaturePopulated[]\n const thisLevelOpening = bothOpenings.find(opening => opening.properties.ordinal === thisOrdinal)\n const thatLevelOpening = bothOpenings.find(opening => opening.properties.ordinal !== thisOrdinal)\n const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates)\n const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? 'up' : 'down'\n const escalatorEntryPoint = turfCenter(thisLevelOpening).geometry.coordinates\n const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle })\n if (element) {\n const _elements = (Array.isArray(element)) ? element : [element]\n this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal)\n }\n } catch (err) {\n console.log(`cannot create escalator`, err)\n }\n }\n \n // Call changeLevelByOrdinal again to show/hide elements\n this.changeLevelByOrdinal(this.currentOrdinals)\n\n this.dispatchEvent(new CustomEvent('renderermanager:elements_created'))\n\n }\n\n changeLevelByOrdinal(targetOrdinal: null | number | number[]): void {\n // if targetOrdinal = null, show all\n this.currentOrdinals = targetOrdinal\n\n if (targetOrdinal === null) {\n const baseOrdinal = 0\n for (const [ordinal, elements] of this.elementsByOrdinal) {\n this.elementRenderer.showElements(elements as any, ordinal - baseOrdinal)\n }\n\n for (const [ordinal, markers] of this.markersByOrdinal) {\n this.markerRenderer.showMarkers(markers as any, ordinal - baseOrdinal)\n }\n } else {\n // if targetOrdinal = number | number[], show target levels\n const baseOrdinal = Array.isArray(targetOrdinal) ? _min(targetOrdinal) : targetOrdinal\n\n for (const [ordinal, elements] of this.elementsByOrdinal) {\n const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal\n if (inOrdinal) {\n this.elementRenderer.showElements(elements as any, ordinal - baseOrdinal)\n } else {\n this.elementRenderer.hideElements(elements as any, ordinal - baseOrdinal)\n }\n }\n\n for (const [ordinal, markers] of this.markersByOrdinal) {\n const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal\n if (inOrdinal) {\n this.markerRenderer.showMarkers(markers as any, ordinal - baseOrdinal)\n } else {\n this.markerRenderer.hideMarkers(markers as any, ordinal - baseOrdinal)\n }\n }\n }\n }\n\n /** \n * ========================================================================\n * Markers\n * ======================================================================== */\n createMarker(coordinate: Position, ordinal: number, text: string, options: any) {\n const marker = this.markerRenderer.createMarker(coordinate, ordinal, text, options)\n const markerId = `${this.markersMap.size + 1}`\n this.addMarkersToManager(markerId, [marker], ordinal)\n }\n\n clearMarkers() {\n for (const [markerId, marker] of this.markersMap) {\n this.markerRenderer.removeMarker(marker as any)\n }\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { GeoJSONMultiPolygonFeature, GeoJSONPolygonFeature } from \"maptalks.three/dist/type\"\nimport * as THREE from \"three\"\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader\"\nimport { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'\nimport { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport { Polygon, Position } from \"geojson\"\nimport turfBuffer from \"@turf/buffer\"\nimport { ImdfFeature } from \"../../../data\"\nimport {\n CreateExtrudePolygonOptionType,\n Element3DRendererOptions,\n IElementRenderer,\n LoadModel3dParameters,\n} from \"../types\"\nimport { element3DRendererOptions as defaultOptions } from './element3DRendererOptions'\nimport { Marker3DRenderer } from \"./Marker3DRenderer\"\nimport { TextSpriteMarker } from \"./objects/TextSpriteMarker\"\n\nconst DEFAULT_POLYGON_OPTION: CreateExtrudePolygonOptionType = {\n color: \"#FFFFFF\",\n offset: 0,\n altitude: 0,\n}\n\nexport const HEIGHT_METER = 4\nexport const MULTIORDINAL_HEIGHT_METER = 9\nexport const WALKWAY_HEIGHT = 0.5\n\nexport const getGeometryOption = (\n feature: ImdfFeature,\n options: Element3DRendererOptions\n): CreateExtrudePolygonOptionType => {\n try {\n const option = options[feature.feature_type] ?? defaultOptions[feature.feature_type]\n const category = feature.properties.category\n return (\n (category && option.byCategory?.[category]) ??\n option?.default ??\n DEFAULT_POLYGON_OPTION\n )\n } catch (err) {\n console.log(err.message, { options, feature })\n }\n}\n\nexport class Element3DRenderer\n extends EventTarget\n implements IElementRenderer<BaseObject | BaseObject[]>\n{\n private options: Element3DRendererOptions\n private map: maptalks.Map\n public threeLayer: ThreeLayer\n private dracoLoader: DRACOLoader\n private lineMaterial: THREE.LineBasicMaterial\n private materialByColorMap: Map<string, THREE.Material>\n\n public markerRenderer: Marker3DRenderer\n\n // Renderer is Ready\n public isReady: boolean = false\n\n constructor(map: maptalks.Map, options: Element3DRendererOptions, layer: ThreeLayer) {\n super()\n\n this.options = options\n this.map = map\n\n // ElementLayer as ThreeLayer\n // this.threeLayer = new ThreeLayer(\"elements\", {\n // forceRenderOnMoving: true,\n // forceRenderOnRotating: true,\n // })\n\n // Use Google public CDN for Draco Decoder\n this.dracoLoader = new DRACOLoader()\n this.dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.7/') \n\n this.lineMaterial = new THREE.LineBasicMaterial({ color: \"#000\" })\n \n // Add layer to map after setup\n this.threeLayer = layer\n\n this.render()\n }\n\n animation() {\n // layer animation support Skipping frames\n this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate\n if (this.threeLayer._needsUpdate) {\n this.threeLayer.redraw()\n }\n requestAnimationFrame(this.animation)\n }\n\n /** Materials */\n getOrCreateMaterialByColor(color) {\n if (!this.materialByColorMap) this.materialByColorMap = new Map()\n\n const existingMaterial = this.materialByColorMap.get(color)\n if (existingMaterial) return existingMaterial\n\n // Create new\n const created = new THREE.MeshLambertMaterial({ color, transparent: true })\n created.toneMapped = false\n this.materialByColorMap.set(color, created)\n return created\n }\n\n createGeometry = (feature: ImdfFeature): BaseObject | BaseObject[] => {\n const {\n offset = 0,\n height: heightOptions,\n bottomHeight: bottomHeightOptions,\n color: colorOptions,\n ...options\n } = getGeometryOption(feature, this.options)\n\n const _this = this\n\n /** Internal createPolygon function */\n const createPolygon = (geometry: Polygon, feature: GeoJSONPolygonFeature|GeoJSONMultiPolygonFeature) => {\n const [outerRing, ...innerRings] = geometry.coordinates\n const offsetFeature =\n offset !== 0\n ? turfBuffer(geometry, offset, { units: \"meters\" }) as GeoJSONPolygonFeature\n : feature\n const color =\n feature.properties.style.polygonFill ?? colorOptions ?? \"#ffffff\"\n if (color === \"transparent\") return\n const material = this.getOrCreateMaterialByColor(color)\n const altitude = feature.properties.ordinal * HEIGHT_METER\n const height = feature.properties.height ?? heightOptions ?? HEIGHT_METER\n const bottomHeight = feature.properties.bottomHeight ?? bottomHeightOptions ?? 0\n const extrudedPolygon = this.threeLayer.toExtrudePolygon(\n offsetFeature,\n { asynchronous: true, ...options, height, bottomHeight, altitude },\n material\n )\n \n extrudedPolygon.on(\"click\", e => {\n console.log(e.target.options.polygon.id)\n })\n\n\n // Create extra lines for visual clarity\n const topLineStrings = [\n new maptalks.LineString(outerRing),\n ...innerRings.map(innerRing => new maptalks.LineString(innerRing))\n ]\n const topLines = this.threeLayer.toLines(\n topLineStrings,\n { altitude, bottomHeight: bottomHeight + height + 0.001, interactive: false },\n this.lineMaterial\n )\n\n const bottomLineStrings = [\n new maptalks.LineString(outerRing),\n ...innerRings.map(innerRing => new maptalks.LineString(innerRing))\n ]\n const bottomLines = this.threeLayer.toLines(\n bottomLineStrings,\n { altitude: altitude, bottomHeight, interactive: false },\n this.lineMaterial\n )\n return [extrudedPolygon, topLines, bottomLines]\n }\n\n try {\n switch (feature.geometry.type) {\n case \"MultiPolygon\": {\n const { coordinates } = feature.geometry\n const multiMeshes = coordinates.flatMap(polygonCoordinates => {\n const meshes = createPolygon({ type: 'Polygon', coordinates: polygonCoordinates }, feature as GeoJSONMultiPolygonFeature)\n this.threeLayer.addMesh(meshes)\n return meshes\n })\n return multiMeshes\n }\n case \"Polygon\": {\n const meshes = createPolygon(feature.geometry, feature as GeoJSONPolygonFeature)\n this.threeLayer.addMesh(meshes)\n return meshes\n }\n }\n } catch (err) {\n console.log(`error createGeometry`, { feature, options })\n }\n }\n\n async createEscalator(\n f: ImdfFeature,\n coordinate: Position,\n options: { angle: number; direction: 'up' | 'down' },\n ): Promise<BaseObject | BaseObject[] | null> {\n\n const { direction: dir, angle } = options;\n\n const model = await this.loadModel3d({\n url: 'https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb',\n properties: {\n rotation: {\n x: 0.5 * Math.PI, // Rotate the model up (new_escalator.glb)\n y: 0,\n z: 0,\n },\n position: { x: 0, y: 0, z: 0 },\n scale: 0.01,\n },\n });\n\n // map heading\n model.rotation.y += (dir === \"up\") ? Math.PI + angle : angle;\n\n const box = new THREE.Box3().setFromObject(model);\n const pivotPoint =\n dir === 'up'\n ? new THREE.Vector3(0, 0, 0)\n : new THREE.Vector3(\n 1 * (box.min.x + box.max.x),\n 1 * (box.min.y + box.max.y),\n 0.60 * box.max.z,\n );\n\n const pivot = new THREE.Group();\n pivot.add(model);\n\n model.position.sub(pivotPoint);\n model.updateMatrixWorld(true);\n\n const altitude = f.properties.ordinal * HEIGHT_METER;\n\n const baseObjectModel = this.threeLayer.toModel(pivot, {\n coordinate,\n altitude,\n });\n\n this.threeLayer.addMesh(baseObjectModel);\n return baseObjectModel;\n }\n\n async createTree(coordinate: Position, ordinal: number): Promise<BaseObject | BaseObject[] | null> {\n const model = await this.loadModel3d({\n url: 'https://dashboard.situm.com/uploads/3dmodels/demoaccount/arbol.glb',\n properties: {\n rotation: {\n x: 0.5 * Math.PI, // Rotate the model up (new_escalator.glb)\n y: 0,\n z: 0,\n },\n position: { x: 0, y: 0, z: 0 },\n scale: 0.01,\n },\n });\n const altitude = ordinal * HEIGHT_METER;\n const baseObjectModel = this.threeLayer.toModel(model, {\n coordinate,\n altitude,\n });\n this.threeLayer.addMesh(baseObjectModel);\n return baseObjectModel\n }\n\n\n createElement(f: ImdfFeature): BaseObject[] | null {\n switch (f.feature_type) {\n default:\n return null\n }\n }\n\n showElements(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER)\n element.show()\n })\n }\n\n hideElements(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n try { \n element.hide()\n } catch (err) {\n console.log(`cannot hide`, err, element)\n }\n })\n }\n\n async loadModel3d(model3d: LoadModel3dParameters) {\n const loader = new GLTFLoader()\n loader.setDRACOLoader(this.dracoLoader)\n\n const { url, properties: modelProperties } = model3d\n const gltf = await loader.loadAsync(url)\n \n const model = gltf.scene\n // จัดขนาด + scale ที่เหมาะสม\n model.rotation.x = modelProperties.rotation.x\n model.rotation.y = modelProperties.rotation.y\n\n model.position.x = modelProperties.position.x\n model.position.y = modelProperties.position.y\n model.position.z = modelProperties.position.z\n \n const scale = modelProperties.scale\n model.scale.set(scale, scale, scale)\n return model\n }\n\n createMarker = (\n coordinates: Position,\n ordinal: number,\n text: string\n ): BaseObject => {\n const options = {\n // scale: 0.05,\n // altitude: ordinal * HEIGHT_METER,\n text,\n // interactive: true,\n }\n\n const marker = new TextSpriteMarker(coordinates, options, this.threeLayer)\n\n this.threeLayer.addMesh([marker])\n return marker\n }\n\n removeMarker = () => {}\n\n render() {\n this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate\n if (this.threeLayer._needsUpdate) {\n // @ts-ignore\n this.threeLayer.redraw()\n }\n\n // this.#animationsToRun.forEach(({ callback }) => callback(this))\n\n //update TWEEN.js animaton\n // TWEEN.update()\n\n requestAnimationFrame(this.render.bind(this))\n }\n}\n","import { Element3DRendererOptions } from \"../types\";\n\nexport const element3DRendererOptions: Element3DRendererOptions = {\n unit: {\n default: { color: \"#ffffff\", height: 4 },\n byCategory: {\n walkway: { color: \"#cccccc\", height: 0.1 },\n terrace: { color: \"#cccccc\", height: 0.1 },\n unenclosedarea: { color: \"#cccccc\", height: 0.2 },\n nonpublic: { color: \"#999999\", height: 0.3 },\n escalator: { height: 0.2 },\n room: { color: \"#ffffff\", height: 2, bottomHeight: 0.12 }\n },\n },\n kiosk: {\n default: { color: \"#666666\", height: 0.6, bottomHeight: 0.12 },\n },\n fixture: {\n default: { color: \"#ffffff\", height: 0.5 },\n byCategory: {\n water: { color: \"#ACD7EC\", height: 0.1 },\n vegetation: { color: \"#91C499\", height: 0.5 }\n }\n }\n}","// TextSpriteMarker.js\nimport { Coordinate, Util } from \"maptalks\"\nimport * as THREE from \"three\"\nimport { BaseObject, ThreeLayer } from \"maptalks.three\" // in some builds it's maptalks.three.BaseObject\nimport { BaseObjectOptionType } from \"maptalks.three/dist/type\"\nimport { isNil, set } from \"lodash\"\nimport { Stop } from \"../../types\"\nimport { interpolateStops } from \"../../utils/interpolateStops\"\n\nconst OPTIONS: TextMarkerOptions = {\n // Texture options\n text: \"\",\n textAlign: \"center\",\n color: \"#ffffff\",\n fontFamily: \"sans-serif\",\n fontSize: 28,\n fontWeight: 400,\n background: \"rgba(0, 0, 0, 0.2)\",\n lineHeight: 32,\n padding: 8,\n strokeColor: \"#000000\",\n strokeWidth: 6,\n strokeStyle: \"round\",\n // Sprite options\n /* Overall scale multiplier */\n scale: 1,\n altitude: 0,\n opacity: 1\n}\n\nexport type TextMarkerOptions = BaseObjectOptionType & {\n // Texture options\n text?: string\n textAlign?: CanvasTextAlign\n color?: CanvasFillStrokeStyles[\"fillStyle\"]\n fontFamily?: string\n fontSize?: number\n fontWeight?: number\n background?: CanvasFillStrokeStyles[\"fillStyle\"]\n lineHeight?: number\n strokeColor?: CanvasFillStrokeStyles[\"strokeStyle\"]\n strokeWidth?: number\n strokeStyle?: CanvasLineJoin\n padding?: number\n maxWidth?: number\n // Sprite options\n scale?: number\n altitude?: number\n bottomHeight?: number\n opacity?: number | { stops: Stop[] }\n}\n\nexport class TextSpriteMarker extends BaseObject {\n #altitudeOffset: number = 0\n declare options: TextMarkerOptions;\n\n constructor(\n coordinate: Coordinate,\n options: TextMarkerOptions,\n layer: ThreeLayer,\n properties: Record<string, any> = {}\n ) {\n options = Util.extend({}, OPTIONS, options, { layer })\n super()\n this._coordinate = new Coordinate(coordinate)\n this._initOptions(options)\n this._createGroup()\n\n this.properties = { ...properties }\n const sprite = this._createSprite()\n\n this.getObject3d().add(sprite)\n\n this._updatePosition()\n\n this.type = \"TextSpriteMarker\"\n }\n\n getOptions(): TextMarkerOptions {\n return super.getOptions()\n }\n\n _createSprite() {\n const options = this.getOptions()\n const texture = this._createTextTexture(options.text, options)\n\n const material = new THREE.SpriteMaterial({\n map: texture,\n transparent: true,\n alphaTest: 0.1,\n })\n\n const sprite = new THREE.Sprite(material)\n\n // position will be set in _animation or directly after added to layer\n // scale to match texture aspect\n const w = texture.image.width\n const h = texture.image.height\n const base = 1 / 16 // to bring canvas px to map size-ish\n\n // Normalize text scale by the current map resolution so sprite size stays visually consistent across zoom levels.\n const normalizedScale = options.scale / this.getMap().getGLRes()\n\n sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1)\n\n // Compute world-space height for text and use it as altitude offset.\n this.#altitudeOffset = Math.max(\n h * base * options.scale * 0.5,\n 0.05 // minimum lift in world units\n )\n\n return sprite\n }\n\n _createTextTexture(text: string, options: TextMarkerOptions = {}) {\n const {\n padding,\n fontSize,\n fontFamily,\n fontWeight,\n lineHeight,\n background,\n color,\n textAlign,\n strokeColor,\n strokeWidth,\n maxWidth,\n } = options || {}\n\n // 1. create a temp canvas to measure\n const canvas = document.createElement(\"canvas\")\n const ctx = canvas.getContext(\"2d\")!\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n\n // 2. split into paragraphs (explicit \\n from user)\n const paragraphs = String(text).split(\"\\n\")\n\n // 3. wrap each paragraph to lines\n const wrappedLines: string[] = []\n\n paragraphs.forEach((paragraph) => {\n if (isNil(maxWidth) || isNaN(maxWidth)) {\n // no wrapping, keep as-is\n wrappedLines.push(paragraph)\n return\n }\n\n const words = paragraph.split(/\\s+/)\n let currentLine = \"\"\n\n words.forEach((word) => {\n const testLine = currentLine ? currentLine + \" \" + word : word\n const testWidth = ctx.measureText(testLine).width\n\n if (testWidth > maxWidth && currentLine) {\n // push current and start new\n wrappedLines.push(currentLine)\n currentLine = word\n } else {\n currentLine = testLine\n }\n })\n\n if (currentLine) {\n wrappedLines.push(currentLine)\n }\n })\n\n // 4. figure out final canvas size\n const lines = wrappedLines.length ? wrappedLines : [\"\"]\n const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0)\n const finalWidth =\n (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2\n const finalHeight = lineHeight * lines.length + padding * 2\n\n canvas.width = finalWidth\n canvas.height = finalHeight\n\n // 5. reapply styles after resize\n const ctx2 = canvas.getContext(\"2d\")!\n ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n ctx2.textAlign = textAlign\n\n // background\n if (background && background !== \"transparent\") {\n ctx2.fillStyle = background\n ctx2.fillRect(0, 0, canvas.width, canvas.height)\n }\n\n // 6. draw all lines (stroke first, then fill)\n lines.forEach((line, i) => {\n const y = padding + lineHeight * (i + 0.8)\n let x = padding\n if (textAlign === \"center\") x = canvas.width / 2\n if (textAlign === \"right\" || textAlign === \"end\")\n x = canvas.width - padding\n\n if (strokeWidth > 0) {\n ctx2.lineWidth = strokeWidth\n ctx2.lineJoin = \"round\"\n ctx2.miterLimit = 2\n ctx2.strokeStyle = strokeColor\n ctx2.strokeText(line, x, y)\n }\n\n ctx2.fillStyle = color\n ctx2.fillText(line, x, y)\n })\n\n const texture = new THREE.CanvasTexture(canvas)\n texture.needsUpdate = true\n texture.minFilter = THREE.LinearFilter\n return texture\n }\n\n _updatePosition() {\n const options = this.getOptions()\n const layer = options.layer\n\n if (!layer) return\n\n const altitude = (options.altitude || 0) + this.#altitudeOffset\n const z = layer.altitudeToVector3(altitude, altitude).x\n const position = layer.coordinateToVector3(this._coordinate, z)\n set(this.properties, \"default.position\", position)\n this.getObject3d().position.copy(position)\n }\n\n _animation() {\n const layer = this.getLayer() as ThreeLayer\n\n if (!this.isAdd || !layer) return\n\n if (this._visible === true) {\n const zoom = layer.map.getZoom()\n \n const object3d = this.getObject3d()\n const { opacity } = this.getOptions()\n \n // Calculate opacity based on type\n let opacityValue: number\n if (typeof opacity === 'number') {\n opacityValue = opacity ?? 1\n } else if (Array.isArray(opacity.stops)) {\n opacityValue = interpolateStops(opacity, zoom)\n } else {\n throw new Error(`Unknown opacity value ${opacity}`)\n }\n // Hide object outside zoom range\n const visible = opacityValue > 0.5\n object3d.visible = visible\n }\n }\n\n setText(text: string) {\n const options = this.getOptions()\n options.text = text\n\n const newSprite = this._createSprite()\n const group = this.getObject3d()\n\n // Remove all old sprites from the group (but keep group itself)\n group.children.forEach((child) => group.remove(child))\n group.add(newSprite)\n\n this._updatePosition()\n }\n\n setAltitude(altitude: number) {\n const bottomHeight = this.options.bottomHeight ?? 0\n return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset)\n }\n}\n","import { Stop } from \"../types\"\n\nexport const interpolateStops = ({ stops }: { stops: Stop[] }, zoom: number) => {\n // If zoom is before the first stop\n if (zoom <= stops[0][0]) return stops[0][1]\n // If zoom is after the last stop\n if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1]\n \n // Find the two stops around the zoom\n for (let i = 0; i < stops.length - 1; i++) {\n const [z1, v1] = stops[i]\n const [z2, v2] = stops[i + 1]\n\n if (zoom >= z1 && zoom <= z2) {\n const t = (zoom - z1) / (z2 - z1)\n return v1 + t * (v2 - v1)\n }\n }\n}","import * as maptalks from \"maptalks\"\nimport { Element2DRendererOptions, IElementRenderer } from \"../types\"\nimport { ImdfFeature, LevelFeature } from \"../../../data\"\nimport { element2DRendererOptions as defaultOptions } from \"./element2DRendererOptions\"\nimport { PolygonOptionsType } from \"maptalks/dist/geometry/Polygon\"\nimport { Position } from \"geojson\"\n\nconst DEFAULT_POLYGON_OPTION: PolygonOptionsType = {\n zIndex: 0,\n symbol: {\n polygonFill: \"#FFFFFF\",\n lineColor: \"#34495E\",\n polygonOpacity: 1,\n lineWidth: 2,\n },\n}\n\nconst ORDINAL_HEIGHT = 4\nconst MULTIORDINAL_HEIGHT_METER = 10\n\nconst getAltitude = (f: LevelFeature) =>\n Math.max(0, f.properties.ordinal * ORDINAL_HEIGHT || 0)\n\nconst getGeometryProperties = (feature: ImdfFeature) => ({\n // Core\n type: \"Feature\",\n id: feature.id,\n geometry: feature.geometry,\n properties: feature.properties,\n // Extra\n feature_type: feature.feature_type,\n category: feature.properties.category,\n name: feature.properties.name?.en,\n})\n\nconst getGeometryOption = (\n feature: ImdfFeature,\n options: Element2DRendererOptions\n): PolygonOptionsType => {\n try {\n const option = options[feature.feature_type] ?? defaultOptions[feature.feature_type]\n const category = feature.properties.category\n return (\n (category && option.byCategory?.[category]) ??\n option?.default ??\n DEFAULT_POLYGON_OPTION\n )\n } catch (err) {\n console.log(err.message, { options, feature })\n }\n}\n\nexport class Element2DRenderer\n extends EventTarget\n implements IElementRenderer<maptalks.Geometry>\n{\n public isReady: boolean = false\n\n private options: Element2DRendererOptions\n private map: maptalks.Map\n private elementLayer: maptalks.VectorLayer\n private markerLayer: maptalks.VectorLayer\n\n constructor(map: maptalks.Map, options: Element2DRendererOptions) {\n super()\n this.options = options\n this.map = map\n\n // Create Layer for elements\n this.elementLayer = new maptalks.VectorLayer(\"elements\")\n this.elementLayer.addTo(this.map)\n\n this.markerLayer = new maptalks.VectorLayer(\"markers\")\n this.markerLayer.addTo(this.map)\n\n // Dispatch ready event, to let manager know we're ready to start\n this.isReady = true\n }\n\n createGeometry = (imdfFeature: ImdfFeature): maptalks.Geometry => {\n // Create Element (Geometry)\n const feature = getGeometryProperties(imdfFeature)\n const { symbol, ...options } = getGeometryOption(imdfFeature, this.options)\n const altitude = feature.properties.ordinal * 10\n const geometry = maptalks.Geometry.fromJSON({\n feature,\n symbol,\n options: {\n ...options,\n zIndex: altitude,\n properties: { altitude },\n },\n })\n\n // Add to layer, and return\n if (Array.isArray(geometry)) {\n geometry.forEach((g) => g.addTo(this.elementLayer))\n return new maptalks.GeometryCollection(geometry)\n } else {\n geometry.addTo(this.elementLayer)\n return geometry\n }\n }\n\n async createEscalator(f: ImdfFeature, coordinates: Position): Promise<maptalks.Geometry | null> {\n return Promise.resolve(null)\n }\n\n async createTree(f: ImdfFeature, coordinates: Position): Promise<maptalks.Geometry | null> {\n return Promise.resolve(null)\n }\n\n createElement = (imdfFeature: ImdfFeature): maptalks.Geometry | null => {\n switch (imdfFeature.feature_type) {\n default:\n return null\n }\n }\n\n showElements(elements: maptalks.Geometry[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER)\n element.show()\n })\n }\n hideElements(elements: maptalks.Geometry[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.hide()\n })\n }\n\n \n}\n","import { Element2DRendererOptions } from \"../types\";\n\nexport const element2DRendererOptions: Element2DRendererOptions = {\n unit: { \n default: { symbol: { polygonFill: '#cccccc' } },\n byCategory: {\n room: { symbol: { polygonFill: '#fff' } },\n walkway: { symbol: { polygonFill: \"#efefef\", lineColor: \"#dadada\", lineWidth: 2 } },\n terrace: { symbol: { polygonFill: \"#efefef\" } },\n unenclosedarea: { symbol: { polygonFill: \"#fff\" } },\n nonpublic: { symbol: { polygonFill: \"#999999\" }},\n }\n },\n kiosk: { \n default: {},\n },\n fixture: {\n default: { symbol: { polygonFill: \"#ffffff\" } },\n byCategory: {\n water: { symbol: { polygonFill: \"#ACD7EC\" } },\n vegetation: { symbol: { polygonFill: \"#91C499\" } }\n }\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { IMarkerRenderer } from \"../types\"\nimport { Position } from \"geojson\"\n\nexport class Marker2DRenderer\n extends EventTarget\n implements IMarkerRenderer<maptalks.ui.UIMarker>\n{\n public isReady: boolean = false\n\n private map: maptalks.Map\n private markerLayer: maptalks.VectorLayer\n\n constructor(map: maptalks.Map) {\n super()\n }\n\n createMarker = (\n coordinates: Position,\n ordinal: number,\n content: string\n ): maptalks.ui.UIMarker => {\n const marker = new maptalks.ui.UIMarker(coordinates, {\n content,\n collision: true,\n collisionFadeIn: true,\n altitude: 0,\n })\n marker.addTo(this.map)\n return marker\n }\n\n removeMarker = (marker: maptalks.ui.UIMarker) => {\n marker.remove()\n }\n\n showMarkers(elements: maptalks.ui.UIMarker[], ordinalDiff: number = 0) {}\n hideMarkers(elements: maptalks.ui.UIMarker[], ordinalDiff: number = 0) {}\n}","import * as maptalks from \"maptalks\"\nimport * as THREE from \"three\"\nimport { IMarkerRenderer } from \"../types\"\nimport { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport { Position } from \"geojson\"\nimport { createSpriteMaterialByLabelSymbol } from \"../utils/svg2material\"\nimport { TextMarkerOptions, TextSpriteMarker } from \"./objects/TextSpriteMarker\"\n\nexport const HEIGHT_METER = 4\nexport const MULTIORDINAL_HEIGHT_METER = 9\n\ntype AnyMarkerOptions = TextMarkerOptions\n\nexport class Marker3DRenderer\n extends EventTarget\n implements IMarkerRenderer<BaseObject>\n{\n public isReady: boolean = false\n\n private threeLayer: ThreeLayer\n\n private map: maptalks.Map\n \n private materialByKey: Map<string, THREE.Material>\n \n\n constructor(map: maptalks.Map, options: any, layer: ThreeLayer) {\n super()\n this.map = map\n this.threeLayer = layer\n }\n\n createTextMarker = (\n position: Position,\n ordinal: number,\n label: string,\n options?: TextMarkerOptions\n ): BaseObject => {\n const combinedOptions = {\n altitude: ordinal * HEIGHT_METER,\n text: label,\n ...(options ?? {})\n }\n const [lng, lat] = position\n const marker = new TextSpriteMarker(new maptalks.Coordinate(lng, lat), combinedOptions, this.threeLayer)\n this.threeLayer.addMesh([marker])\n return marker\n }\n\n createImageMarker = () => {\n // const material = this.getOrCreateIconMaterial(\n // \"amenity.escalator\"\n // ) as THREE.SpriteMaterial\n // const marker = new SpriteMarker(\n // coordinates,\n // options,\n // material,\n // this.threeLayer,\n // {}\n // )\n }\n\n createMarker = (\n coordinates: Position,\n ordinal: number,\n label: string,\n options: AnyMarkerOptions\n ): BaseObject => {\n return this.createTextMarker(coordinates, ordinal, label, options)\n }\n\n removeMarker = (marker: BaseObject) => {\n marker.remove()\n }\n\n showMarkers(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER)\n element.show()\n })\n }\n\n hideMarkers(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n try { \n element.hide()\n } catch (err) {\n console.log(`cannot hide`, err, element)\n }\n })\n }\n\n /** Marker */\n getOrCreateIconMaterial(key) {\n if (!this.materialByKey) this.materialByKey = new Map()\n\n const existingMaterial = this.materialByKey.get(key)\n if (existingMaterial) return existingMaterial\n\n // Create new\n const baseSymbol: maptalks.PathMarkerSymbol = {\n markerType: \"path\",\n markerPath: [\n {\n path: \"M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z\",\n fill: \"#ff0000\",\n },\n ],\n markerPathWidth: 24,\n markerPathHeight: 24\n }\n\n const markerSymbol: maptalks.PathMarkerSymbol = {\n markerType: \"path\",\n markerPath: [],\n // TODO: Get Path by featureType.category\n // markerPath: [{ fill: \"#FFFFFF\", path: \"M 19 3 H 5 c -1.1 0 -2 0.9 -2 2 v 14 c 0 1.1 0.9 2 2 2 h 14 c 1.1 0 2 -0.9 2 -2 V 5 c 0 -1.1 -0.9 -2 -2 -2 Z m -2 6 h -1.7 l -5 9 H 7 c -0.83 0 -1.5 -0.67 -1.5 -1.5 S 6.17 15 7 15 h 1.7 l 5 -9 H 17 c 0.83 0 1.5 0.67 1.5 1.5 S 17.83 9 17 9 Z\" }],\n markerPathWidth: 24,\n markerPathHeight: 24,\n markerWidth: 24,\n markerHeight: 24,\n markerDy: 1.5,\n markerDx: 1.5,\n }\n\n const created = createSpriteMaterialByLabelSymbol([\n baseSymbol,\n markerSymbol,\n ])\n this.materialByKey.set(key, created)\n return created\n }\n}","import { PathMarkerSymbol, SymbolColorType } from \"maptalks\"\nimport { SpriteMaterial, TextureLoader } from \"three\"\n\nexport const svgToDataURL = (\n svgString: string,\n scaleFactor: number = 1\n): Promise<string> => {\n const svgBlob = new Blob([svgString], { type: \"image/svg+xml\" })\n const url = URL.createObjectURL(svgBlob)\n const img = new Image()\n return new Promise((resolve, reject) => {\n img.onload = function () {\n // Calculate the new dimensions\n const newWidth = img.width * scaleFactor\n const newHeight = img.height * scaleFactor\n\n // Create a canvas with the new dimensions\n const canvas = document.createElement(\"canvas\")\n canvas.width = newWidth\n canvas.height = newHeight\n const ctx = canvas.getContext(\"2d\")\n\n // Draw the SVG image onto the canvas with the scaled dimensions\n ctx.drawImage(img, 0, 0, newWidth, newHeight)\n\n // Convert canvas to PNG\n const pngDataUrl = canvas.toDataURL(\"image/png\")\n\n // Resolve the Promise with the PNG data URL\n resolve(pngDataUrl)\n }\n\n // Handle image load errors\n img.onerror = function (error) {\n reject(error)\n }\n\n img.src = url\n })\n}\n\nexport const createSVGPathFromMarkerSymbol = (\n style: PathMarkerSymbol & { fill?: SymbolColorType }\n): string | string[] => {\n const {\n markerWidth = 24,\n markerDx = 0,\n markerDy = 0,\n // markerFill,\n markerPath,\n fill = \"#000000\",\n } = style\n const scale = markerWidth / 24\n const strokeWidth = 2\n const halfStrokeWidth = 0.5 * strokeWidth\n\n if (Array.isArray(markerPath)) {\n return markerPath.map(\n ({ path, fill }) =>\n `<path d=\"${path}\" style=\"transform:translate(${markerDx}px, ${markerDy}px) scale(${scale})\" fill=\"${fill}\" stroke=\"#ffffff\" stroke-width=\"${strokeWidth}\" />`\n )\n }\n\n return `<path d=\"${markerPath}\" style=\"transform:translate(${markerDx}px, ${markerDy}px) scale(${scale})\" fill=\"${fill}\" />`\n}\n\nexport const createSpriteMaterialByLabelSymbol = (\n labelSymbol?: [PathMarkerSymbol, PathMarkerSymbol]\n): SpriteMaterial => {\n const material = new SpriteMaterial()\n try {\n const [base, icon] = labelSymbol ?? [{}, {}]\n const { markerWidth: baseWidth = 24 } = base\n const { markerWidth: iconWidth = 24 } = icon\n const viewBoxDimension = Math.max(baseWidth, iconWidth)\n\n const baseSVG = createSVGPathFromMarkerSymbol(base)\n const iconSVG = icon ? createSVGPathFromMarkerSymbol(icon) : \"\"\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${viewBoxDimension}\" height=\"${viewBoxDimension}\">${baseSVG}${iconSVG}</svg>`\n const textureLoader = new TextureLoader()\n const scaleFactor = 200 / 24 // Scale factor to upscale from 24px to 200px to ensure the resolution is high enough\n\n svgToDataURL(svg, scaleFactor).then((png) => {\n const texture = textureLoader.load(png, () => {\n material.map = texture\n material.needsUpdate = true\n })\n })\n } catch (error) {\n console.warn(`Error createSpriteMaterialByLabelSymbol: `, labelSymbol)\n }\n return material\n}\n","export const getLineCenter = (line: number[][]) => {\n let x = 0, y = 0;\n for (const [lx, ly] of line) {\n x += lx;\n y += ly;\n }\n const len = line.length;\n return [x / len, y / len];\n};\n\n// Returns angle in radians\nexport const angleBetweenLineStrings = (\n line1: number[][],\n line2: number[][],\n): number => {\n const [x1, y1] = getLineCenter(line1);\n const [x2, y2] = getLineCenter(line2);\n\n const dx = x2 - x1;\n const dy = y2 - y1;\n\n // angle in radians, range (-PI, PI)\n return Math.atan2(dy, dx);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,qBAA8B;;;ACGvB,IAAM,mBAAmB;AAEzB,IAAM,qBAAoC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,wBAAuC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,wBAAuC;AAAA,EAClD,GAAG;AAAA,EACH,GAAG;AACL;AAEO,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AAW,YAAY;AAAA,QAC1C,CAAC;AAGD,aAAK,2BAA2B,YAAY;AAG5C,aAAK,wBAAwB,YAAY;AAAA,MAC3C;AAEA,WAAK,cAAc,QAAQ,CAAC,WAAW;AACrC,eAAO,YAAY,EAAE,SAAS,CAAC,UAAU;AACvC,cAAI,MAAM,OAAQ,OAAM,SAAS,UAAU;AAI3C,gBAAM,UAAU,KAAK,mBAAmB,gBAAgB;AAAA,QAC1D,CAAC;AAAA,MACH,CAAC;AAGD,WAAK,eAAe,QAAQ,CAAC,WAAW;AACtC,eAAO,UAAU;AAAA,MACnB,CAAC;AAAA,IACH;AAEA,SAAK,iBAAiB,QAAQ,CAAC,EAAE,SAAS,MAAM,SAAS,IAAI,CAAC;AAG9D,kBAAAS,QAAM,OAAO;AAEb,0BAAsB,KAAK,OAAO,KAAK,IAAI,CAAC;AAAA,EAC9C;AACF;","names":["import_query_core","kiosk","section","unit","feature","feature","options","import_tween","import_lodash","import_center","import_three","import_lodash","import_maptalks","import_center","import_three","scale","_","maptalks","import_maptalks","import_three","OPTIONS","ctx","text","scale","center","import_maptalks","import_three","import_lodash","scale","_","maptalks","import_maptalks","import_three","OPTIONS","feature","import_lodash","center","_","turfLineOffset","scale","feature","_","turfBuffer","turfCenter","feature_type","properties","logoUrl","center","scale","import_three","import_lodash","_","TWEEN","center","import_center","import_maptalks","THREE","maptalks","THREE","import_GLTFLoader","import_buffer","import_maptalks","import_lodash","OPTIONS","feature","turfBuffer","scale","maptalks","DEFAULT_POLYGON_OPTION","MULTIORDINAL_HEIGHT_METER","feature","getGeometryOption","DEFAULT_POLYGON_OPTION","MULTIORDINAL_HEIGHT_METER","maptalks","maptalks","import_three","createSVGPathFromMarkerSymbol","scale","fill","createSpriteMaterialByLabelSymbol","HEIGHT_METER","MULTIORDINAL_HEIGHT_METER","createSpriteMaterialByLabelSymbol","turfCenter","_min","_","turfCenter","center","feature","geometry","scale","bboxPolygon","turfDistance","highlightedAmenityMarker","TWEEN"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/data/index.ts","../src/data/constant.ts","../src/data/api/delivery-project.ts","../src/data/getDataClient.ts","../src/data/populator/index.ts","../src/data/utils/match-filters.ts","../src/IndoorMap/IndoorMap.ts","../../../node_modules/@turf/helpers/index.ts","../../../node_modules/@turf/meta/index.js","../../../node_modules/@turf/bbox/index.ts","../src/IndoorMap/constants.ts","../src/IndoorMap/utils/createElements.js","../src/IndoorMap/object3d/Billboard.js","../src/IndoorMap/object3d/GroundLabel.ts","../src/IndoorMap/object3d/SpriteMarker.ts","../src/IndoorMap/object3d/NavigationPath.ts","../src/IndoorMap/utils/geometry.ts","../src/IndoorMap/utils/svg.ts","../src/IndoorMap/utils/math.ts","../src/IndoorMap/utils/createHighlightElement.ts","../src/IndoorMap/camera/CameraManager.ts","../src/IndoorMap/renderer/RendererManager.ts","../src/IndoorMap/renderer/3d/Element3DRenderer.ts","../src/IndoorMap/renderer/3d/element3DRendererOptions.ts","../src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts","../src/IndoorMap/renderer/utils/interpolateStops.ts","../src/IndoorMap/renderer/2d/Element2DRenderer.ts","../src/IndoorMap/renderer/2d/element2DRendererOptions.ts","../src/IndoorMap/renderer/2d/Marker2DRenderer.ts","../src/IndoorMap/renderer/3d/Marker3DRenderer.ts","../src/IndoorMap/renderer/utils/svg2material.ts","../src/IndoorMap/renderer/utils/angleBetweenLineString.ts"],"sourcesContent":["// Data Module: Get geojson from service\nexport * from \"./data\"\nexport * from \"./IndoorMap\"\n","export { QueryObserver } from \"@tanstack/query-core\"\n\nexport * from \"./types\"\nexport * from \"./constant\"\nexport * from \"./api/delivery-project\"\nexport * from \"./getDataClient\"\n","import { FeatureQueryOptions } from \"./types\"\nimport { FeatureType } from \"./types/feature-api\"\n\nexport const DEFAULT_BASE_URL = \"https://service.venue.in.th/api\"\n\nexport const IMDF_FEATURE_TYPES: FeatureType[] = [\n \"address\",\n \"amenity\",\n \"anchor\",\n \"building\",\n \"detail\",\n \"fixture\",\n \"footprint\",\n \"geofence\",\n \"kiosk\",\n \"level\",\n \"occupant\",\n \"opening\",\n \"relationship\",\n \"section\",\n \"unit\",\n \"venue\",\n]\n\nexport const NONIMDF_FEATURE_TYPES: FeatureType[] = [\n \"taxonomy\",\n \"event\",\n \"promotion\",\n \"label\",\n \"privilege\",\n]\n\nexport const GEOJSON_FEATURE_TYPES: FeatureType[] = [\n ...IMDF_FEATURE_TYPES,\n ...NONIMDF_FEATURE_TYPES,\n]\n\nexport const ALL_FEATURE_TYPES: FeatureType[] = [\n ...GEOJSON_FEATURE_TYPES,\n \"sponsored-content\",\n \"element\",\n]\n\nexport const defaultFeatureQueryOptionsMap: Record<\n FeatureType,\n FeatureQueryOptions\n> = {\n // IMDF\n address: {},\n amenity: {},\n anchor: {},\n building: {},\n detail: { enabled: false },\n fixture: {},\n footprint: {},\n geofence: { enabled: false },\n kiosk: {},\n level: {},\n occupant: {\n refetchInterval: 5 * 60 * 1000, // refresh every 5 min\n staleTime: 5 * 60 * 1000,\n },\n opening: {},\n relationship: {},\n section: {},\n unit: {},\n venue: {},\n\n // OTHERS GEOJSON\n taxonomy: {},\n privilege: {},\n event: {},\n promotion: {\n refetchInterval: 0.5 * 60 * 1000, // refresh every 5 min\n staleTime: 0.5 * 60 * 1000,\n },\n label: {},\n\n // NON GEOJSON\n \"sponsored-content\": {\n refetchInterval: 1 * 60 * 1000, // refresh every 5 min\n },\n element: {},\n page: {},\n}\n","import type {\n FeatureResponseMap,\n FeatureType,\n SponsoredContentStrapiV4ApiResponse,\n} from \"../types/feature-api\"\nimport { DEFAULT_BASE_URL } from \"../constant\"\n\nexport async function fetchDeliveryApi<T extends FeatureType = FeatureType>(\n projectId: string,\n apiKey: string,\n featureType: FeatureType,\n baseUrl: string = DEFAULT_BASE_URL,\n): Promise<FeatureResponseMap[T][]> {\n // TODO: Update Label Endpoint to match other endpoints\n switch (featureType) {\n case \"label\":\n case \"element\": {\n const pluralFeatureType = `${featureType}s`\n const res = await fetch(\n `${baseUrl}/delivery/projects/${projectId}/${pluralFeatureType}.geojson?api-key=${apiKey}`\n )\n if (res.status !== 200) return []\n const items = await res.json()\n return items\n }\n\n case \"sponsored-content\": {\n const res = await fetch(\n `${baseUrl}/delivery/projects/${projectId}/sponsored-content.json?api-key=${apiKey}`\n )\n if (res.status !== 200) return []\n const jsonRes = await res.json()\n const items = jsonRes.data as SponsoredContentStrapiV4ApiResponse[]\n return items.map((item) => ({\n id: item.id,\n ...item.attributes,\n })) as FeatureResponseMap[T][]\n }\n\n default: {\n const res = await fetch(\n `${baseUrl}/delivery/projects/${projectId}/imdf/${featureType}.geojson?api-key=${apiKey}`\n )\n if (res.status !== 200) return []\n const collections = await res.json()\n return collections.features\n }\n }\n}\n\n\nexport async function fetchPreviewApi<T extends FeatureType = FeatureType>(\n projectId: string,\n previewToken: string,\n featureType: FeatureType,\n baseUrl: string = DEFAULT_BASE_URL,\n): Promise<FeatureResponseMap[T][]> {\n // TODO: Update Label Endpoint to match other endpoints\n switch (featureType) {\n case \"label\":\n case \"element\": {\n const pluralFeatureType = `${featureType}s`\n const res = await fetch(\n `${baseUrl}/preview/projects/${projectId}/${pluralFeatureType}.geojson`, {\n headers: {\n Authorization: `Bearer ${previewToken}`\n }\n }\n )\n if (res.status !== 200) return []\n const items = await res.json()\n return items\n }\n\n case \"sponsored-content\": {\n const res = await fetch(\n `${baseUrl}/preview/projects/${projectId}/sponsored-content.json`, {\n headers: {\n Authorization: `Bearer ${previewToken}`\n }\n }\n )\n if (res.status !== 200) return []\n const jsonRes = await res.json()\n const items = jsonRes.data as SponsoredContentStrapiV4ApiResponse[]\n return items.map((item) => ({\n id: item.id,\n ...item.attributes,\n })) as FeatureResponseMap[T][]\n }\n\n default: {\n const res = await fetch(\n `${baseUrl}/preview/projects/${projectId}/imdf/${featureType}.geojson`, {\n headers: {\n Authorization: `Bearer ${previewToken}`\n }\n }\n )\n if (res.status !== 200) return []\n const collections = await res.json()\n return collections.features\n }\n }\n}\n\nexport const safeFetchFeature = async <T extends FeatureType = FeatureType>(\n featureType: FeatureType,\n params: { \n mode: 'delivery' | 'preview',\n projectId: string,\n apiKey: string,\n previewToken?: string,\n baseUrl: string\n } \n): Promise<FeatureResponseMap[T][]> => {\n const mode = params.mode ?? 'delivery'\n const projectId = params.projectId\n const apiKey = params.apiKey\n const previewToken = params.previewToken\n const baseUrl = params.baseUrl ?? DEFAULT_BASE_URL\n\n try {\n let result = []\n \n if (mode === 'delivery') {\n result = await fetchDeliveryApi<T>(\n projectId,\n apiKey,\n featureType,\n baseUrl\n )\n } else if (mode === 'preview') {\n result = await fetchPreviewApi<T>(\n projectId,\n previewToken,\n featureType,\n baseUrl\n )\n }\n return result ?? []\n } catch (e) {\n // Suppress error and return []\n return Promise.resolve([])\n }\n}\n","import { safeFetchFeature } from \"./api/delivery-project\"\nimport { FeatureResponseMap, FeatureType } from \"./types/feature-api\"\nimport {\n EnsureQueryDataOptions,\n QueryClient,\n QueryObserver,\n} from \"@tanstack/query-core\"\nimport {\n FeatureQueryOptions,\n FilterParams,\n FindParams,\n InternalFilterByType,\n InternalFindById,\n PopulatedParams,\n VenueClientOptions,\n VenueDataClient,\n} from \"./types/VenueDataClient\"\nimport { createPopulator } from \"./populator\"\nimport { FeaturePopulatedResponseMap } from \"./types\"\nimport { matchFilters } from \"./utils/match-filters\"\n\nexport const getDataClient = (options: VenueClientOptions): VenueDataClient => {\n const observers = new Map<\n FeatureType,\n { observer: QueryObserver<any, any>, unsubscribe: () => void }\n >()\n\n const queryClient = options.queryClient ?? new QueryClient()\n const { mode = 'delivery', projectId, apiKey, baseUrl, previewToken } = options\n\n if (!projectId)\n throw new Error(\n \"Cannot create VenueDataClient. Reason: `projectId` is missing\"\n )\n \n if (mode === 'delivery' && !apiKey)\n throw new Error(\n \"Cannot create VenueDataClient. Reason: `apiKey` is missing\"\n )\n\n if (mode === 'preview' && !previewToken)\n throw new Error(\n \"Cannot create VenueDataClient. Reason: `previewToken` is missing\"\n )\n\n const createDeliveryApiQueryOptions = <T extends FeatureType = FeatureType>(\n featureType: T\n ) => ({\n queryKey: [\"_deliveryapi\", featureType] as const,\n queryFn: () => safeFetchFeature<T>(featureType, { mode, projectId, apiKey, previewToken, baseUrl }),\n })\n\n /**\n * Internal Functions\n * ***********************************/\n const internalFilterByType: InternalFilterByType = async <T extends FeatureType = FeatureType>(\n featureType: T\n ) => {\n try {\n const features = await queryClient.ensureQueryData<\n FeatureResponseMap[T][],\n unknown,\n FeatureResponseMap[T][]\n >(createDeliveryApiQueryOptions(featureType))\n return features\n } catch (error) {\n throw error\n }\n }\n\n const internalFindById: InternalFindById = async <T extends FeatureType = FeatureType>(\n id: string\n ) => {\n if (id === null) return null\n const featureType = id.slice(0, id.lastIndexOf(\"-\")) as FeatureType\n const feature = await queryClient.ensureQueryData<FeatureResponseMap[T]>({\n queryKey: [\"_deliveryapi\", featureType, id],\n queryFn: async () => {\n const features = await internalFilterByType(featureType)\n const feature = features.find(\n (f) => f.id === id\n ) as FeatureResponseMap[T]\n return feature ?? null\n },\n })\n return feature\n }\n\n // Create `Feature Populator` with internal functions\n const populator = createPopulator({ internalFindById, internalFilterByType })\n\n /**\n * Public Functions\n * ***********************************/\n const registerObserver = (\n featureType: FeatureType,\n refetchInterval: number\n ) => {\n if (observers.has(featureType)) {\n console.warn(`Observer for ${featureType} already exists`)\n const record = observers.get(featureType)\n return record.observer\n }\n \n const options = createDeliveryApiQueryOptions(featureType)\n const observer = new QueryObserver(queryClient, {\n ...options,\n refetchInterval,\n })\n const unsubscribe = observer.subscribe(() => {\n console.log(`[venue-js] Listening to ${featureType} changes (interval = ${refetchInterval}ms)`)\n // TODO: add logs or what to do after subscribe\n })\n observers.set(featureType, { observer, unsubscribe })\n\n return observer\n }\n\n const destroyObserver = (featureType: FeatureType) => {\n const record = observers.get(featureType)\n if (!record) return\n\n record.unsubscribe()\n observers.delete(featureType)\n }\n\n const destroyObservers = () => {\n observers.forEach(({ observer, unsubscribe }) => {\n unsubscribe()\n observer.destroy()\n })\n observers.clear()\n }\n\n const createFilterByTypeQueryOptions = <T extends FeatureType = FeatureType>(\n featureType: T,\n params: FilterParams = {},\n options: FeatureQueryOptions = {}\n ): EnsureQueryDataOptions<FeatureResponseMap[T][] | FeaturePopulatedResponseMap[T][]> => ({\n queryKey: [featureType, \"list\", params] as const,\n queryFn: async () => {\n const features = await internalFilterByType<T>(featureType)\n \n // Filter \n const filters = params.filters ?? {}\n let result = features\n if (params.filters) {\n result = features.filter(f => matchFilters(f, filters))\n }\n\n // Populate\n return params.populate === true\n ? await Promise.all(result.map((f) => populator[featureType](f)))\n : result\n },\n ...(options ?? {}),\n })\n\n const createFindByIdQueryOptions = <T extends FeatureType = FeatureType>(\n featureType: T,\n id: string,\n params: FindParams = {},\n options: FeatureQueryOptions = {}\n ): EnsureQueryDataOptions<FeatureResponseMap[T] | FeaturePopulatedResponseMap[T]> => ({\n queryKey: [featureType, \"detail\", id, params] as const,\n queryFn: async () => {\n const feature = await internalFindById<T>(id)\n return params.populate === true\n ? await populator[featureType](feature)\n : Promise.resolve(feature)\n },\n ...(options ?? {}),\n })\n\n async function filterByType<T extends FeatureType>(featureType: T, params: FilterParams & PopulatedParams): Promise<FeaturePopulatedResponseMap[T][]>\n async function filterByType<T extends FeatureType>(featureType: T, params?: FilterParams): Promise<FeatureResponseMap[T][]>\n async function filterByType<T extends FeatureType>(featureType: T, params?: FilterParams) {\n const filterQueryOptions = createFilterByTypeQueryOptions<T>(\n featureType,\n params\n )\n const features = await queryClient.ensureQueryData(filterQueryOptions)\n return (params?.populate === true) ? features as FeaturePopulatedResponseMap[T][] : features as FeatureResponseMap[T][]\n }\n\n async function findById<T extends FeatureType>(featureType: T, id: string, params: FindParams & PopulatedParams): Promise<FeaturePopulatedResponseMap[T]>\n async function findById<T extends FeatureType>(featureType: T, id: string, params?: FindParams): Promise<FeatureResponseMap[T]>\n async function findById<T extends FeatureType>( featureType: T, id: string, params?: FindParams) {\n const findQueryOptions = createFindByIdQueryOptions<T>(\n featureType,\n id,\n params\n )\n const feature = await queryClient.ensureQueryData(findQueryOptions)\n return feature\n }\n\n return {\n projectId,\n queryClient,\n registerObserver,\n destroyObserver,\n destroyObservers,\n createFilterByTypeQueryOptions,\n createFindByIdQueryOptions,\n filterByType,\n findById,\n }\n}\n","import {\n FeatureResponseMap,\n FeaturePopulatedResponseMap,\n InternalFindById,\n InternalFilterByType,\n SectionFeature,\n} from \"../types\"\n\nimport { booleanWithin } from \"@turf/boolean-within\"\n\ntype CreatePopulatorOptions = {\n internalFindById: InternalFindById\n internalFilterByType: InternalFilterByType\n}\n\ntype PopulatableFeatureType = Extract<\n keyof FeatureResponseMap,\n keyof FeaturePopulatedResponseMap\n>\ntype PopulatorFn<T extends PopulatableFeatureType> = (\n f: FeatureResponseMap[T]\n) => Promise<FeaturePopulatedResponseMap[T]>\n\nexport type Populator = {\n [K in PopulatableFeatureType]?: PopulatorFn<K>\n}\n\nexport const createPopulator = ({\n internalFindById,\n internalFilterByType,\n}: CreatePopulatorOptions): Populator => {\n const populateAddress: PopulatorFn<\"address\"> = (address) =>\n Promise.resolve(address)\n const populateBuilding: PopulatorFn<\"building\"> = (building) =>\n Promise.resolve(building)\n const populateDetail: PopulatorFn<\"detail\"> = (detail) =>\n Promise.resolve(detail)\n const populateFootprint: PopulatorFn<\"footprint\"> = (footprint) =>\n Promise.resolve(footprint)\n const populateGeofence: PopulatorFn<\"geofence\"> = (geofence) =>\n Promise.resolve(geofence)\n const populateRelationship: PopulatorFn<\"relationship\"> = (relationship) =>\n Promise.resolve(relationship)\n const populatePrivilege: PopulatorFn<\"privilege\"> = (privilege) =>\n Promise.resolve(privilege)\n const populateEvent: PopulatorFn<\"event\"> = (event) => Promise.resolve(event)\n\n const populatePromotion: PopulatorFn<\"promotion\"> = async (promotion) => {\n const venue = await internalFindById<\"venue\">(promotion.properties.venue_id)\n return {\n ...promotion,\n properties: {\n ...promotion.properties,\n venue,\n },\n }\n }\n\n const populateAmenity: PopulatorFn<\"amenity\"> = async (amenity) => {\n const units = await Promise.all(\n amenity.properties.unit_ids.map(internalFindById<\"unit\">)\n )\n\n const populatedUnits = await Promise.all(units.map(populateUnit))\n\n const venue = await internalFindById<\"venue\">(amenity.properties.venue_id)\n\n const defaultLevel = populatedUnits[0].properties.level\n\n const kiosks = await internalFilterByType<\"kiosk\">(\"kiosk\")\n const ordinalKiosks = kiosks.filter(\n (kiosk) => kiosk.properties.level_id === defaultLevel.id\n )\n const kiosk = ordinalKiosks.find((kiosk) => booleanWithin(amenity, kiosk))\n return {\n ...amenity,\n properties: {\n ...amenity.properties,\n\n ordinal: defaultLevel.properties.ordinal,\n level_name: defaultLevel.properties.name.en,\n units: populatedUnits,\n venue,\n\n _experimental_kiosk: kiosk ? await populateKiosk(kiosk) : null,\n },\n }\n }\n\n const populateAnchor: PopulatorFn<\"anchor\"> = async (anchor) => {\n const unit = await internalFindById<\"unit\">(anchor.properties.unit_id)\n const level = await internalFindById<\"level\">(unit.properties.level_id)\n\n const sections = await internalFilterByType<\"section\">(\"section\")\n const section = sections.find((section) => booleanWithin(anchor, section))\n\n return {\n ...anchor,\n properties: {\n ...anchor.properties,\n level: await populateLevel(level),\n unit: await populateUnit(unit),\n section: section ? await populateSection(section) : null,\n },\n }\n }\n\n const populateFixture: PopulatorFn<\"fixture\"> = async (fixture) => {\n const level = await internalFindById<\"level\">(fixture.properties.level_id)\n const venue = await internalFindById<\"venue\">(fixture.properties.venue_id)\n const anchor = await internalFindById<\"anchor\">(fixture.properties.anchor_id)\n\n return {\n ...fixture,\n properties: {\n ...fixture.properties,\n anchor: anchor ? await populateAnchor(anchor) : null,\n level: await populateLevel(level),\n venue: await populateVenue(venue),\n ordinal: level.properties.ordinal,\n }\n }\n }\n\n const populateKiosk: PopulatorFn<\"kiosk\"> = async (kiosk) => {\n const level = await internalFindById<\"level\">(kiosk.properties.level_id)\n const venue = await internalFindById<\"venue\">(kiosk.properties.venue_id)\n const anchor = await internalFindById<\"anchor\">(kiosk.properties.anchor_id)\n\n // Find Kiosk's Unit\n const units = await internalFilterByType<\"unit\">(\"unit\")\n const unit = units.find(\n (unit) =>\n unit.properties.category === \"walkway\" &&\n unit.properties.level_id === kiosk.properties.level_id &&\n booleanWithin(kiosk, unit)\n )\n\n let section: SectionFeature | null = null\n\n if (anchor) {\n const sections = await internalFilterByType<\"section\">(\"section\")\n section = sections.find((section) => booleanWithin(anchor, section))\n }\n\n return {\n ...kiosk,\n properties: {\n ...kiosk.properties,\n anchor: anchor ? await populateAnchor(anchor) : null,\n level: await populateLevel(level),\n venue: await populateVenue(venue),\n ordinal: level.properties.ordinal,\n\n unit: unit ? await populateUnit(unit) : null,\n section: section ? await populateSection(section) : null,\n },\n }\n }\n\n const populateLevel: PopulatorFn<\"level\"> = async (level) => {\n const venue = await internalFindById<\"venue\">(level.properties.venue_id)\n return {\n ...level,\n properties: {\n ...level.properties,\n venue,\n },\n }\n }\n\n const populateOccupant: PopulatorFn<\"occupant\"> = async (occupant) => {\n const {\n anchor_id,\n venue_id,\n local_category_ids,\n promotion_ids,\n privilege_ids,\n kiosk_id,\n unit_id,\n kiosk_ids = [],\n unit_ids = [],\n } = occupant.properties\n const anchor = await internalFindById<\"anchor\">(anchor_id)\n const venue = await internalFindById<\"venue\">(venue_id)\n\n const localCategories = await Promise.all(\n local_category_ids.map(internalFindById<\"taxonomy\">)\n )\n const promotions = await Promise.all(\n promotion_ids.map(internalFindById<\"promotion\">)\n )\n const privileges = await Promise.all(\n privilege_ids.map(internalFindById<\"privilege\">)\n )\n const kiosk = await internalFindById<\"kiosk\">(kiosk_id)\n const unit = await internalFindById<\"unit\">(unit_id)\n\n const kiosks = await Promise.all(kiosk_ids.map(internalFindById<\"kiosk\">))\n const units = await Promise.all(unit_ids.map(internalFindById<\"unit\">))\n return {\n ...occupant,\n properties: {\n ...occupant.properties,\n anchor: anchor ? await populateAnchor(anchor) : null,\n local_categories: await Promise.all(\n localCategories.map(populateTaxonomy)\n ),\n venue,\n promotions,\n privileges,\n\n kiosk,\n unit,\n kiosks: await Promise.all(kiosks.map(populateKiosk)),\n units: await Promise.all(units.map(populateUnit)),\n },\n }\n }\n\n const populateOpening: PopulatorFn<\"opening\"> = async (opening) => {\n const venue = await internalFindById<\"venue\">(opening.properties.venue_id)\n const level = await internalFindById<\"level\">(opening.properties.level_id)\n return {\n ...opening,\n properties: {\n venue,\n level: await populateLevel(level),\n ordinal: level.properties.ordinal,\n }\n }\n }\n\n const populateSection: PopulatorFn<\"section\"> = async (section) => {\n const venue = await internalFindById<\"venue\">(section.properties.venue_id)\n const level = await internalFindById<\"level\">(section.properties.level_id)\n return {\n ...section,\n properties: {\n ...section.properties,\n venue,\n level: await populateLevel(level),\n ordinal: level.properties.ordinal,\n },\n }\n }\n\n const populateUnit: PopulatorFn<\"unit\"> = async (unit) => {\n const venue = await internalFindById<\"venue\">(unit.properties.venue_id)\n const level = await internalFindById<\"level\">(unit.properties.level_id)\n\n const sections = await internalFilterByType<\"section\">(\"section\")\n try {\n const section = unit.geometry.type !== 'MultiPolygon' ? sections.find((section) => booleanWithin(unit, section)) : null\n return {\n ...unit,\n properties: {\n ...unit.properties,\n venue,\n ordinal: level.properties.ordinal,\n level: await populateLevel(level),\n section: section ? await populateSection(section) : null,\n },\n }\n } catch (err) {\n console.log(`error finding section `, { unit, sections })\n }\n }\n\n const populateVenue: PopulatorFn<\"venue\"> = (venue) => {\n return Promise.resolve(venue)\n }\n\n const populateTaxonomy: PopulatorFn<\"taxonomy\"> = async (taxonomy) => {\n const venue = await internalFindById<\"venue\">(taxonomy.properties.venue_id)\n return {\n ...taxonomy,\n properties: {\n ...taxonomy.properties,\n venue: venue ? await populateVenue(venue) : null,\n },\n }\n }\n\n const populateFeature = (feature) => Promise.resolve(feature)\n\n return {\n address: populateAddress,\n building: populateBuilding,\n detail: populateDetail,\n fixture: populateFixture,\n footprint: populateFootprint,\n geofence: populateGeofence,\n opening: populateOpening,\n relationship: populateRelationship,\n privilege: populatePrivilege,\n promotion: populatePromotion,\n event: populateEvent,\n label: populateFeature,\n element: populateFeature,\n page: populateFeature,\n\n amenity: populateAmenity,\n anchor: populateAnchor,\n kiosk: populateKiosk,\n level: populateLevel,\n occupant: populateOccupant,\n section: populateSection,\n unit: populateUnit,\n venue: populateVenue,\n\n taxonomy: populateTaxonomy,\n }\n}\n","import type { Value, InFilter, Filter, Filters } from '../types/match-filters'\n\nfunction isInFilter(filter: Filter): filter is InFilter {\n return (\n typeof filter === \"object\" &&\n filter !== null &&\n \"$in\" in filter &&\n Array.isArray((filter as any).$in)\n );\n}\n\nconst someIntersect = (a: Value[], b: Value[]) => a.some(v => b.includes(v));\n\nexport function matchFilter(value: Value | Value[], filter: Filter) {\n\n if (Array.isArray(value)) {\n if (isInFilter(filter)) return someIntersect(value, filter.$in);\n \n // Equal\n return value.includes(filter as Value);\n \n } else {\n if (isInFilter(filter)) return filter.$in.includes(value);\n \n // Equal\n return value === filter;\n }\n}\n\nexport function matchFilters<T extends Record<string, any>>(item: T, filters: Filters): boolean {\n return Object.entries(filters).every(([key, filter]) => {\n return matchFilter(item.properties[key], filter)\n });\n}","import {\n ui,\n Map,\n TileLayer,\n VectorLayer,\n Extent,\n LineString,\n Geometry,\n Marker,\n Coordinate,\n OverlayLayer,\n} from \"maptalks-gl\"\n\nimport { GeoJsonProperties, LineString as LineStringType, Feature } from \"geojson\"\nimport TWEEN from \"@tweenjs/tween.js\"\nimport _ from \"lodash\"\nimport {\n feature as turfFeature,\n lineString,\n point,\n} from \"@turf/helpers\"\nimport turfDistance from \"@turf/distance\"\nimport turfCenter from \"@turf/center\"\nimport bbox from \"@turf/bbox\"\nimport scale from \"@turf/transform-scale\"\nimport bboxPolygon from \"@turf/bbox-polygon\"\nimport { featureCollection } from '@turf/helpers';\n\nimport { PerspectiveCamera } from \"three\"\nimport { ThreeLayer } from \"maptalks.three\"\n\nimport {\n LAYERS,\n LAYER_OPTIONS,\n LAYER_FEATURE_TYPE_OBJ,\n HIGHLIGHT_LAYER_NAME,\n USER_LOCATION_LAYER_NAME,\n ORIGIN_MARKER_ID,\n DESTINATION_MARKER_ID,\n DEFAULT_HIGHLIGHT_OPTIONS,\n DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,\n USER_LOCATION_ELEMENT_ID,\n LAST_USER_LOCATION_ELEMENT_ID_PREFIX,\n ALWAYS_VISIBLE_FEATURE_TYPES,\n LOCALE_SYMBOL_KEY,\n DEFAULT_LOCALE,\n VENUE_EVENTS,\n} from \"./constants\"\n\nimport {\n styledFeatureGenerator,\n getExtrudeConfigByFeature,\n} from \"./utils/createElements\"\n\nimport { getBearingBetweenPoints } from \"./utils/math\"\n\nimport {\n NavigationPath,\n Billboard,\n SpriteMarker,\n GroundLabel,\n} from \"./object3d\"\nimport {\n createHighlighExtrudeObjectController,\n createHighlighBillboardController,\n} from \"./utils/createHighlightElement\"\nimport {\n IMapConfig,\n IndoorMapOptions,\n ISetHighlightElementIdsOptions,\n} from \"./types\"\n\nimport { CameraManager } from \"./camera/CameraManager\"\nimport { RendererManager } from \"./renderer\"\nimport { VenueDataClient } from \"../data\"\n\ntype MapPaddingType = {\n paddingLeft: number;\n paddingRight: number;\n paddingTop: number;\n paddingBottom: number;\n}\n\nconst INITIAL_CENTER = [100.5017051, 13.7572619] // just placeholder\nconst INITIAL_ZOOM = 18.5\nconst CLICK_TOLERANCE = 20\n\nconst defaultOptions: Partial<IndoorMapOptions> = {\n pixelRatio: 1,\n locale: DEFAULT_LOCALE,\n}\n\n\nexport class IndoorMap extends EventTarget {\n //TODO: refac functions; let them do only 1 thing in a function\n\n /** Note: \"#\" means private variables */\n #styler = null\n #featuresInitted = false\n #elementsLoaded = false\n #elements: Record<string, any> = {}\n #features = []\n #markers = []\n #venues = []\n #venueInView: string | null = null\n #ordinals = []\n #mapTheme = {}\n #billboards = []\n #billboardObjects = []\n #spriteMarkerObjects = []\n #mapDecorations = []\n #groundLabels = []\n #groundObjects = []\n #navigationGeometries: Record<string, NavigationPath> = {}\n #venueObjects = []\n #glbObjects = []\n #objects = []\n #object3ds = []\n #isClicked = false\n #highlightElementIds = []\n #highlightObjectIds = []\n #highlightObjectControllers = []\n #userLocationGeometry = null\n #userLocationElement = null\n #mapConfig: IMapConfig = {}\n #locale: string = defaultOptions.locale\n #lastUserLocationGeometries = []\n #lastUserLocationElements = []\n\n #isLayersFadingOnZoom = false\n\n #touchStartTarget = null\n #touchStartPoint = null\n\n #onClickElement = (e) => {}\n #animationsToRun = []\n\n map: Map | null = null\n #dataClient: VenueDataClient\n camera: CameraManager\n rendererManager: RendererManager\n\n showVenueObject = false\n threeLayer: ThreeLayer | null = null\n\n onMapReady = () => {}\n onMapLoading = () => {}\n\n constructor(elementId, options: IndoorMapOptions) {\n super()\n const {\n onMapReady,\n onMapLoading,\n pixelRatio,\n locale,\n } = _.merge({}, defaultOptions, options)\n\n this.map = new Map(elementId, {\n attribution: false,\n center: INITIAL_CENTER,\n zoom: INITIAL_ZOOM,\n clickTimeThreshold: 600,\n centerCross: (options.centerCross ?? false),\n baseLayer: new TileLayer(\"base\", {\n urlTemplate:\n \"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png\",\n subdomains: [\"a\", \"b\", \"c\", \"d\"],\n opacity: 1.0,\n attribution: \"\",\n hitDetect: false,\n decodeImageInWorker: true,\n errorUrl: \"/assets/img/tile-placeholder.png\",\n }),\n layers: [],\n })\n\n /** Manage create elements from imdf features */\n this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer)\n\n /** Manage zoom, bearing, pitch, flyTo, moveCamera to position */\n this.camera = new CameraManager(this.map)\n \n this.locale = locale\n this.pixelRatio = pixelRatio\n\n this.onMapReady = onMapReady\n this.onMapLoading = onMapLoading\n this.showVenueObject = false\n\n // Bind events\n // @ts-expect-error\n this.map.on(\"click\", this.handleMapClick)\n\n this.dataClient = options.dataClient\n }\n\n set dataClient(value) {\n this.#dataClient = value\n \n // Get center from dataClient and move map to center\n this.#dataClient.filterByType(\"venue\")\n .then(venues => {\n /** Find Venue's center */\n const venueCenters = turfCenter(featureCollection(venues));\n const [x, y] = venueCenters.geometry.coordinates\n const center = new Coordinate(x, y)\n\n /** Move Map to center */\n this.camera.setView({ center, pitch: 60, zoom: 19 })\n })\n }\n\n on(eventName: string, handler) {\n this.map.on(eventName, handler)\n }\n\n /**\n * Events\n */\n handleMapClick = ({ coordinate }) => {\n const { x, y } = coordinate\n console.log(\n `[Coordinates]: x: ${_.round(x, 8)} y: ${_.round(\n y,\n 8\n )}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`\n )\n }\n\n handleMapTouchEnd = ({ containerPoint }) => {\n const { x, y } = containerPoint\n const { x: touchStartX, y: touchStartY } = this.#touchStartPoint\n\n const dis = Math.hypot(x - touchStartX, y - touchStartY)\n // @ts-expect-error \n this.map.off(\"touchend\", this.handleMapTouchEnd)\n\n if (dis > 0 && dis < CLICK_TOLERANCE) {\n console.log(\"Forgiving click\", this.#touchStartTarget.properties.id)\n this.handleClickElement({ target: this.#touchStartTarget })\n }\n\n this.#touchStartTarget = null\n this.#touchStartPoint = null\n }\n\n /**\n * Getters & Setters\n */\n get elementsLoaded() {\n return this.#elementsLoaded\n }\n\n get pixelRatio() {\n return this.map.getDevicePixelRatio()\n }\n\n get locale() {\n return this.#locale\n }\n\n set mapTheme(value) {\n this.#mapTheme = value\n this.#styler = styledFeatureGenerator(this.#mapTheme)\n }\n\n get venues() {\n return this.#venues || []\n }\n\n #findAndSetVenueInView = () => {\n const venueInViewWithDistance = this.findVenueInView()\n if (\n venueInViewWithDistance &&\n (!this.#venueInView ||\n venueInViewWithDistance.venueId !== this.#venueInView)\n ) {\n this.#venueInView = venueInViewWithDistance.venueId\n this.map.fire(VENUE_EVENTS.VENUE_MOVEINTOVIEW, venueInViewWithDistance)\n }\n }\n\n set detectVenueInView(value) {\n if (value) {\n // Set initial venueInView\n this.#findAndSetVenueInView()\n this.map.on(\"moveend\", this.#findAndSetVenueInView)\n } else {\n this.map.off(\"moveend\", this.#findAndSetVenueInView)\n }\n }\n\n get ordinals() {\n return this.#ordinals || []\n }\n\n set ordinals(value) {\n if (!Array.isArray(value)) throw new Error(\"ordinals must be Array\")\n this.#ordinals = value\n }\n\n set billboards(value) {\n this.#billboards = value\n }\n\n set mapConfig(value: IMapConfig) {\n this.#mapConfig = value\n }\n\n set mapDecorations(value) {\n this.#mapDecorations = value\n }\n\n set maxZoom(value: number) {\n this.map.setMaxZoom(value)\n const spatialReference = {\n projection: \"EPSG:3857\",\n resolutions: (function () {\n const resolutions = []\n const d = 2 * 6378137 * Math.PI\n for (let i = 0; i < value; i++) {\n resolutions[i] = d / (256 * Math.pow(2, i))\n }\n return resolutions\n })(),\n }\n this.map.setSpatialReference(spatialReference)\n }\n\n set minZoom(value: number) {\n this.map.setMinZoom(value)\n }\n\n set groundLabels(value) {\n this.#groundLabels = value\n }\n\n set pixelRatio(value: number) {\n this.map.setDevicePixelRatio(value)\n }\n\n set onClickElement(func) {\n this.#onClickElement = func\n }\n\n set locale(value: string) {\n this.#locale = value || defaultOptions.locale\n\n // Update elements affected by locale changes.\n this.updateUserLocationSymbolByLocale(this.#locale)\n }\n\n /**\n * Private internal methods\n */\n\n #clearElements() {\n LAYERS.forEach((layerKey) => {\n this.#clearAllElementOnLayerByName(layerKey)\n })\n const scene = this.threeLayer.getScene()\n if (scene) {\n scene.children = scene.children.filter(\n (children) => children instanceof PerspectiveCamera\n )\n }\n }\n\n handleClickElement = (e) => {\n if (this.#isClicked) return\n this.#isClicked = true\n const onClickElement = this.#onClickElement\n if (!_.isFunction(onClickElement)) return\n this.#onClickElement(e)\n this.#isClicked = false\n }\n\n setCenter(center: Coordinate, padding?: MapPaddingType) {\n this.map.setCenter(center, padding)\n }\n\n async #legacy_createElements() {\n const {\n // 2D\n createVenue,\n createOpening,\n createSection,\n createFixture,\n createOccupant,\n createDecoration,\n // 3D\n create3DFootprint,\n create3DGroundLabel,\n create3DBillboard,\n createVenue3DModel,\n createExtrudedUnit,\n create3DFixture,\n create3DAmenityMarker,\n create3DOccupantAmenityMarker,\n create3DOpeningMarker,\n createOccupantGroundLabel,\n // Light\n createAmbientLight,\n createDirectionalLight,\n } = this.#styler\n\n let elements = {}\n let object3ds = []\n\n const scene = this.threeLayer.getScene()\n if (scene) {\n const {\n ambientLight: ambientLightConfig = {},\n directionalLight: directionalLightConfig = {},\n } = _.get(this.#mapConfig, \"light\", {\n ambientLight: {},\n directionalLight: {},\n })\n\n const ambientLight = createAmbientLight(ambientLightConfig)\n scene.add(ambientLight)\n\n const light = createDirectionalLight(directionalLightConfig)\n scene.add(light)\n }\n for (const feature of this.#features) {\n try {\n const { feature_type: featureType, properties, id } = feature\n const layerName = _.get(\n LAYER_FEATURE_TYPE_OBJ,\n featureType,\n featureType\n )\n const layer = this.map.getLayer(layerName)\n let geometry\n const category = _.get(feature, \"properties.category\")\n\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n const textMarkerType = _.get(\n this.#mapConfig,\n \"text_marker_type\",\n \"ui-marker\"\n )\n const featureExtrudeConfig = getExtrudeConfigByFeature(\n extrudeConfig,\n feature\n )\n\n switch (featureType) {\n case \"venue\": {\n geometry = createVenue(feature).addTo(layer)\n // Add 3D Model\n const models = await createVenue3DModel(feature, this.threeLayer)\n models.forEach((model) => {\n model.on(\"click\", this.handleClickElement)\n object3ds.push(model)\n this.#venueObjects.push(model)\n })\n break\n }\n case \"amenity\": {\n if (feature.properties.is_featured) {\n const billboardObj = create3DBillboard(feature, this.threeLayer)\n billboardObj?.on(\"click\", this.handleClickElement)\n this.#billboardObjects.push(billboardObj)\n this.#spriteMarkerObjects.push(billboardObj)\n object3ds.push(billboardObj)\n break\n }\n const marker3d = create3DAmenityMarker(\n feature,\n this.threeLayer,\n extrudeConfig\n )\n marker3d?.on(\"click\", this.handleClickElement)\n this.#spriteMarkerObjects.push(marker3d)\n object3ds.push(marker3d)\n break\n }\n case \"opening\": {\n switch (category) {\n case \"emergencyexit\":\n const { geometry } = turfCenter(feature)\n const markerFeature = {\n ...feature,\n geometry,\n }\n const marker3d = create3DOpeningMarker(\n markerFeature,\n this.threeLayer,\n extrudeConfig\n )?.on(\"click\", this.handleClickElement)\n object3ds.push(marker3d)\n break\n default:\n }\n geometry = createOpening(feature)\n ?.on(\"click\", this.handleClickElement)\n .addTo(layer)\n break\n }\n case \"section\": {\n geometry = createSection(feature)?.addTo(layer)\n break\n }\n case \"occupant\": {\n switch (category) {\n // Create only marker if it is amenity occupant\n case \"currencyexchange\":\n case \"donationcenter\":\n case \"postoffice\":\n const markerFeature = {\n ...feature,\n geometry: feature.properties?.anchor?.geometry,\n }\n const marker3d = create3DOccupantAmenityMarker(\n markerFeature,\n this.threeLayer,\n extrudeConfig\n )?.on(\"click\", this.handleClickElement)\n object3ds.push(marker3d)\n break\n default: {\n // Main Location\n const { kiosk, anchor } = feature.properties\n const { unit } = anchor.properties\n let mainLocation = kiosk || unit || null\n\n // Get related locations excluding current ordinal\n const relatedLocations = [\n ...feature.properties.units,\n ...feature.properties.kiosks,\n ].filter((f) => f.properties.ordinal !== properties.ordinal)\n\n // Combine all locations to process in single loop\n const occupantLocations = [mainLocation, ...relatedLocations]\n const renderType = feature.properties.render_type\n\n occupantLocations.forEach((location, index) => {\n const isMainLocation = index === 0\n\n // Handle 3D elements (currently only ground labels)\n if (renderType === \"Label\") {\n const occupantGroundLabel = createOccupantGroundLabel(\n feature,\n location,\n { textMarkerType, extrudeConfig },\n this.threeLayer\n )\n\n // Add 3D ground label to object3ds\n if (occupantGroundLabel instanceof GroundLabel) {\n occupantGroundLabel.on(\"click\", this.handleClickElement)\n occupantGroundLabel.addTo(this.threeLayer)\n object3ds.push(occupantGroundLabel)\n this.#groundObjects.push(occupantGroundLabel)\n }\n } else {\n // Handle 2D markers (UIMarker or regular Marker)\n const occupantMarker = createOccupant(feature, location, {\n textMarkerType,\n extrudeConfig,\n })\n /**\n * !Temporary condition; can be removed later if we implement all markers (logo, logo + name, name) to UIMarker.\n * UIMarker Can only be added to the map after rc.29\n * https://github.com/maptalks/maptalks.js/releases/tag/v1.0.0-rc.29\n */\n\n // Add marker to map based on type\n if (occupantMarker instanceof ui.UIMarker) {\n occupantMarker.addTo(this.map)\n } else {\n occupantMarker?.on(\"click\", this.handleClickElement)\n occupantMarker?.addTo(layer)\n }\n\n if (isMainLocation) {\n // Set main location add to elements (so it can be show/hide by ordinal)\n geometry = occupantMarker\n } else {\n // For related location add to elements (so it can be show/hide by ordinal)\n elements[`${feature.id}_${index}`] = {\n geometry: occupantMarker,\n properties: location.properties,\n featureType: \"occupant\",\n feature,\n }\n }\n }\n })\n }\n }\n break\n }\n case \"fixture\": {\n const models = await create3DFixture(feature, this.threeLayer)\n models.forEach((model) => {\n model.on(\"click\", this.handleClickElement)\n object3ds.push(model)\n this.#glbObjects.push(model)\n })\n if (!featureExtrudeConfig) {\n geometry = createFixture(feature)?.addTo(layer)\n } else {\n const locatedLevel = feature?.properties?.level\n const levelExtrudeConfig = getExtrudeConfigByFeature(\n extrudeConfig,\n locatedLevel\n )\n const levelHeight = _.get(levelExtrudeConfig, \"height\", 0)\n const option = { ...featureExtrudeConfig, altitude: levelHeight }\n\n const extrudedFixture = createExtrudedUnit(\n feature,\n this.threeLayer,\n option\n )\n object3ds.push(extrudedFixture)\n }\n break\n }\n \n case \"footprint\": {\n // Added 3D Footprint\n const objects = await create3DFootprint(\n feature,\n this.threeLayer,\n featureExtrudeConfig\n )\n objects.forEach((object) => {\n object.on(\"click\", () => {\n const {\n geometry: { coordinates },\n } = turfCenter(feature)\n this.camera.flyToAndZoomIn(coordinates, { pitch: 45 })\n })\n object3ds.push(object)\n this.#objects.push(object)\n })\n\n // Add Footprint Marker\n if (feature.properties.logo) {\n const footprintMarker = create3DBillboard(\n feature,\n this.threeLayer\n )\n object3ds.push(footprintMarker)\n this.#billboardObjects.push(footprintMarker)\n }\n\n break\n }\n default:\n break\n }\n if (!id) throw new Error(`Property is missing ID, ${id}`)\n elements[id] = { geometry, properties, featureType, feature }\n } catch (err) {\n console.warn(`Cannot create ${feature.id}: ${err.message}`)\n }\n }\n\n this.#groundLabels.forEach((label) => {\n const text = label.properties.name\n try {\n const groundLabel = create3DGroundLabel(label, this.threeLayer)\n object3ds.push(groundLabel)\n this.#groundObjects.push(groundLabel)\n } catch (error) {\n console.log(\"error creating ground label for \", text)\n }\n })\n\n this.#mapDecorations.forEach((decoration) => {\n const { id, geometry, properties } = decoration\n const geometryType = decoration?.geometry?.type\n try {\n switch (geometryType) {\n case \"Point\":\n const createdBillboard = create3DBillboard(\n decoration,\n this.threeLayer\n )\n this.#billboardObjects.push(createdBillboard)\n object3ds.push(createdBillboard)\n break\n default:\n const decorationLayer = this.map.getLayer(`base`)\n const createdDecoration = createDecoration(geometry, {\n id,\n ...properties,\n }).addTo(decorationLayer)\n elements[id] = {\n geometry: createdDecoration,\n properties,\n featureType: \"decoration\",\n }\n break\n }\n } catch (error) {\n console.log(\n \"error creating decoration for \",\n decoration.properties.name\n )\n }\n })\n\n // Initiate Canvas render\n this.#elements = elements\n this.#elementsLoaded = true\n this.#featuresInitted = true\n this.#object3ds = object3ds\n if (typeof this.onMapReady === \"function\") this.onMapReady()\n }\n\n #clearAllElementOnLayerByName = (layerName: string) => {\n const layer = this.map.getLayer(layerName) as VectorLayer\n if (layer) layer.clear()\n }\n\n\n /**\n * Change Level & animate to path / geometry / view / etc.\n * ================================== */\n changeLevelByOrdinal(ordinal: null | number | number[]): void {\n // this.#showGeometriesByOrdinal(ordinal) // show / hide geometry on the ordinal\n // this.#showThreeObjectByOrdinal(ordinal)\n this.rendererManager.changeLevelByOrdinal(ordinal)\n }\n\n getFeatureExtent = (feature, scaleFactor = 1) => {\n const [minX, minY, maxX, maxY] = bbox(\n scale(bboxPolygon(bbox(feature)), scaleFactor)\n )\n return new Extent(minX, minY, maxX, maxY)\n }\n\n getExtentCenter = (extent: Extent) => {\n return extent.getCenter()\n }\n\n getExtentZoom = (\n extent: Extent,\n options: { isFraction?: boolean; padding?: MapPaddingType } = {\n isFraction: false,\n padding: {\n paddingLeft: 0,\n paddingRight: 0,\n paddingTop: 0,\n paddingBottom: 0,\n },\n }\n ) => {\n const { isFraction = false, padding } = options\n return this.map.getFitZoom(extent, isFraction, padding)\n }\n\n findVenueInView = (): { venueId: string; distance: number } => {\n const mapCenter = this.map.getCenter()\n const result = this.#venues.reduce<{\n venueId: string\n distance: number\n } | null>((closest, venue) => {\n const { display_point: displayPoint } = venue.properties\n const distance = turfDistance(displayPoint, [mapCenter.x, mapCenter.y])\n if (!closest || distance < closest.distance) {\n return { venueId: venue.id, distance }\n }\n return closest\n }, null)\n return result\n }\n\n flyTo = (center, options) => {\n this.camera.flyTo(center, options)\n }\n\n getLineStringBearing = (feature) => {\n const { geometry } = feature\n const path = new LineString(geometry.coordinates)\n return getBearingBetweenPoints(\n path.getFirstCoordinate(),\n path.getLastCoordinate()\n )\n }\n\n //map animation\n addAnimations(animation: { id: string; callback: () => void }) {\n this.#animationsToRun.push(animation)\n }\n\n removeAnimationById(id: string) {\n this.#animationsToRun = this.#animationsToRun.filter(\n (animation) => animation.id !== id\n )\n }\n\n clearAnimations() {\n this.#animationsToRun = []\n }\n\n /**\n * Hilighting Elements\n * ========================================= */\n // TODO: To consider if we should use setter `set hilightElementIds` instead?\n setHighlightElementIds(\n targetElementIds,\n options: ISetHighlightElementIdsOptions = {}\n ) {\n const highlight3DOptions = _.merge(\n {},\n DEFAULT_HIGHLIGHT_OPTIONS,\n _.get(options, \"highlight3DOptions\", {})\n )\n const highlight2DOptions = _.merge(\n {},\n DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,\n _.get(options, \"highlight2DOptions\", {})\n )\n\n this.setHighlightedObject(targetElementIds, highlight3DOptions)\n return this.setHighlight2DElementIds(targetElementIds, highlight2DOptions)\n }\n setHighlight2DElementIds(targetElementIds, options = {}) {\n const { defaultMarker, symbolSet } = _.merge(\n {},\n DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS,\n options\n )\n const {\n createMarker,\n createHighlightOccupantMarker,\n getElementSymbol,\n getHilighPolygonalSymbol,\n getHighlightMarkerSymbol,\n } = this.#styler\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n /**\n * Hilight new elements\n */\n const elementToHilights = targetElementIds\n .map(\n (elemId) =>\n this.#elements[elemId] ||\n this.#elements[`${LAST_USER_LOCATION_ELEMENT_ID_PREFIX}${elemId}`]\n )\n .filter((elem) => elem)\n\n elementToHilights.forEach((elem) => {\n const { feature, geometry } = elem\n if (!geometry || !feature) return\n\n const hilightLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME)\n if (!hilightLayer) return\n\n const defaultSymbol = getHilighPolygonalSymbol(geometry.type)\n const definedSymbol = symbolSet ? getElementSymbol(symbolSet) : null\n const symbol = _.isEmpty(definedSymbol) ? defaultSymbol : definedSymbol\n\n switch (geometry.type) {\n case \"MultiPolygon\":\n case \"Polygon\": {\n geometry?.updateSymbol(symbol)\n break\n }\n default:\n break\n }\n\n switch (feature.feature_type) {\n case \"amenity\":\n const highlightedAmenityMarker =\n definedSymbol || getHighlightMarkerSymbol()\n geometry?.updateSymbol(highlightedAmenityMarker)\n break\n case \"occupant\": {\n switch (feature.properties.category) {\n case \"currencyexchange\":\n case \"donationcenter\":\n case \"postoffice\":\n const highlightedAmenityMarker =\n definedSymbol || getHighlightMarkerSymbol()\n geometry?.updateSymbol(highlightedAmenityMarker)\n break\n default:\n if (feature.properties.render_type === \"Logo\") {\n this.hideGeometryByElementId(feature.id)\n }\n createHighlightOccupantMarker(feature, {\n extrudeConfig,\n symbol: definedSymbol,\n })\n .on(\"click\", this.handleClickElement)\n .addTo(hilightLayer)\n break\n }\n break\n }\n case \"opening\":\n break\n default:\n if (defaultMarker) createMarker(feature).addTo(hilightLayer)\n break\n }\n\n /* Hide the occupant marker before display the highlight marker */\n // const occupantId = IndexedOccupantMarkers[feature.id]\n // if (occupantId) {\n // hideOccupantMarker(occupantId)\n // }\n })\n\n // Store new hilightIds to prev ref.\n this.#highlightElementIds = targetElementIds\n\n if (elementToHilights.length === 0) return\n return featureCollection(\n elementToHilights.map(({ feature }) => {\n const { geometry } = feature\n if (feature.feature_type === \"occupant\")\n return turfFeature(feature?.properties?.anchor?.geometry)\n return turfFeature(geometry)\n })\n )\n }\n\n clearHighlightElements() {\n /**\n * Clear previous hilights\n */\n this.#clearAllElementOnLayerByName(HIGHLIGHT_LAYER_NAME)\n\n //Return geometry to defaultSymbol\n _(this.#highlightElementIds)\n .map((elemId) => this.#elements[elemId]?.geometry)\n .compact()\n .forEach((geometry) => {\n if (geometry instanceof ui.UIMarker) return\n\n if (geometry instanceof Marker) {\n this.showGeometryByElementId(geometry.properties.id)\n return\n }\n\n try {\n const defaultSymbol = geometry.options.defaultSymbol\n geometry.updateSymbol(defaultSymbol)\n } catch (err) {\n console.log(\n `error cannot return to defaultSymbol, check if \"defaultSymbol\" exists in element creation function`\n )\n }\n })\n this.#highlightElementIds = []\n }\n\n setHighlightedObject(targetObjectIds, options = {}) {\n const { symbolSet } = _.merge({}, DEFAULT_HIGHLIGHT_OPTIONS, options)\n const {\n getElementSymbol,\n getHilighPolygonalSymbol,\n createHighlight2DAmenityMarkerFrom3DMarker,\n } = this.#styler\n const objects = this.threeLayer?.getBaseObjects()\n const objectsToHighlight = objects.filter(({ properties }) =>\n targetObjectIds.includes(properties?.id)\n )\n\n const defaultSymbol = getHilighPolygonalSymbol(\"Polygon\")\n const targetSymbol = symbolSet ? getElementSymbol(symbolSet) : null\n const { polygonFill: color } = _.isEmpty(targetSymbol)\n ? defaultSymbol\n : targetSymbol\n\n const amenityHighlightMode = _.get(\n this.#mapConfig,\n \"amenity_highlight_mode\",\n \"\"\n )\n objectsToHighlight.forEach((obj) => {\n //highlight extruded polygon\n if (obj.type === \"ExtrudePolygon\") {\n const newController = createHighlighExtrudeObjectController(obj, {\n color,\n })\n newController.start()\n this.#highlightObjectControllers.push(newController)\n }\n //highlight amenity marker\n if (obj instanceof SpriteMarker) {\n if (amenityHighlightMode === \"2DMarker\") {\n const hilight2DLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME)\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n obj.hide()\n const { properties: featureProperties } = obj\n createHighlight2DAmenityMarkerFrom3DMarker(\n featureProperties,\n extrudeConfig\n )\n .on(\"click\", this.handleClickElement)\n .addTo(hilight2DLayer)\n } else {\n obj.highlight()\n }\n }\n\n if (obj instanceof Billboard) {\n const newController = createHighlighBillboardController(obj)\n newController.start()\n this.#highlightObjectControllers.push(newController)\n }\n })\n\n this.#highlightObjectIds = targetObjectIds\n }\n\n clearHighlightObject() {\n this.#highlightObjectControllers.forEach((controller) => {\n if (_.isFunction(controller?.clear)) controller.clear()\n })\n this.#highlightObjectIds.forEach((objIds) => {\n const objects = this.threeLayer?.getBaseObjects()\n const objectToResetHighlight = objects.find(({ properties }) =>\n objIds.includes(properties?.id)\n )\n if (objectToResetHighlight instanceof SpriteMarker) {\n objectToResetHighlight.show()\n objectToResetHighlight.removeHighlight()\n }\n })\n // Clear the highlight object controllers\n this.#highlightObjectControllers = []\n this.#highlightObjectIds = []\n }\n\n /**\n * User Location\n ****************************/\n // TODO: To consider if we should use setter `set userLocation` instead?\n\n addUserLocation(value) {\n const { createUserLocationMarker } = this.#styler\n\n this.#userLocationGeometry = value\n\n const { properties, feature_type } = value\n\n // If UserLocationGeometry not exists, create one.\n\n const markerLayer = this.map.getLayer(USER_LOCATION_LAYER_NAME)\n\n if (!this.#userLocationElement?.geometry && markerLayer) {\n const geometry = createUserLocationMarker(value)\n geometry.addTo(markerLayer)\n\n // Add marker to this.#elements\n const element = {\n geometry,\n properties,\n featureType: feature_type,\n feature: value,\n }\n this.#elements[USER_LOCATION_ELEMENT_ID] = element\n this.#userLocationElement = element\n\n this.updateUserLocationSymbolByLocale(this.locale)\n }\n }\n\n updateUserLocationSymbolByLocale(locale: string) {\n const userLocationGeometry = _.get(\n this.#elements,\n `${USER_LOCATION_ELEMENT_ID}.geometry`\n )\n\n if (!userLocationGeometry) return\n\n const currentSymbol = userLocationGeometry.getSymbol()\n\n /**\n * Localized user location marker example.\n * Supports locale-based marker files.\n *\n * Example:\n * {\n * \"markerFile\": \"logo_url\", // Default marker\n * \"locale_symbol\": { \"th\": { \"markerFile\": \"logo_url\" }, \"default\": { \"markerFile\": \"logo_url\" } }\n * }\n */\n const localeSymbolToUpdate = currentSymbol.map((symbol) => {\n const localeSymbol =\n _.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) ||\n _.get(symbol, `${LOCALE_SYMBOL_KEY}.default`)\n if (!_.isPlainObject(localeSymbol)) return symbol\n\n return {\n ...symbol,\n ...localeSymbol,\n }\n })\n userLocationGeometry?.updateSymbol(localeSymbolToUpdate)\n }\n\n removeUserLocation() {\n this.#userLocationGeometry = null\n if (this.#userLocationElement) {\n const { geometry } = this.#userLocationElement\n if (geometry) geometry.remove()\n\n this.#userLocationElement = null\n this.#elements[USER_LOCATION_ELEMENT_ID] = null\n }\n }\n\n showUserLocationMarker() {\n this.#userLocationElement?.geometry.show()\n }\n\n hideUserLocationMarker() {\n this.#userLocationElement?.geometry.hide()\n }\n\n addLastUserLocation(value) {\n const newLastLocationId = value?.id\n // If the last location ID is undefined or exists, no new marker will be added.\n const isExists =\n this.#lastUserLocationGeometries.findIndex(\n ({ feature }) => feature?.id === newLastLocationId\n ) >= 0\n\n if (!newLastLocationId || isExists) return\n\n const { createLastUserLocationMarker } = this.#styler\n\n this.#lastUserLocationGeometries = [\n ...this.#lastUserLocationGeometries,\n value,\n ]\n\n const { properties, feature_type, id } = value\n\n const markerLayer = this.map.getLayer(USER_LOCATION_LAYER_NAME)\n\n const geometry = createLastUserLocationMarker(value)\n if (!geometry) return\n geometry.addTo(markerLayer)\n\n // Add marker to this.#elements\n const element = {\n geometry,\n properties,\n featureType: feature_type,\n feature: value,\n }\n this.#elements[`${LAST_USER_LOCATION_ELEMENT_ID_PREFIX}${id}`] = element\n this.#lastUserLocationElements = [\n ...this.#lastUserLocationElements,\n element,\n ]\n }\n\n removeLastUserLocation() {\n this.#lastUserLocationGeometries = []\n if (\n this.#lastUserLocationElements &&\n this.#lastUserLocationElements.length > 0\n ) {\n for (const lastUserLocationElem of this.#lastUserLocationElements) {\n const { geometry, properties = {} } = lastUserLocationElem\n if (geometry) {\n geometry.remove()\n delete this.#elements[`last_user_location-${properties?.id}`]\n }\n }\n this.#lastUserLocationElements = []\n }\n }\n\n hideLastUserLocationMarker() {\n for (const lastUserLocationElem of this.#lastUserLocationElements) {\n const { geometry } = lastUserLocationElem\n if (geometry) geometry.hide()\n }\n }\n\n /**\n * END of User Location\n ****************************/\n\n showGeometryByElementId = (elementId): void => {\n const geometry: Geometry | undefined = _.get(\n this.#elements,\n `${elementId}.geometry`\n )\n if (geometry) geometry.show()\n }\n\n hideGeometryByElementId = (elementId): void => {\n const geometry: Geometry = _.get(this.#elements, `${elementId}.geometry`)\n if (geometry) geometry.hide()\n }\n\n setSpriteMarkersOpacity = (opacity: number = 1): void => {\n const spriteMarkerObjects = this.#spriteMarkerObjects\n spriteMarkerObjects?.forEach((baseObject) => {\n baseObject.getObject3d().traverse((child) => {\n if (child.isLine || child.isSprite) {\n child.material.opacity = opacity\n }\n })\n })\n }\n\n setFeatureObject3DsOpacity = (opacity: number = 1): void => {\n const objects = this.#object3ds\n objects?.forEach((baseObject) => {\n if (baseObject instanceof NavigationPath) return\n baseObject.getObject3d().traverse((child) => {\n if (child.isMesh === true) {\n child.material.opacity = opacity\n }\n })\n })\n }\n\n /*\n * Enable or disable the fading effect based on the zoom level for all layers except the Venue Model.\n * This function applies when extruded units exceed the edges of the Venue Model while zooming out.\n * It can be enabled only when the Venue Model is present.\n */\n disableLayersFadingOnZoom = (): void => {\n this.#isLayersFadingOnZoom = false\n }\n\n enableLayersFadingOnZoom = (): void => {\n this.#isLayersFadingOnZoom = this.#venueObjects.length !== 0\n }\n\n /**\n * Navigation\n ****************************/\n combineNearbyLineStrings(\n lineStrings: Feature<LineStringType, GeoJsonProperties>[],\n options: {\n properties?: GeoJsonProperties\n distance?: number\n } = { properties: {}, distance: 0.0003 }\n // 0.0003 = 30cm\n ) {\n const { properties = {}, distance = 0.0003 } = options || {}\n const combinedLineStrings = []\n const accLine = []\n if (lineStrings.length === 1) return lineStrings\n\n for (let i = 0; i < lineStrings.length; i++) {\n const line = lineStrings[i]\n const coords = line.geometry.coordinates\n const prevLine = lineStrings[i - 1]\n const firstCoord = _.first(coords)\n const isFirstLine = i === 0\n\n if (isFirstLine) {\n accLine.push(...coords)\n continue\n }\n\n const prevLastCoord = _.last(prevLine.geometry.coordinates)\n const isNearby =\n turfDistance(point(firstCoord), point(prevLastCoord)) < distance\n\n if (!isNearby) {\n const remainingLines = lineStrings.slice(i)\n const res = this.combineNearbyLineStrings(remainingLines, properties)\n combinedLineStrings.push(...res)\n break\n }\n accLine.push(...coords)\n }\n combinedLineStrings.push(lineString(accLine, properties))\n return combinedLineStrings\n }\n\n createNavigationGeometries = (stepGeometries, destinationFeature) => {\n const {\n createOriginMarker,\n createDestinationPinMarker,\n createDestinationLogoMarker,\n create3DStepPath,\n } = this.#styler\n const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME)\n\n const linesByOrdinal = _(stepGeometries)\n .filter(({ geometry }) => geometry.type === \"LineString\")\n .groupBy(\"properties.ordinal\")\n .value()\n\n const joinedLines = _(linesByOrdinal).reduce((acc, lines, key) => {\n const joined = this.combineNearbyLineStrings(lines, {\n properties: { ordinal: +key },\n })\n return [...acc, ...joined]\n }, [])\n\n joinedLines.forEach((line, index) => {\n try {\n const navPath: NavigationPath = create3DStepPath(line, this.threeLayer)\n this.threeLayer.addMesh([navPath])\n this.#navigationGeometries[`line-${index}`] = navPath\n this.#object3ds.push(navPath)\n } catch (err) {\n console.log(err)\n }\n })\n\n stepGeometries.forEach((stepGeometry) => {\n const { geometry, properties, feature_type = null } = stepGeometry\n let stepElement\n try {\n switch (geometry.type) {\n // Create a destination marker and route path\n case \"Point\":\n switch (feature_type) {\n case \"origin-marker\":\n stepElement =\n createOriginMarker(stepGeometry).addTo(routeMarkerLayer)\n break\n case \"destination-marker\":\n const extrudeConfig = _.get(this.#mapConfig, \"extrude\")\n if (destinationFeature.feature_type === \"occupant\") {\n const stepId = _.get(stepGeometry, \"id\")\n // !Update step ID to occupant destination feature ID to prevent unexpected clearing of occupant element from map\n const normalizedDestinationFeature = {\n ...destinationFeature,\n id: stepId,\n }\n const logoUrl = _.get(\n normalizedDestinationFeature,\n \"properties.logo.url\"\n )\n const createOccupantDestinationMarkerFn = logoUrl\n ? createDestinationLogoMarker\n : createDestinationPinMarker\n stepElement = createOccupantDestinationMarkerFn(\n normalizedDestinationFeature,\n { extrudeConfig }\n ).addTo(routeMarkerLayer)\n break\n }\n stepElement = createDestinationPinMarker(destinationFeature, {\n extrudeConfig,\n }).addTo(routeMarkerLayer)\n break\n default:\n this.#navigationGeometries[stepGeometry.id] = stepElement\n break\n }\n break\n default:\n break\n }\n if (stepElement) {\n const { id, feature_type: featureType } = stepGeometry\n // Add tot Elements object\n this.#elements[id] = {\n geometry: stepElement,\n featureType,\n properties: { ...stepGeometry, ...properties },\n }\n //\n }\n } catch (err) {\n // console.log(err, {\n // index: index,\n // stepGeometries,\n // })\n // throw err;\n console.log(err)\n }\n })\n }\n\n createOverviewStepPathByOrdinal = (stepGeometries, viewingOrdinal) => {\n const { createLineStringFromGeometries } = this.#styler\n const initialStepGeometries = stepGeometries\n .filter(({ properties }) => properties.ordinal === viewingOrdinal)\n .map(({ geometry }) => geometry)\n return createLineStringFromGeometries(initialStepGeometries)\n }\n\n clearNavigationGeometries(): void {\n // Remove origin and destination markers from the highlight layer\n const routeMarkerLayer = this.map.getLayer(\n HIGHLIGHT_LAYER_NAME\n ) as OverlayLayer\n const originMarkerGeometry = _.get(\n this.#elements,\n `${ORIGIN_MARKER_ID}.geometry`\n )\n const destinationMarkerGeometry = _.get(\n this.#elements,\n `${DESTINATION_MARKER_ID}.geometry`\n )\n const geometriesToRemove = _.compact([\n originMarkerGeometry,\n destinationMarkerGeometry,\n ])\n\n routeMarkerLayer.removeGeometry(geometriesToRemove)\n\n this.#elements[ORIGIN_MARKER_ID] = null\n this.#elements[DESTINATION_MARKER_ID] = null\n\n // Filter out NavigationPath objects from the global this.#object3ds list\n this.#object3ds = this.#object3ds.filter(\n (obj) => !(obj instanceof NavigationPath)\n )\n\n // Remove related navigation geometry objects\n const objects = this.#navigationGeometries || {}\n _.forEach(objects, (obj) => {\n if (!obj) return\n this.#navigationGeometries[obj.properties.id] = null\n obj.remove()\n })\n }\n /**\n * END of Navigation\n ****************************/\n\n /**\n * hide/show venue 3dmodel\n **/\n\n hideVenueObjects = () => {\n this.showVenueObject = false\n }\n showVenueObjects = () => {\n this.showVenueObject = true\n }\n\n /**\n * Other functions\n */\n\n enableClick = () => this.map.config({ geometryEvents: true })\n disableClick = () => this.map.config({ geometryEvents: false })\n\n freeze = () => this.map.config({ zoomable: false, draggable: false })\n unfreeze = () => this.map.config({ zoomable: true, draggable: true })\n\n /**\n * render (frame)\n */\n getTargetViewCenter = (\n targetView,\n options = { offset: { top: 0, left: 0, right: 0, bottom: 0 } }\n ) => {\n // Extend the input targetView with default values from the current view if not provided\n const map = this.map\n const { offset } = options\n const { top = 0, left = 0, right = 0, bottom = 0 } = offset\n // Temporarily set the map to the target view to calculate the extent.\n // This approach requires that the map view can be adjusted without triggering a visible change.\n const originalState = {\n bearing: map.getBearing(),\n center: map.getCenter(),\n pitch: map.getPitch(),\n zoom: map.getZoom(),\n }\n\n const finalView = {\n bearing: _.isNil(targetView.bearing)\n ? map.getBearing()\n : targetView.bearing,\n center: _.isNil(targetView.center) ? map.getCenter() : targetView.center,\n pitch: _.isNil(targetView.pitch) ? map.getPitch() : targetView.pitch,\n zoom: _.isNil(targetView.zoom) ? map.getZoom() : targetView.zoom,\n }\n\n map.setView(finalView)\n\n // Calculate the visible extent at this state\n const projectedTargetCenter = map\n .coordinateToContainerPoint(finalView.center)\n .add(right / 2 - left / 2, bottom / 2 - top / 2)\n const adjustedTargetCenter = map.containerPointToCoordinate(\n projectedTargetCenter\n )\n // Reset the map to its original state to avoid any visible changes\n map.setView(originalState)\n return adjustedTargetCenter\n }\n\n setMaxExtent(extent: Extent) {\n return this.map.setMaxExtent(extent)\n }\n\n render() {\n // TODO: Update User Location marker position\n const view = this.map.getView()\n const currBearing = view.bearing\n this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate\n if (this.threeLayer._needsUpdate) {\n // @ts-ignore\n this.threeLayer.redraw()\n }\n\n if (this.threeLayer) {\n const objectOpacity = _.clamp(38 - 2 * this.camera.getZoom(), 0, 1)\n\n this.#objects.forEach((object) => {\n object.getObject3d().traverse((child) => {\n if (child.isMesh) child.material.opacity = objectOpacity\n //TODO: recheck this line if it actually works\n /** set Mesh visible = false when opacity is 0\n * and true when opacity > 0\n */\n child.visible = !!objectOpacity\n })\n object.getObject3d().visible = !!objectOpacity\n })\n\n if (this.#billboardObjects) {\n this.#billboardObjects.forEach((object) => {\n const objectScale = _.clamp(\n 20 - 1 * this.camera.getZoom(),\n 1,\n 1.05\n )\n object.getObject3d().scale.set(objectScale, objectScale, 1)\n })\n }\n\n /*\n * The layer appears while zooming in and disappears when zooming out,\n * fully vanishing when the Venue Model is visible (opacity: 1).\n */\n if (this.#isLayersFadingOnZoom) {\n const layerOpacity = _.clamp(1 - objectOpacity, 0, 1)\n // Fading 2D layers.\n LAYERS.forEach((layerKey) => {\n const layer = this.map.getLayer(layerKey)\n if (layer) layer.setOpacity(layerOpacity)\n })\n\n // Fading 3D units, such as extruded units.\n this.setFeatureObject3DsOpacity(layerOpacity)\n\n // Fading sprite markers, such as billboards and amenity markers.\n this.setSpriteMarkersOpacity(layerOpacity)\n }\n\n this.#venueObjects.forEach((object) => {\n object.getObject3d().traverse((child) => {\n if (child.isMesh) child.material.opacity = objectOpacity\n /** set Mesh visible = false when opacity is 0\n * and true when opacity > 0\n */\n child.visible = this.showVenueObject && objectOpacity > 0.4\n })\n })\n\n // Update bearing to each GroundLabel to determine if text should flip or not\n this.#groundObjects.forEach((gLabel) => {\n gLabel.bearing = currBearing\n })\n }\n\n this.#animationsToRun.forEach(({ callback }) => callback(this))\n\n //update TWEEN.js animaton\n TWEEN.update()\n\n requestAnimationFrame(this.render.bind(this))\n }\n}\n","import {\n BBox,\n Feature,\n FeatureCollection,\n Geometry,\n GeometryCollection,\n GeometryObject,\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n Position,\n GeoJsonProperties,\n} from \"geojson\";\n\nimport { Id } from \"./lib/geojson.js\";\nexport * from \"./lib/geojson.js\";\n\n/**\n * @module helpers\n */\n\n// TurfJS Combined Types\nexport type Coord = Feature<Point> | Point | Position;\n\n/**\n * Linear measurement units.\n *\n * ⚠️ Warning. Be aware of the implications of using radian or degree units to\n * measure distance. The distance represented by a degree of longitude *varies*\n * depending on latitude.\n *\n * See https://www.thoughtco.com/degree-of-latitude-and-longitude-distance-4070616\n * for an illustration of this behaviour.\n *\n * @typedef\n */\nexport type Units =\n | \"meters\"\n | \"metres\"\n | \"millimeters\"\n | \"millimetres\"\n | \"centimeters\"\n | \"centimetres\"\n | \"kilometers\"\n | \"kilometres\"\n | \"miles\"\n | \"nauticalmiles\"\n | \"inches\"\n | \"yards\"\n | \"feet\"\n | \"radians\"\n | \"degrees\";\n\n/**\n * Area measurement units.\n *\n * @typedef\n */\nexport type AreaUnits =\n | Exclude<Units, \"radians\" | \"degrees\">\n | \"acres\"\n | \"hectares\";\n\n/**\n * Grid types.\n *\n * @typedef\n */\nexport type Grid = \"point\" | \"square\" | \"hex\" | \"triangle\";\n\n/**\n * Shorthand corner identifiers.\n *\n * @typedef\n */\nexport type Corners = \"sw\" | \"se\" | \"nw\" | \"ne\" | \"center\" | \"centroid\";\n\n/**\n * Geometries made up of lines i.e. lines and polygons.\n *\n * @typedef\n */\nexport type Lines = LineString | MultiLineString | Polygon | MultiPolygon;\n\n/**\n * Convenience type for all possible GeoJSON.\n *\n * @typedef\n */\nexport type AllGeoJSON =\n | Feature\n | FeatureCollection\n | Geometry\n | GeometryCollection;\n\n/**\n * The Earth radius in meters. Used by Turf modules that model the Earth as a sphere. The {@link https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius mean radius} was selected because it is {@link https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended recommended } by the Haversine formula (used by turf/distance) to reduce error.\n *\n * @constant\n */\nexport const earthRadius = 6371008.8;\n\n/**\n * Unit of measurement factors based on earthRadius.\n *\n * Keys are the name of the unit, values are the number of that unit in a single radian\n *\n * @constant\n */\nexport const factors: Record<Units, number> = {\n centimeters: earthRadius * 100,\n centimetres: earthRadius * 100,\n degrees: 360 / (2 * Math.PI),\n feet: earthRadius * 3.28084,\n inches: earthRadius * 39.37,\n kilometers: earthRadius / 1000,\n kilometres: earthRadius / 1000,\n meters: earthRadius,\n metres: earthRadius,\n miles: earthRadius / 1609.344,\n millimeters: earthRadius * 1000,\n millimetres: earthRadius * 1000,\n nauticalmiles: earthRadius / 1852,\n radians: 1,\n yards: earthRadius * 1.0936,\n};\n\n/**\n\n * Area of measurement factors based on 1 square meter.\n *\n * @constant\n */\nexport const areaFactors: Record<AreaUnits, number> = {\n acres: 0.000247105,\n centimeters: 10000,\n centimetres: 10000,\n feet: 10.763910417,\n hectares: 0.0001,\n inches: 1550.003100006,\n kilometers: 0.000001,\n kilometres: 0.000001,\n meters: 1,\n metres: 1,\n miles: 3.86e-7,\n nauticalmiles: 2.9155334959812285e-7,\n millimeters: 1000000,\n millimetres: 1000000,\n yards: 1.195990046,\n};\n\n/**\n * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.\n *\n * @function\n * @param {GeometryObject} geometry input geometry\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<GeometryObject, GeoJsonProperties>} a GeoJSON Feature\n * @example\n * var geometry = {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * };\n *\n * var feature = turf.feature(geometry);\n *\n * //=feature\n */\nexport function feature<\n G extends GeometryObject = Geometry,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n geom: G | null,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<G, P> {\n const feat: any = { type: \"Feature\" };\n if (options.id === 0 || options.id) {\n feat.id = options.id;\n }\n if (options.bbox) {\n feat.bbox = options.bbox;\n }\n feat.properties = properties || {};\n feat.geometry = geom;\n return feat;\n}\n\n/**\n * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.\n * For GeometryCollection type use `helpers.geometryCollection`\n *\n * @function\n * @param {(\"Point\" | \"LineString\" | \"Polygon\" | \"MultiPoint\" | \"MultiLineString\" | \"MultiPolygon\")} type Geometry Type\n * @param {Array<any>} coordinates Coordinates\n * @param {Object} [options={}] Optional Parameters\n * @returns {Geometry} a GeoJSON Geometry\n * @example\n * var type = \"Point\";\n * var coordinates = [110, 50];\n * var geometry = turf.geometry(type, coordinates);\n * // => geometry\n */\nexport function geometry(\n type:\n | \"Point\"\n | \"LineString\"\n | \"Polygon\"\n | \"MultiPoint\"\n | \"MultiLineString\"\n | \"MultiPolygon\",\n coordinates: any[],\n _options: Record<string, never> = {}\n) {\n switch (type) {\n case \"Point\":\n return point(coordinates).geometry;\n case \"LineString\":\n return lineString(coordinates).geometry;\n case \"Polygon\":\n return polygon(coordinates).geometry;\n case \"MultiPoint\":\n return multiPoint(coordinates).geometry;\n case \"MultiLineString\":\n return multiLineString(coordinates).geometry;\n case \"MultiPolygon\":\n return multiPolygon(coordinates).geometry;\n default:\n throw new Error(type + \" is invalid\");\n }\n}\n\n/**\n * Creates a {@link Point} {@link Feature} from a Position.\n *\n * @function\n * @param {Position} coordinates longitude, latitude position (each in decimal degrees)\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<Point, GeoJsonProperties>} a Point feature\n * @example\n * var point = turf.point([-75.343, 39.984]);\n *\n * //=point\n */\nexport function point<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<Point, P> {\n if (!coordinates) {\n throw new Error(\"coordinates is required\");\n }\n if (!Array.isArray(coordinates)) {\n throw new Error(\"coordinates must be an Array\");\n }\n if (coordinates.length < 2) {\n throw new Error(\"coordinates must be at least 2 numbers long\");\n }\n if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {\n throw new Error(\"coordinates must contain numbers\");\n }\n\n const geom: Point = {\n type: \"Point\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.\n *\n * @function\n * @param {Position[]} coordinates an array of Points\n * @param {GeoJsonProperties} [properties={}] Translate these properties to each Feature\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north]\n * associated with the FeatureCollection\n * @param {Id} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<Point>} Point Feature\n * @example\n * var points = turf.points([\n * [-75, 39],\n * [-80, 45],\n * [-78, 50]\n * ]);\n *\n * //=points\n */\nexport function points<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<Point, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return point(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.\n *\n * @function\n * @param {Position[][]} coordinates an array of LinearRings\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<Polygon, GeoJsonProperties>} Polygon Feature\n * @example\n * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });\n *\n * //=polygon\n */\nexport function polygon<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<Polygon, P> {\n for (const ring of coordinates) {\n if (ring.length < 4) {\n throw new Error(\n \"Each LinearRing of a Polygon must have 4 or more Positions.\"\n );\n }\n\n if (ring[ring.length - 1].length !== ring[0].length) {\n throw new Error(\"First and last Position are not equivalent.\");\n }\n\n for (let j = 0; j < ring[ring.length - 1].length; j++) {\n // Check if first point of Polygon contains two numbers\n if (ring[ring.length - 1][j] !== ring[0][j]) {\n throw new Error(\"First and last Position are not equivalent.\");\n }\n }\n }\n const geom: Polygon = {\n type: \"Polygon\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.\n *\n * @function\n * @param {Position[][][]} coordinates an array of Polygon coordinates\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<Polygon, GeoJsonProperties>} Polygon FeatureCollection\n * @example\n * var polygons = turf.polygons([\n * [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],\n * [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],\n * ]);\n *\n * //=polygons\n */\nexport function polygons<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<Polygon, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return polygon(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Creates a {@link LineString} {@link Feature} from an Array of Positions.\n *\n * @function\n * @param {Position[]} coordinates an array of Positions\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<LineString, GeoJsonProperties>} LineString Feature\n * @example\n * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});\n * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});\n *\n * //=linestring1\n * //=linestring2\n */\nexport function lineString<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<LineString, P> {\n if (coordinates.length < 2) {\n throw new Error(\"coordinates must be an array of two or more positions\");\n }\n const geom: LineString = {\n type: \"LineString\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.\n *\n * @function\n * @param {Position[][]} coordinates an array of LinearRings\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north]\n * associated with the FeatureCollection\n * @param {Id} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<LineString, GeoJsonProperties>} LineString FeatureCollection\n * @example\n * var linestrings = turf.lineStrings([\n * [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],\n * [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]\n * ]);\n *\n * //=linestrings\n */\nexport function lineStrings<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<LineString, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return lineString(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.\n *\n * @function\n * @param {Array<Feature<GeometryObject, GeoJsonProperties>>} features input features\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {FeatureCollection<GeometryObject, GeoJsonProperties>} FeatureCollection of Features\n * @example\n * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});\n * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});\n * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});\n *\n * var collection = turf.featureCollection([\n * locationA,\n * locationB,\n * locationC\n * ]);\n *\n * //=collection\n */\nexport function featureCollection<\n G extends GeometryObject = Geometry,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n features: Array<Feature<G, P>>,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<G, P> {\n const fc: any = { type: \"FeatureCollection\" };\n if (options.id) {\n fc.id = options.id;\n }\n if (options.bbox) {\n fc.bbox = options.bbox;\n }\n fc.features = features;\n return fc;\n}\n\n/**\n * Creates a {@link Feature}<{@link MultiLineString}> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Position[][]} coordinates an array of LineStrings\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiLineString, GeoJsonProperties>} a MultiLineString feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);\n *\n * //=multiLine\n */\nexport function multiLineString<\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiLineString, P> {\n const geom: MultiLineString = {\n type: \"MultiLineString\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature}<{@link MultiPoint}> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Position[]} coordinates an array of Positions\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiPoint, GeoJsonProperties>} a MultiPoint feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiPt = turf.multiPoint([[0,0],[10,10]]);\n *\n * //=multiPt\n */\nexport function multiPoint<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiPoint, P> {\n const geom: MultiPoint = {\n type: \"MultiPoint\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature}<{@link MultiPolygon}> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Position[][][]} coordinates an array of Polygons\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiPolygon, GeoJsonProperties>} a multipolygon feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);\n *\n * //=multiPoly\n *\n */\nexport function multiPolygon<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiPolygon, P> {\n const geom: MultiPolygon = {\n type: \"MultiPolygon\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a Feature<GeometryCollection> based on a\n * coordinate array. Properties can be added optionally.\n *\n * @function\n * @param {Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>} geometries an array of GeoJSON Geometries\n * @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {Id} [options.id] Identifier associated with the Feature\n * @returns {Feature<GeometryCollection, GeoJsonProperties>} a GeoJSON GeometryCollection Feature\n * @example\n * var pt = turf.geometry(\"Point\", [100, 0]);\n * var line = turf.geometry(\"LineString\", [[101, 0], [102, 1]]);\n * var collection = turf.geometryCollection([pt, line]);\n *\n * // => collection\n */\nexport function geometryCollection<\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n geometries: Array<\n Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon\n >,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<GeometryCollection, P> {\n const geom: GeometryCollection = {\n type: \"GeometryCollection\",\n geometries,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Round number to precision\n *\n * @function\n * @param {number} num Number\n * @param {number} [precision=0] Precision\n * @returns {number} rounded number\n * @example\n * turf.round(120.4321)\n * //=120\n *\n * turf.round(120.4321, 2)\n * //=120.43\n */\nexport function round(num: number, precision = 0): number {\n if (precision && !(precision >= 0)) {\n throw new Error(\"precision must be a positive number\");\n }\n const multiplier = Math.pow(10, precision || 0);\n return Math.round(num * multiplier) / multiplier;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @function\n * @param {number} radians in radians across the sphere\n * @param {Units} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} distance\n */\nexport function radiansToLength(\n radians: number,\n units: Units = \"kilometers\"\n): number {\n const factor = factors[units];\n if (!factor) {\n throw new Error(units + \" units is invalid\");\n }\n return radians * factor;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @function\n * @param {number} distance in real units\n * @param {Units} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} radians\n */\nexport function lengthToRadians(\n distance: number,\n units: Units = \"kilometers\"\n): number {\n const factor = factors[units];\n if (!factor) {\n throw new Error(units + \" units is invalid\");\n }\n return distance / factor;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet\n *\n * @function\n * @param {number} distance in real units\n * @param {Units} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} degrees\n */\nexport function lengthToDegrees(distance: number, units?: Units): number {\n return radiansToDegrees(lengthToRadians(distance, units));\n}\n\n/**\n * Converts any bearing angle from the north line direction (positive clockwise)\n * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line\n *\n * @function\n * @param {number} bearing angle, between -180 and +180 degrees\n * @returns {number} angle between 0 and 360 degrees\n */\nexport function bearingToAzimuth(bearing: number): number {\n let angle = bearing % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\n\n/**\n * Converts any azimuth angle from the north line direction (positive clockwise)\n * and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line\n *\n * @function\n * @param {number} angle between 0 and 360 degrees\n * @returns {number} bearing between -180 and +180 degrees\n */\nexport function azimuthToBearing(angle: number): number {\n // Ignore full revolutions (multiples of 360)\n angle = angle % 360;\n\n if (angle > 180) {\n return angle - 360;\n } else if (angle < -180) {\n return angle + 360;\n }\n\n return angle;\n}\n\n/**\n * Converts an angle in radians to degrees\n *\n * @function\n * @param {number} radians angle in radians\n * @returns {number} degrees between 0 and 360 degrees\n */\nexport function radiansToDegrees(radians: number): number {\n // % (2 * Math.PI) radians in case someone passes value > 2π\n const normalisedRadians = radians % (2 * Math.PI);\n return (normalisedRadians * 180) / Math.PI;\n}\n\n/**\n * Converts an angle in degrees to radians\n *\n * @function\n * @param {number} degrees angle between 0 and 360 degrees\n * @returns {number} angle in radians\n */\nexport function degreesToRadians(degrees: number): number {\n // % 360 degrees in case someone passes value > 360\n const normalisedDegrees = degrees % 360;\n return (normalisedDegrees * Math.PI) / 180;\n}\n\n/**\n * Converts a length from one unit to another.\n *\n * @function\n * @param {number} length Length to be converted\n * @param {Units} [originalUnit=\"kilometers\"] Input length unit\n * @param {Units} [finalUnit=\"kilometers\"] Returned length unit\n * @returns {number} The converted length\n */\nexport function convertLength(\n length: number,\n originalUnit: Units = \"kilometers\",\n finalUnit: Units = \"kilometers\"\n): number {\n if (!(length >= 0)) {\n throw new Error(\"length must be a positive number\");\n }\n return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);\n}\n\n/**\n * Converts an area from one unit to another.\n *\n * @function\n * @param {number} area Area to be converted\n * @param {AreaUnits} [originalUnit=\"meters\"] Input area unit\n * @param {AreaUnits} [finalUnit=\"kilometers\"] Returned area unit\n * @returns {number} The converted length\n */\nexport function convertArea(\n area: number,\n originalUnit: AreaUnits = \"meters\",\n finalUnit: AreaUnits = \"kilometers\"\n): number {\n if (!(area >= 0)) {\n throw new Error(\"area must be a positive number\");\n }\n\n const startFactor = areaFactors[originalUnit];\n if (!startFactor) {\n throw new Error(\"invalid original units\");\n }\n\n const finalFactor = areaFactors[finalUnit];\n if (!finalFactor) {\n throw new Error(\"invalid final units\");\n }\n\n return (area / startFactor) * finalFactor;\n}\n\n/**\n * isNumber\n *\n * @function\n * @param {any} num Number to validate\n * @returns {boolean} true/false\n * @example\n * turf.isNumber(123)\n * //=true\n * turf.isNumber('foo')\n * //=false\n */\nexport function isNumber(num: any): boolean {\n return !isNaN(num) && num !== null && !Array.isArray(num);\n}\n\n/**\n * isObject\n *\n * @function\n * @param {any} input variable to validate\n * @returns {boolean} true/false, including false for Arrays and Functions\n * @example\n * turf.isObject({elevation: 10})\n * //=true\n * turf.isObject('foo')\n * //=false\n */\nexport function isObject(input: any): boolean {\n return input !== null && typeof input === \"object\" && !Array.isArray(input);\n}\n\n/**\n * Validate BBox\n *\n * @private\n * @param {any} bbox BBox to validate\n * @returns {void}\n * @throws {Error} if BBox is not valid\n * @example\n * validateBBox([-180, -40, 110, 50])\n * //=OK\n * validateBBox([-180, -40])\n * //=Error\n * validateBBox('Foo')\n * //=Error\n * validateBBox(5)\n * //=Error\n * validateBBox(null)\n * //=Error\n * validateBBox(undefined)\n * //=Error\n */\nexport function validateBBox(bbox: any): void {\n if (!bbox) {\n throw new Error(\"bbox is required\");\n }\n if (!Array.isArray(bbox)) {\n throw new Error(\"bbox must be an Array\");\n }\n if (bbox.length !== 4 && bbox.length !== 6) {\n throw new Error(\"bbox must be an Array of 4 or 6 numbers\");\n }\n bbox.forEach((num) => {\n if (!isNumber(num)) {\n throw new Error(\"bbox must only contain numbers\");\n }\n });\n}\n\n/**\n * Validate Id\n *\n * @private\n * @param {any} id Id to validate\n * @returns {void}\n * @throws {Error} if Id is not valid\n * @example\n * validateId([-180, -40, 110, 50])\n * //=Error\n * validateId([-180, -40])\n * //=Error\n * validateId('Foo')\n * //=OK\n * validateId(5)\n * //=OK\n * validateId(null)\n * //=Error\n * validateId(undefined)\n * //=Error\n */\nexport function validateId(id: any): void {\n if (!id) {\n throw new Error(\"id is required\");\n }\n if ([\"string\", \"number\"].indexOf(typeof id) === -1) {\n throw new Error(\"id must be a number or a string\");\n }\n}\n","import { feature, point, lineString, isObject } from \"@turf/helpers\";\n\n/**\n * Callback for coordEach\n *\n * @callback coordEachCallback\n * @param {number[]} currentCoord The current coordinate being processed.\n * @param {number} coordIndex The current index of the coordinate being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over coordinates in any GeoJSON object, similar to Array.forEach()\n *\n * @function\n * @param {AllGeoJSON} geojson any GeoJSON object\n * @param {coordEachCallback} callback a method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)\n * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {\"foo\": \"bar\"}),\n * turf.point([36, 53], {\"hello\": \"world\"})\n * ]);\n *\n * turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=currentCoord\n * //=coordIndex\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * });\n */\nfunction coordEach(geojson, callback, excludeWrapCoord) {\n // Handles null Geometry -- Skips this GeoJSON\n if (geojson === null) return;\n var j,\n k,\n l,\n geometry,\n stopG,\n coords,\n geometryMaybeCollection,\n wrapShrink = 0,\n coordIndex = 0,\n isGeometryCollection,\n type = geojson.type,\n isFeatureCollection = type === \"FeatureCollection\",\n isFeature = type === \"Feature\",\n stop = isFeatureCollection ? geojson.features.length : 1;\n\n // This logic may look a little weird. The reason why it is that way\n // is because it's trying to be fast. GeoJSON supports multiple kinds\n // of objects at its root: FeatureCollection, Features, Geometries.\n // This function has the responsibility of handling all of them, and that\n // means that some of the `for` loops you see below actually just don't apply\n // to certain inputs. For instance, if you give this just a\n // Point geometry, then both loops are short-circuited and all we do\n // is gradually rename the input until it's called 'geometry'.\n //\n // This also aims to allocate as few resources as possible: just a\n // few numbers and booleans, rather than any temporary arrays as would\n // be required with the normalization approach.\n for (var featureIndex = 0; featureIndex < stop; featureIndex++) {\n geometryMaybeCollection = isFeatureCollection\n ? geojson.features[featureIndex].geometry\n : isFeature\n ? geojson.geometry\n : geojson;\n isGeometryCollection = geometryMaybeCollection\n ? geometryMaybeCollection.type === \"GeometryCollection\"\n : false;\n stopG = isGeometryCollection\n ? geometryMaybeCollection.geometries.length\n : 1;\n\n for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {\n var multiFeatureIndex = 0;\n var geometryIndex = 0;\n geometry = isGeometryCollection\n ? geometryMaybeCollection.geometries[geomIndex]\n : geometryMaybeCollection;\n\n // Handles null Geometry -- Skips this geometry\n if (geometry === null) continue;\n coords = geometry.coordinates;\n var geomType = geometry.type;\n\n wrapShrink =\n excludeWrapCoord &&\n (geomType === \"Polygon\" || geomType === \"MultiPolygon\")\n ? 1\n : 0;\n\n switch (geomType) {\n case null:\n break;\n case \"Point\":\n if (\n callback(\n coords,\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n multiFeatureIndex++;\n break;\n case \"LineString\":\n case \"MultiPoint\":\n for (j = 0; j < coords.length; j++) {\n if (\n callback(\n coords[j],\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n if (geomType === \"MultiPoint\") multiFeatureIndex++;\n }\n if (geomType === \"LineString\") multiFeatureIndex++;\n break;\n case \"Polygon\":\n case \"MultiLineString\":\n for (j = 0; j < coords.length; j++) {\n for (k = 0; k < coords[j].length - wrapShrink; k++) {\n if (\n callback(\n coords[j][k],\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n }\n if (geomType === \"MultiLineString\") multiFeatureIndex++;\n if (geomType === \"Polygon\") geometryIndex++;\n }\n if (geomType === \"Polygon\") multiFeatureIndex++;\n break;\n case \"MultiPolygon\":\n for (j = 0; j < coords.length; j++) {\n geometryIndex = 0;\n for (k = 0; k < coords[j].length; k++) {\n for (l = 0; l < coords[j][k].length - wrapShrink; l++) {\n if (\n callback(\n coords[j][k][l],\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n coordIndex++;\n }\n geometryIndex++;\n }\n multiFeatureIndex++;\n }\n break;\n case \"GeometryCollection\":\n for (j = 0; j < geometry.geometries.length; j++)\n if (\n coordEach(geometry.geometries[j], callback, excludeWrapCoord) ===\n false\n )\n return false;\n break;\n default:\n throw new Error(\"Unknown Geometry Type\");\n }\n }\n }\n}\n\n/**\n * Callback for coordReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback coordReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {number[]} currentCoord The current coordinate being processed.\n * @param {number} coordIndex The current index of the coordinate being processed.\n * Starts at index 0, if an initialValue is provided, and at index 1 otherwise.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce coordinates in any GeoJSON object, similar to Array.reduce()\n *\n * @function\n * @param {AllGeoJSON} geojson any GeoJSON object\n * @param {coordReduceCallback} callback a method that takes (previousValue, currentCoord, coordIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {\"foo\": \"bar\"}),\n * turf.point([36, 53], {\"hello\": \"world\"})\n * ]);\n *\n * turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=previousValue\n * //=currentCoord\n * //=coordIndex\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * return currentCoord;\n * });\n */\nfunction coordReduce(geojson, callback, initialValue, excludeWrapCoord) {\n var previousValue = initialValue;\n coordEach(\n geojson,\n function (\n currentCoord,\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) {\n if (coordIndex === 0 && initialValue === undefined)\n previousValue = currentCoord;\n else\n previousValue = callback(\n previousValue,\n currentCoord,\n coordIndex,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n );\n },\n excludeWrapCoord\n );\n return previousValue;\n}\n\n/**\n * Callback for propEach\n *\n * @callback propEachCallback\n * @param {GeoJsonProperties} currentProperties The current Properties being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over properties in any GeoJSON object, similar to Array.forEach()\n *\n * @function\n * @param {FeatureCollection|Feature} geojson any GeoJSON object\n * @param {propEachCallback} callback a method that takes (currentProperties, featureIndex)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.propEach(features, function (currentProperties, featureIndex) {\n * //=currentProperties\n * //=featureIndex\n * });\n */\nfunction propEach(geojson, callback) {\n var i;\n switch (geojson.type) {\n case \"FeatureCollection\":\n for (i = 0; i < geojson.features.length; i++) {\n if (callback(geojson.features[i].properties, i) === false) break;\n }\n break;\n case \"Feature\":\n callback(geojson.properties, 0);\n break;\n }\n}\n\n/**\n * Callback for propReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback propReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {GeoJsonProperties} currentProperties The current Properties being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce properties in any GeoJSON object into a single value,\n * similar to how Array.reduce works. However, in this case we lazily run\n * the reduction, so an array of all properties is unnecessary.\n *\n * @function\n * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object\n * @param {propReduceCallback} callback a method that takes (previousValue, currentProperties, featureIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {\n * //=previousValue\n * //=currentProperties\n * //=featureIndex\n * return currentProperties\n * });\n */\nfunction propReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n propEach(geojson, function (currentProperties, featureIndex) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentProperties;\n else\n previousValue = callback(previousValue, currentProperties, featureIndex);\n });\n return previousValue;\n}\n\n/**\n * Callback for featureEach\n *\n * @callback featureEachCallback\n * @param {Feature<any>} currentFeature The current Feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over features in any GeoJSON object, similar to\n * Array.forEach.\n *\n * @function\n * @param {FeatureCollection|Feature|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {featureEachCallback} callback a method that takes (currentFeature, featureIndex)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.featureEach(features, function (currentFeature, featureIndex) {\n * //=currentFeature\n * //=featureIndex\n * });\n */\nfunction featureEach(geojson, callback) {\n if (geojson.type === \"Feature\") {\n callback(geojson, 0);\n } else if (geojson.type === \"FeatureCollection\") {\n for (var i = 0; i < geojson.features.length; i++) {\n if (callback(geojson.features[i], i) === false) break;\n }\n }\n}\n\n/**\n * Callback for featureReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback featureReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature} currentFeature The current Feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce features in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection|Feature|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {featureReduceCallback} callback a method that takes (previousValue, currentFeature, featureIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {\"foo\": \"bar\"}),\n * turf.point([36, 53], {\"hello\": \"world\"})\n * ]);\n *\n * turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {\n * //=previousValue\n * //=currentFeature\n * //=featureIndex\n * return currentFeature\n * });\n */\nfunction featureReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n featureEach(geojson, function (currentFeature, featureIndex) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentFeature;\n else previousValue = callback(previousValue, currentFeature, featureIndex);\n });\n return previousValue;\n}\n\n/**\n * Get all coordinates from any GeoJSON object.\n *\n * @function\n * @param {AllGeoJSON} geojson any GeoJSON object\n * @returns {Array<Array<number>>} coordinate position array\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * var coords = turf.coordAll(features);\n * //= [[26, 37], [36, 53]]\n */\nfunction coordAll(geojson) {\n var coords = [];\n coordEach(geojson, function (coord) {\n coords.push(coord);\n });\n return coords;\n}\n\n/**\n * Callback for geomEach\n *\n * @callback geomEachCallback\n * @param {GeometryObject} currentGeometry The current Geometry being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {GeoJsonProperties} featureProperties The current Feature Properties being processed.\n * @param {BBox} featureBBox The current Feature BBox being processed.\n * @param {Id} featureId The current Feature Id being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over each geometry in any GeoJSON object, similar to Array.forEach()\n *\n * @function\n * @param {FeatureCollection|Feature|Geometry|GeometryObject|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {geomEachCallback} callback a method that takes (currentGeometry, featureIndex, featureProperties, featureBBox, featureId)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.geomEach(features, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {\n * //=currentGeometry\n * //=featureIndex\n * //=featureProperties\n * //=featureBBox\n * //=featureId\n * });\n */\nfunction geomEach(geojson, callback) {\n var i,\n j,\n g,\n geometry,\n stopG,\n geometryMaybeCollection,\n isGeometryCollection,\n featureProperties,\n featureBBox,\n featureId,\n featureIndex = 0,\n isFeatureCollection = geojson.type === \"FeatureCollection\",\n isFeature = geojson.type === \"Feature\",\n stop = isFeatureCollection ? geojson.features.length : 1;\n\n // This logic may look a little weird. The reason why it is that way\n // is because it's trying to be fast. GeoJSON supports multiple kinds\n // of objects at its root: FeatureCollection, Features, Geometries.\n // This function has the responsibility of handling all of them, and that\n // means that some of the `for` loops you see below actually just don't apply\n // to certain inputs. For instance, if you give this just a\n // Point geometry, then both loops are short-circuited and all we do\n // is gradually rename the input until it's called 'geometry'.\n //\n // This also aims to allocate as few resources as possible: just a\n // few numbers and booleans, rather than any temporary arrays as would\n // be required with the normalization approach.\n for (i = 0; i < stop; i++) {\n geometryMaybeCollection = isFeatureCollection\n ? geojson.features[i].geometry\n : isFeature\n ? geojson.geometry\n : geojson;\n featureProperties = isFeatureCollection\n ? geojson.features[i].properties\n : isFeature\n ? geojson.properties\n : {};\n featureBBox = isFeatureCollection\n ? geojson.features[i].bbox\n : isFeature\n ? geojson.bbox\n : undefined;\n featureId = isFeatureCollection\n ? geojson.features[i].id\n : isFeature\n ? geojson.id\n : undefined;\n isGeometryCollection = geometryMaybeCollection\n ? geometryMaybeCollection.type === \"GeometryCollection\"\n : false;\n stopG = isGeometryCollection\n ? geometryMaybeCollection.geometries.length\n : 1;\n\n for (g = 0; g < stopG; g++) {\n geometry = isGeometryCollection\n ? geometryMaybeCollection.geometries[g]\n : geometryMaybeCollection;\n\n // Handle null Geometry\n if (geometry === null) {\n if (\n callback(\n null,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) === false\n )\n return false;\n continue;\n }\n switch (geometry.type) {\n case \"Point\":\n case \"LineString\":\n case \"MultiPoint\":\n case \"Polygon\":\n case \"MultiLineString\":\n case \"MultiPolygon\": {\n if (\n callback(\n geometry,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) === false\n )\n return false;\n break;\n }\n case \"GeometryCollection\": {\n for (j = 0; j < geometry.geometries.length; j++) {\n if (\n callback(\n geometry.geometries[j],\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) === false\n )\n return false;\n }\n break;\n }\n default:\n throw new Error(\"Unknown Geometry Type\");\n }\n }\n // Only increase `featureIndex` per each feature\n featureIndex++;\n }\n}\n\n/**\n * Callback for geomReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback geomReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {GeometryObject} currentGeometry The current Geometry being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {GeoJsonProperties} featureProperties The current Feature Properties being processed.\n * @param {BBox} featureBBox The current Feature BBox being processed.\n * @param {Id} featureId The current Feature Id being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce geometry in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection|Feature|GeometryObject|GeometryCollection|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {geomReduceCallback} callback a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.point([36, 53], {hello: 'world'})\n * ]);\n *\n * turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {\n * //=previousValue\n * //=currentGeometry\n * //=featureIndex\n * //=featureProperties\n * //=featureBBox\n * //=featureId\n * return currentGeometry\n * });\n */\nfunction geomReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n geomEach(\n geojson,\n function (\n currentGeometry,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n ) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentGeometry;\n else\n previousValue = callback(\n previousValue,\n currentGeometry,\n featureIndex,\n featureProperties,\n featureBBox,\n featureId\n );\n }\n );\n return previousValue;\n}\n\n/**\n * Callback for flattenEach\n *\n * @callback flattenEachCallback\n * @param {Feature} currentFeature The current flattened feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over flattened features in any GeoJSON object, similar to\n * Array.forEach.\n *\n * @function\n * @param {FeatureCollection|Feature|GeometryObject|GeometryCollection|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {flattenEachCallback} callback a method that takes (currentFeature, featureIndex, multiFeatureIndex)\n * @returns {void}\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})\n * ]);\n *\n * turf.flattenEach(features, function (currentFeature, featureIndex, multiFeatureIndex) {\n * //=currentFeature\n * //=featureIndex\n * //=multiFeatureIndex\n * });\n */\nfunction flattenEach(geojson, callback) {\n geomEach(geojson, function (geometry, featureIndex, properties, bbox, id) {\n // Callback for single geometry\n var type = geometry === null ? null : geometry.type;\n switch (type) {\n case null:\n case \"Point\":\n case \"LineString\":\n case \"Polygon\":\n if (\n callback(\n feature(geometry, properties, { bbox: bbox, id: id }),\n featureIndex,\n 0\n ) === false\n )\n return false;\n return;\n }\n\n var geomType;\n\n // Callback for multi-geometry\n switch (type) {\n case \"MultiPoint\":\n geomType = \"Point\";\n break;\n case \"MultiLineString\":\n geomType = \"LineString\";\n break;\n case \"MultiPolygon\":\n geomType = \"Polygon\";\n break;\n }\n\n for (\n var multiFeatureIndex = 0;\n multiFeatureIndex < geometry.coordinates.length;\n multiFeatureIndex++\n ) {\n var coordinate = geometry.coordinates[multiFeatureIndex];\n var geom = {\n type: geomType,\n coordinates: coordinate,\n };\n if (\n callback(feature(geom, properties), featureIndex, multiFeatureIndex) ===\n false\n )\n return false;\n }\n });\n}\n\n/**\n * Callback for flattenReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback flattenReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature} currentFeature The current Feature being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce flattened features in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection|Feature|GeometryObject|GeometryCollection|Feature<GeometryCollection>} geojson any GeoJSON object\n * @param {flattenReduceCallback} callback a method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var features = turf.featureCollection([\n * turf.point([26, 37], {foo: 'bar'}),\n * turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})\n * ]);\n *\n * turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, multiFeatureIndex) {\n * //=previousValue\n * //=currentFeature\n * //=featureIndex\n * //=multiFeatureIndex\n * return currentFeature\n * });\n */\nfunction flattenReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n flattenEach(\n geojson,\n function (currentFeature, featureIndex, multiFeatureIndex) {\n if (\n featureIndex === 0 &&\n multiFeatureIndex === 0 &&\n initialValue === undefined\n )\n previousValue = currentFeature;\n else\n previousValue = callback(\n previousValue,\n currentFeature,\n featureIndex,\n multiFeatureIndex\n );\n }\n );\n return previousValue;\n}\n\n/**\n * Callback for segmentEach\n *\n * @callback segmentEachCallback\n * @param {Feature<LineString>} currentSegment The current Segment being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @param {number} segmentIndex The current index of the Segment being processed.\n * @returns {void}\n */\n\n/**\n * Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()\n * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.\n *\n * @param {AllGeoJSON} geojson any GeoJSON\n * @param {segmentEachCallback} callback a method that takes (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex)\n * @returns {void}\n * @example\n * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);\n *\n * // Iterate over GeoJSON by 2-vertex segments\n * turf.segmentEach(polygon, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {\n * //=currentSegment\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * //=segmentIndex\n * });\n *\n * // Calculate the total number of segments\n * var total = 0;\n * turf.segmentEach(polygon, function () {\n * total++;\n * });\n */\nfunction segmentEach(geojson, callback) {\n flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {\n var segmentIndex = 0;\n\n // Exclude null Geometries\n if (!feature.geometry) return;\n // (Multi)Point geometries do not contain segments therefore they are ignored during this operation.\n var type = feature.geometry.type;\n if (type === \"Point\" || type === \"MultiPoint\") return;\n\n // Generate 2-vertex line segments\n var previousCoords;\n var previousFeatureIndex = 0;\n var previousMultiIndex = 0;\n var prevGeomIndex = 0;\n if (\n coordEach(\n feature,\n function (\n currentCoord,\n coordIndex,\n featureIndexCoord,\n multiPartIndexCoord,\n geometryIndex\n ) {\n // Simulating a meta.coordReduce() since `reduce` operations cannot be stopped by returning `false`\n if (\n previousCoords === undefined ||\n featureIndex > previousFeatureIndex ||\n multiPartIndexCoord > previousMultiIndex ||\n geometryIndex > prevGeomIndex\n ) {\n previousCoords = currentCoord;\n previousFeatureIndex = featureIndex;\n previousMultiIndex = multiPartIndexCoord;\n prevGeomIndex = geometryIndex;\n segmentIndex = 0;\n return;\n }\n var currentSegment = lineString(\n [previousCoords, currentCoord],\n feature.properties\n );\n if (\n callback(\n currentSegment,\n featureIndex,\n multiFeatureIndex,\n geometryIndex,\n segmentIndex\n ) === false\n )\n return false;\n segmentIndex++;\n previousCoords = currentCoord;\n }\n ) === false\n )\n return false;\n });\n}\n\n/**\n * Callback for segmentReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback segmentReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature<LineString>} currentSegment The current Segment being processed.\n * @param {number} featureIndex The current index of the Feature being processed.\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.\n * @param {number} geometryIndex The current index of the Geometry being processed.\n * @param {number} segmentIndex The current index of the Segment being processed.\n * @returns {Reducer}\n */\n\n/**\n * Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()\n * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.\n *\n * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON\n * @param {segmentReduceCallback} callback a method that takes (previousValue, currentSegment, currentIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer}\n * @example\n * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);\n *\n * // Iterate over GeoJSON by 2-vertex segments\n * turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {\n * //= previousSegment\n * //= currentSegment\n * //= featureIndex\n * //= multiFeatureIndex\n * //= geometryIndex\n * //= segmentIndex\n * return currentSegment\n * });\n *\n * // Calculate the total number of segments\n * var initialValue = 0\n * var total = turf.segmentReduce(polygon, function (previousValue) {\n * previousValue++;\n * return previousValue;\n * }, initialValue);\n */\nfunction segmentReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n var started = false;\n segmentEach(\n geojson,\n function (\n currentSegment,\n featureIndex,\n multiFeatureIndex,\n geometryIndex,\n segmentIndex\n ) {\n if (started === false && initialValue === undefined)\n previousValue = currentSegment;\n else\n previousValue = callback(\n previousValue,\n currentSegment,\n featureIndex,\n multiFeatureIndex,\n geometryIndex,\n segmentIndex\n );\n started = true;\n }\n );\n return previousValue;\n}\n\n/**\n * Callback for lineEach\n *\n * @callback lineEachCallback\n * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed\n * @param {number} featureIndex The current index of the Feature being processed\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed\n * @param {number} geometryIndex The current index of the Geometry being processed\n * @returns {void}\n */\n\n/**\n * Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,\n * similar to Array.forEach.\n *\n * @function\n * @param {FeatureCollection<Lines>|Feature<Lines>|Lines|Feature<GeometryCollection>|GeometryCollection} geojson object\n * @param {lineEachCallback} callback a method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex)\n * @returns {void}\n * @example\n * var multiLine = turf.multiLineString([\n * [[26, 37], [35, 45]],\n * [[36, 53], [38, 50], [41, 55]]\n * ]);\n *\n * turf.lineEach(multiLine, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=currentLine\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * });\n */\nfunction lineEach(geojson, callback) {\n // validation\n if (!geojson) throw new Error(\"geojson is required\");\n\n flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {\n if (feature.geometry === null) return;\n var type = feature.geometry.type;\n var coords = feature.geometry.coordinates;\n switch (type) {\n case \"LineString\":\n if (callback(feature, featureIndex, multiFeatureIndex, 0, 0) === false)\n return false;\n break;\n case \"Polygon\":\n for (\n var geometryIndex = 0;\n geometryIndex < coords.length;\n geometryIndex++\n ) {\n if (\n callback(\n lineString(coords[geometryIndex], feature.properties),\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n ) === false\n )\n return false;\n }\n break;\n }\n });\n}\n\n/**\n * Callback for lineReduce\n *\n * The first time the callback function is called, the values provided as arguments depend\n * on whether the reduce method has an initialValue argument.\n *\n * If an initialValue is provided to the reduce method:\n * - The previousValue argument is initialValue.\n * - The currentValue argument is the value of the first element present in the array.\n *\n * If an initialValue is not provided:\n * - The previousValue argument is the value of the first element present in the array.\n * - The currentValue argument is the value of the second element present in the array.\n *\n * @callback lineReduceCallback\n * @param {Reducer} previousValue The accumulated value previously returned in the last invocation\n * of the callback, or initialValue, if supplied.\n * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed.\n * @param {number} featureIndex The current index of the Feature being processed\n * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed\n * @param {number} geometryIndex The current index of the Geometry being processed\n * @returns {Reducer}\n */\n\n/**\n * Reduce features in any GeoJSON object, similar to Array.reduce().\n *\n * @function\n * @param {FeatureCollection<Lines>|Feature<Lines>|Lines|Feature<GeometryCollection>|GeometryCollection} geojson object\n * @param {Function} callback a method that takes (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)\n * @param {Reducer} [initialValue] Value to use as the first argument to the first call of the callback.\n * @returns {Reducer} The value that results from the reduction.\n * @example\n * var multiPoly = turf.multiPolygon([\n * turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),\n * turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])\n * ]);\n *\n * turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) {\n * //=previousValue\n * //=currentLine\n * //=featureIndex\n * //=multiFeatureIndex\n * //=geometryIndex\n * return currentLine\n * });\n */\nfunction lineReduce(geojson, callback, initialValue) {\n var previousValue = initialValue;\n lineEach(\n geojson,\n function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {\n if (featureIndex === 0 && initialValue === undefined)\n previousValue = currentLine;\n else\n previousValue = callback(\n previousValue,\n currentLine,\n featureIndex,\n multiFeatureIndex,\n geometryIndex\n );\n }\n );\n return previousValue;\n}\n\n/**\n * Finds a particular 2-vertex LineString Segment from a GeoJSON using `@turf/meta` indexes.\n *\n * Negative indexes are permitted.\n * Point & MultiPoint will always return null.\n *\n * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.featureIndex=0] Feature Index\n * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index\n * @param {number} [options.geometryIndex=0] Geometry Index\n * @param {number} [options.segmentIndex=0] Segment Index\n * @param {Object} [options.properties={}] Translate Properties to output LineString\n * @param {BBox} [options.bbox={}] Translate BBox to output LineString\n * @param {number|string} [options.id={}] Translate Id to output LineString\n * @returns {Feature<LineString>} 2-vertex GeoJSON Feature LineString\n * @example\n * var multiLine = turf.multiLineString([\n * [[10, 10], [50, 30], [30, 40]],\n * [[-10, -10], [-50, -30], [-30, -40]]\n * ]);\n *\n * // First Segment (defaults are 0)\n * turf.findSegment(multiLine);\n * // => Feature<LineString<[[10, 10], [50, 30]]>>\n *\n * // First Segment of 2nd Multi Feature\n * turf.findSegment(multiLine, {multiFeatureIndex: 1});\n * // => Feature<LineString<[[-10, -10], [-50, -30]]>>\n *\n * // Last Segment of Last Multi Feature\n * turf.findSegment(multiLine, {multiFeatureIndex: -1, segmentIndex: -1});\n * // => Feature<LineString<[[-50, -30], [-30, -40]]>>\n */\nfunction findSegment(geojson, options) {\n // Optional Parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var featureIndex = options.featureIndex || 0;\n var multiFeatureIndex = options.multiFeatureIndex || 0;\n var geometryIndex = options.geometryIndex || 0;\n var segmentIndex = options.segmentIndex || 0;\n\n // Find FeatureIndex\n var properties = options.properties;\n var geometry;\n\n switch (geojson.type) {\n case \"FeatureCollection\":\n if (featureIndex < 0)\n featureIndex = geojson.features.length + featureIndex;\n properties = properties || geojson.features[featureIndex].properties;\n geometry = geojson.features[featureIndex].geometry;\n break;\n case \"Feature\":\n properties = properties || geojson.properties;\n geometry = geojson.geometry;\n break;\n case \"Point\":\n case \"MultiPoint\":\n return null;\n case \"LineString\":\n case \"Polygon\":\n case \"MultiLineString\":\n case \"MultiPolygon\":\n geometry = geojson;\n break;\n default:\n throw new Error(\"geojson is invalid\");\n }\n\n // Find SegmentIndex\n if (geometry === null) return null;\n var coords = geometry.coordinates;\n switch (geometry.type) {\n case \"Point\":\n case \"MultiPoint\":\n return null;\n case \"LineString\":\n if (segmentIndex < 0) segmentIndex = coords.length + segmentIndex - 1;\n return lineString(\n [coords[segmentIndex], coords[segmentIndex + 1]],\n properties,\n options\n );\n case \"Polygon\":\n if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;\n if (segmentIndex < 0)\n segmentIndex = coords[geometryIndex].length + segmentIndex - 1;\n return lineString(\n [\n coords[geometryIndex][segmentIndex],\n coords[geometryIndex][segmentIndex + 1],\n ],\n properties,\n options\n );\n case \"MultiLineString\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (segmentIndex < 0)\n segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;\n return lineString(\n [\n coords[multiFeatureIndex][segmentIndex],\n coords[multiFeatureIndex][segmentIndex + 1],\n ],\n properties,\n options\n );\n case \"MultiPolygon\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (geometryIndex < 0)\n geometryIndex = coords[multiFeatureIndex].length + geometryIndex;\n if (segmentIndex < 0)\n segmentIndex =\n coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;\n return lineString(\n [\n coords[multiFeatureIndex][geometryIndex][segmentIndex],\n coords[multiFeatureIndex][geometryIndex][segmentIndex + 1],\n ],\n properties,\n options\n );\n }\n throw new Error(\"geojson is invalid\");\n}\n\n/**\n * Finds a particular Point from a GeoJSON using `@turf/meta` indexes.\n *\n * Negative indexes are permitted.\n *\n * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.featureIndex=0] Feature Index\n * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index\n * @param {number} [options.geometryIndex=0] Geometry Index\n * @param {number} [options.coordIndex=0] Coord Index\n * @param {Object} [options.properties={}] Translate Properties to output Point\n * @param {BBox} [options.bbox={}] Translate BBox to output Point\n * @param {number|string} [options.id={}] Translate Id to output Point\n * @returns {Feature<Point>} 2-vertex GeoJSON Feature Point\n * @example\n * var multiLine = turf.multiLineString([\n * [[10, 10], [50, 30], [30, 40]],\n * [[-10, -10], [-50, -30], [-30, -40]]\n * ]);\n *\n * // First Segment (defaults are 0)\n * turf.findPoint(multiLine);\n * // => Feature<Point<[10, 10]>>\n *\n * // First Segment of the 2nd Multi-Feature\n * turf.findPoint(multiLine, {multiFeatureIndex: 1});\n * // => Feature<Point<[-10, -10]>>\n *\n * // Last Segment of last Multi-Feature\n * turf.findPoint(multiLine, {multiFeatureIndex: -1, coordIndex: -1});\n * // => Feature<Point<[-30, -40]>>\n */\nfunction findPoint(geojson, options) {\n // Optional Parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var featureIndex = options.featureIndex || 0;\n var multiFeatureIndex = options.multiFeatureIndex || 0;\n var geometryIndex = options.geometryIndex || 0;\n var coordIndex = options.coordIndex || 0;\n\n // Find FeatureIndex\n var properties = options.properties;\n var geometry;\n\n switch (geojson.type) {\n case \"FeatureCollection\":\n if (featureIndex < 0)\n featureIndex = geojson.features.length + featureIndex;\n properties = properties || geojson.features[featureIndex].properties;\n geometry = geojson.features[featureIndex].geometry;\n break;\n case \"Feature\":\n properties = properties || geojson.properties;\n geometry = geojson.geometry;\n break;\n case \"Point\":\n case \"MultiPoint\":\n return null;\n case \"LineString\":\n case \"Polygon\":\n case \"MultiLineString\":\n case \"MultiPolygon\":\n geometry = geojson;\n break;\n default:\n throw new Error(\"geojson is invalid\");\n }\n\n // Find Coord Index\n if (geometry === null) return null;\n var coords = geometry.coordinates;\n switch (geometry.type) {\n case \"Point\":\n return point(coords, properties, options);\n case \"MultiPoint\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n return point(coords[multiFeatureIndex], properties, options);\n case \"LineString\":\n if (coordIndex < 0) coordIndex = coords.length + coordIndex;\n return point(coords[coordIndex], properties, options);\n case \"Polygon\":\n if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;\n if (coordIndex < 0)\n coordIndex = coords[geometryIndex].length + coordIndex;\n return point(coords[geometryIndex][coordIndex], properties, options);\n case \"MultiLineString\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (coordIndex < 0)\n coordIndex = coords[multiFeatureIndex].length + coordIndex;\n return point(coords[multiFeatureIndex][coordIndex], properties, options);\n case \"MultiPolygon\":\n if (multiFeatureIndex < 0)\n multiFeatureIndex = coords.length + multiFeatureIndex;\n if (geometryIndex < 0)\n geometryIndex = coords[multiFeatureIndex].length + geometryIndex;\n if (coordIndex < 0)\n coordIndex =\n coords[multiFeatureIndex][geometryIndex].length - coordIndex;\n return point(\n coords[multiFeatureIndex][geometryIndex][coordIndex],\n properties,\n options\n );\n }\n throw new Error(\"geojson is invalid\");\n}\n\nexport {\n coordReduce,\n coordEach,\n propEach,\n propReduce,\n featureReduce,\n featureEach,\n coordAll,\n geomReduce,\n geomEach,\n flattenReduce,\n flattenEach,\n segmentReduce,\n segmentEach,\n lineReduce,\n lineEach,\n findSegment,\n findPoint,\n};\n","import { BBox } from \"geojson\";\nimport { AllGeoJSON } from \"@turf/helpers\";\nimport { coordEach } from \"@turf/meta\";\n\n/**\n * Calculates the bounding box for any GeoJSON object, including FeatureCollection.\n * Uses geojson.bbox if available and options.recompute is not set.\n *\n * @function\n * @param {GeoJSON} geojson any GeoJSON object\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson\n * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order\n * @example\n * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);\n * var bbox = turf.bbox(line);\n * var bboxPolygon = turf.bboxPolygon(bbox);\n *\n * //addToMap\n * var addToMap = [line, bboxPolygon]\n */\nfunction bbox(\n geojson: AllGeoJSON,\n options: {\n recompute?: boolean;\n } = {}\n): BBox {\n if (geojson.bbox != null && true !== options.recompute) {\n return geojson.bbox;\n }\n const result: BBox = [Infinity, Infinity, -Infinity, -Infinity];\n coordEach(geojson, (coord) => {\n if (result[0] > coord[0]) {\n result[0] = coord[0];\n }\n if (result[1] > coord[1]) {\n result[1] = coord[1];\n }\n if (result[2] < coord[0]) {\n result[2] = coord[0];\n }\n if (result[3] < coord[1]) {\n result[3] = coord[1];\n }\n });\n return result;\n}\n\nexport { bbox };\nexport default bbox;\n","import { IHighlightOptions, ISetHighlight2DElementIdsOptions } from \"./types\"\n\nconst defaultLayerOption = { enableAltitude: true }\n\nconst VENUE = \"venue\"\nconst LEVEL = \"level\"\nconst UNIT = \"unit\"\nconst FIXTURE = \"fixture\"\nconst KIOSK = \"kiosk\"\nconst OPENING = \"opening\"\nconst SECTION = \"section\"\nconst FOOTPRINT = \"footprint\"\n\nconst AMENITY = \"amenity\"\nconst OCCUPANT = \"occupant\"\n\nconst GEOLOCATION = \"geolocation\"\nconst ORIGIN_MARKER = \"origin-marker\"\nconst DESTINATION_MARKER = \"destination-marker\"\n\nconst DECORATION = \"decoration\"\n\nexport const ALWAYS_VISIBLE_FEATURE_TYPES = [VENUE, FOOTPRINT]\nexport const BASE_LAYER_NAME = \"base\"\nexport const POI_MARKER_LAYER_NAME = \"poi\"\nexport const MARKER_LAYER_NAME = \"marker\"\nexport const HIGHLIGHT_LAYER_NAME = \"highlight\"\nexport const USER_LOCATION_LAYER_NAME = \"user_location\"\n\nexport const ORIGIN_MARKER_ID = \"master-origin-marker\"\nexport const DESTINATION_MARKER_ID = \"master-destination-marker\"\nexport const USER_LOCATION_ELEMENT_ID = \"user_location\"\nexport const LAST_USER_LOCATION_ELEMENT_ID_PREFIX = \"last_user_location-\"\n\nexport const LOCALE_SYMBOL_KEY = \"locale_symbol\"\nexport const DEFAULT_LOCALE = \"en\"\n\nexport const DEFAULT_HIGHLIGHT_OPTIONS: IHighlightOptions = {\n symbolSet: null,\n}\nexport const DEFAULT_SET_HIGHLIGHT_2DELEMENT_IDS_OPTIONS: ISetHighlight2DElementIdsOptions =\n {\n symbolSet: null,\n defaultMarker: false,\n }\n\nexport const LAYERS = [\n BASE_LAYER_NAME,\n POI_MARKER_LAYER_NAME,\n HIGHLIGHT_LAYER_NAME,\n USER_LOCATION_LAYER_NAME,\n]\n\nexport const LAYER_OPTIONS = {\n [BASE_LAYER_NAME]: {\n ...defaultLayerOption,\n forceRenderOnMoving: true,\n forceRenderOnRotating: true,\n forceRenderOnZooming: true,\n },\n [POI_MARKER_LAYER_NAME]: {\n ...defaultLayerOption,\n forceRenderOnMoving: true,\n forceRenderOnRotating: true,\n forceRenderOnZooming: true,\n zIndex: 10,\n collision: true,\n collisionDelay: 1200,\n },\n [MARKER_LAYER_NAME]: { ...defaultLayerOption },\n [HIGHLIGHT_LAYER_NAME]: { ...defaultLayerOption, zIndex: 98 },\n [USER_LOCATION_LAYER_NAME]: { ...defaultLayerOption, zIndex: 99 },\n}\n\nexport const LAYER_FEATURE_TYPE_OBJ = {\n [VENUE]: BASE_LAYER_NAME,\n [LEVEL]: BASE_LAYER_NAME,\n [UNIT]: BASE_LAYER_NAME,\n [FIXTURE]: BASE_LAYER_NAME,\n [KIOSK]: BASE_LAYER_NAME,\n [OPENING]: BASE_LAYER_NAME,\n [SECTION]: BASE_LAYER_NAME,\n [FOOTPRINT]: BASE_LAYER_NAME,\n [AMENITY]: MARKER_LAYER_NAME,\n [OCCUPANT]: POI_MARKER_LAYER_NAME,\n [GEOLOCATION]: USER_LOCATION_LAYER_NAME,\n [ORIGIN_MARKER]: HIGHLIGHT_LAYER_NAME,\n [DESTINATION_MARKER]: HIGHLIGHT_LAYER_NAME,\n [DECORATION]: BASE_LAYER_NAME,\n}\n\n/** Custom Venue Platform Events. Prefix with \"venue:\" to avoid collision */\nexport const VENUE_EVENTS = {\n VENUE_MOVEINTOVIEW: \"venue:venuemoveintoview\", // When a map is moved and a venue moved into a viewport\n}\n","import _ from \"lodash\"\nimport {\n Polygon,\n MultiPolygon,\n LineString,\n Marker,\n Coordinate,\n MultiLineString,\n ui,\n} from \"maptalks\"\nimport turfCenter from \"@turf/center\"\nimport turfBuffer from \"@turf/buffer\"\n\nimport {\n TextureLoader,\n SpriteMaterial,\n MeshLambertMaterial,\n AmbientLight,\n DirectionalLight,\n} from \"three\"\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\"\n\nimport {\n GroundLabel,\n SpriteMarker,\n Billboard,\n NavigationPath,\n} from \"../object3d\"\nimport { getCenterFromGeometry, createPolygonFromLineString } from \"./geometry\"\nimport { createSVGPathFromMarkerSymbol, svgToPng } from \"./svg\"\n\nconst GeometryType = {\n Polygon,\n MultiPolygon,\n}\n\nconst ORDINAL_HEIGHT = 0 // in version 3D change ORDINAL_HEIGHT for set altitude of geometry\n\nconst VENUE_Z_INDEX = 0\n\nconst LEVEL_Z_INDEX = 2\nconst UNIT_Z_INDEX = 3\nconst FIXTURE_Z_INDEX = 4\nconst DECORATION_Z_INDEX = 4\nconst KIOSK_Z_INDEX = 5\nconst OPENING_Z_INDEX = 3\nconst SECTION_Z_INDEX = 6\nconst USER_LOCATION_Z_INDEX = 99\nconst LAST_LOCATION_Z_INDEX = USER_LOCATION_Z_INDEX - 1\n\nconst PREFIX_HIGHLIGHTED_SYMBOL_KEY = \"highlighted\"\nconst SPRITE_MARKER_FEATURE = [\n \"amenity-atm\",\n \"amenity-babychanging\",\n \"amenity-strollerrental\",\n \"amenity-boardinggate.ferry\",\n \"amenity-elevator\",\n \"amenity-escalator\",\n \"amenity-stairs\",\n \"amenity-information\",\n \"amenity-information.transit\",\n \"amenity-wheelchair\",\n \"amenity-restroom\",\n \"amenity-restroom.male\",\n \"amenity-restroom.female\",\n \"amenity-restroom.wheelchair\",\n \"amenity-restroom.family\",\n \"amenity-restroom.unisex\",\n \"amenity-taxi\",\n \"amenity-groundtransportation\",\n \"amenity-bus\",\n \"amenity-bus.muni\",\n \"amenity-shuttle\",\n \"amenity-parking\",\n \"amenity-parking.shortterm\",\n \"amenity-parking.longterm\",\n \"amenity-parking.waitingarea\",\n \"amenity-parking.compact\",\n \"amenity-parking.ev\",\n \"amenity-parking.bicycle\",\n \"amenity-parking.motorcycle\",\n \"amenity-privatelounge\",\n \"amenity-rideshare\",\n \"amenity-valet\",\n \"amenity-landmark\",\n \"amenity-rail.muni\",\n \"amenity-service\",\n \"amenity-smokingarea\",\n \"amenity-ticketing\",\n \"amenity-meetingpoint\",\n \"amenity-prayerroom\",\n \"amenity-firstaid\",\n \"amenity-ticketing.rail\",\n \"amenity-exhibit\",\n \"amenity-mothersroom\",\n \"amenity-checkin.desk\",\n \"amenity-baggagestorage\",\n \"amenity-baggagecarts\",\n \"amenity-library\",\n \"amenity-coinlocker\",\n \"amenity-powerchargingstation\",\n \"amenity-wheelchairassit\",\n \"amenity-lostandfound\",\n \"amenity-foodservice\",\n \"amenity-businesscenter\",\n \"amenity-guestservices\",\n \"amenity-emergencyshelter\",\n \"amenity-prayerroom.buddhism\",\n \"amenity-defibrillator\",\n \"amenity-drinkingfountain\",\n \"amenity-handsanitizerstation\",\n \"amenity-unspecified\",\n \"amenity-entry\",\n \"amenity-fireextinguisher\",\n \"amenity-security\",\n \"amenity-seating\",\n \"amenity-copymachine\",\n \"amenity-fieldofplay\",\n \"amenity-fieldofplay.soccer\",\n \"amenity-amphitheater\",\n \"amenity-hoteling\",\n \"occupant-currencyexchange\",\n \"occupant-donationcenter\",\n \"occupant-bank\",\n \"occupant-books\",\n \"occupant-postoffice\",\n \"opening-emergencyexit\",\n]\n\nconst SPRITE_HIGHLIGHT_MARKER_FEATURE = SPRITE_MARKER_FEATURE.map(\n (featCate) =>\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${featCate.split(\"-\").join(\".\")}`\n)\n\nconst OCCUPANT_TEXT_MARKER_CLASSNAME = \"mtk-occupant-text-marker\"\n\nconst getAltitude = (properties) =>\n Math.max(0, properties.ordinal * ORDINAL_HEIGHT || 0)\n\nconst createRoomUnit = (feature, style, options) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n })\n}\nconst createAmenityUnit = (feature, style, options = {}) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n const area = new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n })\n return area\n}\n\nconst createNonpublicUnit = (feature, style, options = {}) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: {\n ...style,\n },\n })\n}\nconst createWalkwayUnit = (feature, style, options) => {\n const { geometry, id, properties } = feature\n const { allowOverride, inheritFillColorToLine } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n id,\n feature_type: \"unit\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: {\n ...symbolStyle,\n },\n })\n}\n\nconst createWaterFixture = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, inheritFillColorToLine, zIndex } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: {\n ...style,\n },\n zIndex,\n })\n}\n\nconst createVegetationFixture = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, inheritFillColorToLine, zIndex } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: {\n ...symbolStyle,\n },\n zIndex,\n })\n}\n\nconst createObstructionalFixture = (feature, style = {}, options = {}) => {\n const { geometry, properties = {} } = feature\n const { model3d } = properties\n const { allowOverride, inheritFillColorToLine, zIndex } = options\n const symbolStyle = { ...style }\n if (!_.isEmpty(model3d)) return\n if (allowOverride) _.merge(symbolStyle, properties.style)\n if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill\n //create polygon with line-offset if geometry is lineString\n if (geometry.type === \"LineString\") {\n const polygon = createPolygonFromLineString(geometry)\n return new GeometryType[\"Polygon\"](polygon, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n zIndex,\n })\n }\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n defaultSymbol: symbolStyle,\n zIndex,\n })\n}\n\nconst createVegetationSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n}\n\nconst creatingSeatingSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n}\n\nconst creatingDefaultSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n try {\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n } catch (error) {\n console.warn(`Error creatingDefaultSection`, geometry.type)\n }\n}\n\nconst createEatingDrinkingSection = (feature, symbol = {}) => {\n const { geometry, properties } = feature\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol,\n zIndex: SECTION_Z_INDEX,\n })\n}\n\nconst createPrincipalOpening = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, zIndex } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n try {\n return new LineString(geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n zIndex,\n })\n } catch (error) {\n console.log(`error creating pedestrian principal opening:`, feature)\n }\n}\n\nconst createEmergencyExitOpening = (feature, style, options = {}) => {\n const { geometry, properties } = feature\n const { allowOverride, zIndex } = options\n const symbolStyle = { ...style }\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n try {\n return new LineString(geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n zIndex,\n })\n } catch (error) {\n console.log(`error creating emergency exit opening:`, feature)\n }\n}\nconst createPedestrianOpening = (feature, style, options = {}) => {\n const { geometry, properties, id } = feature\n const { allowOverride, zIndex } = options\n const symbolStyle = { ...style }\n\n if (allowOverride) _.merge(symbolStyle, properties.style)\n\n try {\n return new LineString(geometry.coordinates, {\n properties: {\n id,\n feature_type: \"opening\",\n category: properties.category,\n altitude: getAltitude(properties),\n },\n symbol: symbolStyle,\n zIndex,\n })\n } catch (error) {\n console.log(`error creating pedestrian opening:`, feature)\n }\n}\n\nconst loadModel3d = (model3d, coordinate, threeLayer) => {\n return new Promise((resolve, reject) => {\n const loader = new GLTFLoader()\n const { url, properties: modelProperties } = model3d\n loader.load(\n url,\n (gltf) => {\n const object3d = gltf.scene\n // จัดขนาด + scale ที่เหมาะสม\n object3d.rotation.x = _.get(modelProperties, \"rotation.x\")\n object3d.rotation.y = _.get(modelProperties, \"rotation.y\")\n object3d.scale.set(...(_.get(modelProperties, \"scale\") || []))\n\n const object = threeLayer.toModel(object3d, {\n coordinate,\n })\n\n object.getObject3d().traverse((child) => {\n if (child.isMesh === true) {\n child.material.transparent = true\n child.material.metalness = 0.1 // set to near 0 because metal requires environment to reflect light to, if there's nothing then metal will become black.\n }\n })\n\n resolve(object)\n },\n (xhr) => {},\n (error) => {\n reject(error)\n }\n )\n })\n}\n\nconst create3DModels = async (\n models,\n defaultCoordinate,\n properties,\n threeLayer\n) => {\n let modelObjs = []\n for (let j = 0; j < models.length; j++) {\n const model = models[j]\n const positionCoord = _.get(model, \"properties.position\")\n const coord = positionCoord || defaultCoordinate\n const object = await loadModel3d(model, coord, threeLayer)\n object.properties = properties\n modelObjs.push(object)\n }\n\n return modelObjs\n}\n\nconst createExtrudePolygon = (\n geometry,\n threeLayer,\n material,\n height,\n properties = {},\n options\n) => {\n const { offset = 0, altitude = 0 } = options\n const offsetGeometry = turfBuffer(geometry, offset, { units: \"meters\" })\n const object = threeLayer.toExtrudePolygon(\n offsetGeometry,\n { height, async: true, altitude },\n material\n )\n object.properties = properties\n return object\n}\n\nconst create3DMarker = (\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n) => {\n return new SpriteMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n}\n\n/**\n * Retrieves the extrude configuration for a feature.\n *\n * @param {Object} baseExtrudeConfig - The default extrude configuration defined in the map settings within the app config content type.\n * @param {Object} feature - The target feature object for which the extrude value is required.\n * @returns {Object|undefined} - The extrude value from the feature's `properties` field, or the base extrude configuration as a fallback if not defined.\n */\nexport const getExtrudeConfigByFeature = (baseExtrudeConfig, feature = {}) => {\n const { feature_type: featureType } = feature\n // Retrieve extrude configuration from the extrude field in the feature's properties\n const featureExtrudeConfig = _.get(feature, \"properties.extrude\")\n\n // Retrieve extrude configuration from the base extrude settings. (Map Config)\n const featureCategory = _.get(feature, \"properties.category\")\n const baseFeatureExtrudeConfig = _.get(\n baseExtrudeConfig,\n `${featureType}.${featureCategory || featureType}`\n )\n\n // Fallback to base extrude configuration if the feature's extrude field is not defined.\n return featureExtrudeConfig ?? baseFeatureExtrudeConfig\n}\n\nconst getFeatureMarkerConfig = (feature, mapConfig = {}) => {\n const { textMarkerType, extrudeConfig = {}, symbol } = mapConfig\n\n const location = getLocationByFeature(feature)\n const featureExtrudeConfig = getExtrudeConfigByFeature(\n extrudeConfig,\n location\n )\n\n return {\n markerSymbol: symbol,\n textMarkerType,\n featureExtrudeConfig,\n }\n}\n\nexport const createSpriteMaterialByLabelSymbol = (labelSymbol = []) => {\n const material = new SpriteMaterial()\n try {\n const [base, icon] = labelSymbol\n const { markerWidth: baseWidth = 24 } = base\n const { markerWidth: iconWidth = 24 } = icon\n const viewBoxDimension = Math.max(baseWidth, iconWidth)\n\n const baseSVG = createSVGPathFromMarkerSymbol(base)\n const iconSVG = createSVGPathFromMarkerSymbol(icon)\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${viewBoxDimension}\" height=\"${viewBoxDimension}\">${baseSVG}${iconSVG}</svg>`\n const textureLoader = new TextureLoader()\n const scaleFactor = 200 / 24 // Scale factor to upscale from 24px to 200px to ensure the resolution is high enough\n\n svgToPng(svg, scaleFactor).then((png) => {\n const texture = textureLoader.load(png, () => {\n material.map = texture\n material.needsUpdate = true\n })\n })\n } catch (error) {\n console.warn(`Error createSpriteMaterialByLabelSymbol: `, labelSymbol)\n }\n return material\n}\n\nexport const createStyledUIMarkerElement = ({\n style,\n textContent,\n className,\n}) => {\n const element = document.createElement(\"div\")\n for (const key in style) {\n element.style[key] = style[key]\n }\n element.className = className\n element.textContent = textContent\n //! Use outerHTML to return HTML string instead of element object to avoid DOM event warnings from Maptalks.js.\n return element.outerHTML\n}\n\nexport const styledFeatureGenerator = (mapTheme) => {\n const getElementSymbol = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.geometry.symbol`)\n if (featureType === key) return featureTypeTheme\n const categoryTheme = _.get(mapTheme, `${key}.geometry.symbol`)\n return _.merge({}, featureTypeTheme, categoryTheme)\n }\n\n const getLabelSymbol = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.label`)\n const categoryTheme = _.get(mapTheme, `${key}.label`)\n const mergedSymbol = _.merge({}, featureTypeTheme, categoryTheme)\n let symbols = _.values(_.map(mergedSymbol, \"symbol\"))\n const markerIndexToMove = symbols.findIndex(\n ({ elementType }) => elementType === \"label.marker\"\n )\n\n // Move the label.marker symbol to the last of array\n if (markerIndexToMove >= 0) {\n const markerSymbolToMove = _.pullAt(symbols, markerIndexToMove)[0]\n symbols.push(markerSymbolToMove)\n }\n\n return symbols\n }\n\n const getUIMarkerSymbol = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.ui.marker`)\n const categoryTheme = _.get(mapTheme, `${key}.ui.marker`)\n const mergedSymbol = _.merge({}, featureTypeTheme, categoryTheme)\n const symbol = _.get(mergedSymbol, \"symbol\")\n return symbol\n }\n const getUIMarkerOptions = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeTheme = _.get(mapTheme, `${featureType}.ui.marker`)\n const categoryTheme = _.get(mapTheme, `${key}.ui.marker`)\n const mergedSymbol = _.merge({}, featureTypeTheme, categoryTheme)\n const options = _.get(mergedSymbol, \"options\")\n return options\n }\n\n const getLabelOptions = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeSymbol = _.get(mapTheme, `${featureType}.label`)\n const categorySymbol = _.get(mapTheme, `${key}.label`)\n const mergedSymbol = _.merge({}, featureTypeSymbol, categorySymbol)\n return _.reduce(\n mergedSymbol,\n (acc, symbol) => ({ ...acc, ..._.get(symbol, \"options\", {}) }),\n {}\n )\n }\n\n const generateSpriteMarkerMaterial = () => {\n return SPRITE_MARKER_FEATURE.reduce((acc, featCate) => {\n const [featureType, category] = featCate.split(\"-\")\n const key = `${featureType}.${category}`\n const labelSymbol = getLabelSymbol(key)\n const material = createSpriteMaterialByLabelSymbol(labelSymbol)\n return { ...acc, [key]: material }\n }, {})\n }\n\n const generateSpriteHighlightMarkerOption = () => {\n return SPRITE_HIGHLIGHT_MARKER_FEATURE.reduce((acc, featCate) => {\n const categoryKey = _.last(featCate.split(\"-\")) // Example: highlighted-amenity.atm -> amenity.atm\n const defaultLabelSymbol = getLabelSymbol(categoryKey)\n const highlightLabelSymbol = getLabelSymbol(featCate)\n const [defaultBase, defaultIcon] = defaultLabelSymbol\n const [highlightBase, highlightIcon] = highlightLabelSymbol\n const base = _.merge({}, defaultBase, highlightBase)\n const icon = _.merge({}, defaultIcon, highlightIcon)\n\n const material = createSpriteMaterialByLabelSymbol([base, icon])\n const options = getLabelOptions(featCate)\n return { ...acc, [featCate]: { material, options } }\n }, {})\n }\n\n const spriteMarkerMaterialObj = generateSpriteMarkerMaterial()\n const spriteHighlightMarkerOptionObj = generateSpriteHighlightMarkerOption()\n\n const getElementOptions = (key) => {\n const [featureType] = key.split(\".\")\n const featureTypeOptions = _.get(\n mapTheme,\n `${featureType}.geometry.options`\n )\n\n const categoryOptions = _.get(mapTheme, `${key}.geometry.options`)\n\n return _.merge({}, featureTypeOptions, categoryOptions)\n }\n\n const createOccupantMarker = (feature, locatedFeature, mapConfig) => {\n const { textMarkerType, featureExtrudeConfig } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\", 0)\n const { properties, id, feature_type } = feature\n if (!properties.anchor) return\n\n /**\n * Prepare geometry for occupant marker positioning:\n * - Use anchor coordinates if the location feature is the main location\n * - Otherwise, use the center of the location feature\n */\n const mainLocationId =\n _.get(properties, \"unit.id\") || _.get(properties, \"kiosk.id\")\n const isMainLocationFeature = mainLocationId === locatedFeature?.id\n const { geometry: mainLocationGeometry } = properties?.anchor\n const geometry = isMainLocationFeature\n ? mainLocationGeometry\n : turfCenter(locatedFeature)?.geometry\n\n const baseProperties = {\n id,\n feature_type,\n category: properties.category,\n altitude: getAltitude(properties),\n }\n const occupantName = _.isEmpty(properties.short_name)\n ? properties.name\n : properties.short_name\n\n if (locatedFeature) {\n const { feature_type, properties } = locatedFeature\n const { category } = properties\n const locatedLabelOption =\n feature_type === \"kiosk\"\n ? getLabelOptions(`${feature_type}`)\n : getLabelOptions(`${feature_type}.${category}`)\n const { hidden = false } = locatedLabelOption || {}\n if (hidden) return\n }\n\n const getValidatedRenderType = (requestedType, logoUrl) => {\n // If requestType is \"Logo\" or \"Logo + Name\" and no logo, fallback to \"Name\"\n if (requestedType === \"Logo\" || requestedType === \"Logo + Name\") {\n return logoUrl ? requestedType : \"Name\"\n }\n return requestedType\n }\n\n const logoUrl = _.get(properties, \"logo.url\")\n const requestedRenderType = _.get(properties, \"render_type\", \"Name\")\n const renderType = getValidatedRenderType(requestedRenderType, logoUrl)\n if (renderType === \"Label\") return null\n\n const renderPriority = properties.render_priority || 3\n const labelSymbol = getLabelSymbol(`occupant-${_.toLower(renderType)}`)\n const markerSymbol = _.last(labelSymbol)\n\n const coordinates = _.get(geometry, \"coordinates\")\n\n const priorityLabelSymbol = getLabelSymbol(\n `occupant-${_.toLower(renderType)}-${renderPriority}`\n )\n const priorityMarkerSymbol = _.last(priorityLabelSymbol) || {}\n\n switch (renderType) {\n case \"Logo\":\n _.set(priorityMarkerSymbol, \"markerFile\", logoUrl)\n\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties) + markerHeight,\n ...baseProperties,\n },\n symbol: priorityLabelSymbol,\n })\n\n case \"Logo + Name\":\n return new Marker(coordinates, {\n properties: {\n name: occupantName.en,\n altitude: getAltitude(properties) + markerHeight,\n ...baseProperties,\n },\n symbol: {\n textName: \"{name}\",\n markerFile: logoUrl,\n textHaloRadius: {\n stops: [\n [20, 1],\n [21, 2],\n ],\n },\n ...markerSymbol,\n ...priorityMarkerSymbol,\n },\n })\n case \"None\":\n return new ui.UIMarker(coordinates, {\n properties: { ...baseProperties },\n content: createStyledUIMarkerElement({\n style: { display: \"none\" },\n textContent: occupantName.en,\n }),\n altitude: getAltitude(properties) + markerHeight,\n })\n case \"Name\":\n default:\n if (textMarkerType === \"marker\") {\n return new Marker(coordinates, {\n properties: {\n name: occupantName.en,\n altitude: getAltitude(properties) + markerHeight,\n ...baseProperties,\n },\n symbol: {\n textName: \"{name}\",\n //TODO:: implement symbol scaler later\n textHaloRadius: {\n stops: [\n [20, 1],\n [21, 2],\n ],\n },\n ...markerSymbol,\n ...priorityMarkerSymbol,\n },\n })\n }\n\n const uiMarkerSymbol = getUIMarkerSymbol(\n `occupant-${_.toLower(renderType)}`\n )\n const uiMarkerPrioritySymbol = getUIMarkerSymbol(\n `occupant-${_.toLower(renderType)}-${renderPriority}`\n )\n const uiMarkerPriorityOptions = getUIMarkerOptions(\n `occupant-${_.toLower(renderType)}-${renderPriority}`\n )\n\n const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol }\n return new ui.UIMarker(coordinates, {\n properties: { ...baseProperties },\n content: createStyledUIMarkerElement({\n style,\n textContent: occupantName.en,\n className: OCCUPANT_TEXT_MARKER_CLASSNAME,\n }),\n collision: true,\n collisionFadeIn: true,\n altitude: getAltitude(properties) + markerHeight,\n ...uiMarkerPriorityOptions,\n })\n }\n }\n\n const getFeatureProperties = (feature) => {\n const { id, feature_type, properties } = feature\n const { category, ordinal, style = {} } = properties\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n const { allowOverride } = getElementOptions(`${feature_type}.${category}`)\n if (allowOverride) _.merge(elementStyle, style)\n const { polygonFill: color } = elementStyle\n const featureProperty = {\n id,\n feature_type,\n category: category || feature_type,\n ordinal,\n defaultColor: color,\n }\n return featureProperty\n }\n\n return {\n getElementSymbol,\n getHilighPolygonalSymbol: (type) => {\n switch (type) {\n case \"MultiPolygon\":\n case \"Polygon\": {\n return getElementSymbol(\"hilight-polygonal\")\n }\n case \"Point\": {\n return getElementSymbol(\"hilight-marker\")\n }\n default:\n break\n }\n },\n getHighlightMarkerSymbol: () => {\n return getElementSymbol(\"highlighted-marker\")\n },\n createVenue: (feature) => {\n const { geometry, feature_type } = feature\n const symbolStyle = getElementSymbol(feature_type)\n return new GeometryType[geometry.type](geometry.coordinates, {\n symbol: {\n ...symbolStyle,\n },\n zIndex: VENUE_Z_INDEX,\n })\n },\n\n createLevel: (feature) => {\n const { geometry, properties, feature_type } = feature\n const { category } = properties\n\n const style = getElementSymbol(`${feature_type}.${category}`)\n // const options = getElementOptions(`${feature_type}.${category}`)\n\n return new GeometryType[geometry.type](geometry.coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: {\n ...style,\n },\n zIndex: LEVEL_Z_INDEX,\n })\n },\n\n\n createMarker: (feature) => {\n try {\n const { geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const markerSymbol = getElementSymbol(\"pin-marker\")\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n symbol: markerSymbol,\n })\n } catch (err) {\n console.log(`error creating marker:`, feature)\n }\n },\n createOriginMarker: (feature) => {\n const { id, geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const markerSymbol = getElementSymbol(\"origin-marker\")\n try {\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties),\n },\n id,\n symbol: markerSymbol,\n })\n } catch (error) {\n console.log(`error creating origin marker:`, feature)\n }\n },\n createDestinationPinMarker: (feature, mapConfig) => {\n const { featureExtrudeConfig } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\")\n // Get Label from located unit / kiosk\n const { id, properties } = feature\n const geometry =\n _.get(feature, \"geometry\") ||\n _.get(feature, \"properties.anchor.geometry\")\n const coordinates = getCenterFromGeometry(geometry)\n const symbol = getElementSymbol(\"pin-marker\")\n try {\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties) + markerHeight,\n },\n id,\n symbol,\n })\n } catch (error) {\n console.log(`error creating destination marker:`, feature)\n }\n },\n createDestinationLogoMarker: (feature, mapConfig = {}) => {\n const { featureExtrudeConfig } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\", 0)\n\n // Get Label from located unit / kiosk\n const { properties, id } = feature\n const { geometry } = properties.anchor\n const logoUrl = _.get(properties, \"logo.url\")\n const coordinates = getCenterFromGeometry(geometry)\n const [markerBase, markerLabel] = getLabelSymbol(\n \"highlighted-logo-marker\"\n )\n try {\n return new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties) + markerHeight,\n },\n id,\n symbol: [markerBase, { ...markerLabel, markerFile: logoUrl }],\n })\n } catch (error) {\n console.log(`error creating destination marker:`, feature)\n }\n },\n\n createUserLocationMarker: (feature) => {\n try {\n const { geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const symbolStyle = getElementSymbol(\"user-location\") || {}\n const marker = new Marker(coordinates, {\n properties: {\n altitude: getAltitude(properties),\n ordinal: properties.ordinal !== null ? properties.ordinal : null,\n },\n symbol: symbolStyle.start,\n zIndex: USER_LOCATION_Z_INDEX,\n })\n\n marker.animate(\n {\n symbol: symbolStyle.end,\n },\n {\n repeat: true,\n easing: \"upAndDown\",\n duration: 1500,\n }\n )\n return marker\n } catch (err) {\n console.log(`error creating marker:`, feature)\n }\n },\n\n createLastUserLocationMarker: (feature) => {\n try {\n const { geometry, properties } = feature\n const coordinates = getCenterFromGeometry(geometry)\n const symbolStyle = getElementSymbol(\"last-user-location\") || {}\n const options = getElementOptions(\"last-user-location\") || {}\n const marker = new Marker(coordinates, {\n properties: {\n ...options,\n altitude: getAltitude(properties),\n ordinal: properties.ordinal !== null ? properties.ordinal : null,\n },\n symbol: symbolStyle,\n zIndex: LAST_LOCATION_Z_INDEX,\n })\n\n return marker\n } catch (err) {\n console.log(`error creating marker:`, feature)\n }\n },\n\n createHighlightOccupantMarker: (feature, mapConfig) => {\n const { featureExtrudeConfig, markerSymbol } = getFeatureMarkerConfig(\n feature,\n mapConfig\n )\n const markerHeight = _.get(featureExtrudeConfig, \"height\")\n const { id, feature_type, properties } = feature\n\n if (!properties.anchor) return\n\n const markerProperties = {\n ...properties,\n id,\n feature_type,\n altitude: getAltitude(properties) + markerHeight,\n }\n\n const { geometry } = properties?.anchor\n const coordinates = _.get(geometry, \"coordinates\")\n const logoUrl = _.get(properties, \"logo.url\")\n\n // If the symbol option is defined, create a marker.\n if (markerSymbol) {\n return new Marker(coordinates, {\n properties: markerProperties,\n symbol: markerSymbol,\n })\n }\n\n //use pin-marker if no logo\n if (!logoUrl) {\n const symbol = getElementSymbol(\"pin-marker\")\n return new Marker(coordinates, {\n properties: markerProperties,\n symbol,\n })\n }\n\n const labelSymbol = getLabelSymbol(\"highlight-occupant-logo\")\n const priorityMarkerSymbol = _.last(labelSymbol) || {}\n _.set(priorityMarkerSymbol, \"markerFile\", logoUrl)\n return new Marker(coordinates, {\n properties: markerProperties,\n symbol: labelSymbol,\n })\n },\n createHighlight2DAmenityMarkerFrom3DMarker: (feature, mapConfig) => {\n const { coordinates, units, kiosk } = feature\n const amenityLocatedUnit = _.first(units)\n\n const unitConfig = getExtrudeConfigByFeature(\n mapConfig,\n amenityLocatedUnit\n )\n const unitHeight = _.get(unitConfig, \"height\", 0)\n const kioskConfig = getExtrudeConfigByFeature(mapConfig, kiosk)\n const kioskHeight = _.get(kioskConfig, \"height\", 0)\n\n const markerHeight = unitHeight + kioskHeight\n\n const symbol = getElementSymbol(\"highlight-amenity-marker\")\n return new Marker(coordinates, {\n properties: {\n ...feature,\n altitude: markerHeight,\n },\n symbol,\n })\n },\n\n createSection: (feature) => {\n const { properties, feature_type } = feature\n const { category } = properties\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n switch (category) {\n case \"eatingdrinking\":\n return createEatingDrinkingSection(feature, elementStyle)\n case \"vegetation\":\n return createVegetationSection(feature, elementStyle)\n case \"seating\":\n return creatingSeatingSection(feature, elementStyle)\n default:\n return creatingDefaultSection(feature, elementStyle)\n }\n },\n\n createOccupant: (feature, location, mapConfig) => {\n return createOccupantMarker(feature, location, mapConfig)\n },\n\n createOpening: (feature) => {\n const {\n feature_type,\n properties: { category },\n } = feature\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n const options = {\n ...getElementOptions(`${feature_type}.${category}`),\n zIndex: OPENING_Z_INDEX,\n }\n switch (feature.properties.category) {\n case \"pedestrian\":\n return createPedestrianOpening(feature, elementStyle, options)\n case \"pedestrian.principal\":\n return createPrincipalOpening(feature, elementStyle, options)\n case \"emergencyexit\":\n return createEmergencyExitOpening(feature, elementStyle, options)\n default:\n break\n }\n },\n\n createFixture: (feature) => {\n const {\n feature_type,\n properties: { category },\n } = feature\n const elementStyle = getElementSymbol(`${feature_type}.${category}`)\n const options = {\n ...getElementOptions(`${feature_type}.${category}`),\n zIndex: FIXTURE_Z_INDEX,\n }\n switch (feature.properties.category) {\n case \"water\":\n return createWaterFixture(feature, elementStyle, options)\n case \"vegetation\":\n return createVegetationFixture(feature, elementStyle, options)\n case \"equipment\":\n case \"obstruction\":\n case \"stage\":\n case \"desk\":\n case \"wall\":\n return createObstructionalFixture(feature, elementStyle, options)\n default:\n break\n }\n },\n\n createLineStringFromGeometries: (geometries) => {\n const mergedCoordinates = _(geometries)\n .map((geometry) => {\n switch (geometry.type) {\n case \"Point\":\n return [\n geometry?.getCoordinates\n ? geometry?.getCoordinates()\n : new Coordinate(geometry.coordinates),\n ]\n case \"Polygon\":\n return [\n geometry?.getCenter\n ? geometry?.getCenter()\n : new Polygon(geometry.coordinates).getCenter(),\n ]\n case \"MultiPolygon\":\n return [\n geometry?.getCenter\n ? geometry?.getCenter()\n : new MultiPolygon(geometry.coordinates).getCenter(),\n ]\n case \"LineString\":\n default:\n return geometry?.getCoordinates\n ? geometry?.getCoordinates()\n : new LineString(geometry.coordinates).getCoordinates()\n }\n })\n .flatten()\n .value()\n const stepPathLineSymbol = getElementSymbol(\"navigation-path\")\n const startPathSymbolMarker = getElementSymbol(\"navigation-path-start\")\n\n const line = new LineString(mergedCoordinates, {\n smoothness: 0.5,\n symbol: [...stepPathLineSymbol, startPathSymbolMarker],\n })\n\n return line\n },\n create3DStepPath: (feature, threeLayer, option = {}) => {\n const stepPathLineSymbol = getElementSymbol(\"navigation-path\")\n const pathLineSymbol = stepPathLineSymbol[1]\n const pathLineEffect = stepPathLineSymbol[0]\n const lineOptions = {\n color: pathLineSymbol?.lineColor,\n opacity: pathLineSymbol?.lineOpacity,\n }\n const outlineOptions = {\n color: pathLineEffect?.lineColor,\n opacity: pathLineEffect?.lineOpacity,\n }\n\n return new NavigationPath(\n feature,\n threeLayer,\n getFeatureProperties(feature),\n option,\n lineOptions,\n outlineOptions\n )\n },\n\n createDecoration: (decoration, options) => {\n const { type, coordinates } = decoration\n const { id, ordinal, symbol } = options\n const formattedProperties = {\n properties: {\n id,\n altitude: getAltitude(options),\n ordinal,\n },\n symbol,\n zIndex: DECORATION_Z_INDEX,\n }\n switch (type) {\n case \"Polygon\":\n return new Polygon(coordinates, formattedProperties)\n case \"MultiPolygon\":\n return new MultiPolygon(coordinates, formattedProperties)\n case \"LineString\":\n return new LineString(coordinates, formattedProperties)\n case \"MultiLineString\":\n return new MultiLineString(coordinates, formattedProperties)\n default:\n return null\n }\n },\n\n /** Three JS */\n create3DFootprint: async (feature, threeLayer, options) => {\n const objects = []\n const extrudeHeight = _.get(options, \"height\")\n if (!extrudeHeight) return objects\n\n const { properties } = feature\n const footprintProperties = getFeatureProperties(feature)\n\n // Use properties.model3d if exists\n const hasModel3ds =\n Array.isArray(properties.model3d) && properties.model3d.length > 0\n if (hasModel3ds) {\n const models = properties.model3d\n const center = turfCenter(feature)\n const coordinate = _.get(center, \"geometry.coordinates\")\n for (const model of models) {\n const object = await loadModel3d(model, coordinate, threeLayer)\n object.properties = footprintProperties\n objects.push(object)\n }\n } else {\n const color = footprintProperties.defaultColor\n //skip create extrude polygon if color === \"transparent\" because js can't convert color:\"transparent\" to material color\n if (color === \"transparent\") return\n const material = new MeshLambertMaterial({\n color,\n transparent: true,\n })\n const object = createExtrudePolygon(\n feature.geometry,\n threeLayer,\n material,\n extrudeHeight,\n footprintProperties,\n {}\n )\n objects.push(object)\n }\n\n return objects\n },\n create3DGroundLabel: (label, threeLayer) => {\n const text = label.properties.name\n const bound = label.geometry.coordinates[0]\n if (_.isNil(bound)) throw new Error(\"Invalid coordinates\")\n\n // Retrieve label symbol from map theme\n const groundLabelSymbol = getElementSymbol(\"ground-label\")\n\n // Retrieve label symbol from label feature properties\n const featureSymbol = _.get(label, \"properties\", {})\n\n // Apply default style from map theme if not defined in label feature\n const groundLabelOptions = _.merge(\n {},\n { text },\n groundLabelSymbol,\n featureSymbol\n )\n\n return new GroundLabel(bound, groundLabelOptions, threeLayer)\n },\n\n createOccupantGroundLabel: (feature, location, mapConfig, threeLayer) => {\n const text = feature.properties.name.en\n const bound = location.geometry.coordinates[0]\n if (_.isNil(bound)) throw new Error(\"Invalid coordinates\")\n\n const groundLabelSymbol = getElementSymbol(\"occupant-flat-label\")\n const groundLabelOptions = getElementOptions(\"occupant-flat-label\")\n\n const baseAltitude = getAltitude(location.properties)\n const extrudeHeight = _.get(\n mapConfig,\n \"extrudeConfig.unit.room.height\",\n 0\n )\n const totalAltitude = baseAltitude + extrudeHeight + 0.05\n\n const customAngle = _.get(feature, \"properties.style.angle\")\n const offsetX = _.get(feature, \"properties.style.offsetX\", 0)\n const offsetY = _.get(feature, \"properties.style.offsetY\", 0)\n\n const featureSymbol = {\n name: text,\n ordinal: location.properties.ordinal,\n venue_id: feature.properties.venue_id,\n }\n\n // symbol, options and custom properties\n const mergedGroundLabelOptions = _.merge(\n {},\n { text },\n groundLabelSymbol,\n groundLabelOptions,\n featureSymbol,\n {\n altitude: totalAltitude,\n offsetX,\n offsetY,\n // set custom angle\n ...(!_.isNil(customAngle) ? { angle: customAngle } : {}),\n }\n )\n\n const groundLabel = new GroundLabel(\n bound,\n mergedGroundLabelOptions,\n threeLayer\n )\n return groundLabel\n },\n\n create3DBillboard: (billboard, threeLayer) => {\n const { id, feature_type, properties } = billboard\n const {\n logo,\n altitude,\n scale,\n alphaTest,\n legColor,\n showLeg,\n is_clickable,\n } = properties\n const coordinates = getCenterFromGeometry(billboard.geometry)\n const billboardProperties = {\n ...billboard.properties,\n id,\n feature_type,\n }\n\n const options = {\n altitude,\n scale,\n alphaTest,\n legColor,\n showLeg,\n interactive: is_clickable,\n }\n\n return new Billboard(\n coordinates,\n options,\n logo?.url,\n threeLayer,\n billboardProperties\n )\n },\n create3DAmenityMarker: (feature, threeLayer, config) => {\n const { geometry, properties, feature_type, id } = feature\n const { category, units, kiosk, is_clickable } = properties\n const amenityLocatedUnit = _.first(units)\n const isLocatedUnitModel3dAvailable = !_.isEmpty(\n amenityLocatedUnit?.properties?.model3d\n )\n const isLocatedKioskModel3dAvailable = !_.isEmpty(\n kiosk?.properties?.model3d\n )\n\n const unitConfig = getExtrudeConfigByFeature(config, amenityLocatedUnit)\n const unitHeight = isLocatedUnitModel3dAvailable\n ? 0\n : _.get(unitConfig, \"height\", 0)\n const kioskConfig = getExtrudeConfigByFeature(config, kiosk)\n const kioskHeight = isLocatedKioskModel3dAvailable\n ? 0\n : _.get(kioskConfig, \"height\", 0)\n\n const coordinates = _.get(geometry, \"coordinates\")\n\n const markerProperties = {\n ...properties,\n coordinates,\n id,\n feature_type,\n }\n\n const material = _.get(\n spriteMarkerMaterialObj,\n `${feature_type}.${category}`\n )\n\n const highlightOptions = _.get(\n spriteHighlightMarkerOptionObj,\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`\n )\n\n const options = {\n scale: 0.05,\n altitude: unitHeight + kioskHeight,\n highlight: highlightOptions,\n interactive: is_clickable,\n }\n\n return create3DMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n },\n\n create3DOccupantAmenityMarker: (feature, threeLayer, config) => {\n const { geometry, properties, feature_type, id } = feature\n const { category, unit, kiosk } = properties\n const amenityLocation = kiosk || unit\n const locationConfig = getExtrudeConfigByFeature(config, amenityLocation)\n const coordinates = _.get(geometry, \"coordinates\")\n\n const markerProperties = {\n ...properties,\n coordinates,\n id,\n feature_type,\n }\n\n const material = _.get(\n spriteMarkerMaterialObj,\n `${feature_type}.${category}`\n )\n\n const highlightOptions = _.get(\n spriteHighlightMarkerOptionObj,\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`\n )\n\n const options = {\n scale: 0.05,\n altitude: _.get(locationConfig, \"height\", 0),\n highlight: highlightOptions,\n }\n\n return create3DMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n },\n create3DOpeningMarker: (feature, threeLayer, config) => {\n const { geometry, properties, feature_type, id } = feature\n const { category, unit, kiosk } = properties\n const amenityLocation = kiosk || unit\n const locationConfig = getExtrudeConfigByFeature(config, amenityLocation)\n const coordinates = _.get(geometry, \"coordinates\")\n\n const markerProperties = {\n ...properties,\n coordinates,\n id,\n feature_type,\n }\n\n const material = _.get(\n spriteMarkerMaterialObj,\n `${feature_type}.${category}`\n )\n\n const highlightOptions = _.get(\n spriteHighlightMarkerOptionObj,\n `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`\n )\n\n const options = {\n scale: 0.05,\n altitude: _.get(locationConfig, \"height\", 0),\n highlight: highlightOptions,\n }\n\n return create3DMarker(\n coordinates,\n options,\n material,\n threeLayer,\n markerProperties\n )\n },\n\n\n createVenue3DModel: async (venue, threeLayer) => {\n const { id, feature_type, properties } = venue\n const { category, model3d } = properties\n const modelProperty = {\n id,\n feature_type,\n category,\n }\n const center = turfCenter(venue)\n const centerCoord = _.get(center, \"geometry.coordinates\")\n const modelPosition = _.get(model3d, \"properties.position\", centerCoord)\n const models = await create3DModels(\n model3d,\n modelPosition,\n modelProperty,\n threeLayer\n )\n return models\n },\n\n create3DFixture: async (fixture, threeLayer) => {\n const { id, feature_type, properties } = fixture\n const { category, ordinal, model3d } = properties\n\n const modelProperty = {\n id,\n feature_type,\n category,\n ordinal,\n }\n\n const center = turfCenter(fixture)\n const coordinate = _.get(center, \"geometry.coordinates\")\n const models = await create3DModels(\n model3d,\n coordinate,\n modelProperty,\n threeLayer\n )\n return models\n },\n createExtrudedUnit: (unit, threeLayer, options) => {\n const extrudeHeight = _.get(options, \"height\")\n if (!extrudeHeight) return\n //NOTE: this is temporary condition that only extrude when the unit is \"room\"\n const unitProperty = getFeatureProperties(unit)\n //NOTE: offset will be dynamic in future improvement\n const options3d = {\n // TODO: Move to extrude config later\n offset: -0.1,\n altitude: _.get(options, \"altitude\", 0),\n }\n const color = unitProperty.defaultColor\n if (color === \"transparent\") return\n const material = new MeshLambertMaterial({\n color,\n transparent: true,\n })\n //create polygon with line-offset if geometry is lineString\n if (unit.geometry.type === \"LineString\") {\n const polygon = createPolygonFromLineString(unit.geometry)\n const geometry = {\n type: \"Polygon\",\n coordinates: polygon,\n }\n return createExtrudePolygon(\n geometry,\n threeLayer,\n material,\n extrudeHeight,\n unitProperty,\n options3d\n )\n }\n const object = createExtrudePolygon(\n unit.geometry,\n threeLayer,\n material,\n extrudeHeight,\n unitProperty,\n options3d\n )\n return object\n },\n \n createAmbientLight: (config) => {\n const { color: colorString = \"0xffffff\", intensity = 1 } = config\n const color = parseInt(colorString, 16)\n const ambientLight = new AmbientLight(color, intensity)\n return ambientLight\n },\n createDirectionalLight: (config) => {\n const {\n color: colorString = \"0xffffff\",\n intensity = 1,\n position: positionString = [0, 0, 0],\n } = config\n const color = parseInt(colorString, 16)\n const [x, y, z] = positionString\n const light = new DirectionalLight(color, intensity)\n light.position.set(x, y, z).normalize()\n return light\n },\n }\n}\n\nconst EXCEPT_AMENITY_LOCATION_CATEGORIES = [\n \"walkway\",\n \"nonpublic\",\n \"parking\",\n \"opentobelow\",\n \"unspecified\",\n]\nexport const getLocationByAmenity = (feature) => {\n const unit = _.get(feature, \"properties.units[0]\", null)\n const unitCategory = _.get(unit, \"properties.category\")\n if (!unit) return feature.id\n return EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory)\n ? feature\n : unit\n}\n\nexport const getLocationByOccupant = (feature) => {\n const kiosk = _.get(feature, \"properties.kiosk\", null)\n const unit = _.get(feature, \"properties.anchor.properties.unit\", null)\n return kiosk || unit\n}\n\nexport const getLocationIdByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"kiosk\":\n case \"unit\":\n case \"opening\":\n return feature.id\n case \"amenity\":\n return getLocationByAmenity(feature)?.id\n case \"occupant\":\n return getLocationByOccupant(feature)?.id\n case \"promotion\":\n case \"event\":\n return feature.properties?.feature_id\n default:\n return\n }\n}\n\nexport const getFeatureByLocationId = (id, features = []) => {\n return features?.find((f) => {\n const mainLocationId = getLocationIdByFeature(f)\n const relatedLocationIds = getRelatedLocationIdsByFeature(f)\n return mainLocationId === id || relatedLocationIds.includes(id)\n })\n}\n\nexport const isClickableFeature = (feature) => {\n const isClickable = _.get(feature, \"properties.is_clickable\")\n switch (feature?.feature_type) {\n case \"amenity\":\n return _.isNull(isClickable) ? true : isClickable\n case \"occupant\":\n return true\n default:\n return\n }\n}\n\nexport const getLocationByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"amenity\":\n return getLocationByAmenity(feature)\n case \"occupant\":\n return getLocationByOccupant(feature)\n default:\n return\n }\n}\n\n/*\n * Utility functions to retrieve related locations for amenities and occupants.\n * - Used for highlighting on the floor plan.\n * - Displays location details.\n */\n\nexport const getRelatedLocationsByOccupant = (feature) => {\n const kiosks = _.get(feature, \"properties.kiosks\", [])\n const units = _.get(feature, \"properties.units\", [])\n return [...kiosks, ...units]\n}\n\nexport const getRelatedLocationsByAmenity = (feature) => {\n const units = _.get(feature, \"properties.units\", [])\n\n if (units.length === 0) return [feature]\n\n return units.filter((unit) => {\n const unitCategory = _.get(unit, \"properties.category\")\n return !EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory)\n })\n}\n\nexport const getRelatedLocationIdsByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"amenity\":\n return getRelatedLocationsByAmenity(feature).map((v) => v?.id)\n case \"occupant\":\n return getRelatedLocationsByOccupant(feature).map((v) => v?.id)\n default:\n return []\n }\n}\n\nexport const getRelatedLocationsByFeature = (feature) => {\n switch (feature?.feature_type) {\n case \"amenity\":\n return getRelatedLocationsByAmenity(feature)\n case \"occupant\":\n return getRelatedLocationsByOccupant(feature)\n default:\n return []\n }\n}\n\nexport const getOrdinalByLocationId = (locationId, feature) => {\n if (!feature) return null\n\n const mainUnit = _.get(feature, \"properties.unit\")\n const mainKiosk = _.get(feature, \"properties.kiosk\")\n const relatedLocations = getRelatedLocationsByFeature(feature)\n\n const allLocations = [mainUnit, mainKiosk, ...relatedLocations].filter(\n Boolean\n )\n const targetLocation = allLocations.find(\n (location) => location.id === locationId\n )\n\n return targetLocation\n ? _.get(targetLocation, \"properties.level.properties.ordinal\") ||\n _.get(targetLocation, \"properties.ordinal\")\n : null\n}\n","import * as maptalks from \"maptalks\"\nimport { BaseObject } from \"maptalks.three\"\nimport {\n LineBasicMaterial,\n BufferGeometry,\n Float32BufferAttribute,\n Line,\n TextureLoader,\n SpriteMaterial,\n Sprite,\n} from \"three\"\nimport _ from \"lodash\"\n\nconst OPTIONS = {\n altitude: 25,\n scale: 0.00015,\n alphaTest: 0.3,\n legColor: \"#ff0400\",\n showLeg: true,\n}\n\nconst getImgDimension = async (url) => {\n const img = new Image()\n img.src = url\n await img.decode()\n return { naturalWidth: img.naturalWidth, naturalHeight: img.naturalHeight }\n}\n\nexport class Billboard extends BaseObject {\n #layer = null\n constructor(coordinate, options, src, layer, properties) {\n options = maptalks.Util.extend({}, OPTIONS, options, {\n layer,\n coordinate,\n })\n super()\n //Initialize internal configuration\n this.#layer = layer\n this._initOptions(options)\n const {\n altitude = OPTIONS.altitude,\n scale = OPTIONS.scale,\n alphaTest = OPTIONS.alphaTest,\n legColor = OPTIONS.legColor,\n showLeg = OPTIONS.showLeg,\n } = options\n this.properties = { ...properties }\n this._createGroup()\n\n // Screen size / base mobile screen size ratio => 375\n const divider = _.clamp(window.innerWidth / 375 / 1.75, 1, 1.7)\n // Leg\n if (showLeg) {\n const lineMaterial = new LineBasicMaterial({\n color: legColor,\n transparent: true,\n })\n const lineHeight = layer.altitudeToVector3(altitude, altitude).x\n const lineGeometry = new BufferGeometry()\n const positions = [0, 0, 0, 0, 0, -lineHeight]\n lineGeometry.setAttribute(\n \"position\",\n new Float32BufferAttribute(positions, 3)\n )\n const line = new Line(lineGeometry, lineMaterial)\n this.getObject3d().add(line)\n }\n\n getImgDimension(src).then(({ naturalWidth, naturalHeight }) => {\n // Image\n const map = new TextureLoader().load(src)\n const material = new SpriteMaterial({\n map: map,\n color: 0xffffff,\n alphaTest: alphaTest,\n })\n material.needsUpdate = true\n const sprite = new Sprite(material)\n sprite.material.sizeAttenuation = false\n sprite.scale.set(\n (scale * naturalWidth) / divider,\n (scale * naturalHeight) / divider,\n 1\n )\n this.getObject3d().add(sprite)\n })\n\n // set object3d position\n const z = layer.altitudeToVector3(altitude, altitude).x\n const position = layer.coordinateToVector3(coordinate, z)\n _.set(this.properties, \"default.position\", position)\n _.set(this.properties, \"default.altitude\", altitude)\n _.set(this.properties, \"default.scale\", scale)\n this.getObject3d().position.copy(position)\n }\n\n setLineHeight(altitude) {\n const lineHeight = this.#layer.altitudeToVector3(altitude, altitude).x\n const geometry = this.getObject3d().children[0].geometry\n const positionAttribute = geometry.getAttribute(\"position\")\n positionAttribute.setZ(1, -lineHeight)\n positionAttribute.needsUpdate = true\n\n this.getObject3d().position.z = lineHeight\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { BaseObject } from \"maptalks.three\"\nimport {\n Texture,\n Mesh,\n MeshPhongMaterial,\n PlaneGeometry,\n Material,\n} from \"three\"\nimport { largestRect } from \"d3plus-shape\"\nimport { max, merge, isNumber, isArray, range } from \"lodash-es\"\n\nconst OPTIONS = {\n // Allowing click through and prevent interaction\n interactive: false,\n altitude: 0,\n}\n\nconst defaultFlatLabelOptions = {\n fontSize: 14,\n fontFamily: \"Manrope\",\n fontWeight: 600,\n margin: 0,\n scaleMin: 0.5,\n lineHeight: 1.05,\n scaleStep: 0.05,\n textAlign: \"center\",\n textBaseline: \"middle\",\n fillStyle: \"#000\",\n}\n\nconst defaultRectAngleToCalc = range(-90, 92, 2)\n\nexport const getMaterial = (text, flatLabelOptions) => {\n const options = merge({}, defaultFlatLabelOptions, flatLabelOptions)\n\n const {\n fontSize: initialFontSize,\n fontFamily,\n fontWeight,\n margin,\n scaleMin,\n scaleStep,\n fillStyle,\n lineHeight,\n textAlign,\n strokeStyle,\n lineWidth,\n textBaseline,\n } = options\n\n const pixelMultiplier = 4\n const SIZE = 100 * pixelMultiplier\n const fontSize = initialFontSize * (pixelMultiplier * 1.25)\n const canvas = document.createElement(\"canvas\")\n canvas.width = canvas.height = SIZE\n const ctx = canvas.getContext(\"2d\")\n\n ctx.font = `${fontWeight} ${fontSize}px \"${fontFamily}\", Arial`\n ctx.textAlign = textAlign\n ctx.textBaseline = textBaseline\n ctx.fillStyle = fillStyle\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n\n // Function to wrap text automatically\n const wrapText = (ctx, text, maxWidth) => {\n const words = text.trim().split(/\\s+/)\n if (words.length <= 1) return [text]\n\n const lines = []\n const MAX_LINES = 3\n let currentLine = words[0]\n\n for (let i = 1; i < words.length; i++) {\n const lineToMeasure = currentLine + \" \" + words[i]\n if (ctx.measureText(lineToMeasure).width > maxWidth) {\n lines.push(currentLine)\n currentLine = words[i]\n } else {\n currentLine = lineToMeasure\n }\n }\n lines.push(currentLine)\n return lines.slice(0, MAX_LINES) // Limit to 3 lines\n }\n\n /** Check if text contains manual line breaks */\n const hasManualBreaks = text.includes(\"\\n\")\n let texts\n\n if (hasManualBreaks) {\n // Use manual line breaks\n texts = text.split(/\\n/g)\n } else {\n // Auto-wrap text\n const maxWidth = SIZE - 2 * margin\n texts = wrapText(ctx, text, maxWidth)\n }\n\n /** Automatically recalculate font size to fit the bound */\n let textWidth: number = max(texts.map((text) => ctx.measureText(text).width))\n let scale = 1\n while (scale > 0 && textWidth + 2 * margin > SIZE) {\n scale -= scaleStep\n ctx.font = `${fontWeight} ${scale * fontSize}px \"${fontFamily}\", Arial`\n textWidth = max(texts.map((text) => ctx.measureText(text).width))\n }\n\n // If the text is larger than scaleMin, then render it\n const center = { x: 0.5 * SIZE, y: 0.5 * SIZE }\n\n if (scale > scaleMin) {\n const totalHeight = texts.length * (fontSize * scale * lineHeight)\n const startY =\n center.y - totalHeight / 2 + fontSize * scale * lineHeight * 0.5 // Adjust startY when offset multi text line\n\n texts.forEach((text, index) => {\n const yOffset = startY + index * (fontSize * scale * lineHeight)\n if (strokeStyle && lineWidth) {\n ctx.strokeText(text, center.x, yOffset) // Draw outlined text\n }\n ctx.fillText(text, center.x, yOffset)\n })\n }\n\n const texture = new Texture(canvas)\n texture.needsUpdate = true\n\n const material = new MeshPhongMaterial({\n map: texture,\n transparent: true,\n // @ref: https://threejs.org/docs/#api/en/materials/Material.alphaTest\n alphaTest: 0.3,\n })\n return material\n}\n\nexport class GroundLabel extends BaseObject {\n #angle = 0\n #bearing = 0\n #text = \"\"\n #offsetX = 0\n #offsetY = 0\n #originalPosition = null\n #layer = null\n\n constructor(bound, options, layer) {\n options = maptalks.Util.extend({}, OPTIONS, options, {\n layer,\n coordinate: bound,\n })\n\n const {\n altitude,\n text,\n fontSize,\n fillStyle,\n textAlign,\n fontFamily,\n textBaseline,\n strokeStyle,\n lineWidth,\n angle = defaultRectAngleToCalc,\n maxFontScale,\n offsetX = 0,\n offsetY = 0,\n ...properties\n } = options\n\n super()\n this._initOptions(options)\n this.properties = properties\n\n this.#offsetX = offsetX\n this.#offsetY = offsetY\n this.#layer = layer\n\n const material = getMaterial(text, {\n fillStyle,\n fontSize,\n textAlign,\n textBaseline,\n fontFamily,\n strokeStyle,\n lineWidth,\n })\n\n // Convert angle to array if it's a single number\n const rectAngles = isArray(angle) ? angle : [angle]\n\n material.needsUpdate = true\n\n const rect = largestRect(bound, {\n cache: true,\n /**\n * Black magic here:\n * For some reason if we allow angle -90 or 90, some polygon will use that angle even if it's wrong angle to use.\n * So we remove -90 and 90 from choices, and use -85 & 85 instead.\n */\n angle: rectAngles,\n })\n\n const { cx, cy, width, angle: calculatedAngle } = rect\n this.#text = text\n this.#angle = calculatedAngle // Always use calculated angle from largestRect\n\n const geometry = new PlaneGeometry(1, 1)\n this._createMesh(geometry, material)\n\n // set object3d position\n const z = layer.altitudeToVector3(altitude, altitude).x\n const basePosition = layer.coordinateToVector3({ x: cx, y: cy }, z)\n\n this.#originalPosition = basePosition.clone()\n const finalPosition = this.#calculateFinalPosition(basePosition)\n\n const scale = width / 0.0006456122659\n // check if it has maxFontScaleLimit from option use maxFontScale\n const finalScale =\n maxFontScale && scale > maxFontScale ? maxFontScale : scale\n this.getObject3d().scale.set(finalScale, finalScale, finalScale)\n this.getObject3d().position.copy(finalPosition)\n this.getObject3d().rotation.z = (Math.PI / 180) * this.#angle\n }\n\n #calculateFinalPosition(basePosition) {\n if (this.#offsetX === 0 && this.#offsetY === 0) {\n return basePosition\n }\n\n const offsetCoordinate = {\n x: this.#offsetX,\n y: this.#offsetY,\n }\n\n const z = this.#layer.altitudeToVector3(0, 0).x\n const offsetVector = this.#layer.coordinateToVector3(offsetCoordinate, z)\n const zeroVector = this.#layer.coordinateToVector3({ x: 0, y: 0 }, z)\n\n const worldOffsetX = offsetVector.x - zeroVector.x\n const worldOffsetY = offsetVector.y - zeroVector.y\n\n return {\n x: basePosition.x + worldOffsetX,\n y: basePosition.y + worldOffsetY,\n z: basePosition.z,\n }\n }\n\n #updatePosition() {\n if (this.#originalPosition && this.#layer) {\n const finalPosition = this.#calculateFinalPosition(this.#originalPosition)\n this.getObject3d().position.copy(finalPosition)\n }\n }\n\n set bearing(value) {\n this.#bearing = value\n const degree = this.#angle + this.#bearing\n const angle = degree > 90 || degree < -90 ? this.#angle + 180 : this.#angle\n this.getObject3d().rotation.z = (Math.PI / 180) * angle\n }\n\n get angle() {\n return this.#angle\n }\n\n get currentAngle() {\n return this.#angle\n }\n\n get text() {\n return this.#text\n }\n\n get offsetX() {\n return this.#offsetX\n }\n\n get offsetY() {\n return this.#offsetY\n }\n\n get offset() {\n return { x: this.#offsetX, y: this.#offsetY }\n }\n\n set offsetX(value) {\n if (isNumber(value)) {\n this.#offsetX = value\n this.#updatePosition()\n }\n }\n\n set offsetY(value) {\n if (isNumber(value)) {\n this.#offsetY = value\n this.#updatePosition()\n }\n }\n\n set angle(newAngle) {\n if (isNumber(newAngle)) {\n this.#angle = newAngle\n this.getObject3d().rotation.z = (Math.PI / 180) * this.#angle\n }\n }\n\n setOffset(offsetX, offsetY) {\n if (isNumber(offsetX) && isNumber(offsetY)) {\n this.#offsetX = offsetX\n this.#offsetY = offsetY\n this.#updatePosition()\n }\n }\n\n addOffset(deltaX, deltaY) {\n if (isNumber(deltaX) && isNumber(deltaY)) {\n this.#offsetX += deltaX\n this.#offsetY += deltaY\n this.#updatePosition()\n }\n }\n\n resetOffset() {\n this.#offsetX = 0\n this.#offsetY = 0\n this.#updatePosition()\n }\n\n moveToPosition(targetX, targetY) {\n if (this.#originalPosition && this.#layer) {\n const currentCenter = this.#layer.vector3ToCoordinate(\n this.#originalPosition\n )\n this.#offsetX = targetX - currentCenter.x\n this.#offsetY = targetY - currentCenter.y\n this.#updatePosition()\n }\n }\n\n updateText(newText, options: Record<string, unknown> = {}) {\n this.#text = newText\n\n const materialOptions = {\n fillStyle: options.fillStyle || this.properties.fillStyle,\n fontSize: options.fontSize || this.properties.fontSize,\n textAlign: options.textAlign || this.properties.textAlign,\n textBaseline: options.textBaseline || this.properties.textBaseline,\n fontFamily: options.fontFamily || this.properties.fontFamily,\n strokeStyle: options.strokeStyle || this.properties.strokeStyle,\n lineWidth: options.lineWidth || this.properties.lineWidth,\n }\n\n const newMaterial = getMaterial(newText, materialOptions) as Material\n ;(this.getObject3d() as Mesh).material = newMaterial\n newMaterial.needsUpdate = true\n }\n}\n","import { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport { Sprite, SpriteMaterial } from \"three\"\nimport _ from \"lodash\"\n\nconst DEFAULT_SCALE = 0.05\nconst DEFAULT_ALTITUDE = 0\nconst DEFAULT_ALPHATEST = 0.3\nconst DEFAULT_OPTIONS = {\n scale: DEFAULT_SCALE,\n altitude: DEFAULT_ALTITUDE,\n alphaTest: DEFAULT_ALPHATEST,\n highlight: {\n options: {\n scale: DEFAULT_SCALE * 1.25,\n },\n material: null,\n },\n}\n\ninterface IOptions {\n scale: number\n altitude: number\n alphaTest?: number\n highlight?: {\n options: {\n altitude?: number\n scale?: number\n }\n material?: SpriteMaterial\n }\n}\n\nexport class SpriteMarker extends BaseObject {\n #default = null\n #highlight = null\n constructor(\n coordinate,\n options: IOptions,\n material: SpriteMaterial,\n layer: ThreeLayer,\n properties: object\n ) {\n super()\n //Initialize internal configuration\n this._initOptions(options)\n this._createGroup()\n const {\n altitude = DEFAULT_OPTIONS.altitude,\n scale = DEFAULT_OPTIONS.scale,\n highlight = DEFAULT_OPTIONS.highlight,\n alphaTest = DEFAULT_OPTIONS.alphaTest,\n } = options\n this.properties = { ...properties }\n\n const modifiedAltitude = altitude + 2\n\n this.#default = { options: { scale, altitude: modifiedAltitude }, material }\n this.#highlight = _.merge({}, DEFAULT_OPTIONS.highlight, highlight)\n\n /**\n * Add alphaTest to render only non-transparent pixels in PNG images.\n * [@Doc](https://threejs.org/docs/#api/en/materials/Material.alphaTest)\n */\n if (material && material instanceof SpriteMaterial)\n material.alphaTest = alphaTest\n\n const sprite = new Sprite(material)\n sprite.scale.set(scale, scale, scale) // Set sprite scale\n\n const obj3d = this.getObject3d()\n obj3d.add(sprite)\n // set object3d position\n const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x\n const position = layer.coordinateToVector3(coordinate, z)\n _.set(this.properties, \"default.position\", position)\n this.getObject3d().position.copy(position)\n }\n\n // Different objects need to implement their own methods\n setSymbol(material: SpriteMaterial) {\n if (material && material instanceof SpriteMaterial) {\n const sprite = (this.getObject3d() as any).children[0]\n\n if (!sprite) return this\n\n sprite.material = material\n sprite.material.needsUpdate = true\n }\n return this\n }\n\n setScale(scaleX: number, scaleY: number = scaleX, scaleZ: number = scaleX) {\n const sprite = (this.getObject3d() as any).children[0]\n if (!sprite) return this\n\n sprite.scale.set(scaleX, scaleY, scaleZ)\n\n return this\n }\n\n // Different objects need to implement their own methods\n getSymbol(): SpriteMaterial {\n return (this.getObject3d() as any)?.children[0]?.material\n }\n\n highlight() {\n const { material, options } = this.#highlight\n if (material) this.setSymbol(material)\n if (options.scale) this.setScale(options.scale)\n if (options.altitude) this.setAltitude(options.altitude)\n return this\n }\n\n removeHighlight() {\n const { material, options } = this.#default\n if (material) this.setSymbol(material)\n if (options.scale) this.setScale(options.scale)\n if (options.altitude) this.setAltitude(options.altitude)\n return this\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { BaseObject } from \"maptalks.three\"\nimport { MeshBasicMaterial, ShaderMaterial, Color } from \"three\"\n\nconst OPTIONS = {\n altitude: 0,\n}\n\nconst DEFAULT_LINE_OPTION = {\n color: \"#000\",\n opacity: 1,\n}\nconst DEFAULT_LINE_EFFECT_OPTION = {\n color: \"#000\",\n opacity: 1,\n}\n\n// In case we want to open/close this animation per project.\nconst ENABLE_ANIMATED_PATH = true\n\nexport class NavigationPath extends BaseObject {\n constructor(\n feature,\n layer,\n properties,\n options,\n lineOptions = DEFAULT_LINE_OPTION,\n outlineOption = DEFAULT_LINE_EFFECT_OPTION\n ) {\n options = maptalks.Util.extend({}, OPTIONS, options, {\n layer,\n })\n super()\n //Initialize internal configuration\n this._initOptions(options)\n const { altitude = OPTIONS.altitude } = options\n this.properties = { ...properties }\n this._createGroup()\n\n const { color: lineColor, opacity: lineOpacity } =\n lineOptions || DEFAULT_LINE_OPTION\n\n const staticMaterial = new MeshBasicMaterial({\n transparent: true,\n color: lineColor || \"#fff\",\n opacity: lineOpacity || 1,\n depthWrite: false,\n })\n\n const uniforms = {\n time: { value: 0 },\n color: { value: new Color(lineColor || \"#fff\") },\n opacity: { value: lineOpacity || 1 },\n }\n this._uniforms = uniforms\n this._t = 0 // Start time = 0\n\n /**\n * Animation formula\n * float dash = smoothstep(0.3, 0.7, abs(sin(vUv.x * 1.0 - time * 0.1)));\n * | vUv.x * 1.0 | controls dash length & frequency\n * | - time * 1.0 | animates motion to the right\n */\n const animatedMaterial = new ShaderMaterial({\n uniforms,\n transparent: true,\n depthWrite: false,\n vertexShader: `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: `\n uniform float time;\n uniform vec3 color;\n uniform float opacity;\n varying vec2 vUv;\n\n void main() {\n float dash = smoothstep(0.3, 0.7, abs(sin(vUv.x * 1.0 - time * 0.1)));\n gl_FragColor = vec4(color, opacity * dash);\n }\n `,\n })\n\n const pathGeometry = maptalks.GeoJSON.toGeometry(feature)\n const line = layer.toPath(\n pathGeometry,\n {\n interactive: false,\n cornerRadius: 2,\n width: 0.5,\n },\n ENABLE_ANIMATED_PATH ? animatedMaterial : staticMaterial\n )\n\n const { color: outlineColor, opacity: outlineOpacity } = outlineOption || {}\n const outlineMaterial = new MeshBasicMaterial({\n transparent: true,\n color: outlineColor || \"#fff\",\n opacity: outlineOpacity || 1,\n })\n\n const lineOutLine = layer.toPath(\n pathGeometry,\n {\n interactive: false,\n cornerRadius: 2,\n width: 1,\n },\n outlineMaterial\n )\n this.getObject3d().add(lineOutLine.getObject3d())\n this.getObject3d().add(line.getObject3d())\n\n // set object3d position\n const z = layer.altitudeToVector3(altitude + 0.25, altitude + 0.25).x\n const pos = this.getObject3d().position\n\n const position = layer.coordinateToVector3([pos.x, pos.y], z)\n // _.set(this.properties, \"default.position\", position)\n\n this.getObject3d().position.copy(position)\n }\n\n _animation() {\n this._t = this._t + 1\n this._uniforms.time.value = this._t\n }\n}\n","import center from \"@turf/center\"\nimport { Polygon, MultiPolygon, Point, LineString } from \"geojson\"\nimport _ from \"lodash\"\nimport turfLineOffset from \"@turf/line-offset\"\nimport { lineString as turfLineString } from \"@turf/helpers\"\n\n// Calculates the center point of a GeoJSON geometry and Return as a Coordinates.\nexport const getCenterFromGeometry = (geometry?: Polygon | MultiPolygon | Point | LineString): number[] | null => {\n try {\n const { type = null, coordinates = null } = geometry\n if (!type || !coordinates) return null\n const centerPoint = center(geometry)\n return _.get(centerPoint, \"geometry.coordinates\") // Coordinates\n } catch (error) {\n return null\n }\n}\n\nexport const createPolygonFromLineString = (geometry) => {\n const line = turfLineString(geometry.coordinates)\n const left = turfLineOffset(line, 0.3, { units: \"meters\" })\n const right = turfLineOffset(line, -0.3, { units: \"meters\" })\n const leftCoords = left.geometry.coordinates\n const rightCoords = right.geometry.coordinates.reverse()\n const polygon = [...leftCoords, ...rightCoords, leftCoords[0]]\n return [polygon]\n}\n","export const svgToPng = (svgString: string, scaleFactor: number = 1) => {\n const svgBlob = new Blob([svgString], { type: \"image/svg+xml\" })\n const url = URL.createObjectURL(svgBlob)\n const img = new Image()\n return new Promise((resolve, reject) => {\n img.onload = function () {\n // Calculate the new dimensions\n const newWidth = img.width * scaleFactor\n const newHeight = img.height * scaleFactor\n\n // Create a canvas with the new dimensions\n const canvas = document.createElement(\"canvas\")\n canvas.width = newWidth\n canvas.height = newHeight\n const ctx = canvas.getContext(\"2d\")\n\n // Draw the SVG image onto the canvas with the scaled dimensions\n ctx.drawImage(img, 0, 0, newWidth, newHeight)\n\n // Convert canvas to PNG\n const pngDataUrl = canvas.toDataURL(\"image/png\")\n\n // Resolve the Promise with the PNG data URL\n resolve(pngDataUrl)\n }\n\n // Handle image load errors\n img.onerror = function (error) {\n reject(error)\n }\n\n img.src = url\n })\n}\n\nexport const createSVGPathFromMarkerSymbol = (style) => {\n const {\n markerWidth = 24,\n markerDx = 0,\n markerDy = 0,\n markerFill,\n markerPath,\n } = style\n const scale = markerWidth / 24\n return `<path d=\"${markerPath}\" style=\"transform:translate(${markerDx}px, ${markerDy}px) scale(${scale})\" fill=\"${markerFill}\"/>`\n}\n","interface ICoordinate {\n x: number\n y: number\n z?: number\n}\n\ntype RadToDegree = (rad: number) => number\n\ntype GetBearingBetweenPoints = (\n origin: ICoordinate,\n destination: ICoordinate\n) => number\n\ntype GetSuitablyValueBetweenBearings = (\n newBearing: number,\n currentBearing: number\n) => number\n\nconst radToDegree: RadToDegree = (rad) => rad * (180 / Math.PI)\n\nexport const getBearingBetweenPoints: GetBearingBetweenPoints = (\n origin,\n destination\n) => {\n const twoPI = Math.PI * 2\n\n if (origin.x === destination.x && origin.y === destination.y) return\n let theta = Math.atan2(destination.x - origin.x, destination.y - origin.y)\n\n if (theta < 0.0) theta += twoPI\n\n return Math.floor(radToDegree(theta))\n}\n\nexport const getSuitablyValueBetweenBearings: GetSuitablyValueBetweenBearings =\n (newBearing, currentBearing) => {\n const difference = Math.abs(newBearing - currentBearing)\n\n // Adjust newBearing to ensure the shortest direction\n if (difference > 180)\n return newBearing > 0 ? newBearing - 360 : newBearing + 360\n\n return newBearing // Return as is if the difference is within limits\n }\n","import { Color } from \"three\"\nimport _ from \"lodash\"\nimport TWEEN from \"@tweenjs/tween.js\"\n\nimport { BaseObject } from \"maptalks.three\"\nimport { Billboard } from \"../object3d\"\n\n//TODO:: refactor this option logic later\nconst DEFAULT_ALTITUDE_FACTOR = 0.5\nexport const createHighlighBillboardController = (\n obj: Billboard,\n { altitudeFactor = DEFAULT_ALTITUDE_FACTOR } = {}\n) => {\n const controller = { start: () => {}, clear: () => {} }\n if (!(obj instanceof Billboard)) return controller\n\n const altitude = obj.properties.default.altitude\n\n const newAltitude = _.clamp(altitude * altitudeFactor, 0, altitude)\n const tween = new TWEEN.Tween({ altitude })\n .to({ altitude: newAltitude }, 800)\n .easing(TWEEN.Easing.Quartic.Out)\n .onUpdate((newUpdate) => {\n obj.setLineHeight(newUpdate.altitude)\n })\n\n controller.start = () => {\n tween.start()\n }\n\n controller.clear = () => {\n tween.stop().to({ altitude }, 1600).startFromCurrentValues()\n }\n\n return controller\n}\n\nexport const createHighlighExtrudeObjectController = (\n obj: BaseObject,\n { color }\n) => {\n const controller = { start: () => {}, clear: () => {} }\n if (\n obj?.type !== \"ExtrudePolygon\" ||\n _.isNil(obj?.object3d?.material?.color) ||\n _.isNil(color)\n )\n return controller\n\n controller.start = () => {\n obj.object3d.material.color = new Color(color)\n }\n\n controller.clear = () => {\n const objectDefaultColor = _.get(obj, \"properties.defaultColor\")\n obj.object3d.material.color = new Color(objectDefaultColor)\n }\n\n return controller\n}\n","import { Map } from \"maptalks-gl\"\nimport { MapAnimationOptionsType, MapViewType } from \"maptalks/dist/map/Map\"\n\nexport interface CameraManagerOptions {\n defaultView?: MapViewType\n}\n\nexport const ZOOM_OUT_LEVEL = 21\nexport const ZOOM_IN_LEVEL = 24\n\nexport class CameraManager {\n map: Map\n\n constructor(map: Map, options?: CameraManagerOptions) {\n this.map = map\n\n if (options?.defaultView) {\n this.setView(options?.defaultView)\n }\n }\n\n /** Private method */\n #animateflyTo(viewOptions = {}, options = {}, callbackOption = () => {}) {\n const { start, end } = {\n start: (frame) => {},\n end: (frame) => {},\n ...callbackOption,\n }\n this.map.flyTo(viewOptions, options, (frame) => {\n if (frame.state.playState === \"running\" && frame.state.progress === 0)\n start(frame)\n if (frame.state.playState === \"finished\") end(frame)\n })\n }\n\n /** Public methods */\n getView = (): MapViewType => {\n return this.map.getView()\n }\n\n getZoom = (): number => {\n return this.map.getView().zoom\n }\n\n setView = (value: MapViewType) => {\n this.map.setView(value)\n }\n\n flyTo = (center, options: MapAnimationOptionsType & MapViewType = {}) => {\n const currentView = this.getView()\n const {\n zoom = ZOOM_OUT_LEVEL,\n pitch = 60,\n duration = 600,\n easing = \"out\",\n bearing = currentView.bearing,\n } = options\n this.#animateflyTo(\n {\n center,\n zoom,\n pitch,\n bearing,\n },\n { duration, easing }\n )\n }\n\n flyToAndZoomIn = (\n centerPoint,\n options: MapAnimationOptionsType & MapViewType = {}\n ) => {\n const {\n zoom = ZOOM_IN_LEVEL,\n pitch = 60,\n duration = 600,\n easing = \"out\",\n } = options\n this.#animateflyTo(\n {\n center: centerPoint,\n zoom,\n pitch,\n },\n { duration, easing }\n )\n }\n}\n","import * as maptalks from \"maptalks\"\nimport _min from \"lodash/min\"\nimport _partition from \"lodash/partition\"\nimport { center as turfCenter } from \"@turf/center\"\nimport { Position } from \"geojson\"\nimport { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport * as THREE from \"three\"\n\nimport type { RendererManagerOptions } from \"./types\"\nimport { Element3DRenderer } from \"./3d/Element3DRenderer\"\nimport { Element2DRenderer } from \"./2d/Element2DRenderer\"\nimport { Marker2DRenderer } from \"./2d/Marker2DRenderer\"\nimport { Marker3DRenderer } from \"./3d/Marker3DRenderer\"\n\nimport {\n KioskFeaturePopulated,\n OpeningFeaturePopulated,\n UnitFeaturePopulated,\n VenueDataClient,\n} from \"../../data\"\nimport { angleBetweenLineStrings } from \"./utils/angleBetweenLineString\"\n\nexport class RendererManager extends EventTarget {\n map: maptalks.Map\n\n options: RendererManagerOptions\n\n // Client for fetching data\n #dataClient: VenueDataClient\n\n /** Elements: Responsible for converting feature info elements and add to map */\n private elementRenderer: Element2DRenderer | Element3DRenderer\n private markerRenderer: Marker2DRenderer | Marker3DRenderer\n\n private elementsMap: Map<string, maptalks.Geometry | BaseObject>\n private elementsByOrdinal: Map<\n number,\n Array<maptalks.Geometry> | Array<BaseObject>\n >\n\n private currentOrdinals: number | number[] | null\n\n private markersMap: Map<string, maptalks.ui.UIMarker | BaseObject>\n private markersByOrdinal: Map<\n number,\n Array<maptalks.ui.UIMarker> | Array<BaseObject>\n >\n\n constructor(map: maptalks.Map, dataClient: VenueDataClient, options: RendererManagerOptions) {\n super()\n this.map = map\n this.options = options\n this.elementsMap = new Map()\n this.elementsByOrdinal = new Map()\n\n this.markersMap = new Map()\n this.markersByOrdinal = new Map()\n\n this.#dataClient = dataClient\n\n if (options.type === \"3D\") {\n // ElementLayer as ThreeLayer\n const threeLayer = new ThreeLayer(\"elements\", {\n forceRenderOnMoving: true,\n forceRenderOnRotating: true,\n })\n \n const _this = this\n\n threeLayer.prepareToDraw = function (gl, scene, camera) {\n \n const ambientLight = new THREE.AmbientLight(0xffffff, 0.3)\n scene.add(ambientLight)\n \n const dirColor = 0xffffff\n const dllight = new THREE.DirectionalLight(dirColor, 0.8)\n dllight.position.set(0, -10, 10).normalize()\n scene.add(dllight)\n \n // nice optional fill\n const hemi = new THREE.HemisphereLight(0xffffff, 0x444444, 0.4)\n scene.add(hemi)\n\n // Element renderer creates and owns the ThreeLayer\n _this.elementRenderer = new Element3DRenderer(map, options.elements, threeLayer)\n\n // Get the ThreeLayer from element renderer to share with marker renderer\n _this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer)\n\n if (typeof options.onRendererReady === 'function') {\n options.onRendererReady()\n }\n\n _this.#createElements()\n }\n\n threeLayer.addTo(this.map)\n \n \n } else {\n // 2D doesn't need shared layer\n this.elementRenderer = new Element2DRenderer(map, options.elements)\n this.markerRenderer = new Marker2DRenderer(map)\n\n this.#createElements()\n }\n }\n\n getElementsByOrdinal = (ordinal: number) => {\n const exist = this.elementsByOrdinal.get(ordinal)\n if (!exist) this.elementsByOrdinal.set(ordinal, [])\n return this.elementsByOrdinal.get(ordinal)\n }\n\n getMarkersByOrdinal = (ordinal: number) => {\n const exist = this.markersByOrdinal.get(ordinal)\n if (!exist) this.markersByOrdinal.set(ordinal, [])\n return this.markersByOrdinal.get(ordinal)\n }\n\n addElementsToManager = (id, elements, ordinal) => {\n this.elementsMap.set(id, elements)\n elements.forEach((el) => {\n this.getElementsByOrdinal(ordinal).push(el)\n })\n\n const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals\n if (inOrdinal) {\n this.elementRenderer.showElements(elements as any, ordinal)\n } else {\n this.elementRenderer.hideElements(elements as any, ordinal)\n }\n }\n\n addMarkersToManager = (id, markers, ordinal) => {\n this.markersMap.set(id, markers)\n markers.forEach((el) => {\n this.getMarkersByOrdinal(ordinal).push(el)\n })\n\n const inOrdinal = Array.isArray(this.currentOrdinals) ? this.currentOrdinals.includes(ordinal) : ordinal === this.currentOrdinals\n if (inOrdinal) {\n this.markerRenderer.showMarkers(markers, ordinal)\n } else {\n this.markerRenderer.hideMarkers(markers, ordinal)\n }\n }\n async #createElements() {\n /** Levels */\n const levels = await this.#dataClient.filterByType(\"level\", {\n populate: true,\n })\n\n const relationships = await this.#dataClient.filterByType('relationship')\n\n /** Fixtures */\n const fixtures = (await this.#dataClient.filterByType(\"fixture\", { populate: true }))\n fixtures\n .forEach((fixture) => {\n const element = this.elementRenderer.createGeometry(fixture)\n if (element) {\n const _elements = Array.isArray(element) ? element : [element]\n this.addElementsToManager(fixture.id, _elements, fixture.properties.level.properties.ordinal)\n }\n })\n\n /** Units */\n const units = (await this.#dataClient.filterByType<\"unit\">(\"unit\", {\n populate: true,\n })) as UnitFeaturePopulated[]\n\n units\n .filter(\n (u) => ![\"opentobelow\", \"escalator\"].includes(u.properties.category)\n )\n .forEach((unit) => {\n const element = this.elementRenderer.createGeometry(unit)\n if (element) {\n const _elements = Array.isArray(element) ? element : [element]\n this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal)\n }\n })\n\n /** Kiosks */\n const kiosks = (await this.#dataClient.filterByType<\"kiosk\">(\"kiosk\", {\n populate: true,\n })) as KioskFeaturePopulated[]\n kiosks.forEach((kiosk) => {\n const element = this.elementRenderer.createGeometry(kiosk)\n if (element) {\n const _elements = Array.isArray(element) ? element : [element]\n this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal)\n }\n })\n\n /**\n * Escalators\n */\n const escalators = units.filter(u => u.properties.category === 'escalator')\n for (const escalator of escalators) {\n try {\n const escalatorRelationships = relationships.filter(r => (r.properties?.intermediary || []).some(inter => inter.id === escalator.id))\n if (escalatorRelationships.length === 0) {\n throw new Error('Cannot find escalator relationship')\n }\n if (escalatorRelationships.length > 1) {\n throw new Error('Found more than one relationship')\n }\n const thisOrdinal = escalator.properties.ordinal\n const relationship = escalatorRelationships[0]\n const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id]\n const bothOpenings = await Promise.all(\n bothOpeningIds.map(id => this.#dataClient.findById('opening', id, { populate: true }))\n ) as OpeningFeaturePopulated[]\n const thisLevelOpening = bothOpenings.find(opening => opening.properties.ordinal === thisOrdinal)\n const thatLevelOpening = bothOpenings.find(opening => opening.properties.ordinal !== thisOrdinal)\n const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates)\n const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? 'up' : 'down'\n const escalatorEntryPoint = turfCenter(thisLevelOpening).geometry.coordinates\n const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle })\n if (element) {\n const _elements = (Array.isArray(element)) ? element : [element]\n this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal)\n }\n } catch (err) {\n console.log(`cannot create escalator`, err)\n }\n }\n \n // Call changeLevelByOrdinal again to show/hide elements\n this.changeLevelByOrdinal(this.currentOrdinals)\n\n this.dispatchEvent(new CustomEvent('renderermanager:elements_created'))\n\n }\n\n changeLevelByOrdinal(targetOrdinal: null | number | number[]): void {\n // if targetOrdinal = null, show all\n this.currentOrdinals = targetOrdinal\n\n if (targetOrdinal === null) {\n const baseOrdinal = 0\n for (const [ordinal, elements] of this.elementsByOrdinal) {\n this.elementRenderer.showElements(elements as any, ordinal - baseOrdinal)\n }\n\n for (const [ordinal, markers] of this.markersByOrdinal) {\n this.markerRenderer.showMarkers(markers as any, ordinal - baseOrdinal)\n }\n } else {\n // if targetOrdinal = number | number[], show target levels\n const baseOrdinal = Array.isArray(targetOrdinal) ? _min(targetOrdinal) : targetOrdinal\n\n for (const [ordinal, elements] of this.elementsByOrdinal) {\n const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal\n if (inOrdinal) {\n this.elementRenderer.showElements(elements as any, ordinal - baseOrdinal)\n } else {\n this.elementRenderer.hideElements(elements as any, ordinal - baseOrdinal)\n }\n }\n\n for (const [ordinal, markers] of this.markersByOrdinal) {\n const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal\n if (inOrdinal) {\n this.markerRenderer.showMarkers(markers as any, ordinal - baseOrdinal)\n } else {\n this.markerRenderer.hideMarkers(markers as any, ordinal - baseOrdinal)\n }\n }\n }\n }\n\n /** \n * ========================================================================\n * Markers\n * ======================================================================== */\n createMarker(coordinate: Position, ordinal: number, text: string, options: any) {\n const marker = this.markerRenderer.createMarker(coordinate, ordinal, text, options)\n const markerId = `${this.markersMap.size + 1}`\n this.addMarkersToManager(markerId, [marker], ordinal)\n }\n\n clearMarkers() {\n for (const [markerId, marker] of this.markersMap) {\n this.markerRenderer.removeMarker(marker as any)\n }\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { GeoJSONMultiPolygonFeature, GeoJSONPolygonFeature } from \"maptalks.three/dist/type\"\nimport * as THREE from \"three\"\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader\"\nimport { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'\nimport { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport { Polygon, Position } from \"geojson\"\nimport turfBuffer from \"@turf/buffer\"\nimport { ImdfFeature } from \"../../../data\"\nimport {\n CreateExtrudePolygonOptionType,\n Element3DRendererOptions,\n IElementRenderer,\n LoadModel3dParameters,\n} from \"../types\"\nimport { element3DRendererOptions as defaultOptions } from './element3DRendererOptions'\nimport { Marker3DRenderer } from \"./Marker3DRenderer\"\nimport { TextSpriteMarker } from \"./objects/TextSpriteMarker\"\n\nconst DEFAULT_POLYGON_OPTION: CreateExtrudePolygonOptionType = {\n color: \"#FFFFFF\",\n offset: 0,\n altitude: 0,\n}\n\nexport const HEIGHT_METER = 4\nexport const MULTIORDINAL_HEIGHT_METER = 9\nexport const WALKWAY_HEIGHT = 0.5\n\nexport const getGeometryOption = (\n feature: ImdfFeature,\n options: Element3DRendererOptions\n): CreateExtrudePolygonOptionType => {\n try {\n const option = options[feature.feature_type] ?? defaultOptions[feature.feature_type]\n const category = feature.properties.category\n return (\n (category && option.byCategory?.[category]) ??\n option?.default ??\n DEFAULT_POLYGON_OPTION\n )\n } catch (err) {\n console.log(err.message, { options, feature })\n }\n}\n\nexport class Element3DRenderer\n extends EventTarget\n implements IElementRenderer<BaseObject | BaseObject[]>\n{\n private options: Element3DRendererOptions\n private map: maptalks.Map\n public threeLayer: ThreeLayer\n private dracoLoader: DRACOLoader\n private lineMaterial: THREE.LineBasicMaterial\n private materialByColorMap: Map<string, THREE.Material>\n\n public markerRenderer: Marker3DRenderer\n\n // Renderer is Ready\n public isReady: boolean = false\n\n constructor(map: maptalks.Map, options: Element3DRendererOptions, layer: ThreeLayer) {\n super()\n\n this.options = options\n this.map = map\n\n // ElementLayer as ThreeLayer\n // this.threeLayer = new ThreeLayer(\"elements\", {\n // forceRenderOnMoving: true,\n // forceRenderOnRotating: true,\n // })\n\n // Use Google public CDN for Draco Decoder\n this.dracoLoader = new DRACOLoader()\n this.dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.7/') \n\n this.lineMaterial = new THREE.LineBasicMaterial({ color: \"#000\" })\n \n // Add layer to map after setup\n this.threeLayer = layer\n\n this.render()\n }\n\n animation() {\n // layer animation support Skipping frames\n this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate\n if (this.threeLayer._needsUpdate) {\n this.threeLayer.redraw()\n }\n requestAnimationFrame(this.animation)\n }\n\n /** Materials */\n getOrCreateMaterialByColor(color) {\n if (!this.materialByColorMap) this.materialByColorMap = new Map()\n\n const existingMaterial = this.materialByColorMap.get(color)\n if (existingMaterial) return existingMaterial\n\n // Create new\n const created = new THREE.MeshLambertMaterial({ color, transparent: true })\n created.toneMapped = false\n this.materialByColorMap.set(color, created)\n return created\n }\n\n createGeometry = (feature: ImdfFeature): BaseObject | BaseObject[] => {\n const {\n offset = 0,\n height: heightOptions,\n bottomHeight: bottomHeightOptions,\n color: colorOptions,\n ...options\n } = getGeometryOption(feature, this.options)\n\n const _this = this\n\n /** Internal createPolygon function */\n const createPolygon = (geometry: Polygon, feature: GeoJSONPolygonFeature|GeoJSONMultiPolygonFeature) => {\n const [outerRing, ...innerRings] = geometry.coordinates\n const offsetFeature =\n offset !== 0\n ? turfBuffer(geometry, offset, { units: \"meters\" }) as GeoJSONPolygonFeature\n : feature\n const color =\n feature.properties.style.polygonFill ?? colorOptions ?? \"#ffffff\"\n if (color === \"transparent\") return\n const material = this.getOrCreateMaterialByColor(color)\n const altitude = feature.properties.ordinal * HEIGHT_METER\n const height = feature.properties.height ?? heightOptions ?? HEIGHT_METER\n const bottomHeight = feature.properties.bottomHeight ?? bottomHeightOptions ?? 0\n const extrudedPolygon = this.threeLayer.toExtrudePolygon(\n offsetFeature,\n { asynchronous: true, ...options, height, bottomHeight, altitude },\n material\n )\n \n extrudedPolygon.on(\"click\", e => {\n console.log(e.target.options.polygon.id)\n })\n\n\n // Create extra lines for visual clarity\n const topLineStrings = [\n new maptalks.LineString(outerRing),\n ...innerRings.map(innerRing => new maptalks.LineString(innerRing))\n ]\n const topLines = this.threeLayer.toLines(\n topLineStrings,\n { altitude, bottomHeight: bottomHeight + height + 0.001, interactive: false },\n this.lineMaterial\n )\n\n const bottomLineStrings = [\n new maptalks.LineString(outerRing),\n ...innerRings.map(innerRing => new maptalks.LineString(innerRing))\n ]\n const bottomLines = this.threeLayer.toLines(\n bottomLineStrings,\n { altitude: altitude, bottomHeight, interactive: false },\n this.lineMaterial\n )\n return [extrudedPolygon, topLines, bottomLines]\n }\n\n try {\n switch (feature.geometry.type) {\n case \"MultiPolygon\": {\n const { coordinates } = feature.geometry\n const multiMeshes = coordinates.flatMap(polygonCoordinates => {\n const meshes = createPolygon({ type: 'Polygon', coordinates: polygonCoordinates }, feature as GeoJSONMultiPolygonFeature)\n this.threeLayer.addMesh(meshes)\n return meshes\n })\n return multiMeshes\n }\n case \"Polygon\": {\n const meshes = createPolygon(feature.geometry, feature as GeoJSONPolygonFeature)\n this.threeLayer.addMesh(meshes)\n return meshes\n }\n }\n } catch (err) {\n console.log(`error createGeometry`, { feature, options })\n }\n }\n\n async createEscalator(\n f: ImdfFeature,\n coordinate: Position,\n options: { angle: number; direction: 'up' | 'down' },\n ): Promise<BaseObject | BaseObject[] | null> {\n\n const { direction: dir, angle } = options;\n\n const model = await this.loadModel3d({\n url: 'https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb',\n properties: {\n rotation: {\n x: 0.5 * Math.PI, // Rotate the model up (new_escalator.glb)\n y: 0,\n z: 0,\n },\n position: { x: 0, y: 0, z: 0 },\n scale: 0.01,\n },\n });\n\n // map heading\n model.rotation.y += (dir === \"up\") ? Math.PI + angle : angle;\n\n const box = new THREE.Box3().setFromObject(model);\n const pivotPoint =\n dir === 'up'\n ? new THREE.Vector3(0, 0, 0)\n : new THREE.Vector3(\n 1 * (box.min.x + box.max.x),\n 1 * (box.min.y + box.max.y),\n 0.60 * box.max.z,\n );\n\n const pivot = new THREE.Group();\n pivot.add(model);\n\n model.position.sub(pivotPoint);\n model.updateMatrixWorld(true);\n\n const altitude = f.properties.ordinal * HEIGHT_METER;\n\n const baseObjectModel = this.threeLayer.toModel(pivot, {\n coordinate,\n altitude,\n });\n\n this.threeLayer.addMesh(baseObjectModel);\n return baseObjectModel;\n }\n\n async createTree(coordinate: Position, ordinal: number): Promise<BaseObject | BaseObject[] | null> {\n const model = await this.loadModel3d({\n url: 'https://dashboard.situm.com/uploads/3dmodels/demoaccount/arbol.glb',\n properties: {\n rotation: {\n x: 0.5 * Math.PI, // Rotate the model up (new_escalator.glb)\n y: 0,\n z: 0,\n },\n position: { x: 0, y: 0, z: 0 },\n scale: 0.01,\n },\n });\n const altitude = ordinal * HEIGHT_METER;\n const baseObjectModel = this.threeLayer.toModel(model, {\n coordinate,\n altitude,\n });\n this.threeLayer.addMesh(baseObjectModel);\n return baseObjectModel\n }\n\n\n createElement(f: ImdfFeature): BaseObject[] | null {\n switch (f.feature_type) {\n default:\n return null\n }\n }\n\n showElements(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER)\n element.show()\n })\n }\n\n hideElements(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n try { \n element.hide()\n } catch (err) {\n console.log(`cannot hide`, err, element)\n }\n })\n }\n\n async loadModel3d(model3d: LoadModel3dParameters) {\n const loader = new GLTFLoader()\n loader.setDRACOLoader(this.dracoLoader)\n\n const { url, properties: modelProperties } = model3d\n const gltf = await loader.loadAsync(url)\n \n const model = gltf.scene\n // จัดขนาด + scale ที่เหมาะสม\n model.rotation.x = modelProperties.rotation.x\n model.rotation.y = modelProperties.rotation.y\n\n model.position.x = modelProperties.position.x\n model.position.y = modelProperties.position.y\n model.position.z = modelProperties.position.z\n \n const scale = modelProperties.scale\n model.scale.set(scale, scale, scale)\n return model\n }\n\n createMarker = (\n coordinates: Position,\n ordinal: number,\n text: string\n ): BaseObject => {\n const options = {\n // scale: 0.05,\n // altitude: ordinal * HEIGHT_METER,\n text,\n // interactive: true,\n }\n\n const marker = new TextSpriteMarker(coordinates, options, this.threeLayer)\n\n this.threeLayer.addMesh([marker])\n return marker\n }\n\n removeMarker = () => {}\n\n render() {\n this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate\n if (this.threeLayer._needsUpdate) {\n // @ts-ignore\n this.threeLayer.redraw()\n }\n\n // this.#animationsToRun.forEach(({ callback }) => callback(this))\n\n //update TWEEN.js animaton\n // TWEEN.update()\n\n requestAnimationFrame(this.render.bind(this))\n }\n}\n","import { Element3DRendererOptions } from \"../types\";\n\nexport const element3DRendererOptions: Element3DRendererOptions = {\n unit: {\n default: { color: \"#ffffff\", height: 4 },\n byCategory: {\n walkway: { color: \"#cccccc\", height: 0.1 },\n terrace: { color: \"#cccccc\", height: 0.1 },\n unenclosedarea: { color: \"#cccccc\", height: 0.2 },\n nonpublic: { color: \"#999999\", height: 0.3 },\n escalator: { height: 0.2 },\n room: { color: \"#ffffff\", height: 2, bottomHeight: 0.12 }\n },\n },\n kiosk: {\n default: { color: \"#666666\", height: 0.6, bottomHeight: 0.12 },\n },\n fixture: {\n default: { color: \"#ffffff\", height: 0.5 },\n byCategory: {\n water: { color: \"#ACD7EC\", height: 0.1 },\n vegetation: { color: \"#91C499\", height: 0.5 }\n }\n }\n}","// TextSpriteMarker.js\nimport { Coordinate, Util } from \"maptalks\"\nimport * as THREE from \"three\"\nimport { BaseObject, ThreeLayer } from \"maptalks.three\" // in some builds it's maptalks.three.BaseObject\nimport { BaseObjectOptionType } from \"maptalks.three/dist/type\"\nimport { isNil, set } from \"lodash\"\nimport { Stop } from \"../../types\"\nimport { interpolateStops } from \"../../utils/interpolateStops\"\n\nconst OPTIONS: TextMarkerOptions = {\n // Texture options\n text: \"\",\n textAlign: \"center\",\n color: \"#ffffff\",\n fontFamily: \"sans-serif\",\n fontSize: 28,\n fontWeight: 400,\n background: \"rgba(0, 0, 0, 0.2)\",\n lineHeight: 32,\n padding: 8,\n strokeColor: \"#000000\",\n strokeWidth: 6,\n strokeStyle: \"round\",\n // Sprite options\n /* Overall scale multiplier */\n scale: 1,\n altitude: 0,\n opacity: 1\n}\n\nexport type TextMarkerOptions = BaseObjectOptionType & {\n // Texture options\n text?: string\n textAlign?: CanvasTextAlign\n color?: CanvasFillStrokeStyles[\"fillStyle\"]\n fontFamily?: string\n fontSize?: number\n fontWeight?: number\n background?: CanvasFillStrokeStyles[\"fillStyle\"]\n lineHeight?: number\n strokeColor?: CanvasFillStrokeStyles[\"strokeStyle\"]\n strokeWidth?: number\n strokeStyle?: CanvasLineJoin\n padding?: number\n maxWidth?: number\n // Sprite options\n scale?: number\n altitude?: number\n bottomHeight?: number\n opacity?: number | { stops: Stop[] }\n}\n\nexport class TextSpriteMarker extends BaseObject {\n #altitudeOffset: number = 0\n declare options: TextMarkerOptions;\n\n constructor(\n coordinate: Coordinate,\n options: TextMarkerOptions,\n layer: ThreeLayer,\n properties: Record<string, any> = {}\n ) {\n options = Util.extend({}, OPTIONS, options, { layer })\n super()\n this._coordinate = new Coordinate(coordinate)\n this._initOptions(options)\n this._createGroup()\n\n this.properties = { ...properties }\n const sprite = this._createSprite()\n\n this.getObject3d().add(sprite)\n\n this._updatePosition()\n\n this.type = \"TextSpriteMarker\"\n }\n\n getOptions(): TextMarkerOptions {\n return super.getOptions()\n }\n\n _createSprite() {\n const options = this.getOptions()\n const texture = this._createTextTexture(options.text, options)\n\n const material = new THREE.SpriteMaterial({\n map: texture,\n transparent: true,\n alphaTest: 0.1,\n })\n\n const sprite = new THREE.Sprite(material)\n\n // position will be set in _animation or directly after added to layer\n // scale to match texture aspect\n const w = texture.image.width\n const h = texture.image.height\n const base = 1 / 16 // to bring canvas px to map size-ish\n\n // Normalize text scale by the current map resolution so sprite size stays visually consistent across zoom levels.\n const normalizedScale = options.scale / this.getMap().getGLRes()\n\n sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1)\n\n // Compute world-space height for text and use it as altitude offset.\n this.#altitudeOffset = Math.max(\n h * base * options.scale * 0.5,\n 0.05 // minimum lift in world units\n )\n\n return sprite\n }\n\n _createTextTexture(text: string, options: TextMarkerOptions = {}) {\n const {\n padding,\n fontSize,\n fontFamily,\n fontWeight,\n lineHeight,\n background,\n color,\n textAlign,\n strokeColor,\n strokeWidth,\n maxWidth,\n } = options || {}\n\n // 1. create a temp canvas to measure\n const canvas = document.createElement(\"canvas\")\n const ctx = canvas.getContext(\"2d\")!\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n\n // 2. split into paragraphs (explicit \\n from user)\n const paragraphs = String(text).split(\"\\n\")\n\n // 3. wrap each paragraph to lines\n const wrappedLines: string[] = []\n\n paragraphs.forEach((paragraph) => {\n if (isNil(maxWidth) || isNaN(maxWidth)) {\n // no wrapping, keep as-is\n wrappedLines.push(paragraph)\n return\n }\n\n const words = paragraph.split(/\\s+/)\n let currentLine = \"\"\n\n words.forEach((word) => {\n const testLine = currentLine ? currentLine + \" \" + word : word\n const testWidth = ctx.measureText(testLine).width\n\n if (testWidth > maxWidth && currentLine) {\n // push current and start new\n wrappedLines.push(currentLine)\n currentLine = word\n } else {\n currentLine = testLine\n }\n })\n\n if (currentLine) {\n wrappedLines.push(currentLine)\n }\n })\n\n // 4. figure out final canvas size\n const lines = wrappedLines.length ? wrappedLines : [\"\"]\n const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0)\n const finalWidth =\n (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2\n const finalHeight = lineHeight * lines.length + padding * 2\n\n canvas.width = finalWidth\n canvas.height = finalHeight\n\n // 5. reapply styles after resize\n const ctx2 = canvas.getContext(\"2d\")!\n ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n ctx2.textAlign = textAlign\n\n // background\n if (background && background !== \"transparent\") {\n ctx2.fillStyle = background\n ctx2.fillRect(0, 0, canvas.width, canvas.height)\n }\n\n // 6. draw all lines (stroke first, then fill)\n lines.forEach((line, i) => {\n const y = padding + lineHeight * (i + 0.8)\n let x = padding\n if (textAlign === \"center\") x = canvas.width / 2\n if (textAlign === \"right\" || textAlign === \"end\")\n x = canvas.width - padding\n\n if (strokeWidth > 0) {\n ctx2.lineWidth = strokeWidth\n ctx2.lineJoin = \"round\"\n ctx2.miterLimit = 2\n ctx2.strokeStyle = strokeColor\n ctx2.strokeText(line, x, y)\n }\n\n ctx2.fillStyle = color\n ctx2.fillText(line, x, y)\n })\n\n const texture = new THREE.CanvasTexture(canvas)\n texture.needsUpdate = true\n texture.minFilter = THREE.LinearFilter\n return texture\n }\n\n _updatePosition() {\n const options = this.getOptions()\n const layer = options.layer\n\n if (!layer) return\n\n const altitude = (options.altitude || 0) + this.#altitudeOffset\n const z = layer.altitudeToVector3(altitude, altitude).x\n const position = layer.coordinateToVector3(this._coordinate, z)\n set(this.properties, \"default.position\", position)\n this.getObject3d().position.copy(position)\n }\n\n _animation() {\n const layer = this.getLayer() as ThreeLayer\n\n if (!this.isAdd || !layer) return\n\n if (this._visible === true) {\n const zoom = layer.map.getZoom()\n \n const object3d = this.getObject3d()\n const { opacity } = this.getOptions()\n \n // Calculate opacity based on type\n let opacityValue: number\n if (typeof opacity === 'number') {\n opacityValue = opacity ?? 1\n } else if (Array.isArray(opacity.stops)) {\n opacityValue = interpolateStops(opacity, zoom)\n } else {\n throw new Error(`Unknown opacity value ${opacity}`)\n }\n // Hide object outside zoom range\n const visible = opacityValue > 0.5\n object3d.visible = visible\n }\n }\n\n setText(text: string) {\n const options = this.getOptions()\n options.text = text\n\n const newSprite = this._createSprite()\n const group = this.getObject3d()\n\n // Remove all old sprites from the group (but keep group itself)\n group.children.forEach((child) => group.remove(child))\n group.add(newSprite)\n\n this._updatePosition()\n }\n\n setAltitude(altitude: number) {\n const bottomHeight = this.options.bottomHeight ?? 0\n return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset)\n }\n}\n","import { Stop } from \"../types\"\n\nexport const interpolateStops = ({ stops }: { stops: Stop[] }, zoom: number) => {\n // If zoom is before the first stop\n if (zoom <= stops[0][0]) return stops[0][1]\n // If zoom is after the last stop\n if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1]\n \n // Find the two stops around the zoom\n for (let i = 0; i < stops.length - 1; i++) {\n const [z1, v1] = stops[i]\n const [z2, v2] = stops[i + 1]\n\n if (zoom >= z1 && zoom <= z2) {\n const t = (zoom - z1) / (z2 - z1)\n return v1 + t * (v2 - v1)\n }\n }\n}","import * as maptalks from \"maptalks\"\nimport { Element2DRendererOptions, IElementRenderer } from \"../types\"\nimport { ImdfFeature, LevelFeature } from \"../../../data\"\nimport { element2DRendererOptions as defaultOptions } from \"./element2DRendererOptions\"\nimport { PolygonOptionsType } from \"maptalks/dist/geometry/Polygon\"\nimport { Position } from \"geojson\"\n\nconst DEFAULT_POLYGON_OPTION: PolygonOptionsType = {\n zIndex: 0,\n symbol: {\n polygonFill: \"#FFFFFF\",\n lineColor: \"#34495E\",\n polygonOpacity: 1,\n lineWidth: 2,\n },\n}\n\nconst ORDINAL_HEIGHT = 4\nconst MULTIORDINAL_HEIGHT_METER = 10\n\nconst getAltitude = (f: LevelFeature) =>\n Math.max(0, f.properties.ordinal * ORDINAL_HEIGHT || 0)\n\nconst getGeometryProperties = (feature: ImdfFeature) => ({\n // Core\n type: \"Feature\",\n id: feature.id,\n geometry: feature.geometry,\n properties: feature.properties,\n // Extra\n feature_type: feature.feature_type,\n category: feature.properties.category,\n name: feature.properties.name?.en,\n})\n\nconst getGeometryOption = (\n feature: ImdfFeature,\n options: Element2DRendererOptions\n): PolygonOptionsType => {\n try {\n const option = options[feature.feature_type] ?? defaultOptions[feature.feature_type]\n const category = feature.properties.category\n return (\n (category && option.byCategory?.[category]) ??\n option?.default ??\n DEFAULT_POLYGON_OPTION\n )\n } catch (err) {\n console.log(err.message, { options, feature })\n }\n}\n\nexport class Element2DRenderer\n extends EventTarget\n implements IElementRenderer<maptalks.Geometry>\n{\n public isReady: boolean = false\n\n private options: Element2DRendererOptions\n private map: maptalks.Map\n private elementLayer: maptalks.VectorLayer\n private markerLayer: maptalks.VectorLayer\n\n constructor(map: maptalks.Map, options: Element2DRendererOptions) {\n super()\n this.options = options\n this.map = map\n\n // Create Layer for elements\n this.elementLayer = new maptalks.VectorLayer(\"elements\")\n this.elementLayer.addTo(this.map)\n\n this.markerLayer = new maptalks.VectorLayer(\"markers\")\n this.markerLayer.addTo(this.map)\n\n // Dispatch ready event, to let manager know we're ready to start\n this.isReady = true\n }\n\n createGeometry = (imdfFeature: ImdfFeature): maptalks.Geometry => {\n // Create Element (Geometry)\n const feature = getGeometryProperties(imdfFeature)\n const { symbol, ...options } = getGeometryOption(imdfFeature, this.options)\n const altitude = feature.properties.ordinal * 10\n const geometry = maptalks.Geometry.fromJSON({\n feature,\n symbol,\n options: {\n ...options,\n zIndex: altitude,\n properties: { altitude },\n },\n })\n\n // Add to layer, and return\n if (Array.isArray(geometry)) {\n geometry.forEach((g) => g.addTo(this.elementLayer))\n return new maptalks.GeometryCollection(geometry)\n } else {\n geometry.addTo(this.elementLayer)\n return geometry\n }\n }\n\n async createEscalator(f: ImdfFeature, coordinates: Position): Promise<maptalks.Geometry | null> {\n return Promise.resolve(null)\n }\n\n async createTree(f: ImdfFeature, coordinates: Position): Promise<maptalks.Geometry | null> {\n return Promise.resolve(null)\n }\n\n createElement = (imdfFeature: ImdfFeature): maptalks.Geometry | null => {\n switch (imdfFeature.feature_type) {\n default:\n return null\n }\n }\n\n showElements(elements: maptalks.Geometry[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER)\n element.show()\n })\n }\n hideElements(elements: maptalks.Geometry[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.hide()\n })\n }\n\n \n}\n","import { Element2DRendererOptions } from \"../types\";\n\nexport const element2DRendererOptions: Element2DRendererOptions = {\n unit: { \n default: { symbol: { polygonFill: '#cccccc' } },\n byCategory: {\n room: { symbol: { polygonFill: '#fff' } },\n walkway: { symbol: { polygonFill: \"#efefef\", lineColor: \"#dadada\", lineWidth: 2 } },\n terrace: { symbol: { polygonFill: \"#efefef\" } },\n unenclosedarea: { symbol: { polygonFill: \"#fff\" } },\n nonpublic: { symbol: { polygonFill: \"#999999\" }},\n }\n },\n kiosk: { \n default: {},\n },\n fixture: {\n default: { symbol: { polygonFill: \"#ffffff\" } },\n byCategory: {\n water: { symbol: { polygonFill: \"#ACD7EC\" } },\n vegetation: { symbol: { polygonFill: \"#91C499\" } }\n }\n }\n}\n","import * as maptalks from \"maptalks\"\nimport { IMarkerRenderer } from \"../types\"\nimport { Position } from \"geojson\"\n\nexport class Marker2DRenderer\n extends EventTarget\n implements IMarkerRenderer<maptalks.ui.UIMarker>\n{\n public isReady: boolean = false\n\n private map: maptalks.Map\n private markerLayer: maptalks.VectorLayer\n\n constructor(map: maptalks.Map) {\n super()\n }\n\n createMarker = (\n coordinates: Position,\n ordinal: number,\n content: string\n ): maptalks.ui.UIMarker => {\n const marker = new maptalks.ui.UIMarker(coordinates, {\n content,\n collision: true,\n collisionFadeIn: true,\n altitude: 0,\n })\n marker.addTo(this.map)\n return marker\n }\n\n removeMarker = (marker: maptalks.ui.UIMarker) => {\n marker.remove()\n }\n\n showMarkers(elements: maptalks.ui.UIMarker[], ordinalDiff: number = 0) {}\n hideMarkers(elements: maptalks.ui.UIMarker[], ordinalDiff: number = 0) {}\n}","import * as maptalks from \"maptalks\"\nimport * as THREE from \"three\"\nimport { IMarkerRenderer } from \"../types\"\nimport { BaseObject, ThreeLayer } from \"maptalks.three\"\nimport { Position } from \"geojson\"\nimport { createSpriteMaterialByLabelSymbol } from \"../utils/svg2material\"\nimport { TextMarkerOptions, TextSpriteMarker } from \"./objects/TextSpriteMarker\"\n\nexport const HEIGHT_METER = 4\nexport const MULTIORDINAL_HEIGHT_METER = 9\n\ntype AnyMarkerOptions = TextMarkerOptions\n\nexport class Marker3DRenderer\n extends EventTarget\n implements IMarkerRenderer<BaseObject>\n{\n public isReady: boolean = false\n\n private threeLayer: ThreeLayer\n\n private map: maptalks.Map\n \n private materialByKey: Map<string, THREE.Material>\n \n\n constructor(map: maptalks.Map, options: any, layer: ThreeLayer) {\n super()\n this.map = map\n this.threeLayer = layer\n }\n\n createTextMarker = (\n position: Position,\n ordinal: number,\n label: string,\n options?: TextMarkerOptions\n ): BaseObject => {\n const combinedOptions = {\n altitude: ordinal * HEIGHT_METER,\n text: label,\n ...(options ?? {})\n }\n const [lng, lat] = position\n const marker = new TextSpriteMarker(new maptalks.Coordinate(lng, lat), combinedOptions, this.threeLayer)\n this.threeLayer.addMesh([marker])\n return marker\n }\n\n createImageMarker = () => {\n // const material = this.getOrCreateIconMaterial(\n // \"amenity.escalator\"\n // ) as THREE.SpriteMaterial\n // const marker = new SpriteMarker(\n // coordinates,\n // options,\n // material,\n // this.threeLayer,\n // {}\n // )\n }\n\n createMarker = (\n coordinates: Position,\n ordinal: number,\n label: string,\n options: AnyMarkerOptions\n ): BaseObject => {\n return this.createTextMarker(coordinates, ordinal, label, options)\n }\n\n removeMarker = (marker: BaseObject) => {\n marker.remove()\n }\n\n showMarkers(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER)\n element.show()\n })\n }\n\n hideMarkers(elements: BaseObject[], ordinalDiff: number = 0) {\n elements.forEach((element) => {\n try { \n element.hide()\n } catch (err) {\n console.log(`cannot hide`, err, element)\n }\n })\n }\n\n /** Marker */\n getOrCreateIconMaterial(key) {\n if (!this.materialByKey) this.materialByKey = new Map()\n\n const existingMaterial = this.materialByKey.get(key)\n if (existingMaterial) return existingMaterial\n\n // Create new\n const baseSymbol: maptalks.PathMarkerSymbol = {\n markerType: \"path\",\n markerPath: [\n {\n path: \"M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z\",\n fill: \"#ff0000\",\n },\n ],\n markerPathWidth: 24,\n markerPathHeight: 24\n }\n\n const markerSymbol: maptalks.PathMarkerSymbol = {\n markerType: \"path\",\n markerPath: [],\n // TODO: Get Path by featureType.category\n // markerPath: [{ fill: \"#FFFFFF\", path: \"M 19 3 H 5 c -1.1 0 -2 0.9 -2 2 v 14 c 0 1.1 0.9 2 2 2 h 14 c 1.1 0 2 -0.9 2 -2 V 5 c 0 -1.1 -0.9 -2 -2 -2 Z m -2 6 h -1.7 l -5 9 H 7 c -0.83 0 -1.5 -0.67 -1.5 -1.5 S 6.17 15 7 15 h 1.7 l 5 -9 H 17 c 0.83 0 1.5 0.67 1.5 1.5 S 17.83 9 17 9 Z\" }],\n markerPathWidth: 24,\n markerPathHeight: 24,\n markerWidth: 24,\n markerHeight: 24,\n markerDy: 1.5,\n markerDx: 1.5,\n }\n\n const created = createSpriteMaterialByLabelSymbol([\n baseSymbol,\n markerSymbol,\n ])\n this.materialByKey.set(key, created)\n return created\n }\n}","import { PathMarkerSymbol, SymbolColorType } from \"maptalks\"\nimport { SpriteMaterial, TextureLoader } from \"three\"\n\nexport const svgToDataURL = (\n svgString: string,\n scaleFactor: number = 1\n): Promise<string> => {\n const svgBlob = new Blob([svgString], { type: \"image/svg+xml\" })\n const url = URL.createObjectURL(svgBlob)\n const img = new Image()\n return new Promise((resolve, reject) => {\n img.onload = function () {\n // Calculate the new dimensions\n const newWidth = img.width * scaleFactor\n const newHeight = img.height * scaleFactor\n\n // Create a canvas with the new dimensions\n const canvas = document.createElement(\"canvas\")\n canvas.width = newWidth\n canvas.height = newHeight\n const ctx = canvas.getContext(\"2d\")\n\n // Draw the SVG image onto the canvas with the scaled dimensions\n ctx.drawImage(img, 0, 0, newWidth, newHeight)\n\n // Convert canvas to PNG\n const pngDataUrl = canvas.toDataURL(\"image/png\")\n\n // Resolve the Promise with the PNG data URL\n resolve(pngDataUrl)\n }\n\n // Handle image load errors\n img.onerror = function (error) {\n reject(error)\n }\n\n img.src = url\n })\n}\n\nexport const createSVGPathFromMarkerSymbol = (\n style: PathMarkerSymbol & { fill?: SymbolColorType }\n): string | string[] => {\n const {\n markerWidth = 24,\n markerDx = 0,\n markerDy = 0,\n // markerFill,\n markerPath,\n fill = \"#000000\",\n } = style\n const scale = markerWidth / 24\n const strokeWidth = 2\n const halfStrokeWidth = 0.5 * strokeWidth\n\n if (Array.isArray(markerPath)) {\n return markerPath.map(\n ({ path, fill }) =>\n `<path d=\"${path}\" style=\"transform:translate(${markerDx}px, ${markerDy}px) scale(${scale})\" fill=\"${fill}\" stroke=\"#ffffff\" stroke-width=\"${strokeWidth}\" />`\n )\n }\n\n return `<path d=\"${markerPath}\" style=\"transform:translate(${markerDx}px, ${markerDy}px) scale(${scale})\" fill=\"${fill}\" />`\n}\n\nexport const createSpriteMaterialByLabelSymbol = (\n labelSymbol?: [PathMarkerSymbol, PathMarkerSymbol]\n): SpriteMaterial => {\n const material = new SpriteMaterial()\n try {\n const [base, icon] = labelSymbol ?? [{}, {}]\n const { markerWidth: baseWidth = 24 } = base\n const { markerWidth: iconWidth = 24 } = icon\n const viewBoxDimension = Math.max(baseWidth, iconWidth)\n\n const baseSVG = createSVGPathFromMarkerSymbol(base)\n const iconSVG = icon ? createSVGPathFromMarkerSymbol(icon) : \"\"\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${viewBoxDimension}\" height=\"${viewBoxDimension}\">${baseSVG}${iconSVG}</svg>`\n const textureLoader = new TextureLoader()\n const scaleFactor = 200 / 24 // Scale factor to upscale from 24px to 200px to ensure the resolution is high enough\n\n svgToDataURL(svg, scaleFactor).then((png) => {\n const texture = textureLoader.load(png, () => {\n material.map = texture\n material.needsUpdate = true\n })\n })\n } catch (error) {\n console.warn(`Error createSpriteMaterialByLabelSymbol: `, labelSymbol)\n }\n return material\n}\n","export const getLineCenter = (line: number[][]) => {\n let x = 0, y = 0;\n for (const [lx, ly] of line) {\n x += lx;\n y += ly;\n }\n const len = line.length;\n return [x / len, y / len];\n};\n\n// Returns angle in radians\nexport const angleBetweenLineStrings = (\n line1: number[][],\n line2: number[][],\n): number => {\n const [x1, y1] = getLineCenter(line1);\n const [x2, y2] = getLineCenter(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AAEA,WAAK,cAAc,QAAQ,CAAC,WAAW;AACrC,eAAO,YAAY,EAAE,SAAS,CAAC,UAAU;AACvC,cAAI,MAAM,OAAQ,OAAM,SAAS,UAAU;AAI3C,gBAAM,UAAU,KAAK,mBAAmB,gBAAgB;AAAA,QAC1D,CAAC;AAAA,MACH,CAAC;AAGD,WAAK,eAAe,QAAQ,CAAC,WAAW;AACtC,eAAO,UAAU;AAAA,MACnB,CAAC;AAAA,IACH;AAEA,SAAK,iBAAiB,QAAQ,CAAC,EAAE,SAAS,MAAM,SAAS,IAAI,CAAC;AAG9D,kBAAAS,QAAM,OAAO;AAEb,0BAAsB,KAAK,OAAO,KAAK,IAAI,CAAC;AAAA,EAC9C;AACF;","names":["import_query_core","kiosk","section","unit","feature","feature","options","import_tween","import_lodash","import_center","import_three","import_lodash","import_maptalks","import_center","import_three","scale","_","maptalks","import_maptalks","import_three","OPTIONS","ctx","text","scale","center","import_maptalks","import_three","import_lodash","scale","_","maptalks","import_maptalks","import_three","OPTIONS","feature","import_lodash","center","_","turfLineOffset","scale","feature","_","turfBuffer","turfCenter","feature_type","properties","logoUrl","center","scale","import_three","import_lodash","_","TWEEN","center","import_center","import_maptalks","THREE","maptalks","THREE","import_GLTFLoader","import_buffer","import_maptalks","import_lodash","OPTIONS","feature","turfBuffer","scale","maptalks","DEFAULT_POLYGON_OPTION","MULTIORDINAL_HEIGHT_METER","feature","getGeometryOption","DEFAULT_POLYGON_OPTION","MULTIORDINAL_HEIGHT_METER","maptalks","maptalks","import_three","createSVGPathFromMarkerSymbol","scale","fill","createSpriteMaterialByLabelSymbol","HEIGHT_METER","MULTIORDINAL_HEIGHT_METER","createSpriteMaterialByLabelSymbol","turfCenter","_min","_","turfCenter","center","feature","geometry","scale","bboxPolygon","turfDistance","highlightedAmenityMarker","TWEEN"]}
|