@@ -221,25 +221,42 @@ end
221
221
Feature (x; kwargs... ) = Feature (x, values (kwargs))
222
222
223
223
"""
224
- Frees the Feature out of metadata
225
- i.e. returns and array of geometries
224
+
225
+ metafree(x::Feature)
226
+ metafree(x::Array{Feature})
227
+
228
+ Free the Feature from metadata
229
+ i.e. returns the geometry/array of geometries
226
230
"""
227
- function metafree (F :: Feature )
228
- getproperty (F, :main )
231
+ function metafree (x :: Feature )
232
+ getfield (x, 1 )
229
233
end
230
- metafree (x:: AbstractVector{<: Feature} ) = [ getproperty (i, :main ) for i in x]
234
+ metafree (x:: AbstractVector{<: Feature} ) = map (metafree, x)
231
235
232
236
"""
233
- Returns the metadata of a Feature
237
+
238
+ meta(x::Feature)
239
+ meta(x::Array{Feature})
240
+
241
+ Returns the metadata of a `Feature`
234
242
"""
235
243
function meta (x:: Feature )
236
- getfield (x, :meta )
244
+ getfield (x, 2 )
237
245
end
238
- meta (x:: AbstractVector{<: Feature} ) = [ getproperty (i, :meta ) for i in x]
246
+ meta (x:: AbstractVector{<: Feature} ) = map (meta, x)
239
247
240
248
# helper methods
241
- Base. getproperty (f:: Feature , s:: Symbol ) = s == :main ? getfield (f, 1 ) : s == :meta ? getfield (f, 2 ) : getproperty (getfield (f, 2 ), s)
242
- Base. propertynames (f:: Feature ) = (:main , propertynames (f. meta)... )
249
+ function Base. getproperty (x:: Feature , field:: Symbol )
250
+ if field == :main
251
+ metafree (x)
252
+ elseif field == :meta
253
+ meta (x)
254
+ else
255
+ getproperty (meta (x), field)
256
+ end
257
+ end
258
+
259
+ Base. propertynames (x:: Feature ) = (:main , propertynames (meta (x))... )
243
260
getnamestypes (:: Type{Feature{T, Names, Types}} ) where {T, Names, Types} = (T, Names, Types)
244
261
245
262
# explicitly give the "schema" of the object to StructArrays
0 commit comments