geoview-core - v2.3.0
    Preparing search index...

    Class ProjectionAbstract

    Class used to handle functions for transforming projections.

    Index
    CUSTOM_WKT_AND_NUM: { [wkt_num: string]: string } = {}

    Holding all custom generated wkt

    CUSTOM_WKT_NUM: number = 1001

    Incremental number when creating custom WKTs on the fly

    PROJECTION_NAMES: Record<string, string> = ...

    Constant used for the available projection names

    PROJECTIONS: Record<string, OLProjection> = {}

    List of supported projections and their OpenLayers projection

    • Fetches definitions for unsupported projections and adds them.

      Parameters

      • code: number

        Projection code number

      Returns Promise<Projection>

      A promise that resolves when the projection is added

    • Checks if a projection exists for GeoView and if not it adds it on-the-fly by fetching its definition from epsg.io.

      Accepts:

      • A TypeProjection object (with wkid / latestWkid / wkt)
      • A ProjectionLike string (e.g., "EPSG:4326", CRS URI/URN, or an OLProjection instance)
      • A numeric EPSG code (e.g., 4326)

      Parameters

      • projection: number | ProjectionLike | TypeProjection

        The projection identifier to check and register if missing

      Returns Promise<Projection>

      A promise that resolves with the OLProjection

    • Resolves an OGC CRS URI or standard code string to an OpenLayers projection.

      Supports formats:

      • http://www.opengis.net/def/crs/EPSG/0/4326EPSG:4326
      • http://www.opengis.net/def/crs/OGC/1.3/CRS84CRS:84
      • urn:ogc:def:crs:EPSG::4326EPSG:4326
      • EPSG:4326 (pass-through)

      Parameters

      • crs: string

        The CRS string (URI, URN, or authority:code)

      Returns Projection | undefined

      The resolved OpenLayers projection, or undefined if unrecognized

    • Wrapper around OpenLayers get function that fetches a Projection object for the code specified.

      Parameters

      • projectionObj: TypeProjection | undefined

        A projection object with properties such as latestWkid, wkid, or wkt

      Returns Projection | undefined

      Projection object, or undefined if not in list

    • Resolves a projection from various input formats to an OpenLayers Projection object.

      Supports:

      • Authority:code strings (e.g., "EPSG:4326", "CRS:84")
      • Numeric EPSG codes (e.g., 4326, 3857)
      • Numeric strings (e.g., "4326", "3857")
      • OGC CRS URIs (e.g., "http://www.opengis.net/def/crs/EPSG/0/4326")
      • OGC URNs (e.g., "urn:ogc:def:crs:EPSG::4326")
      • Existing OLProjection objects (pass-through)

      Parameters

      • projection: number | ProjectionLike

        A projection identifier (string, number, or OLProjection)

      Returns Projection

      The resolved OpenLayers Projection object

      When the projection cannot be resolved

    • Wrapper around OpenLayers get function that fetches a Projection object for the code specified.

      Parameters

      • customWKT: string

        A code string which is a combination of authority and identifier such as "EPSG:4326"

      Returns Projection

      Projection object, or undefined if not in list

    • Reads the numeric EPSG code from a projection identifier.

      Supports:

      • Numeric input (e.g., 4326) — returned immediately
      • Case-insensitive "EPSG:4326", "epsg:3857", "EpSg: 1234" strings
      • OLProjection objects (extracts the code via getCode())

      The function trims whitespace and validates that the string matches a proper EPSG:<number> pattern. Returns undefined if the format is invalid or the numeric part is not a valid number.

      Parameters

      • projection: number | ProjectionLike

        The projection identifier containing the EPSG code (string, number, or OLProjection)

      Returns number | undefined

      The extracted EPSG numeric code, or undefined if invalid

    • Reads an extent and verifies if it might be reversed (ymin,xmin,ymax,ymin) and when so puts it back in order (xmin,ymin,xmax,ymax).

      Parameters

      • projection: string

        The projection the extent is in

      • extent: Extent

        The extent to check

      Returns Extent

      The extent in order (xmin,ymin,xmax,ymax)

    • Extracts the projection name from a WKT string.

      Parses the first quoted string after the opening keyword (e.g., PROJCS["NAD83 / BC Albers", ...] returns "NAD83 / BC Albers").

      Parameters

      • wkt: string

        The WKT projection definition string

      Returns string | undefined

      The extracted projection name, or undefined if not found

    • Wrapper around OpenLayers function to transforms a coordinate from one projection to another.

      Parameters

      • coordinate: Coordinate

        Longitude/latitude coordinate

      • inProjection: Projection

        Actual projection of the coordinate

      • outProjection: Projection

        Desired projection of the coordinate

      Returns Coordinate

      Coordinate as projected

    • Transforms an extent from source projection to destination projection.

      This returns a new extent (and does not modify the original).

      Parameters

      • extent: Extent

        The extent to transform

      • source: Projection

        Source projection-like

      • destination: Projection

        Destination projection-like

      • stops: number = 25

        Optional number of stops per side used for the transform. The default value is 25

      Returns Coordinate[]

      The densified extent transformed in the destination projection

    • Transforms an extent from source projection to destination projection.

      This returns a new extent (and does not modify the original).

      Parameters

      • extent: Extent

        The extent to transform

      • projection: TypeProjection | undefined

        An object containing a wkid or wkt property

      • destination: Projection

        Destination projection-like

      • Optionalstops: number

        Optional number of stops per side used for the transform. By default only the corners are used

      Returns Extent

      The new extent transformed in the destination projection

    • Transforms an extent from source projection to destination projection.

      This returns a new extent (and does not modify the original).

      Parameters

      • extent: Extent

        The extent to transform

      • source: Projection

        Source projection-like

      • destination: Projection

        Destination projection-like

      • Optionalstops: number

        Optional number of stops per side used for the transform. By default only the corners are used

      Returns Extent

      The new extent transformed in the destination projection

    • Transforms an extent from source projection to destination projection.

      This returns a new extent (and does not modify the original).

      Parameters

      • extent: Extent

        The extent to transform

      • wkid: number

        An EPSG id number

      • destination: Projection

        Destination projection-like

      • Optionalstops: number

        Optional number of stops per side used for the transform. By default only the corners are used

      Returns Extent

      The new extent transformed in the destination projection

    • Transforms an extent from source projection to destination projection.

      This returns a new extent (and does not modify the original).

      Parameters

      • extent: Extent

        The extent to transform

      • customWKT: string

        A custom WKT projection

      • destination: Projection

        Destination projection-like

      • Optionalstops: number

        Optional number of stops per side used for the transform. By default only the corners are used

      Returns Extent

      The new extent transformed in the destination projection

    • Converts points from one projection to another using proj4.

      Parameters

      • points: Coordinate[]

        Array of passed in points to convert

      • fromProj: string

        Projection to be converted from

      • toProj: string

        Projection to be converted to

      Returns number[][]

      The converted points array