Commit ed6f4158 authored by Riegel's avatar Riegel
Browse files

Removed unnecessary instanceof casts. Ref #69

parent 7b16c17e
...@@ -213,12 +213,10 @@ public class SelfIntersectionUtil { ...@@ -213,12 +213,10 @@ public class SelfIntersectionUtil {
// intersection is only an edge, not a polygon // intersection is only an edge, not a polygon
// edge intersections are allowed // edge intersections are allowed
return PolygonIntersection.none(); return PolygonIntersection.none();
} else if (intersection instanceof GeometryCollection) { } else if (intersection instanceof GeometryCollection col) {
GeometryCollection col = (GeometryCollection) intersection;
for (int i = 0; i < col.getNumGeometries(); i++) { for (int i = 0; i < col.getNumGeometries(); i++) {
org.locationtech.jts.geom.Geometry interGeom = col.getGeometryN(i); org.locationtech.jts.geom.Geometry interGeom = col.getGeometryN(i);
if (interGeom instanceof org.locationtech.jts.geom.Polygon) { if (interGeom instanceof org.locationtech.jts.geom.Polygon intPoly) {
org.locationtech.jts.geom.Polygon intPoly = (org.locationtech.jts.geom.Polygon) interGeom;
ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly); ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly);
return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal()); return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal());
} }
...@@ -226,8 +224,7 @@ public class SelfIntersectionUtil { ...@@ -226,8 +224,7 @@ public class SelfIntersectionUtil {
// no polygon in collection, so no intersection // no polygon in collection, so no intersection
return PolygonIntersection.none(); return PolygonIntersection.none();
} }
if (intersection instanceof org.locationtech.jts.geom.Polygon) { if (intersection instanceof org.locationtech.jts.geom.Polygon intPoly) {
org.locationtech.jts.geom.Polygon intPoly = (org.locationtech.jts.geom.Polygon) intersection;
ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly); ConcretePolygon poly = convertToPolygon(plane1, projectionAxis, intPoly);
return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal()); return PolygonIntersection.polygon(poly, p1.getOriginal(), p2.getOriginal());
} else { } else {
......
...@@ -141,18 +141,18 @@ public class XmlStreamReporter implements StreamReporter { ...@@ -141,18 +141,18 @@ public class XmlStreamReporter implements StreamReporter {
@Override @Override
public void report(CityObject co) { public void report(CityObject co) {
if (co instanceof Building) { if (co instanceof Building bu) {
reportBuilding((Building) co); reportBuilding(bu);
} else if (co instanceof Vegetation) { } else if (co instanceof Vegetation ve) {
reportVegetation((Vegetation) co); reportVegetation(ve);
} else if (co instanceof TransportationObject) { } else if (co instanceof TransportationObject to) {
reportTrans((TransportationObject) co); reportTrans(to);
} else if (co instanceof BridgeObject) { } else if (co instanceof BridgeObject bo) {
reportBridge((BridgeObject) co); reportBridge(bo);
} else if (co instanceof WaterObject) { } else if (co instanceof WaterObject wo) {
reportWater((WaterObject) co); reportWater(wo);
} else if (co instanceof LandObject) { } else if (co instanceof LandObject lo) {
reportLand((LandObject) co); reportLand(lo);
} else { } else {
throw new IllegalStateException("Not reportable CityObject found: " + co.getClass().getSimpleName()); throw new IllegalStateException("Not reportable CityObject found: " + co.getClass().getSimpleName());
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment