Skip to content

Commit

Permalink
Merge branch 'master' into feature/awf/gdal-warp-bindings-1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin authored Nov 19, 2020
2 parents 121b4b8 + e545d6d commit 02839d8
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Fix `Encoder[GeometryCollection]` including subclasses of GeometryCollection twice in the json
(MultiPolygon, Multipoint,MultiLinestring) [#3167](https://github.com/locationtech/geotrellis/issues/3167)
-Fix `LayoutTileSource` buffer should only be 1/2 a cellsize to avoid going out of bounds and creating `NODATA` values [#3302](https://github.com/locationtech/geotrellis/pull/3302)
- Fix `LayoutTileSource` buffer should only be 1/2 a cellsize to avoid going out of bounds and creating `NODATA` values [#3302](https://github.com/locationtech/geotrellis/pull/3302)
- Remove unused allocation from CroppedTile [#3297](https://github.com/locationtech/geotrellis/pull/3297)
- gdal-warp-bindings 1.1.1 bugfix release addresses a crash when initializing the bindings on MacOS. See https://github.com/geotrellis/gdal-warp-bindings#macos
- Fix GeometryCollection::getAll extension method [#3295](https://github.com/locationtech/geotrellis/pull/3295)
- Update gdal-warp-bindings v1.1.1 [#3303](https://github.com/locationtech/geotrellis/pull/3303)
- gdal-warp-bindings 1.1.1 is a bugfix release that addresses a crash when initializing the bindings on MacOS. See:
- https://github.com/geotrellis/gdal-warp-bindings#macos
- https://github.com/geotrellis/gdal-warp-bindings/pull/99

## [3.5.0] - 2020-08-18

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait ExtraGeometryCollectionMethods extends MethodExtensions[GeometryCollection
def getAll[G <: Geometry : ClassTag]: Seq[G] = {
val lb = scala.collection.mutable.ListBuffer.empty[G]
cfor(0)(_ < self.getNumGeometries, _ + 1){ i =>
if (classTag[G].runtimeClass.isInstance(self.getGeometryN(i)))
if (classTag[G].runtimeClass == self.getGeometryN(i).getClass)
lb += self.getGeometryN(i).asInstanceOf[G]
}
lb.toSeq
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2016 Azavea
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package geotrellis.vector

import geotrellis.proj4.{LatLng, WebMercator}

import org.scalatest.matchers.should.Matchers
import org.scalatest.funspec.AnyFunSpec

class GeometryCollectionSpec extends AnyFunSpec with Matchers {
describe("GeometryCollection") {
it("should reproject without duplication") {
val p = Point(1,1)
val mp = MultiPoint(p, p)
val gc = GeometryCollection(multiPoints = Seq(mp))

val pp = p.reproject(LatLng, WebMercator)
val mpp = MultiPoint(pp, pp)
val gcp = GeometryCollection(multiPoints = Seq(mpp))

gc.reproject(LatLng, WebMercator) should be (gcp)
}

it("getAll should work right for all types") {
val p0 = Point(0, 0)
val p1 = Point(1, 0)
val p2 = Point(0, 1)
val ls = LineString(p0, p1)
val pg = Polygon(p0, p1, p2, p0)
val mp = MultiPoint(p0, p1, p2)
val mpg = MultiPolygon(pg)
val mls = MultiLineString(ls)
val gc = GeometryCollection(points = Seq(p0))

val gc1 = GeometryCollection(points = Seq(p0),
lines = Seq(ls),
polygons = Seq(pg),
multiPoints = Seq(mp),
multiLines = Seq(mls),
multiPolygons = Seq(mpg),
geometryCollections = Seq(gc))

gc1.getAll[Point] should be (Seq(p0))
gc1.getAll[LineString] should be (Seq(ls))
gc1.getAll[Polygon] should be (Seq(pg))
gc1.getAll[MultiPoint] should be (Seq(mp))
gc1.getAll[MultiLineString] should be (Seq(mls))
gc1.getAll[MultiPolygon] should be (Seq(mpg))
gc1.getAll[GeometryCollection] should be (Seq(gc))
}
}
}

0 comments on commit 02839d8

Please sign in to comment.