Skip to content

Commit

Permalink
Change some syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
katus98 committed Dec 19, 2020
1 parent f422398 commit 1393e21
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/main/java/com/katus/util/GeometryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.katus.constant.GeomConstant;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryCollection;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

Expand Down Expand Up @@ -43,21 +42,17 @@ public static Geometry breakByDimension(Geometry geometry, int dimension) {
Geometry unionGeom;
int d = getDimensionOfGeomType(geometry);
if (d == 3) { // GeometryCollection
GeometryCollection collection = (GeometryCollection) geometry;
List<Geometry> geometries = new ArrayList<>();
for (int i = 0; i < collection.getNumGeometries(); i++) {
Geometry geometryN = collection.getGeometryN(i);
if (getDimensionOfGeomType(geometryN) == dimension) {
for (int i = 0; i < geometry.getNumGeometries(); i++) {
Geometry geometryN = geometry.getGeometryN(i);
if (getDimensionOfGeomType(geometryN) == dimension && !geometryN.isEmpty()) {
geometries.add(geometryN);
}
}
if (geometries.isEmpty()) {
unionGeom = GeomConstant.EMPTY_GEOMETRY;
unionGeom = getEmptyGeometryByDimension(dimension);
} else {
unionGeom = geometries.get(0);
for (int i = 1; i < geometries.size(); i++) {
unionGeom = unionGeom.union(geometries.get(i));
}
unionGeom = geometries.stream().reduce(Geometry::union).get();
}
} else if (d == dimension) {
unionGeom = geometry;
Expand Down

0 comments on commit 1393e21

Please sign in to comment.