rafaqz / Extents.jl

A shared Extent object for Julia spatial data, with DE-9IM spatial predicates
MIT License
4 stars 3 forks source link

empty Extent #4

Open visr opened 2 years ago

visr commented 2 years ago

I thought for a moment this returned a different type, but it's just show.

julia> Extent()
ExtentNamedTuple()

But it made me think, should we allow these to be created? And what about tuples for a dimension that are not size 2?

julia> Extent(X=(2,3,4))
Extent(X = (2, 3, 4),)

julia> Extent(X=(2,))
Extent(X = (2,),)

Should we check for these in the inner constructor?

visr commented 2 years ago

And what about Extent(X=(2,1))? That works now as well. But perhaps it should? I don't know.

I'm thinking about extents crossing the antimeridian https://datatracker.ietf.org/doc/html/rfc7946#section-5 for instance. Because of that in geojson the bbox is not defined by min and max, but by southwest to northeast.

But there are already some operations defined in this package in terms of min and max. So then we should enforce that the bounds are ascending for each dimension?

rafaqz commented 2 years ago

Thanks this is good feedback. We should only allow 2 tuples.

But Im not sure how to handle antimerideans. We could force ascending order in Tuples, but add a struct wrapper that adds the wrapping point (e.g. 180) when thats allowed.

visr commented 2 years ago

Yeah perhaps we should park the antimeridian for now, it's quite domain specific.

See #6.

Related to the 2 tuples, do you think it makes sense to add outer constructors that support AbstractVector and then run extrema on them to find the extents, such that this would work:

julia> Extent(X=[2,1,4])

julia> extrema([2,1,4])
(1, 4)
rafaqz commented 2 years ago

Ok, maybe I'll make a PR demoing antimeridean ideas at some point.

Im hesitant about the vector idea. Half the time geospatial raster data represents intervals so the vector of point values doesn't define the extent anyway... so lets leave that to users to do for now.