comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java @ 8747:e9d912c97fa8

We expect that every river has only one RiverAxis of kind 1 This allowed to reduce code duplication and some cleanups.
author Tom Gottfried <tom@intevation.de>
date Fri, 05 Jun 2015 16:56:47 +0200
parents 572c102b1819
children 5e38e2924c07
comparison
equal deleted inserted replaced
8746:e701ef544ffa 8747:e9d912c97fa8
785 DGMAccess access = new DGMAccess(artifact); 785 DGMAccess access = new DGMAccess(artifact);
786 String river = access.getRiverName(); 786 String river = access.getRiverName();
787 String srid = String.valueOf(access.getDGM().getSrid()); 787 String srid = String.valueOf(access.getDGM().getSrid());
788 String srs = "EPSG:" + srid; 788 String srs = "EPSG:" + srid;
789 789
790 List<RiverAxis> axes = null; 790 RiverAxis axis = null;
791 try { 791 try {
792 axes = RiverAxis.getRiverAxis(river); 792 axis = RiverAxis.getRiverAxis(river);
793 } 793 }
794 catch (HibernateException iae) { 794 catch (HibernateException iae) {
795 log.warn("No valid river axis found for " + river); 795 log.warn("No valid river axis found for " + river);
796 return; 796 return;
797 } 797 }
798 if (axes == null || axes.isEmpty()) { 798 if (axis == null) {
799 log.warn("Could not find river axis for: '" + river + "'"); 799 log.warn("Could not find river axis for: '" + river + "'");
800 return; 800 return;
801 } 801 }
802 802
803 SimpleFeatureType ft = GeometryUtils.buildFeatureType( 803 SimpleFeatureType ft = GeometryUtils.buildFeatureType(
804 "axis", srs, LineString.class); 804 "axis", srs, LineString.class);
805 805
806 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft); 806 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft);
807 FeatureCollection collection = FeatureCollections.newCollection(); 807 FeatureCollection collection = FeatureCollections.newCollection();
808 808
809 for (int i = 0, n = axes.size(); i < n; i++) { 809 builder.add(axis.getGeom());
810 RiverAxis axis = axes.get(i); 810 collection.add(builder.buildFeature("0"));
811
812 builder.add(axis.getGeom());
813 collection.add(builder.buildFeature(String.valueOf(i)));
814
815 builder.reset();
816 }
817 811
818 File axisShape = new File(dir, WSPLGEN_AXIS); 812 File axisShape = new File(dir, WSPLGEN_AXIS);
819 813
820 boolean a = GeometryUtils.writeShapefile( 814 boolean a = GeometryUtils.writeShapefile(
821 axisShape, 815 axisShape,

http://dive4elements.wald.intevation.org