Skip to content

Commit

Permalink
add constants that define what the keys are, for portability
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Nov 24, 2024
1 parent c086f32 commit b26a5cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/fallbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ issimple(t::AbstractMultiPointTrait, geom) = allunique((getgeom(t, geom)))
issimple(t::AbstractMultiCurveTrait, geom) = all(issimple.(getgeom(t, geom)))
isclosed(t::AbstractMultiCurveTrait, geom) = all(isclosed.(getgeom(t, geom)))

crs(::Nothing, geom) = _get_dataapi_metadata(geom, "GEOINTERFACE:crs", nothing) # see `metadata.jl`
crs(::AbstractTrait, geom) = _get_dataapi_metadata(geom, "GEOINTERFACE:crs", nothing) # see `metadata.jl`
"The key used to retrieve and store the CRS from DataAPI.jl metadata, if no other solution exists in that format."
const GEOINTERFACE_CRS_KEY = "GEOINTERFACE:crs"

crs(::Nothing, geom) = _get_dataapi_metadata(geom, GEOINTERFACE_CRS_KEY, nothing) # see `metadata.jl`
crs(::AbstractTrait, geom) = _get_dataapi_metadata(geom, GEOINTERFACE_CRS_KEY, nothing) # see `metadata.jl`

# FeatureCollection
getfeature(t::AbstractFeatureCollectionTrait, fc) = (getfeature(t, fc, i) for i in 1:nfeature(t, fc))
Expand Down
7 changes: 6 additions & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ automatically delegate to this method.
isfeaturecollection(x::T) where {T} = isfeaturecollection(T)
isfeaturecollection(::Type{T}) where {T} = false

"""
The key used to retrieve and store the geometrycolumns from DataAPI.jl metadata, if no other solution exists in that format.
"""
const GEOINTERFACE_GEOMETRYCOLUMNS_KEY = "GEOINTERFACE:geometrycolumns"

"""
GeoInterface.geometrycolumns(featurecollection) => (:geometry,)
Expand All @@ -47,7 +52,7 @@ which contain geometries that support GeoInterface.
This is always a `Tuple` of `Symbol`s.
"""
function geometrycolumns(featurecollection)
gcs = _get_dataapi_metadata(featurecollection, "GEOINTERFACE:geometrycolumns", (:geometry,)) # see `metadata.jl`
gcs = _get_dataapi_metadata(featurecollection, GEOINTERFACE_GEOMETRYCOLUMNS_KEY, (:geometry,)) # see `metadata.jl`
return _aftercare_geometrycolumns(gcs)
end

Expand Down

0 comments on commit b26a5cd

Please sign in to comment.