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

GB.Meta() errors for Multi Geometries #63

Closed
Sov-trotter opened this issue Jun 14, 2020 · 2 comments
Closed

GB.Meta() errors for Multi Geometries #63

Sov-trotter opened this issue Jun 14, 2020 · 2 comments

Comments

@Sov-trotter
Copy link
Contributor

For Geometries like MultiPoint, MultiPolygon the following error occurs,

julia> using GeometryBasicsjulia> p1 = Point(3, 1)
2-element Point{2,Int64} with indices SOneTo(2):
3
1
julia> poi = meta(p1, city="Abuja", rainfall=1221.2)
2-element PointMeta{2,Int64,Point{2,Int64},(:city, :rainfall),Tuple{String,Float64}} with indices SOneTo(2):
3
1
julia> MultiPoint([p1])
1-element MultiPoint{2,Int64,Point{2,Int64},Array{Point{2,Int64},1}}:
[3, 1]
julia> meta(MultiPoint([p1]), city="Abuja", rainfall=1221.2)
ERROR: Metadata needs to be an array with the same length as data items. Found: String

also passing the metadata as a NamedTuple reproduces the error,

julia> using GeometryBasics; const GB = GeometryBasics
GeometryBasics

julia> tup = (featurecla = "Land", min_zoom = 0, scalerank = 0)
(featurecla = "Land", min_zoom = 0, scalerank = 0)

julia> polys = [Polygon(rand(Point{2, Float32}, 20)) for i in 1:10];

julia> multipoly = MultiPolygon(polys; tup...)  
ERROR: Metadata needs to be an array with the same length as data items. Found: String
@Sov-trotter
Copy link
Contributor Author

Sov-trotter commented Jun 14, 2020

One possible workaround is the way this issue was solved #52, i.e. defining a meta type for remaining multigeometries,
but as @visr pointed out the meta() call is going here rather than going to the overload method, so there might be something else happening?

@visr
Copy link
Member

visr commented Jun 14, 2020

A key point here is that generally a multi geometry is interpreted similarly to a single geometry, i.e. one feature, or one row in a table.

It may be fine to have multi geometries implemented as vectors of their single part versions, but they are not the same thing. In a vector of points, each point can have it's own metadata. In a MultiPoint, there is only one geometry, so only one metadata. Having a single multi geometry as a StructArray therefore does not quite seem the right approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants