Skip to content

Commit 5d7fd2f

Browse files
committed
GeoTrellisPath.parse should preserve unrecognized uri parameters
1 parent 5d6193a commit 5d7fd2f

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

store/src/main/scala/geotrellis/store/GeoTrellisPath.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ object GeoTrellisPath {
7070
case _ => ""
7171
}
7272

73-
s"${scheme.split("\\+").last}://$authority${uri.path}".some
73+
val queryStringClean = {
74+
val filtered = queryString.removeAll(layerNameParam, zoomLevelParam, bandCountParam)
75+
if(filtered.isEmpty) "" else s"?${filtered.toString()}"
76+
}
77+
78+
s"${scheme.split("\\+").last}://$authority${uri.path}$queryStringClean".trim.some
7479
}
7580

7681
catalogPath.fold(Option.empty[GeoTrellisPath]) { catalogPath =>

store/src/test/scala/geotrellis/store/GeoTrellisPathSpec.scala

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class GeoTrellisPathSpec extends AnyFunSpec {
2323

2424
it("should fail to parse without a layer") {
2525
val path = GeoTrellisPath.parseOption("file:///foo/bar?zoom=1")
26-
assert(path == None)
26+
assert(path.isEmpty)
2727
}
2828

2929
it("should fail to parse without a zoom") {
3030
val path = GeoTrellisPath.parseOption("file:///foo/bar?layer=baz")
31-
assert(path == None)
31+
assert(path.isEmpty)
3232
}
3333

3434
it("should parse a local absolute file path without scheme") {
@@ -59,7 +59,7 @@ class GeoTrellisPathSpec extends AnyFunSpec {
5959
val path = GeoTrellisPath.parse("file:///foo/bar?layer=baz&band_count=1&zoom=10")
6060
assert(path.layerName == "baz")
6161
assert(path.zoomLevel == 10)
62-
assert(path.bandCount == Some(1))
62+
assert(path.bandCount.contains(1))
6363
}
6464

6565
it("should parse hdfs scheme") {
@@ -74,6 +74,20 @@ class GeoTrellisPathSpec extends AnyFunSpec {
7474
assert(path.layerName == "foo")
7575
}
7676

77+
it("should parse hbase scheme") {
78+
val path = GeoTrellisPath.parse("hbase://zookeeper:2181?master=master_host&attributes=attributes_table&layers=layers_table&layer=foo&zoom=1")
79+
assert(path.value == "hbase://zookeeper:2181?master=master_host&attributes=attributes_table&layers=layers_table")
80+
assert(path.layerName == "foo")
81+
assert(path.zoomLevel == 1)
82+
}
83+
84+
it("should parse accumulo scheme") {
85+
val path = GeoTrellisPath.parse("accumulo://root:@localhost/fake?attributes=attributes&layers=tiles&layer=foo&zoom=1")
86+
assert(path.value == "accumulo://root:@localhost/fake?attributes=attributes&layers=tiles")
87+
assert(path.layerName == "foo")
88+
assert(path.zoomLevel == 1)
89+
}
90+
7791
it("should parse absolute file scheme with gt+ prefix") {
7892
val path = GeoTrellisPath.parse("gt+file:///absolute/path?layer=foo&zoom=1")
7993
assert(path.value == "file:///absolute/path")

0 commit comments

Comments
 (0)