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

Enhance ArchGDAL OGR objects with parametric composite types #266

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
506af24
1st draft with steal geometry and parametric composite types
mathieu17g Nov 22, 2021
a146c79
`NamedTuple` in `FDType` to avoid too many calls to `ogr_f_getfieldin…
mathieu17g Nov 26, 2021
c42f116
New `convert` functions for `_infergeomtype` and specialized version …
mathieu17g Dec 8, 2021
b7b6cdd
Implemented new `Tables.columns` functions for `FDP_AbstractFeatureLa…
mathieu17g Dec 16, 2021
f496f69
Tables unit test repair and `schema` functions cleaning
mathieu17g Dec 19, 2021
3412a90
Fixes for Julia >= 1.7
mathieu17g Dec 20, 2021
b32ebde
Confined use of parametric types to Tables.jl interface
mathieu17g Jan 14, 2022
5ee5fb1
Merge branch 'master' into Enhance_ArchGDAL_types
mathieu17g Jan 14, 2022
60ae0c2
Merge remote-tracking branch 'upstream/master' into Enhance_ArchGDAL_…
mathieu17g Jan 14, 2022
9feb711
Added a new test data file for parametric AG types' tests
mathieu17g Jan 14, 2022
572e133
Added a second new test data file for parametric AG types' tests
mathieu17g Jan 14, 2022
d28f70c
Added new Tables.jl interface to BenchmarkCI
mathieu17g Jan 14, 2022
ef382df
Updated github actions for BenchmarkCI : Julia version
mathieu17g Jan 14, 2022
535fc5f
BenchmarkCI: moved from Tables.columns to Tables.columntable for fair…
mathieu17g Jan 14, 2022
17bf5d2
Cleaning and code reformatting
mathieu17g Jan 15, 2022
2ca3a4c
Updated comments in tables2.jl
mathieu17g Jan 15, 2022
12636f5
Merge remote-tracking branch 'upstream/master' into Enhance_ArchGDAL_…
mathieu17g Feb 14, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: 1.6
version: 1
- uses: julia-actions/julia-buildpkg@latest
- name: Install dependencies
run: julia -e 'using Pkg; pkg"add PkgBenchmark [email protected]"'
Expand Down
28 changes: 16 additions & 12 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ road_shapefile_file =
joinpath(road_shapefile_dir, splitpath(road_shapefile_dir)[end] * ".shp")

# Benchmarks
SUITE["shapefile_to_table"]["frenchroads_with_GDAL.jl_via_vsizip"] =
@benchmarkable Tables.columns(
AG.getlayer(
AG.read("/vsizip/" * relpath($road_shapefile_ziparchive)), # relpath is a workaround in case there are spaces in local fullpath (incompatible with /vsizip usage) when benchmarkpkg is run locally
0,
),
SUITE["shapefile_to_table"]["frenchroads_ArchGDAL_vsizip"] =
@benchmarkable Tables.columntable(
AG.getlayer(AG.read("/vsizip/" * relpath($road_shapefile_ziparchive))), # relpath is a workaround in case there are spaces in local fullpath (incompatible with /vsizip usage) when benchmarkpkg is run locally
)
SUITE["shapefile_to_table"]["frenchroads_with_GDAL.jl"] =
@benchmarkable Tables.columns(AG.getlayer(AG.read($road_shapefile_file), 0))
SUITE["shapefile_to_table"]["frenchroads_with_Shapefile.jl"] =
@benchmarkable begin
Tables.columns(Shapefile.Table($road_shapefile_file))
end
SUITE["shapefile_to_table"]["frenchroads_ArchGDAL"] =
@benchmarkable Tables.columntable(
AG.getlayer(AG.read($road_shapefile_file), 0),
)
SUITE["shapefile_to_table"]["frenchroads_ArchGDAL_new_Tables_interface_vsizip"] =
@benchmarkable Tables.columntable(
AG.Table(AG.read("/vsizip/" * relpath($road_shapefile_ziparchive))), # relpath is a workaround in case there are spaces in local fullpath (incompatible with /vsizip usage) when benchmarkpkg is run locally
)
SUITE["shapefile_to_table"]["frenchroads_ArchGDAL_new_Tables_interface"] =
@benchmarkable Tables.columntable(AG.Table($road_shapefile_file))
SUITE["shapefile_to_table"]["frenchroads_Shapefile"] = @benchmarkable begin
Tables.columntable(Shapefile.Table($road_shapefile_file))
end
10 changes: 4 additions & 6 deletions benchmark/remotefiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ julia> open(filepath/filename) do f
end
```
"""
remotefiles = [
(
"data/road.zip",
"058bdc549d0fc5bfb6deaef138e48758ca79ae20df79c2fb4c40cb878f48bfd8",
),
]
remotefiles = [(
"data/road.zip",
"058bdc549d0fc5bfb6deaef138e48758ca79ae20df79c2fb4c40cb878f48bfd8",
)]

function verify(path::AbstractString, hash::AbstractString)
@assert occursin(r"^[0-9a-f]{64}$", hash)
Expand Down
1 change: 1 addition & 0 deletions src/ArchGDAL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ include("context.jl")
include("base/iterators.jl")
include("base/display.jl")
include("tables.jl")
include("tables2.jl")
include("geointerface.jl")
include("convert.jl")

Expand Down
10 changes: 5 additions & 5 deletions src/base/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function Base.show(
end

# assumes that the layer is reset, and will reset it after display
function Base.show(io::IO, layer::AbstractFeatureLayer)::Nothing
function Base.show(io::IO, layer::DUAL_AbstractFeatureLayer)
if layer.ptr == C_NULL
print(io, "NULL FeatureLayer")
return nothing
Expand Down Expand Up @@ -172,7 +172,7 @@ function Base.show(io::IO, layer::AbstractFeatureLayer)::Nothing
return nothing
end

function Base.show(io::IO, featuredefn::AbstractFeatureDefn)::Nothing
function Base.show(io::IO, featuredefn::DUAL_AbstractFeatureDefn)::Nothing
if featuredefn.ptr == C_NULL
print(io, "NULL FeatureDefn")
return nothing
Expand All @@ -195,7 +195,7 @@ function Base.show(io::IO, featuredefn::AbstractFeatureDefn)::Nothing
return nothing
end

function Base.show(io::IO, fd::AbstractFieldDefn)::Nothing
function Base.show(io::IO, fd::DUAL_AbstractFieldDefn)::Nothing
if fd.ptr == C_NULL
print(io, "NULL FieldDefn")
return nothing
Expand All @@ -204,7 +204,7 @@ function Base.show(io::IO, fd::AbstractFieldDefn)::Nothing
return nothing
end

function Base.show(io::IO, gfd::AbstractGeomFieldDefn)::Nothing
function Base.show(io::IO, gfd::DUAL_AbstractGeomFieldDefn)::Nothing
if gfd.ptr == C_NULL
print(io, "NULL GeomFieldDefn")
return nothing
Expand All @@ -213,7 +213,7 @@ function Base.show(io::IO, gfd::AbstractGeomFieldDefn)::Nothing
return nothing
end

function Base.show(io::IO, feature::Feature)::Nothing
function Base.show(io::IO, feature::DUAL_AbstractFeature)::Nothing
if feature.ptr == C_NULL
print(io, "NULL Feature")
return nothing
Expand Down
4 changes: 2 additions & 2 deletions src/base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ end

Base.eltype(layer::AbstractFeatureLayer)::DataType = Feature

Base.IteratorSize(::Type{<:AbstractFeatureLayer}) = Base.SizeUnknown()
Base.IteratorSize(::Type{<:DUAL_AbstractFeatureLayer}) = Base.SizeUnknown()

Base.length(layer::AbstractFeatureLayer)::Integer = nfeature(layer, true)
Base.length(layer::DUAL_AbstractFeatureLayer)::Integer = nfeature(layer, true)

struct BlockIterator{T<:Integer}
rows::T
Expand Down
156 changes: 82 additions & 74 deletions src/constants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,80 +298,88 @@ convert(GDAL.OGRwkbGeometryType, ArchGDAL.wkbUnknown)
wkbUnknown::OGRwkbGeometryType = 0x00000000
```
"""
@enum(
OGRwkbGeometryType,
wkbUnknown = 0,
wkbPoint = 1,
wkbLineString = 2,
wkbPolygon = 3,
wkbMultiPoint = 4,
wkbMultiLineString = 5,
wkbMultiPolygon = 6,
wkbGeometryCollection = 7,
wkbCircularString = 8,
wkbCompoundCurve = 9,
wkbCurvePolygon = 10,
wkbMultiCurve = 11,
wkbMultiSurface = 12,
wkbCurve = 13,
wkbSurface = 14,
wkbPolyhedralSurface = 15,
wkbTIN = 16,
wkbTriangle = 17,
wkbNone = 18,
wkbLinearRing = 19,
wkbCircularStringZ = 20,
wkbCompoundCurveZ = 21,
wkbCurvePolygonZ = 22,
wkbMultiCurveZ = 23,
wkbMultiSurfaceZ = 24,
wkbCurveZ = 25,
wkbSurfaceZ = 26,
wkbPolyhedralSurfaceZ = 27,
wkbTINZ = 28,
wkbTriangleZ = 29,
wkbPointM = 30,
wkbLineStringM = 31,
wkbPolygonM = 32,
wkbMultiPointM = 33,
wkbMultiLineStringM = 34,
wkbMultiPolygonM = 35,
wkbGeometryCollectionM = 36,
wkbCircularStringM = 37,
wkbCompoundCurveM = 38,
wkbCurvePolygonM = 39,
wkbMultiCurveM = 40,
wkbMultiSurfaceM = 41,
wkbCurveM = 42,
wkbSurfaceM = 43,
wkbPolyhedralSurfaceM = 44,
wkbTINM = 45,
wkbTriangleM = 46,
wkbPointZM = 47,
wkbLineStringZM = 48,
wkbPolygonZM = 49,
wkbMultiPointZM = 50,
wkbMultiLineStringZM = 51,
wkbMultiPolygonZM = 52,
wkbGeometryCollectionZM = 53,
wkbCircularStringZM = 54,
wkbCompoundCurveZM = 55,
wkbCurvePolygonZM = 56,
wkbMultiCurveZM = 57,
wkbMultiSurfaceZM = 58,
wkbCurveZM = 59,
wkbSurfaceZM = 60,
wkbPolyhedralSurfaceZM = 61,
wkbTINZM = 62,
wkbTriangleZM = 63,
wkbPoint25D = 64,
wkbLineString25D = 65,
wkbPolygon25D = 66,
wkbMultiPoint25D = 67,
wkbMultiLineString25D = 68,
wkbMultiPolygon25D = 69,
wkbGeometryCollection25D = 70,
)
@enum OGRwkbGeometryType::UInt32 begin
wkbUnknown = 0x00000000
wkbPoint = 0x00000001
wkbLineString = 0x00000002
wkbPolygon = 0x00000003
wkbMultiPoint = 0x00000004
wkbMultiLineString = 0x00000005
wkbMultiPolygon = 0x00000006
wkbGeometryCollection = 0x00000007
wkbCircularString = 0x00000008
wkbCompoundCurve = 0x00000009
wkbCurvePolygon = 0x0000000a
wkbMultiCurve = 0x0000000b
wkbMultiSurface = 0x0000000c
wkbCurve = 0x0000000d
wkbSurface = 0x0000000e
wkbPolyhedralSurface = 0x0000000f
wkbTIN = 0x00000010
wkbTriangle = 0x00000011
wkbNone = 0x00000064
wkbLinearRing = 0x00000065
wkbCircularStringZ = 0x000003f0
wkbCompoundCurveZ = 0x000003f1
wkbCurvePolygonZ = 0x000003f2
wkbMultiCurveZ = 0x000003f3
wkbMultiSurfaceZ = 0x000003f4
wkbCurveZ = 0x000003f5
wkbSurfaceZ = 0x000003f6
wkbPolyhedralSurfaceZ = 0x000003f7
wkbTINZ = 0x000003f8
wkbTriangleZ = 0x000003f9
wkbPointM = 0x000007d1
wkbLineStringM = 0x000007d2
wkbPolygonM = 0x000007d3
wkbMultiPointM = 0x000007d4
wkbMultiLineStringM = 0x000007d5
wkbMultiPolygonM = 0x000007d6
wkbGeometryCollectionM = 0x000007d7
wkbCircularStringM = 0x000007d8
wkbCompoundCurveM = 0x000007d9
wkbCurvePolygonM = 0x000007da
wkbMultiCurveM = 0x000007db
wkbMultiSurfaceM = 0x000007dc
wkbCurveM = 0x000007dd
wkbSurfaceM = 0x000007de
wkbPolyhedralSurfaceM = 0x000007df
wkbTINM = 0x000007e0
wkbTriangleM = 0x000007e1
wkbPointZM = 0x00000bb9
wkbLineStringZM = 0x00000bba
wkbPolygonZM = 0x00000bbb
wkbMultiPointZM = 0x00000bbc
wkbMultiLineStringZM = 0x00000bbd
wkbMultiPolygonZM = 0x00000bbe
wkbGeometryCollectionZM = 0x00000bbf
wkbCircularStringZM = 0x00000bc0
wkbCompoundCurveZM = 0x00000bc1
wkbCurvePolygonZM = 0x00000bc2
wkbMultiCurveZM = 0x00000bc3
wkbMultiSurfaceZM = 0x00000bc4
wkbCurveZM = 0x00000bc5
wkbSurfaceZM = 0x00000bc6
wkbPolyhedralSurfaceZM = 0x00000bc7
wkbTINZM = 0x00000bc8
wkbTriangleZM = 0x00000bc9
wkbPoint25D = 0x80000001
wkbLineString25D = 0x80000002
wkbPolygon25D = 0x80000003
wkbMultiPoint25D = 0x80000004
wkbMultiLineString25D = 0x80000005
wkbMultiPolygon25D = 0x80000006
wkbGeometryCollection25D = 0x80000007
end
@assert begin
all(
string.(instances(OGRwkbGeometryType)) .==
string.(instances(GDAL.OGRwkbGeometryType)),
) && all(
Integer.(instances(OGRwkbGeometryType)) .==
Integer.(instances(GDAL.OGRwkbGeometryType)),
)
end

"""
The value of `OGRwkbByteOrder` could be different from `GDAL.OGRwkbByteOrder`.
Expand Down
9 changes: 3 additions & 6 deletions src/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,21 +524,18 @@ Fetch the first layer and raise an error if `dataset` contains more than one lay
The returned layer remains owned by the `dataset` and should not be deleted by
the application.
"""
function getlayer(dataset::AbstractDataset)::IFeatureLayer
function getlayer(dataset::AbstractDataset)
nlayer(dataset) == 1 ||
error("Dataset has multiple layers. Specify the layer number or name")
return IFeatureLayer(
GDAL.gdaldatasetgetlayer(dataset.ptr, 0),
ownedby = dataset,
)
return getlayer(dataset, 0)
end

unsafe_getlayer(dataset::AbstractDataset, i::Integer)::FeatureLayer =
FeatureLayer(GDAL.gdaldatasetgetlayer(dataset.ptr, i))
function unsafe_getlayer(dataset::AbstractDataset)::FeatureLayer
nlayer(dataset) == 1 ||
error("Dataset has multiple layers. Specify the layer number or name")
return FeatureLayer(GDAL.gdaldatasetgetlayer(dataset.ptr, 0))
return unsafe_getlayer(dataset, 0)
end

"""
Expand Down
Loading