JuliaGeo / Shapefile.jl

Parsing .shp files in Julia
http://juliageo.org/Shapefile.jl/
MIT License
82 stars 14 forks source link

Fix getproperty(Row, :geometry) #83

Closed felixcremer closed 1 year ago

felixcremer commented 1 year ago

This change allows to access the geometry of a Shapefile.Row via Row.geometry. This PR fixes #82. This change is also needed so that Tables.columns of a collection of Shapefile.Row works (which you can end up with when filtering a Shapefile by some column values).

Why is Base.propertynames(Row) overloaded so that it doesn't also show the :geometry column? I thought about also changing that, but it is actively tested for, therefore I was hesitant to change it.

rafaqz commented 1 year ago

I think we have to change propertynames if we change getproperty.

From the propertynames docs:

Get a tuple or a vector of the properties (x.property) of an object x. This is typically the same as fieldnames(typeof(x)), but types that overload getproperty should generally overload propertynames as well to get the properties of an instance of the type.

So go ahead and change the test ;)

felixcremer commented 1 year ago

I went ahead and changed the test. ;-) And the function as well.

rafaqz commented 1 year ago

One question I have is how this interacts with round trip read/write - I guess DBFTables.jl just ignores the :geometry column in the Table?

@joshday are there any issues with merging this in relation to your work on write ?

joshday commented 1 year ago

Shouldn't be any issues on writing. Shapefile.write drops any column with elements that satisfy GeoInterface.isgeometry for the dbf file.