Commit e6709f76 authored by Eric Duminil's avatar Eric Duminil
Browse files

Avoid nullpointererror.

parent 6fd92db6
...@@ -18,7 +18,6 @@ import java.util.Set; ...@@ -18,7 +18,6 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.citygml4j.core.model.CityGMLVersion; import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.building.Building; import org.citygml4j.core.model.building.Building;
import org.citygml4j.core.model.core.AbstractCityObject; import org.citygml4j.core.model.core.AbstractCityObject;
...@@ -63,7 +62,6 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty; ...@@ -63,7 +62,6 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty; import org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty;
import org.xmlobjects.gml.model.geometry.primitives.LinearRing; import org.xmlobjects.gml.model.geometry.primitives.LinearRing;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty; import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citygml.green.osm.jaxb.OSM; import de.hft.stuttgart.citygml.green.osm.jaxb.OSM;
import de.hft.stuttgart.citygml.green.osm.jaxb.OsmMember; import de.hft.stuttgart.citygml.green.osm.jaxb.OsmMember;
import de.hft.stuttgart.citygml.green.osm.jaxb.OsmNode; import de.hft.stuttgart.citygml.green.osm.jaxb.OsmNode;
...@@ -204,7 +202,6 @@ public class GreenEnricher ...@@ -204,7 +202,6 @@ public class GreenEnricher
} }
public static void createTransformers(CityModel cityModel) { public static void createTransformers(CityModel cityModel) {
String epsgCode = extractEpsgCode(cityModel); String epsgCode = extractEpsgCode(cityModel);
sourceCRS = CRS_FACTORY.createFromName(epsgCode); sourceCRS = CRS_FACTORY.createFromName(epsgCode);
...@@ -218,7 +215,7 @@ public class GreenEnricher ...@@ -218,7 +215,7 @@ public class GreenEnricher
WaterBody wb = new WaterBody(); WaterBody wb = new WaterBody();
org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(waterArea.getArea()); org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(waterArea.getArea());
if (poly == null) { if (poly == null) {
// System.out.println("Skipping WaterBody " + waterArea.getArea()); // System.out.println("Skipping WaterBody " + waterArea.getArea());
continue; continue;
} }
MultiSurface ms = new MultiSurface(); MultiSurface ms = new MultiSurface();
...@@ -233,7 +230,7 @@ public class GreenEnricher ...@@ -233,7 +230,7 @@ public class GreenEnricher
for (GreenArea ga : greenAreas) { for (GreenArea ga : greenAreas) {
org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(ga.getArea()); org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(ga.getArea());
if (poly == null) { if (poly == null) {
// System.out.println("Skipping " + ga.getArea()); // System.out.println("Skipping " + ga.getArea());
continue; continue;
} }
PlantCover cover = new PlantCover(); PlantCover cover = new PlantCover();
...@@ -349,7 +346,7 @@ public class GreenEnricher ...@@ -349,7 +346,7 @@ public class GreenEnricher
GreenArea area2 = greenAreas.get(j); GreenArea area2 = greenAreas.get(j);
if (area1.getArea().intersects(area2.getArea())) { if (area1.getArea().intersects(area2.getArea())) {
Geometry difference = area1.getArea().difference(area2.getArea()); Geometry difference = area1.getArea().difference(area2.getArea());
// System.out.println(difference); // System.out.println(difference);
if (difference instanceof MultiPolygon) { if (difference instanceof MultiPolygon) {
MultiPolygon multi = (MultiPolygon) difference; MultiPolygon multi = (MultiPolygon) difference;
Polygon poly1 = (Polygon) multi.getGeometryN(0); Polygon poly1 = (Polygon) multi.getGeometryN(0);
...@@ -478,7 +475,7 @@ public class GreenEnricher ...@@ -478,7 +475,7 @@ public class GreenEnricher
if (member.getRole().isBlank()) { if (member.getRole().isBlank()) {
// assume outer ring // assume outer ring
// check if this ring is closed // check if this ring is closed
if (coordinates.get(0).equals2D(coordinates.get(coordinates.size() - 1))) { if (!coordinates.isEmpty() && coordinates.get(0).equals2D(coordinates.get(coordinates.size() - 1))) {
// ring is closed, create a polygon out of it // ring is closed, create a polygon out of it
Polygon polygon = GEOM_FACTORY.createPolygon(coordinates.toArray(new Coordinate[coordinates.size()])); Polygon polygon = GEOM_FACTORY.createPolygon(coordinates.toArray(new Coordinate[coordinates.size()]));
coordinates.clear(); coordinates.clear();
...@@ -840,7 +837,7 @@ public class GreenEnricher ...@@ -840,7 +837,7 @@ public class GreenEnricher
Road road = new Road(); Road road = new Road();
org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(roadArea.getArea()); org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(roadArea.getArea());
if (poly == null) { if (poly == null) {
// System.out.println("Skipping RoadArea: " + roadArea.getArea()); // System.out.println("Skipping RoadArea: " + roadArea.getArea());
continue; continue;
} }
MultiSurface ms = new MultiSurface(); MultiSurface ms = new MultiSurface();
...@@ -857,7 +854,7 @@ public class GreenEnricher ...@@ -857,7 +854,7 @@ public class GreenEnricher
LandUse landUse = new LandUse(); LandUse landUse = new LandUse();
org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(landUseArea.getArea()); org.xmlobjects.gml.model.geometry.primitives.Polygon poly = convertToCityGmlPoly(landUseArea.getArea());
if (poly == null) { if (poly == null) {
// System.out.println("Skipping RoadArea: " + landUseArea.getArea()); // System.out.println("Skipping RoadArea: " + landUseArea.getArea());
continue; continue;
} }
MultiSurface ms = new MultiSurface(); MultiSurface ms = new MultiSurface();
......
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