-
Notifications
You must be signed in to change notification settings - Fork 11
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
Union bboxes #259
Merged
Merged
Union bboxes #259
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
modules/core-test/js/src/test/scala/com/azavea/stac4s/JsFPLawsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.azavea.stac4s | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatest.matchers.must.Matchers | ||
import org.scalatestplus.scalacheck.Checkers | ||
import org.typelevel.discipline.scalatest.FunSuiteDiscipline | ||
|
||
import cats.kernel.laws.discipline.SemigroupTests | ||
import com.azavea.stac4s.testing.TestInstances | ||
|
||
class JsFPLawsSpec extends AnyFunSuite with FunSuiteDiscipline with Checkers with Matchers with TestInstances { | ||
checkAll("Semigroup.Bbox", SemigroupTests[Bbox].semigroup) | ||
} |
13 changes: 13 additions & 0 deletions
13
modules/core-test/jvm/src/test/scala/com/azavea/stac4s/JvmFPLawsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.azavea.stac4s | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatest.matchers.must.Matchers | ||
import org.scalatestplus.scalacheck.Checkers | ||
import org.typelevel.discipline.scalatest.FunSuiteDiscipline | ||
|
||
import cats.kernel.laws.discipline.SemigroupTests | ||
import com.azavea.stac4s.testing.TestInstances | ||
|
||
class JvmFPLawsSpec extends AnyFunSuite with FunSuiteDiscipline with Checkers with Matchers with TestInstances { | ||
checkAll("Semigroup.Bbox", SemigroupTests[Bbox].semigroup) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will give the incorrect results if (at least) one of the bboxes crosses the antimeridian, e.g.,
[178.0, 0.0, -178.0, 1.0] ∪ [177.0, 0.0, 178.0, 1.0]
should be[177.0, 0.0, -178.0, 1.0]
instead of[177.0, 0.0, 178.0, 1.0]
(-178 is the most northeasterly point of the extent rather than the max value of 178)it might also be useful to name the attributes like
(sw|ne)_(lon|lat)
instead of(x|y)(min|max)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof that's a fair point. On the one hand there's nothing here that says this is lat/long only, on the other hand it's a special type to hold bboxes from geojson which should always be lat/long, and on the third hand there's the projection extension which lives in core. Do you know off-hand whether there are many existing catalogs that implement extension? There's the example linked in the extension itself, but stacindex doesn't have much. If that extension weren't in core I'd say it's a user problem but its being in core makes me feel like we should at least make an explicit decision about it, even if that decision is "user-land problem".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that connected to the projection extension? It has its own set of fields and none of them is the Bbox.
I had a feeling that it only adds these
proj
fields and new geometry fields can already be in other than LatLon projections.P.S. for consisteny reasons (with GT) I prefer x / y / min / max ¯_(ツ)_/¯ I always forget the lat / lon / sw / ne ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we have two different BBox types? One is locked to WGS 84 and used for the Feature/Item bbox and has union, and the other (used for proj:bbox) is just an abstraction of 2 or 3 points that (I don't think) can have a generalized union operation -- the killer argument there is probably that 2
BBox
s don't necessarily have to be in the same CRS. I have no idea how polar projections work either, but seems like that would be another edge case.I originally created the projection extension to standardize the native geometry fields used by Astraea EOD, but bbox was added to the spec later by someone else, so EOD doesn't use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Projection has a bbox field
proj:bbox
https://github.com/radiantearth/stac-spec/tree/dev/extensions/projection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're going to have a lot of trouble getting consistent anti-meridian handling.
I did some experiments with shapely, turf, and jts. I created boxes with xmin = 179, xmax = -179, ymin = 0, ymax = 2 with each of them.
With shapely and jts, the library helpfully flips the x min / max for you and you end up with this guy:
With turf there's no box helper, but I created a polygon with those coordinates, which worked great:
except neither geojson.io nor qgis thinks that's a valid feature / geometry.
I think the choice for anti-meridian handling is between exceeding the lat/long bounds (e.g., -179 gets rewritten to 181 if the xmin is 179) and noting that bbox unions when interpreted as lat/long can produce surprising bboxes while steering people toward preferring the geometry field whenever they have a choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I entered the turf feature incorrectly into geojson.io the first time -- it displays it, but not surprisingly I guess it also displays as the huge equatorial rectangle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid comparing this against the geometry behavior in those libraries -- I think a lot of those tools make the (almost always reasonable, but wrong) assumption that antimeridian-spanning polygons are just wound the wrong way and are supposed to be the "horizontal" inverse. I do think it's an odd behavior to just take the min and max of the two bbox points, since it's unlikely those would be flipped.
But, I think it's reasonable to expect that if I have an antimeridian spanning bbox and union it with something else, I get an antimeridian spanning bbox back. The edge case (literally!) of two bboxes that align on opposite sides of the antimeridan should probably give back a -180 to 180 bbox instead of an antimeridian spanning one. In other cases where an antimeridian-spanning bbox is smaller than the non-antimeridian-spanning one (e.g., one scene in Australia and one in Alaska), I wouldn't necessarily expect to get back the smallest bbox and/or one that spanned the antimeridian, so a huge non-antimeridian-spanning one covering most of the globe would be reasonable.
But, overall, whatever the semantics are for union, the resulting bbox should actually cover the two input bboxes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm proposing to accomplish with e.g. rewriting -179 to 181. What I'm especially interested in avoiding is:
Extent
s in GeoTrellis, which we'll get if we keep the smaller max than minI want to scope down what I'm responsible for here to:
That is what's required for azavea/franklin#623, which is the problem this PR is trying to solve. I propose solving that by being naive/trusting about what min and max mean and sticking with the very basic implementation that's already here.
I want to defer responsibility for:
I think the central tension is that bboxes in stac4s don't know anything about projections, but our notion of "covers" here is aware that these coordinates are on a globe.
If GT supported 3d
Extent
s andProjectedExtent
s we could re-use those and solve this problem there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jisantuc 👍 all makes sense to me; I will post here issues that came to mind after this conversation happened (leaving it here for the history purposes so we'd remember having this covnersation):