Skip to content

Commit

Permalink
Folliowing @visr and @yeesian remarks:
Browse files Browse the repository at this point in the history
- modified Project.toml dep order
- fixed a typo in `_fromtable` comments
- transformed notes into `!!! warning` in tables.md doc
  • Loading branch information
mathieu17g committed Oct 28, 2021
1 parent a33bc88 commit b08919b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 4 additions & 3 deletions docs/src/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ ds = AG.write(layer.ownedby, "test.shp", driver=AG.getdriver("ESRI Shapefile"))
DataFrame(AG.getlayer(AG.read("test.shp"), 0))
rm.(["test.shp", "test.shx", "test.dbf"]) # hide
```
As OGR ESRI Shapefile driver
- [does not support multi geometries](https://gdal.org/development/rfc/rfc41_multiple_geometry_fields.html#drivers), the second geometry has been dropped
- does not support nullable fields, the `missing` location has been replaced by `""`
!!! warning
As OGR ESRI Shapefile driver [does not support multi geometries](https://gdal.org/development/rfc/rfc41_multiple_geometry_fields.html#drivers), the second geometry has been dropped
!!! warning
As OGR ESRI Shapefile driver does not support nullable fields, the `missing` location has been replaced by `""`
### Example of writing with GML driver
Using the GML 3.2.1 more capable driver/format, you can write more information to the file
```@repl tables
Expand Down
18 changes: 11 additions & 7 deletions src/tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Handles the case where names and types in `sch` are different from `nothing`
function _fromtable(
sch::Tables.Schema{names,types},
rows;
name::String,
layer_name::String,
parseWKT::Bool,
parseWKB::Bool,
)::IFeatureLayer where {names,types}
Expand Down Expand Up @@ -186,7 +186,7 @@ function _fromtable(
# end

# Search in first rows for WKT strings or WKB binary data until for each
# columns with a comptible type (`String` or `Vector{UInt8}` tested
# columns with a compatible type (`String` or `Vector{UInt8}` tested
# through their converted value to `OGRFieldType`, namely: `OFTString` or
# `OFTBinary`), a non `missing` nor `nothing` value is found
if parseWKT || parseWKB
Expand Down Expand Up @@ -274,7 +274,7 @@ function _fromtable(

# Create layer
(layer, geomindices, fieldindices) =
_create_empty_layer_from_AGtypes(strnames, AGtypes, name)
_create_empty_layer_from_AGtypes(strnames, AGtypes, layer_name)

# Populate layer
for row in rows
Expand Down Expand Up @@ -347,7 +347,11 @@ Construct an IFeatureLayer from a source implementing Tables.jl interface
## Restrictions
- Source must contains at least one geometry column
- Geometry columns are recognized by their element type being a subtype of `Union{IGeometry, Nothing, Missing}`
- Geometry columns are recognized by their element type being a subtype of:
- `Union{IGeometry, Nothing, Missing}` or
- `Union{GeoInterface.AbstractGeometry, Nothing, Missing}` or
- `Union{String, Nothing, Missing}` provided that String values can be decoded as WKT or
- `Union{Vector{UInt8}, Nothing, Missing}` provided that Vector{UInt8} values can be decoded as WKB
- Non geometry columns must contain types handled by GDAL/OGR (e.g. not `Int128` nor composite type)
## Returns
Expand All @@ -367,7 +371,7 @@ julia> nt = NamedTuple([
])
(point = Union{Missing, ArchGDAL.IGeometry{ArchGDAL.wkbPoint}}[Geometry: POINT (30 10), missing], mixedgeom = ArchGDAL.IGeometry[Geometry: POINT (5 10), Geometry: LINESTRING (30 10,10 30)], id = ["5.1", "5.2"], zoom = [1.0, 2.0], location = Union{Missing, String}[missing, "New Delhi"])
julia> layer = AG.IFeatureLayer(nt; name="towns")
julia> layer = AG.IFeatureLayer(nt; layer_name="towns")
Layer: towns
Geometry 0 (point): [wkbPoint]
Geometry 1 (mixedgeom): [wkbUnknown]
Expand All @@ -378,7 +382,7 @@ Layer: towns
"""
function IFeatureLayer(
table;
name::String = "layer",
layer_name::String = "layer",
parseWKT::Bool = false,
parseWKB::Bool = false,
)::IFeatureLayer
Expand All @@ -391,7 +395,7 @@ function IFeatureLayer(
return _fromtable(
schema,
rows;
name = name,
layer_name = layer_name,
parseWKT = parseWKT,
parseWKB = parseWKB,
)
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ GDAL = "add2ef01-049f-52c4-9ee2-e494f65e021a"
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
LibGEOS = "a90b1aa1-3769-5649-ba7e-abc5a9d163eb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
LibGEOS = "a90b1aa1-3769-5649-ba7e-abc5a9d163eb"

0 comments on commit b08919b

Please sign in to comment.