geoview-core
    Preparing search index...

    Class GeoUtilitiesAbstract

    Index

    Constructors

    Methods

    • Apply buffer to extent

      Parameters

      • extent: Extent

        The extent to check and buffer

      • bufferSize: number = 5000

        Buffer size in map units (default: 5000)

      Returns Extent

      Buffered extent

    • Calculates distance along a path define by array of Coordinates

      Parameters

      • coordinates: Coordinate[]

        Array of corrdinates

      • inProj: string

        Input projection (EPSG:4326, EPSG:3978, ESPG:3857)

      • outProj: string

        Output projection (EPSG:3978, ESPG:3857)

      Returns { sections: number[]; total: number }

      • The total distance in kilometers and distance for each section
    • Create empty basemap tilelayer to use as initial basemap while we load basemap so the viewer will not fails if basemap is not avialable

      Returns TileLayer<XYZ | VectorTile<RenderFeature> | OSM>

      The created empty basemap

    • Ensures a service URL includes standardized OGC parameters (SERVICE, REQUEST, VERSION), overriding any existing ones with the correct casing and values. The function normalizes query parameter keys, removes lowercase variants (service, request), and ensures the final URL contains correctly capitalized parameters with the specified values. If the VERSION parameter is missing, a default value is added.

      Parameters

      • url: string

        The input service URL, which may be absolute or relative.

      • service: string

        The OGC service type (e.g., "WMS", "WFS", "WMTS").

      • request: string

        The OGC request type (e.g., "GetMap", "GetFeature", "GetCapabilities").

      • Optionalversion: string = '1.3.0'

        The default service version to enforce if not already present.

      Returns string

      The normalized and fully qualified service request URL.

    • Builds a complete DescribeFeatureType URL for a WFS service.

      Parameters

      • url: string

        The base WFS service URL.

      • layerId: string

        The layer or feature type name to describe.

      • version: string

        The WFS version.

      • OptionaloutputFormat: string

        Optional output format (e.g., "application/json", "text/xml").

      Returns string

      A fully qualified DescribeFeatureType request URL.

    • Builds a complete GetCapabilities URL for a specific OGC service.

      Parameters

      • url: string

        The base service URL.

      • service: string

        The service type (e.g., "WMS", "WFS").

      • Optionallayers: string

        Optional layer name(s) to include in the request.

      Returns string

      A fully qualified GetCapabilities request URL.

    • Builds a complete GetFeature URL for a WMS/WFS service.

      Parameters

      • url: string

        The base WFS service URL.

      • layerId: string

        The layer or feature type name to request.

      • version: string

        The WFS version.

      • OptionaloutputFormat: string

        Optional output format (e.g., "application/json").

      • outfields: TypeOutfields[] | undefined
      • xmlFilter: string | undefined
      • outputProjectionCode: string | undefined

      Returns string

      A fully qualified GetFeature request URL.

    • Builds a complete GetLegendGraphic URL for a WMS service.

      Parameters

      • url: string

        The base WMS service URL.

      • layerId: string

        The layer name for which to retrieve the legend.

      • version: string

        The WMS version.

      • Optionalformat: string = 'image/png'

        Optional image format for the legend (e.g., "image/png").

      Returns string

      A fully qualified GetLegendGraphic request URL.

    • Builds a complete GetStyles URL for a WMS service.

      Parameters

      • url: string

        The base WMS service URL.

      • Optionallayers: string

        Optional layer name(s) to include in the request.

      • Optionalversion: string

        Optional WMS version.

      Returns string

      A fully qualified GetStyles request URL.

    • Removes specified query parameters from a URL, preserving all others. This method normalizes a URL by stripping out any query parameters whose keys match the ones provided in removeParams. It works even if the URL contains multiple ? or & characters (e.g., proxy-wrapped URLs).

      Parameters

      • url: string

        The URL to normalize.

      • removeParams: string[]

        Array of parameter names (case-insensitive) to remove from the URL.

      Returns string

      • The normalized URL with the specified parameters removed.
    • Converts an esri geometry type string to a TypeStyleGeometry.

      Parameters

      • esriGeometryType: string

        The esri geometry type to convert

      Returns
          | "Point"
          | "MultiPoint"
          | "LineString"
          | "MultiLineString"
          | "Polygon"
          | "MultiPolygon"

      The corresponding TypeStyleGeometry

      When the geometry type is not supported.

    • Returns the Geometry representation of a given geojson

      Parameters

      • geojson: string

        The geojson

      • readOptions: ReadOptions

        Read options to convert the geojson to a geometry

      Returns Geometry | undefined

      • The Geometry representation of the geojson
    • Function for checking if two geometries have the same coordinates

      Parameters

      • geom1: Geometry

        The first geometry

      • geom2: Geometry

        The second geometry

      Returns boolean

      Whether the two geometries are equal or not

    • Returns the WKT representation of a given geometry.

      Parameters

      • geometry: Geometry

        The geometry

      Returns string | undefined

      The WKT representation of the geometry

    • Extracts the base URL (origin + pathname) from a full URL string, removing any query parameters, hash fragments, or authentication data.

      Parameters

      • url: string

        The full URL string to process.

      Returns string

      The normalized base URL consisting of the origin and pathname.

    • Default drawing style for GeoView

      Parameters

      • OptionalstrokeColor: string | Color
      • OptionalstrokeWidth: number
      • OptionalfillColor: string | Color

      Returns Style

      An Open Layers styling for drawing on a map

    • Fetch the json response from the ESRI map server to get REST endpoint metadata.

      Parameters

      • url: string

        The url of the ESRI map server.

      Returns Promise<unknown>

      A json promise containing the result of the query.

    • Returns the intersection of 2 extents.

      Parameters

      • extentA: Extent | undefined

        First extent

      • OptionalextentB: Extent

        Optional second extent

      Returns Extent | undefined

      The intersection of the extents

    • Returns the union of 2 extents.

      Parameters

      • extentA: Extent | undefined

        First extent

      • OptionalextentB: Extent

        Optional second extent

      Returns Extent | undefined

      The union of the extents

    • Generates legend layer icon metadata from a layer legend definition. This method extracts icon imagery and legend item details from the provided layerLegend, handling both vector and non-vector legends. Behavior:

      • Vector legends:
        • Iterates through each geometry type in the legend definition.
        • Generates icon images from HTML canvas elements using toDataURL().
        • Supports both simple and categorized style configurations.
        • Builds an iconList of TypeLegendItem entries per geometry type.
        • Assigns:
          • iconImage as the primary icon (first legend item)
          • iconImageStacked as the secondary icon when multiple entries exist
      • Non-vector legends:
        • Attempts to extract a canvas image directly from layerLegend.legend.
        • Falls back to 'no data' if no canvas is available. Notes:
      • Duplicate legend labels within categorized styles are filtered out.
      • Visibility defaults to true unless explicitly set to false.
      • Returns undefined if layerLegend is null or undefined.

      Parameters

      • schemaTag: TypeGeoviewLayerType

        The layer schema type used to determine whether the legend should be interpreted as vector-based.

      • layerLegend: TypeLegend | null | undefined

        The legend configuration object associated with the layer.

      Returns TypeLegendLayerItem[] | undefined

      An array of legend layer item metadata containing icon images and legend entries, or undefined if no legend is provided.

    • Extracts and normalizes legend items from a collection of legend layer icons. This method:

      • Flattens all iconList entries from the provided legend layer items.
      • Handles special layer types (imageStatic and GeoTIFF) by dynamically creating a legend item using the iconImage property. For imageStatic and GeoTIFF schema tags, if at least one icon is present, an additional legend item is created with:
      • geometryType set to 'Point'
      • name set to 'image'
      • icon set from icons[0].iconImage
      • isVisible set to true

      Parameters

      • schemaTag: TypeGeoviewLayerType

        The layer schema type used to determine special handling logic (e.g., 'imageStatic', 'GeoTIFF').

      • icons: TypeLegendLayerItem[]

        The list of legend layer items containing optional iconList collections and optional iconImage values.

      Returns TypeLegendItem[]

      A flattened array of legend items derived from the provided icons, including any dynamically generated items for special layer types.

    • Return the map server url from a layer service.

      Parameters

      • url: string

        The service url for a wms / dynamic or feature layers.

      • rest: boolean = false

        Boolean value to add rest services if not present (default false).

      Returns string

      The map server url.

    • Gets meters per pixel for different projections

      Parameters

      • projection: TypeValidMapProjectionCodes

        The projection of the map

      • resolution: number

        The resolution of the map

      • Optionallat: number

        The latitude, only needed for Web Mercator

      Returns number

      Number representing meters per pixel

    • Fetch the json response from the XML response of a WMS getCapabilities request.

      Parameters

      • url: string

        The url the url of the WMS server.

      • Optionallayers: string

        The layers to query separate by.

      • OptionalcallbackNewMetadataUrl: CallbackNewMetadataDelegate

        Callback executed when a proxy had to be used to fetch the metadata. The parameter sent in the callback is the proxy prefix with the '?' at the end.

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process.

      Returns Promise<TypeMetadataWMS>

      A json promise containing the result of the query.

      When the request exceeds the timeout duration.

      When the request was aborted by the caller's signal.

      When the response is not OK (non-2xx).

      When the JSON response is empty.

      When a network issue happened.

    • Fetch the json response from the XML response of a WMS getCapabilities request.

      Parameters

      • url: string

        The url the url of the WMS server.

      • OptionalcallbackNewMetadataUrl: CallbackNewMetadataDelegate

        Callback executed when a proxy had to be used to fetch the metadata. The parameter sent in the callback is the proxy prefix with the '?' at the end.

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process.

      Returns Promise<string>

      A json promise containing the result of the query.

      When the request exceeds the timeout duration.

      When the request was aborted by the caller's signal.

      When the response is not OK (non-2xx).

      When the JSON response is empty.

      When a network issue happened.

    • Fetch the json response from the XML response of a WMS getCapabilities request.

      Parameters

      • url: string

        The url the url of the WMS server.

      • Optionallayers: string

        The layers to query separate by.

      • OptionalcallbackNewMetadataUrl: CallbackNewMetadataDelegate

        Callback executed when a proxy had to be used to fetch the metadata. The parameter sent in the callback is the proxy prefix with the '?' at the end.

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process.

      Returns Promise<TypeStylesWMS>

      A json promise containing the result of the query.

      When the request exceeds the timeout duration.

      When the request was aborted by the caller's signal.

      When the response is not OK (non-2xx).

      When the JSON response is empty.

      When a network issue happened.

    • Checks whether a given value is a valid GeoJSON FeatureCollection object.

      Parameters

      • value: any

        The value to test (can be any type).

      Returns boolean

      true if the value appears to be a GeoJSON FeatureCollection, otherwise false.

    • type guard function that redefines a TypeLegend as a TypeVectorLegend if the type attribute of the verifyIfLegend parameter is valid. The type ascention applies only to the true block of the if clause.

      Parameters

      • verifyIfLegend: TypeLegend

        object to test in order to determine if the type ascention is valid

      • schemaTag: TypeGeoviewLayerType

      Returns verifyIfLegend is TypeVectorLegend

      returns true if the payload is valid

    • Extracts the EPSG code from a GeoJSON object's CRS definition. Accepts either a GeoJSON object or a JSON string. If the GeoJSON contains a crs entry with a properties.name field in the form "urn:ogc:def:crs:EPSG::<code>", it is normalized to "EPSG:<code>".

      Parameters

      • geojson: any

        A GeoJSON object or a JSON string representing one.

      Returns string | undefined

      The normalized EPSG code (e.g., "EPSG:3005"), or undefined if the CRS is not defined.

    • Extracts the EPSG code from a GeoJSON object's CRS definition. Accepts either a GeoJSON object or a JSON string. If the GeoJSON contains a crs entry with a properties.name field in the form "urn:ogc:def:crs:EPSG::<code>", it is normalized to "EPSG:<code>".

      Parameters

      • gml: any

      Returns string | undefined

      The normalized EPSG code (e.g., "EPSG:3005"), or undefined if the CRS is not defined.

    • Reads OpenLayers features from an Esri features object.

      Parameters

      • features: unknown

        The Features data to read.

      • Optionaloptions: ReadOptions

        Optional read options such as projection or extent.

      Returns Feature<Geometry>[]

      An array of parsed OpenLayers Feature instances.

    • Reads OpenLayers features from a GeoJSON object.

      Parameters

      • geojson: unknown

        The GeoJSON data to read.

      • Optionaloptions: ReadOptions

        Optional read options such as projection or extent.

      Returns Feature<Geometry>[]

      An array of parsed OpenLayers Feature instances.

    • Reads OpenLayers features from a KML object.

      Parameters

      • kmlObject: unknown

        The KML data to read.

      • Optionaloptions: ReadOptions

        Optional read options such as projection or extent.

      Returns Feature<Geometry>[]

      An array of parsed OpenLayers Feature instances.

    • Reads OpenLayers features from an WFS features object.

      Parameters

      • features: unknown

        The Features data to read.

      • version: string
      • Optionaloptions: ReadOptions

        Optional read options such as projection or extent.

      Returns Feature<Geometry>[]

      An array of parsed OpenLayers Feature instances.

    • Reads OpenLayers features from a WKBObject object.

      Parameters

      • wkbObject: string | ArrayBuffer | ArrayBufferView<ArrayBufferLike>

        The WKBObject data to read.

      • Optionaloptions: ReadOptions

        Optional read options such as projection or extent.

      Returns Feature<Geometry>[]

      An array of parsed OpenLayers Feature instances.

    • Replaces or adds the BBOX parameter in a WMS GetMap URL.

      Parameters

      • url: string

        The original WMS GetMap URL

      • newCRS: string

        The new CRS

      • newBBOX: number[]

        The new BBOX to set, as an array of 4 numbers: [minX, minY, maxX, maxY]

      Returns string

      A new URL string with the updated BBOX parameter

    • Checks validity of lat long, LCC, or Web Mercator extent and updates values if invalid.

      Parameters

      • extent: Extent

        The extent to validate.

      • code: string = 'EPSG:4326'

        The projection code of the extent. Default EPSG:4326.

      Returns Extent

      The validated extent

    • Validates lat long, LCC, or Web Mercator extent if it is defined.

      Parameters

      • extent: Extent | undefined

        The extent to validate.

      • code: string = 'EPSG:4326'

        The projection code of the extent. Default EPSG:4326.

      Returns Extent | undefined

      The validated extent if it was defined.

    • Converts a WFS geometry type string to a TypeStyleGeometry.

      Parameters

      • wfsGeometryType: string

        The wfs geometry type to convert

      Returns
          | "Point"
          | "MultiPoint"
          | "LineString"
          | "MultiLineString"
          | "Polygon"
          | "MultiPolygon"

      The corresponding TypeStyleGeometry

      When the geometry type is not supported.

    • Returns the Geometry representation of a given wkt.

      Parameters

      • wkt: string

        The well known text

      • readOptions: ReadOptions

        Read options to convert the wkt to a geometry

      Returns Geometry | undefined

      The Geometry representation of the wkt

    • Serializes an OpenLayers geometry into a GML3 string. This method uses the OpenLayers GML3 format to convert the provided Geometry object into a GML XML string, using the specified spatial reference system (srsName).

      Parameters

      • geometry: Geometry

        The OpenLayers geometry to serialize.

      • srsName: string

        The spatial reference system (e.g., 'EPSG:3857') to assign to the GML geometry.

      Returns string

      The serialized GML geometry as a string.