Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java @ 4569:276d9bd3c77d
Workaround for NPE in FloodMapState.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 20 Nov 2012 12:53:14 +0100 |
parents | b1912514e0f5 |
children | 861c47e0a8a0 |
comparison
equal
deleted
inserted
replaced
4568:bbd82bd8e541 | 4569:276d9bd3c77d |
---|---|
1 package de.intevation.flys.artifacts.states; | 1 package de.intevation.flys.artifacts.states; |
2 | |
3 import java.io.File; | |
4 import java.io.FileNotFoundException; | |
5 import java.io.FileOutputStream; | |
6 import java.io.IOException; | |
7 import java.util.ArrayList; | |
8 import java.util.List; | |
9 | |
10 import org.apache.log4j.Logger; | |
11 import org.geotools.feature.FeatureCollection; | |
12 import org.geotools.feature.FeatureCollections; | |
13 import org.geotools.feature.simple.SimpleFeatureBuilder; | |
14 import org.opengis.feature.simple.SimpleFeature; | |
15 import org.opengis.feature.simple.SimpleFeatureType; | |
16 | 2 |
17 import com.vividsolutions.jts.geom.Coordinate; | 3 import com.vividsolutions.jts.geom.Coordinate; |
18 import com.vividsolutions.jts.geom.Geometry; | 4 import com.vividsolutions.jts.geom.Geometry; |
19 import com.vividsolutions.jts.geom.LineString; | 5 import com.vividsolutions.jts.geom.LineString; |
20 import com.vividsolutions.jts.geom.Polygon; | 6 import com.vividsolutions.jts.geom.Polygon; |
46 import de.intevation.flys.utils.MapfileGenerator; | 32 import de.intevation.flys.utils.MapfileGenerator; |
47 import de.intevation.flys.wsplgen.FacetCreator; | 33 import de.intevation.flys.wsplgen.FacetCreator; |
48 import de.intevation.flys.wsplgen.JobObserver; | 34 import de.intevation.flys.wsplgen.JobObserver; |
49 import de.intevation.flys.wsplgen.Scheduler; | 35 import de.intevation.flys.wsplgen.Scheduler; |
50 | 36 |
37 import java.io.File; | |
38 import java.io.FileNotFoundException; | |
39 import java.io.FileOutputStream; | |
40 import java.io.IOException; | |
41 import java.util.ArrayList; | |
42 import java.util.List; | |
43 | |
44 import org.apache.log4j.Logger; | |
45 import org.geotools.feature.FeatureCollection; | |
46 import org.geotools.feature.FeatureCollections; | |
47 import org.geotools.feature.simple.SimpleFeatureBuilder; | |
48 import org.opengis.feature.simple.SimpleFeature; | |
49 import org.opengis.feature.simple.SimpleFeatureType; | |
50 | |
51 | 51 |
52 public class FloodMapState | 52 public class FloodMapState |
53 extends DefaultState | 53 extends DefaultState |
54 implements FacetTypes | 54 implements FacetTypes |
55 { | 55 { |
515 for (SimpleFeature feature: f) { | 515 for (SimpleFeature feature: f) { |
516 Geometry geom = (Geometry) feature.getDefaultGeometry(); | 516 Geometry geom = (Geometry) feature.getDefaultGeometry(); |
517 | 517 |
518 | 518 |
519 if (geom instanceof LineString) { | 519 if (geom instanceof LineString) { |
520 geom = applyElevationAttribute(feature, (LineString) geom); | 520 geom = applyElevationAttribute(feature, geom); |
521 lines.add(feature); | 521 lines.add(feature); |
522 } | 522 } |
523 else if (geom instanceof Polygon) { | 523 else if (geom instanceof Polygon) { |
524 geom = applyElevationAttribute(feature, (Polygon) geom); | 524 geom = applyElevationAttribute(feature, geom); |
525 polygons.add(feature); | 525 polygons.add(feature); |
526 } | 526 } |
527 else { | 527 else { |
528 logger.warn("Feature not supported: " + geom.getClass()); | 528 logger.warn("Feature not supported: " + geom.getClass()); |
529 } | 529 } |
741 } | 741 } |
742 | 742 |
743 | 743 |
744 protected WQKms getWQKms(FLYSArtifact flys, CallContext cc) { | 744 protected WQKms getWQKms(FLYSArtifact flys, CallContext cc) { |
745 String wspString = flys.getDataAsString(WSP_ARTIFACT); | 745 String wspString = flys.getDataAsString(WSP_ARTIFACT); |
746 String[] parts = wspString.split(";"); | 746 if (wspString == null) { |
747 | 747 logger.debug("getWQKms(): wspString == null"); |
748 return null; | |
749 } | |
750 String[] parts = wspString.split(";"); | |
748 String otherArtifact = parts[0]; | 751 String otherArtifact = parts[0]; |
749 | 752 |
750 int idx = -1; | 753 int idx = -1; |
751 try { | 754 try { |
752 idx = Integer.parseInt(parts[2]); | 755 idx = Integer.parseInt(parts[2]); |
841 } | 844 } |
842 if (!target.exists()) { | 845 if (!target.exists()) { |
843 target.mkdir(); | 846 target.mkdir(); |
844 } | 847 } |
845 FileTools.walkTree(source, new FileTools.FileVisitor() { | 848 FileTools.walkTree(source, new FileTools.FileVisitor() { |
849 @Override | |
846 public boolean visit(File file) { | 850 public boolean visit(File file) { |
847 if (!file.isDirectory()) { | 851 if (!file.isDirectory()) { |
848 String name = file.getName(); | 852 String name = file.getName(); |
849 String suffix = ""; | 853 String suffix = ""; |
850 int pos = name.lastIndexOf('.'); | 854 int pos = name.lastIndexOf('.'); |