Source code for pyproj.enums

"""
This module contains enumerations used in pyproj.
"""

from enum import Enum, IntFlag


class BaseEnum(Enum):
    """
    Base enumeration class that handles
    input as strings ignoring case.
    """

    @classmethod
    def create(cls, item):
        """
        Handles finding the enumeration
        ignoring case if provided as a string.
        """
        try:
            return cls(item)
        except ValueError:
            pass
        if isinstance(item, str):
            item = item.upper()
        for member in cls:
            if member.value == item:
                return member
        raise ValueError(
            f"Invalid value supplied '{item}'. "
            f"Only {tuple(version.value for version in cls)} are supported."
        )


[docs] class WktVersion(BaseEnum): """ .. versionadded:: 2.2.0 Supported CRS WKT string versions See: :c:enum:`PJ_WKT_TYPE` """ #: WKT Version 2 from 2015 WKT2_2015 = "WKT2_2015" #: WKT Version 2 from 2015 Simplified WKT2_2015_SIMPLIFIED = "WKT2_2015_SIMPLIFIED" #: Deprecated alias for WKT Version 2 from 2019 WKT2_2018 = "WKT2_2018" #: Deprecated alias for WKT Version 2 from 2019 Simplified WKT2_2018_SIMPLIFIED = "WKT2_2018_SIMPLIFIED" #: WKT Version 2 from 2019 WKT2_2019 = "WKT2_2019" #: WKT Version 2 from 2019 Simplified WKT2_2019_SIMPLIFIED = "WKT2_2019_SIMPLIFIED" #: WKT Version 1 GDAL Style WKT1_GDAL = "WKT1_GDAL" #: WKT Version 1 ESRI Style WKT1_ESRI = "WKT1_ESRI"
[docs] class ProjVersion(BaseEnum): """ .. versionadded:: 2.2.0 Supported CRS PROJ string versions """ #: PROJ String version 4 PROJ_4 = 4 #: PROJ String version 5 PROJ_5 = 5
[docs] class TransformDirection(BaseEnum): """ .. versionadded:: 2.2.0 Supported transform directions """ #: Forward direction FORWARD = "FORWARD" #: Inverse direction INVERSE = "INVERSE" #: Do nothing IDENT = "IDENT"
[docs] class PJType(BaseEnum): """ .. versionadded:: 2.4.0 PJ Types for listing codes with :func:`pyproj.get_codes` See: :c:enum:`PJ_TYPE` Attributes ---------- UNKNOWN ELLIPSOID PRIME_MERIDIAN GEODETIC_REFERENCE_FRAME DYNAMIC_GEODETIC_REFERENCE_FRAME VERTICAL_REFERENCE_FRAME DYNAMIC_VERTICAL_REFERENCE_FRAME DATUM_ENSEMBLE CRS GEODETIC_CRS GEOCENTRIC_CRS GEOGRAPHIC_CRS GEOGRAPHIC_2D_CRS GEOGRAPHIC_3D_CRS VERTICAL_CRS PROJECTED_CRS COMPOUND_CRS TEMPORAL_CRS ENGINEERING_CRS BOUND_CRS OTHER_CRS CONVERSION TRANSFORMATION CONCATENATED_OPERATION OTHER_COORDINATE_OPERATION """ UNKNOWN = "UNKNOWN" ELLIPSOID = "ELLIPSOID" PRIME_MERIDIAN = "PRIME_MERIDIAN" GEODETIC_REFERENCE_FRAME = "GEODETIC_REFERENCE_FRAME" DYNAMIC_GEODETIC_REFERENCE_FRAME = "DYNAMIC_GEODETIC_REFERENCE_FRAME" VERTICAL_REFERENCE_FRAME = "VERTICAL_REFERENCE_FRAME" DYNAMIC_VERTICAL_REFERENCE_FRAME = "DYNAMIC_VERTICAL_REFERENCE_FRAME" DATUM_ENSEMBLE = "DATUM_ENSEMBLE" CRS = "CRS" GEODETIC_CRS = "GEODETIC_CRS" GEOCENTRIC_CRS = "GEOCENTRIC_CRS" GEOGRAPHIC_CRS = "GEOGRAPHIC_CRS" GEOGRAPHIC_2D_CRS = "GEOGRAPHIC_2D_CRS" GEOGRAPHIC_3D_CRS = "GEOGRAPHIC_3D_CRS" VERTICAL_CRS = "VERTICAL_CRS" PROJECTED_CRS = "PROJECTED_CRS" DERIVED_PROJECTED_CRS = "DERIVED_PROJECTED_CRS" COMPOUND_CRS = "COMPOUND_CRS" TEMPORAL_CRS = "TEMPORAL_CRS" ENGINEERING_CRS = "ENGINEERING_CRS" BOUND_CRS = "BOUND_CRS" OTHER_CRS = "OTHER_CRS" CONVERSION = "CONVERSION" TRANSFORMATION = "TRANSFORMATION" CONCATENATED_OPERATION = "CONCATENATED_OPERATION" OTHER_COORDINATE_OPERATION = "OTHER_COORDINATE_OPERATION"
[docs] class GeodIntermediateFlag(IntFlag): """ .. versionadded:: 3.1.0 Flags to be used in Geod.[inv|fwd]_intermediate() """ DEFAULT = 0x0 NPTS_ROUND = 0x0 NPTS_CEIL = 0x1 NPTS_TRUNC = 0x2 DEL_S_RECALC = 0x00 DEL_S_NO_RECALC = 0x10 AZIS_DISCARD = 0x000 AZIS_KEEP = 0x100
class CRSExtentUse(BaseEnum): """ .. versionadded:: 3.8.0 See: :c:enum:`PROJ_CRS_EXTENT_USE` Controls how CRS extents are used when building candidate coordinate operations in :class:`pyproj.transformer.TransformerGroup`. Mirrors the PROJ CLI option ``--crs-extent-use``. Values ------ NONE Ignore CRS areas of use. BOTH Require both source & target CRS extents to intersect operation area. INTERSECTION Use intersection of source & target CRS extents. SMALLEST Use the smallest of source or target CRS extent. """ NONE = "NONE" BOTH = "BOTH" INTERSECTION = "INTERSECTION" SMALLEST = "SMALLEST" class IntermediateCRSUse(BaseEnum): """ .. versionadded:: 3.8.0 Mirrors the ``--pivot-crs`` modes from the PROJ CLI and controls how intermediate/pivot CRS candidates are considered when building :class:`pyproj.transformer.TransformerGroup` operations. Values ------ ALWAYS Always search via the provided pivot CRS list (or PROJ defaults). IF_NO_DIRECT_TRANSFORMATION Only fall back to pivots when no direct operation exists. NEVER Do not attempt to use pivot CRS. """ ALWAYS = "ALWAYS" IF_NO_DIRECT_TRANSFORMATION = "IF_NO_DIRECT_TRANSFORMATION" NEVER = "NEVER" class GridAvailabilityUse(BaseEnum): """ .. versionadded:: 3.8.0 Mirrors the ``--grid-check`` option from the PROJ CLI and controls how grid availability affects the candidate coordinate operations in :class:`pyproj.transformer.TransformerGroup`. See: :c:enum:`PROJ_GRID_AVAILABILITY_USE` Values ------ SORT Grid availability is used for sorting operations (prefer operations with available grids). Equivalent to projinfo's ``--grid-check sort``. DISCARD_MISSING Discard operations that reference missing grids. Equivalent to projinfo's ``--grid-check discard_missing``. NONE Ignore grid availability (include all operations). Equivalent to projinfo's ``--grid-check none``. KNOWN_AVAILABLE Only consider operations where all required grids are known to be available. Equivalent to projinfo's ``--grid-check known_available``. """ SORT = "SORT" DISCARD_MISSING = "DISCARD_MISSING" NONE = "NONE" KNOWN_AVAILABLE = "KNOWN_AVAILABLE"