Skip to content

Make createAlignedGridExtent actually align to GridExtents - #2878

Merged
pomadchin merged 2 commits into
locationtech:masterfrom
jpolchlo:fix/grid-extent-alignment
Mar 7, 2019
Merged

pomadchin merged 2 commits into
locationtech:masterfrom
jpolchlo:fix/grid-extent-alignment

Conversation

@jpolchlo

@jpolchlo jpolchlo commented Feb 25, 2019 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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