yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
141 stars 27 forks source link

`is3d` and `ismeasured` are missing #303

Closed evetion closed 2 years ago

evetion commented 2 years ago

Encountered in #290.

is3d and ismeasured are missing which makes finding out which coordinate dimensions are implemented difficult. They're easily implemented though:

"""
    is3d(geom::AbstractGeometry)

Returns `true` if the geometry has a z coordinate, otherwise `false`.
"""
is3d(geom::AbstractGeometry)::Bool = GDAL.ogr_g_is3d(geom.ptr) == 1

"""
    ismeasured(geom::AbstractGeometry)

Returns `true` if the geometry has a m coordinate, otherwise `false`.
"""
ismeasured(geom::AbstractGeometry)::Bool = GDAL.ogr_g_ismeasured(geom.ptr) == 1

However, a simple test gives the following:

julia> point =  AG.createpoint(100, 70, 1)
Geometry: POINT (100 70 1)
julia> is3d(point)
false
julia> AG.GDAL.ogr_g_is3d(point.ptr)
2

Not sure if related, but looking at the source (https://github.dev/OSGeo/gdal/blob/9e9f8b294418e5f2670dacd5cacb5d6cdeabb797/ogr/ogr_geometry.h#L405), I can see that the is3d flag being set is 2 in this case.

Because of this oddity, I haven't yet implemented it.

evetion commented 2 years ago

Well, the functions ogr_g_is3d and similar ones don't return a boolean, but just the & result. isempty only worked because it's flag is 0x1 😓.

evetion commented 2 years ago

Implemented in https://github.com/yeesian/ArchGDAL.jl/pull/290

yeesian commented 2 years ago

Leaving this open until #290 is merged.