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<OSM | XYZ | VectorTile<RenderFeature>>

      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.

    • 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

    • This method gets the legend styles used by the the layer as specified by the style configuration.

      Parameters

      • styleConfig: TypeLayerStyleConfig

        Layer style configuration.

      Returns Promise<
          Partial<
              Record<
                  | "Point"
                  | "MultiPoint"
                  | "LineString"
                  | "MultiLineString"
                  | "Polygon"
                  | "MultiPolygon",
                  TypeStyleRepresentation,
              >,
          >,
      >

      A promise that the layer styles are processed.

    • Gets map scale for Web Mercator or Lambert Conformal Conic projections

      Parameters

      • view: View

        The view to get the current scale from

      Returns number | undefined

      number representing scale (e.g. 50000 for 1:50,000)

    • 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

    • Converts a map scale to zoom level

      Parameters

      • view: View

        The view for converting the zoom

      • zoom: number

        The desired zoom (e.g. 50000 for 1:50,000)

      Returns number | undefined

      number representing the closest scale for the given zoom number

    • 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
      • OptionalabortSignal: AbortSignal

        Abort signal to handle cancelling of fetch.

      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
      • OptionalabortSignal: AbortSignal

        Abort signal to handle cancelling of fetch.

      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
      • OptionalabortSignal: AbortSignal

        Abort signal to handle cancelling of fetch.

      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.

    • Converts a map scale to zoom level

      Parameters

      • view: View

        The view for converting the scale

      • targetScale: number | undefined

        The desired scale (e.g. 50000 for 1:50,000)

      • OptionaldpiValue: number

      Returns number | undefined

      number representing the closest zoom level for the given scale

    • 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.

    • 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 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 WKBObject object.

      Parameters

      • wkbObject: unknown

        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 | undefined

        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.