MVFv3 API Documentation
    Preparing search index...
    • Merges a locale pack into it's base MVF to create a localized MVF.

      It has special handling for arrays containing "identifiable objects" (ie, an object with an 'id' or 'key' property somewhere in it's structure, like a Feature with 'properties.id' or 'properties.key'). In those cases, the merge will only update the objects that have a corresponding 'id' or 'key' in the locale pack, by merging in only the properties that are present in the locale pack.

      This allows a locale pack to contain updates to only some objects in an array, without having to update every object in the array.

      Also, this function does NOT have detailed understanding of MVF's structure, outside of the manifest, and the rule that files and folders turn directly into properties of the same name (with extension removed) on the parsed MVF.

      This should mean it's able to handle localization of MVFs with arbitrary MVF extensions included.

      Key features:

      1. Clones the original parsed MVF
      2. Deep merges objects and arrays, with special handling for arrays containing objects with 'id' or 'key' properties somewhere.
      3. Adds new properties from the locale pack that don't exist in the full ParsedMVF.
      4. Keeps the original folder_struct from the full ParsedMVF.

      Type Parameters

      • T extends {
            floors: {
                features: {
                    geometry:
                        | null
                        | { coordinates: [number, number][][]; type: "Polygon" }
                        | { coordinates: [number, number][][][]; type: "MultiPolygon" };
                    properties: {
                        elevation: number;
                        id: `f_${string}`;
                        maxHeight?: number;
                        subtitle?: string;
                    } & {
                        details?: {
                            description?: string;
                            externalId?: string;
                            icon?: string;
                            name?: string;
                            shortName?: string;
                        };
                    };
                    type: "Feature";
                }[];
                type: "FeatureCollection";
            };
            geometry: Partial<
                {
                    [x: `f_${string}`]: {
                        features: {
                            geometry: | { coordinates: [number, number]; type: "Point" }
                            | { coordinates: [number, number][]; type: "MultiPoint" }
                            | { coordinates: [number, number][]; type: "LineString" }
                            | { coordinates: [(...), (...)][][]; type: "MultiLineString" }
                            | { coordinates: [(...), (...)][][]; type: "Polygon" }
                            | { coordinates: (...)[][][]; type: "MultiPolygon" };
                            properties: { id: `g_${string}` } & {
                                details?: {
                                    description?: (...) | (...);
                                    externalId?: (...) | (...);
                                    icon?: (...) | (...);
                                    name?: (...) | (...);
                                    shortName?: (...) | (...);
                                };
                            };
                            type: "Feature";
                        }[];
                        type: "FeatureCollection";
                    };
                },
            >;
            manifest: {
                features: {
                    geometry: { coordinates: [number, number]; type: "Point" };
                    properties: {
                        contents: (
                            | {
                                children: (
                                    | (
                                        { type: "folder"; name: string; children: (any | { type: "file"; name: string; })[]; }
                                    )
                                    | { name: ...; type: ... }
                                )[];
                                name: string;
                                type: "folder";
                            }
                            | { name: string; type: "file" }
                        )[];
                        name: string;
                        time: string;
                        version: "3.0.0";
                        defaultFloor?: `f_${string}`;
                        language?: string;
                        mapId?: string;
                        naturalBearing?: number;
                        orgId?: string;
                        tzid?: `${string}/${string}`;
                    };
                    type: "Feature";
                }[];
                type: "FeatureCollection";
            };
        }

      Parameters

      • full: T

        The complete MVF object to merge into.

      • partial: LocalePack<T>

        The partial LocalePack containing localized updates.

      Returns T

      A new localized MVF object that is the result of merging the partial locale pack into the full MVF.

      Note: The merging process always preserves the 'id' or 'key' field on any kept objects, and the structure of the manifest, ensuring the integrity of the MVF structure while allowing for localized content updates.