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

Make createAlignedGridExtent actually align to GridExtents #2878

Merged
merged 2 commits into from
Mar 7, 2019

Conversation

jpolchlo
Copy link
Contributor

@jpolchlo jpolchlo commented Feb 25, 2019

Overview

The sad state of affairs before this PR:

scala> GridExtent(Extent(0,0,3.5,3.5), 1.0, 1.0)
res12: geotrellis.raster.GridExtent = GridExtent(Extent(0.0, 0.0, 3.5, 3.5),1.0,1.0)

scala> res12.createAlignedRasterExtent(res12.extent)
res13: geotrellis.raster.RasterExtent = GridExtent(Extent(0.0, 0.0, 3.5, 3.5),1.0,1.0)

scala> res12.createAlignedRasterExtent(Extent(0,0,3.8,3.8))
res14: geotrellis.raster.RasterExtent = GridExtent(Extent(0.0, 0.0, 4.5, 4.5),1.0,1.0)

I fixed it and introduced the possibility that the alignment point (a point at the intersection of the target cell grid) might be specified by the user (in case one wanted the grid to align to a point other than the upper left of the GridExtent's extent):

scala> GridExtent(Extent(0,0,3.5,3.5), 1.0, 1.0)
res0: geotrellis.raster.GridExtent = GridExtent(Extent(0.0, 0.0, 3.5, 3.5),1.0,1.0)

scala> res0.createAlignedGridExtent(res0.extent)
res1: geotrellis.raster.GridExtent = GridExtent(Extent(0.0, -0.5, 4.0, 3.5),1.0,1.0)

scala> res0.createAlignedGridExtent(res0.extent, Point(0,0))
res2: geotrellis.raster.GridExtent = GridExtent(Extent(0.0, 0.0, 4.0, 4.0),1.0,1.0)

Signed-off-by: jpolchlo [email protected]

Checklist

  • docs/CHANGELOG.rst updated, if necessary
  • docs guides update, if necessary
  • New user API has useful Scaladoc strings
  • Unit tests added for bug-fix or new feature

@pomadchin
Copy link
Member

@pomadchin pomadchin merged commit bc2fdde into locationtech:master Mar 7, 2019
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

Successfully merging this pull request may close these issues.

2 participants