Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new GeoInterface traits #290

Merged
merged 19 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 17 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
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ uuid = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
keywords = ["GDAL", "IO"]
license = "MIT"
desc = "A high level API for GDAL - Geospatial Data Abstraction Library"
version = "0.8.5"
version = "0.9.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
Extents = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
GDAL = "add2ef01-049f-52c4-9ee2-e494f65e021a"
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeoInterfaceRecipes = "0329782f-3d07-4b52-b9f6-d3137cf03c7a"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
CEnum = "0.4"
ColorTypes = "0.10, 0.11"
DiskArrays = "0.3"
Extents = "0.1"
GDAL = "1.3"
GeoFormatTypes = "0.3, 0.4"
GeoInterface = "0.4, 0.5"
GeoInterface = "1"
GeoInterfaceRecipes = "1.0"
ImageCore = "0.8, 0.9"
Tables = "1"
julia = "1.6"
3 changes: 2 additions & 1 deletion src/ArchGDAL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module ArchGDAL
using Dates
using GDAL: GDAL
using GeoFormatTypes: GeoFormatTypes
using GeoInterface: GeoInterface
import GeoInterface
using GeoInterfaceRecipes
using Tables: Tables
using ImageCore: Normed, N0f8, N0f16, N0f32, ImageCore
using ColorTypes: ColorTypes
Expand Down
32 changes: 19 additions & 13 deletions src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Convert a `GeoFormatTypes.GeoFormat` object to Geometry, then to the target
format. The Geom trait is needed to separate out convert for CRS for
WellKnownText and GML, which may contain both.

Both `Geom` and `Mixed` formats are converted to Geometries by default.
Both `Geom` and `Mixed` formats are converted to Geometries by default.
To convert a `Mixed` format to crs, `CRS` must be explicitly passed for `mode`.
"""

Expand All @@ -20,36 +20,42 @@ function Base.convert(
mode::Union{GFT.FormatMode,Type{GFT.FormatMode}},
source::GFT.GeoFormat,
)
return convert(target, convert(AbstractGeometry, source))
return convert(target, convert(IGeometry, source))
end

"""
convert(::Type{<:AbstractGeometry},
convert(::Type{<:IGeometry},
source::GeoFormatTypes.AbstractWellKnownText)
convert(::Type{<:AbstractGeometry}, source::GeoFormatTypes.WellKnownBinary)
convert(::Type{<:AbstractGeometry}, source::GeoFormatTypes.GeoJSON)
convert(::Type{<:AbstractGeometry}, source::GeoFormatTypes.GML)
convert(::Type{<:IGeometry}, source::GeoFormatTypes.WellKnownBinary)
convert(::Type{<:IGeometry}, source::GeoFormatTypes.GeoJSON)
convert(::Type{<:IGeometry}, source::GeoFormatTypes.GML)

Convert `GeoFormat` geometry data to an ArchGDAL `Geometry` type
"""

function Base.convert(
::Type{<:AbstractGeometry},
source::GFT.AbstractWellKnownText,
)
::Type{<:IGeometry},
source::X,
)::IGeometry where {X<:GFT.WellKnownText}
return fromWKT(GFT.val(source))
end
function Base.convert(::Type{<:AbstractGeometry}, source::GFT.WellKnownBinary)
function Base.convert(
::Type{<:IGeometry},
source::X,
)::IGeometry where {X<:GFT.WellKnownBinary}
return fromWKB(GFT.val(source))
end
function Base.convert(::Type{<:AbstractGeometry}, source::GFT.GeoJSON)
function Base.convert(::Type{<:IGeometry}, source::X) where {X<:GFT.GeoJSON}
return fromJSON(GFT.val(source))
end
function Base.convert(::Type{<:AbstractGeometry}, source::GFT.GML)
function Base.convert(::Type{<:IGeometry}, source::X) where {X<:GFT.GML}
return fromGML(GFT.val(source))
end

function Base.convert(::Type{IGeometry{wkbUnknown}}, source::AbstractGeometry)
function Base.convert(
::Type{IGeometry{wkbUnknown}},
source::X,
) where {X<:AbstractGeometry}
result = IGeometry(C_NULL)
result.ptr = unsafe_clone(source).ptr
return result
Expand Down
Loading