Skip to content

Commit

Permalink
GridBounds: coordsIter output should match coords
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Jul 21, 2017
1 parent d93600e commit d1b9b39
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,13 @@ class GridBoundsSpec extends FunSpec with Matchers{
GridBounds.distinct(gridBounds).map(_.size).sum should be ((101 * 101) - (25 * 25 * 2))
}
}

describe("GridBounds.coords") {
// TODO This test can be removed in 2.0
it("should match the output of coordsIter") {
val gbs = GridBounds(0, 0, 10, 10)

gbs.coordsIter.toSeq shouldBe gbs.coords.toSeq
}
}
}
2 changes: 1 addition & 1 deletion raster/src/main/scala/geotrellis/raster/GridBounds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ case class GridBounds(colMin: Int, rowMin: Int, colMax: Int, rowMax: Int) {
def coordsIter: Iterator[(Int, Int)] = for {
row <- Iterator.range(0, height)
col <- Iterator.range(0, width)
} yield (row, col)
} yield (col + colMin, row + rowMin)

/**
* Return the intersection of the present [[GridBounds]] and the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import geotrellis.spark.testkit.TestEnvironment
import org.apache.hadoop.conf.Configuration
import com.amazonaws.auth.AWSCredentials
import org.apache.hadoop.mapreduce.{ TaskAttemptContext, InputSplit }
import org.apache.spark.rdd.RDD

import java.nio.file.{ Paths, Files }
import spire.syntax.cfor._
Expand All @@ -51,14 +52,18 @@ class S3GeoTiffRDDSpec
val testGeoTiffPath = "spark/src/test/resources/all-ones.tif"
val geoTiffBytes = Files.readAllBytes(Paths.get(testGeoTiffPath))
mockClient.putObject(bucket, key, geoTiffBytes)
val source1 = S3GeoTiffRDD.spatial(bucket, key, S3GeoTiffRDD.Options(getS3Client = () => new MockS3Client))
val source2 = S3GeoTiffRDD.spatial(bucket, key, S3GeoTiffRDD.Options(maxTileSize = Some(128), getS3Client = () => new MockS3Client))

val source1: RDD[(ProjectedExtent, Tile)] =
S3GeoTiffRDD.spatial(bucket, key, S3GeoTiffRDD.Options(getS3Client = () => new MockS3Client))
val source2: RDD[(ProjectedExtent, Tile)] =
S3GeoTiffRDD.spatial(bucket, key, S3GeoTiffRDD.Options(maxTileSize = Some(128), getS3Client = () => new MockS3Client))

source1.count should be < (source2.count)

val (_, md) = source1.collectMetadata[SpatialKey](FloatingLayoutScheme(256))

val stitched1 = source1.tileToLayout(md).stitch
val stitched2 = source2.tileToLayout(md).stitch
val stitched1: Tile = source1.tileToLayout(md).stitch
val stitched2: Tile = source2.tileToLayout(md).stitch

assertEqual(stitched1, stitched2)
}
Expand Down

0 comments on commit d1b9b39

Please sign in to comment.