diff --git a/src/interface.jl b/src/interface.jl index 08f96ba..2c95979 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -217,7 +217,9 @@ Note that this is only valid for [`AbstractCurveTrait`](@ref)s. """ length(geom) = length(geomtrait(geom), geom) + # Surface + """ area(geom) -> Number @@ -226,6 +228,7 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s. """ area(geom) = area(geomtrait(geom), geom) + """ centroid(geom) -> Point @@ -235,6 +238,7 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s. """ centroid(geom) = centroid(geomtrait(geom), geom) + """ pointonsurface(geom) -> Point @@ -243,6 +247,7 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s. """ pointonsurface(geom) = pointonsurface(geomtrait(geom), geom) + """ boundary(geom) -> Curve @@ -251,7 +256,9 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s. """ boundary(geom) = boundary(geomtrait(geom), geom) + # Polygon/Triangle + """ nring(geom) -> Integer @@ -670,3 +677,12 @@ astext(geom) = astext(geomtrait(geom), geom) Convert `geom` into Well Known Binary (WKB) representation, such as `000000000140000000000000004010000000000000`. """ asbinary(geom) = asbinary(geomtrait(geom), geom) + +""" + crstrait(geom) -> AbstractCRSTrait + +Retrieves the type of the Coordinate Reference System for the given `geom`. +Defaults to retrieving from `crs(geom)` and to `UnknownTrait` if not implemented. + +""" +crstrait(geom) = UnknownTrait() diff --git a/src/types.jl b/src/types.jl index 6710a1b..206d4db 100644 --- a/src/types.jl +++ b/src/types.jl @@ -93,6 +93,26 @@ abstract type AbstractFeatureCollectionTrait <: AbstractTrait end "A FeatureCollectionTrait holds objects of `FeatureTrait`" struct FeatureCollectionTrait <: AbstractFeatureCollectionTrait end +"Supertype for all coordinate reference system traits" +abstract type AbstractCRSTrait end + +"An AbstractProjectedTrait for all projected coordinate reference systems" +abstract type AbstractProjectedTrait <: AbstractCRSTrait end +"An AbstractGeographicTrait for all geographic coordinate reference systems" +abstract type AbstractGeographicTrait <: AbstractCRSTrait end + +"An ProjectedTrait for all projected coordinate reference systems" +struct ProjectedTrait <: AbstractProjectedTrait end +"An GeographicTrait for all geographic coordinate reference systems" +struct GeographicTrait <: AbstractGeographicTrait end +"An UnknownTrait for all unknown (assumed projected) coordinate reference systems" +struct UnknownTrait <: AbstractProjectedTrait + function UnknownTrait() + Base.depwarn("It is unknown whether your geometry is projected or geographic. Please implement `crstrait` for your geometry.", :UnknownTrait) + new() + end +end + "An AbstractRasterTrait for all rasters" abstract type AbstractRasterTrait <: AbstractTrait end struct RasterTrait <: AbstractRasterTrait end