Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix tests with new ARG format.

  • Loading branch information...
commit 7c4ad98a73987f581ff2c1daf0dc8239fe635747 1 parent 17b672a
@joshmarcus authored
View
1  src/main/scala/geotrellis/data/arg.scala
@@ -46,6 +46,7 @@ object ArgReader extends FileReader {
object ArgWriter extends Writer {
def rasterType = "arg"
+ def dataType = "legacy"
def write(path:String, raster:IntRaster, name:String) {
val i = path.lastIndexOf(".")
View
4 src/main/scala/geotrellis/data/arg32.scala
@@ -43,11 +43,13 @@ trait ArgNWriter extends Writer {
def width:Int
def rasterType:String
+ def dataType = "Int" + (width * 8).toString
+
def write(path:String, raster:IntRaster, name:String) {
val i = path.lastIndexOf(".")
val base = path.substring(0, i)
writeMetadataJSON(base + ".json", name, raster.rasterExtent)
- writeData(base + "." + rasterType, raster)
+ writeData(base + ".arg", raster)
}
private def writeData(path:String, raster:IntRaster) {
View
3  src/main/scala/geotrellis/data/ascii.scala
@@ -145,7 +145,8 @@ object AsciiReader extends FileReader {
}
object AsciiWriter extends Writer {
- def rasterType = "arg32"
+ def rasterType = "ascii"
+ def dataType = ""
def write(path:String, raster:IntRaster, name:String) {
write(path, raster, name, NODATA)
View
10 src/main/scala/geotrellis/data/data.scala
@@ -173,15 +173,18 @@ trait FileReader extends Reader {
}
trait Writer {
+
def write(path:String, raster:IntRaster) { write(path, raster, raster.name) }
def write(path:String, raster:IntRaster, name:String):Unit
def rasterType: String
+ def dataType:String
def writeMetadataJSON(path:String, name:String, re:RasterExtent) {
val metadata = """{
"layer": "%s",
+ "datatype": "%s",
"type": "%s",
"xmin": %f,
"xmax": %f,
@@ -190,8 +193,11 @@ trait Writer {
"cols": %d,
"rows": %d,
"cellwidth": %f,
- "cellheight": %f
-}""".format(name, rasterType, re.extent.xmin, re.extent.xmax, re.extent.ymin,
+ "cellheight": %f,
+ "epsg": 3785,
+ "yskew": 0.0,
+ "xskew": 0.0
+}""".format(name, rasterType, dataType, re.extent.xmin, re.extent.xmax, re.extent.ymin,
re.extent.ymax, re.cols, re.rows, re.cellwidth, re.cellheight)
val bos = new BufferedOutputStream(new FileOutputStream(path))
View
1  src/main/scala/geotrellis/data/geotiff.scala
@@ -108,6 +108,7 @@ object GeoTiffReader extends FileReader {
object GeoTiffWriter extends Writer {
def rasterType = "geotiff"
+ def dataType = ""
def write(path:String, raster:IntRaster, name:String) {
val re = raster.rasterExtent
View
2  src/main/scala/geotrellis/raster/TileRaster.scala
@@ -51,7 +51,7 @@ object Tiler {
def tileName(name:String, col:Int, row:Int) = "%s_%d_%d".format(name, col, row)
def tilePath(path:String, name:String, col:Int, row:Int) = {
- "%s/%s_%d_%d.arg32".format(path, name, col, row)
+ "%s/%s_%d_%d.arg".format(path, name, col, row)
}
def writeTiles(tiles:TileRasterData, name:String, path:String) = {
View
BIN  src/test/resources/fake.img32.arg
Binary file not shown
View
2  src/test/resources/fake.img8.arg
@@ -1 +1 @@
-!"#$1234
+1234!"#$
View
BIN  src/test/resources/quad32.arg
Binary file not shown
View
2  src/test/resources/quad8.arg
@@ -1 +1 @@
-
+
View
6 src/test/scala/geotrellis/data/arg.scala
@@ -15,7 +15,7 @@ import geotrellis.data._
class ArgSpec extends Spec with MustMatchers with ShouldMatchers {
describe("An ArgReader") {
val server = TestServer()
- val path1 = "src/test/resources/fake.img.arg"
+ val path1 = "src/test/resources/fake.img8.arg"
it("should build a valid raster") {
val raster = ArgReader.readPath(path1, None, None)
@@ -39,7 +39,7 @@ class ArgSpec extends Spec with MustMatchers with ShouldMatchers {
ArgWriter.write(path2, raster)
val data1 = io.Source.fromFile(path2).mkString
- val data2 = io.Source.fromFile("src/test/resources/fake.img.arg").mkString
+ val data2 = io.Source.fromFile("src/test/resources/fake.img8.arg").mkString
val base = path2.substring(0, path2.lastIndexOf("."))
@@ -55,7 +55,7 @@ class ArgSpec extends Spec with MustMatchers with ShouldMatchers {
val cellheight = abs(ymax - ymin) / cols
val e = Extent(xmin, ymin, xmax, ymax)
val re = RasterExtent(e, cellwidth, cellheight, cols, rows)
- ArgReader.readPath("src/test/resources/quad.arg", None, Some(re))
+ ArgReader.readPath("src/test/resources/quad8.arg", None, Some(re))
}
// helper function
View
19 src/test/scala/geotrellis/data/arg32.scala
@@ -22,7 +22,7 @@ class Arg32Spec extends Spec with MustMatchers with ShouldMatchers {
describe("An Arg32Reader") {
val server = TestServer()
- val path1 = "src/test/resources/fake.img.arg32"
+ val path1 = "src/test/resources/fake.img32.arg"
it("should use correct no data values") {
ArgFormat.noData(1) must be === -128
@@ -48,17 +48,18 @@ class Arg32Spec extends Spec with MustMatchers with ShouldMatchers {
val raster = Arg32Reader.readPath(path1, None, None)
it("should write to full paths ") {
- val fh = java.io.File.createTempFile("foog", ".arg32")
+ val fh = java.io.File.createTempFile("foog", ".arg")
val path = fh.getPath
- val base = path.substring(0, path.length - 6)
+ val base = path.substring(0, path.length - 4)
+ println("base path: " + base)
Arg32Writer.write(path, raster)
val data1 = io.Source.fromFile(path).mkString
- val data2 = io.Source.fromFile("src/test/resources/fake.img.arg32").mkString
+ val data2 = io.Source.fromFile("src/test/resources/fake.img32.arg").mkString
- new java.io.File(base + ".arg32").delete() must be === true
- new java.io.File(base + ".json").delete() must be === true
+ //new java.io.File(base + ".arg").delete() must be === true
+ //new java.io.File(base + ".json").delete() must be === true
data1 must be === data2
}
@@ -68,9 +69,9 @@ class Arg32Spec extends Spec with MustMatchers with ShouldMatchers {
val data1 = Array.fill[Int](16)(nd)
val raster = IntRaster(data1, geo)
- val fh = java.io.File.createTempFile("nodata", ".arg32")
+ val fh = java.io.File.createTempFile("nodata", ".arg")
val path = fh.getPath
- val base = path.substring(0, path.length - 6)
+ val base = path.substring(0, path.length - 4)
Arg32Writer.write(path, raster)
@@ -92,7 +93,7 @@ class Arg32Spec extends Spec with MustMatchers with ShouldMatchers {
val e = Extent(xmin, ymin, xmax, ymax)
val re = RasterExtent(e, cellwidth, cellheight, cols, rows)
- Arg32Reader.readPath("src/test/resources/quad.arg32", None, Some(re))
+ Arg32Reader.readPath("src/test/resources/quad32.arg", None, Some(re))
}
// helper function
View
2  src/test/scala/geotrellis/data/intraster.scala
@@ -16,7 +16,7 @@ class IntRasterReaderSpec extends Spec with MustMatchers with ShouldMatchers {
val geo = RasterExtent(e, 8.0, 8.0, 10, 10)
val server = TestServer()
- val raster = server.loadRaster("src/test/resources/quad.arg", geo)
+ val raster = server.loadRaster("src/test/resources/quad8.arg", geo)
val raster2 = IntRasterReader.read(raster, None)
View
4 src/test/scala/geotrellis/operation/StandardDeviation.scala
@@ -13,8 +13,8 @@ class DeviationRasterSpec extends Spec with MustMatchers with ShouldMatchers {
describe("The DeviationRaster operation") {
it("should work") {
- val r1 = LoadFile("src/test/resources/quad.arg")
- val r2 = LoadFile("src/test/resources/quad.arg")
+ val r1 = LoadFile("src/test/resources/quad8.arg")
+ val r2 = LoadFile("src/test/resources/quad8.arg")
val h = BuildMapHistogram(r1)
val s = StandardDeviation(r2, h, 1000)
val raster = server.run(s)
View
26 src/test/scala/geotrellis/operation/int.scala
@@ -61,7 +61,7 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
}
it("LoadFile") {
- val L = LoadFile("src/test/resources/fake.img.arg")
+ val L = LoadFile("src/test/resources/fake.img8.arg")
val raster = server.run(L)
raster.get(0, 0) must be === 49
@@ -70,18 +70,18 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
it("LoadFile, take 2") {
- val L2 = LoadFile("src/test/resources/fake.img.arg")
+ val L2 = LoadFile("src/test/resources/fake.img8.arg")
val raster2 = server.run(L2)
raster2.get(0, 0) must be === 49
raster2.get(3, 3) must be === 4
}
it("LoadFile, w/ resampling") {
- val G1 = LoadRasterExtentFromFile("src/test/resources/fake.img.arg")
+ val G1 = LoadRasterExtentFromFile("src/test/resources/fake.img8.arg")
val geo1 = server.run(G1)
val G2 = BuildRasterExtent( geo1.extent.xmin, geo1.extent.ymin, geo1.extent.xmax, geo1.extent.ymax, 2, 2)
- val L = LoadFile("src/test/resources/fake.img.arg", G2)
+ val L = LoadFile("src/test/resources/fake.img8.arg", G2)
val raster = server.run(L)
raster.get(0, 0) must be === 34
raster.get(1, 0) must be === 36
@@ -98,11 +98,11 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
}
it("LoadResampledArgFile, take 2") {
- val G1 = LoadRasterExtentFromFile("src/test/resources/fake.img.arg")
+ val G1 = LoadRasterExtentFromFile("src/test/resources/fake.img8.arg")
val geo1 = server.run(G1)
val G2 = BuildRasterExtent( geo1.extent.xmin, geo1.extent.ymin, geo1.extent.xmax, geo1.extent.ymax, 2, 2)
- val L = LoadFile("src/test/resources/fake.img.arg", G2)
+ val L = LoadFile("src/test/resources/fake.img8.arg", G2)
val raster = server.run(L)
raster.get(0, 0) must be === 34
@@ -113,7 +113,7 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
it("ResampleRaster") {
- val L = LoadFile("src/test/resources/quad.arg")
+ val L = LoadFile("src/test/resources/quad8.arg")
val F = ResampleRaster(L, 4, 4)
val raster = server.run(F)
@@ -127,9 +127,9 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
it("test Literal implicit") {
import geotrellis.operation.Literal._
- val G1 = LoadRasterExtentFromFile("src/test/resources/fake.img.arg")
+ val G1 = LoadRasterExtentFromFile("src/test/resources/fake.img8.arg")
val geo1 = server.run(G1)
- val L = LoadFile("src/test/resources/fake.img.arg", geo1)
+ val L = LoadFile("src/test/resources/fake.img8.arg", geo1)
}
it("should LoadArgFileChunk with subextents that are within the arg extent") {
@@ -138,7 +138,7 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
val G = BuildRasterExtent(xmin = -90, ymin = 20,
xmax = -80, ymax = 40,
cols = 1, rows = 1)
- val L = LoadFile("src/test/resources/fake2.img.arg", G)
+ val L = LoadFile("src/test/resources/fake2.img8.arg", G)
}
it("CopyRaster") {
@@ -208,7 +208,7 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
}
it("GenerateStatistics") {
- val R = LoadFile("src/test/resources/quad.arg")
+ val R = LoadFile("src/test/resources/quad8.arg")
val S = GenerateStatistics(BuildMapHistogram(R))
val stats = server.run(S)
@@ -220,8 +220,8 @@ class IntSpecX extends Spec with MustMatchers with ShouldMatchers {
it("StandardDeviation") {
val newServer = TestServer()
- val R1 = LoadFile("src/test/resources/quad.arg")
- val R2 = LoadFile("src/test/resources/quad.arg")
+ val R1 = LoadFile("src/test/resources/quad8.arg")
+ val R2 = LoadFile("src/test/resources/quad8.arg")
val H = BuildMapHistogram(R1)
val S = StandardDeviation(R2, H, 1000)
val raster = newServer.run(S)
View
5 src/test/scala/geotrellis/process/catalog.scala
@@ -39,7 +39,10 @@ val json0 = """
"cellwidth": 20.0,
"cellheight": 20.0,
"cols": 5,
- "rows": 5
+ "rows": 5,
+ "epsg": 3785,
+ "xskew": 0.0,
+ "yskew": 0.0
}
}
"""
View
2  src/test/scala/geotrellis/process/server.scala
@@ -21,7 +21,7 @@ describe("A Server") {
//}
it("should use caching for LoadRaster") {
- val path = "src/test/resources/quadborder.arg32"
+ val path = "src/test/resources/quadborder8.arg"
val server = TestServer()
//server.enableCaching
Please sign in to comment.
Something went wrong with that request. Please try again.