Mercurial > dive4elements > river
changeset 3303:96daa8a4c48f
Fix and workaround NullPointerExceptions
flys-artifacts/trunk@4988 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 13 Jul 2012 10:54:56 +0000 |
parents | 453d2d0c4258 |
children | 02d5731b43a2 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java |
diffstat | 3 files changed, 28 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Jul 13 10:44:18 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jul 13 10:54:56 2012 +0000 @@ -1,3 +1,9 @@ +2012-07-13 Christian Lins <christian.lins@intevation.de> + + * src/main/java/de/intevation/flys/utils/MapfileGenerator.java, + src/main/java/de/intevation/flys/utils/GeometryUtils.java: + Fix and workaround NullPointerExceptions. + 2012-07-13 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/wsplgen/WSPLGENCallable.java, @@ -10,8 +16,8 @@ src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java, src/main/java/de/intevation/flys/artifacts/MapArtifact.java, src/main/java/de/intevation/flys/utils/MapfileGenerator.java, - src/main/java/de/intevation/flys/exports/MapGenerator.java: Organized - and added missing imports. + src/main/java/de/intevation/flys/exports/MapGenerator.java: + Organized and added missing imports. 2012-07-13 Ingo Weinzierl <ingo@intevation.de>
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Fri Jul 13 10:44:18 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Fri Jul 13 10:54:56 2012 +0000 @@ -76,7 +76,7 @@ public static String getRiverBounds(String rivername) { Envelope env = getRiverBoundary(rivername); - if (env == null) { + if (env != null) { return jtsBoundsToOLBounds(env); } @@ -91,11 +91,12 @@ * @return the OpenLayers boundary of <i>env</i>. */ public static String jtsBoundsToOLBounds(Envelope env) { - return "" + - env.getMinX() + " " + - env.getMinY() + " " + - env.getMaxX() + " " + - env.getMaxY(); + StringBuilder buf = new StringBuilder(); + buf.append(env.getMinX()); buf.append(' '); + buf.append(env.getMinY()); buf.append(' '); + buf.append(env.getMaxX()); buf.append(' '); + buf.append(env.getMaxY()); + return buf.toString(); } public static String createOLBounds(Geometry a, Geometry b) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java Fri Jul 13 10:44:18 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java Fri Jul 13 10:54:56 2012 +0000 @@ -1,5 +1,14 @@ package de.intevation.flys.utils; +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.common.utils.Config; +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.LayerInfo; +import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; +import de.intevation.flys.artifacts.model.map.WMSLayerFacet; +import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; +import de.intevation.flys.artifacts.resources.Resources; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; @@ -18,15 +27,6 @@ import org.geotools.data.shapefile.shp.ShapefileHeader; import org.geotools.data.shapefile.shp.ShapefileReader; -import de.intevation.artifacts.CallContext; -import de.intevation.artifacts.common.utils.Config; -import de.intevation.flys.artifacts.FLYSArtifact; -import de.intevation.flys.artifacts.model.LayerInfo; -import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; -import de.intevation.flys.artifacts.model.map.WMSLayerFacet; -import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; -import de.intevation.flys.artifacts.resources.Resources; - /** * This class iterates over a bunch of directories, searches for meta * information coresponding to shapefiles and creates a mapfile which is used by @@ -67,7 +67,7 @@ private String velocityLogfile; private VelocityEngine velocityEngine; - private boolean lock[]; + private final boolean lock[]; @@ -610,7 +610,9 @@ layerinfo.setData(wms.getData()); layerinfo.setTitle(wms.getDescription()); layerinfo.setStyle(style); - layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); + if(wms.getExtent() != null) { + layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); + } layerinfo.setConnection(wms.getConnection()); layerinfo.setConnectionType(wms.getConnectionType()); layerinfo.setLabelItem(wms.getLabelItem());