Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ Note that this is only valid for [`AbstractCurveTrait`](@ref)s.
"""
length(geom) = length(geomtrait(geom), geom)


# Surface

"""
area(geom) -> Number

Expand All @@ -226,6 +228,7 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s.
"""
area(geom) = area(geomtrait(geom), geom)


"""
centroid(geom) -> Point

Expand All @@ -235,6 +238,7 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s.
"""
centroid(geom) = centroid(geomtrait(geom), geom)


"""
pointonsurface(geom) -> Point

Expand All @@ -243,6 +247,7 @@ Note that this is only valid for [`AbstractSurfaceTrait`](@ref)s.
"""
pointonsurface(geom) = pointonsurface(geomtrait(geom), geom)


"""
boundary(geom) -> Curve

Expand All @@ -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

Expand Down Expand Up @@ -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()
20 changes: 20 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this inherit from AbstractCRStrait?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we assume projected anyway then dispatch can just be on AbstractProjectedTrait right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I assume you implement GeometryOps with Abstractprojected and catch both.

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