comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java @ 7055:1f38656b68c4

DGM SRIds are now fetched from database instead of configuration.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 19 Sep 2013 16:27:33 +0200
parents 93e7f947f6fa
children a56fe3bc6700
comparison
equal deleted inserted replaced
7054:f4d6ef50665a 7055:1f38656b68c4
28 import org.dive4elements.artifacts.CallContext; 28 import org.dive4elements.artifacts.CallContext;
29 import org.dive4elements.artifacts.CallMeta; 29 import org.dive4elements.artifacts.CallMeta;
30 import org.dive4elements.artifacts.GlobalContext; 30 import org.dive4elements.artifacts.GlobalContext;
31 import org.dive4elements.artifacts.common.utils.FileTools; 31 import org.dive4elements.artifacts.common.utils.FileTools;
32 import org.dive4elements.river.artifacts.D4EArtifact; 32 import org.dive4elements.river.artifacts.D4EArtifact;
33 import org.dive4elements.river.artifacts.access.DGMAccess;
33 import org.dive4elements.river.artifacts.access.RangeAccess; 34 import org.dive4elements.river.artifacts.access.RangeAccess;
34 import org.dive4elements.river.artifacts.context.RiverContext; 35 import org.dive4elements.river.artifacts.context.RiverContext;
35 import org.dive4elements.river.artifacts.model.CalculationMessage; 36 import org.dive4elements.river.artifacts.model.CalculationMessage;
36 import org.dive4elements.river.artifacts.model.CalculationResult; 37 import org.dive4elements.river.artifacts.model.CalculationResult;
37 import org.dive4elements.river.artifacts.model.FacetTypes; 38 import org.dive4elements.river.artifacts.model.FacetTypes;
410 artifact, 411 artifact,
411 artifactDir, 412 artifactDir,
412 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, 413 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
413 HWS_LINES_SHAPE, 414 HWS_LINES_SHAPE,
414 "LINE", 415 "LINE",
415 "31467", 416 "31467", // XXX: This should be dynamically fetched from database.
416 "hws"); 417 "hws");
417 job.addLin(artifactDir + "/" + HWS_LINES_SHAPE); 418 job.addLin(artifactDir + "/" + HWS_LINES_SHAPE);
418 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL, 419 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL,
419 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, 420 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
420 FLOODMAP_HWS_LINES,2); 421 FLOODMAP_HWS_LINES,2);
534 D4EArtifact artifact, 535 D4EArtifact artifact,
535 FacetCreator facetCreator, 536 FacetCreator facetCreator,
536 File dir, 537 File dir,
537 WSPLGENJob job 538 WSPLGENJob job
538 ) { 539 ) {
539 String river = artifact.getDataAsString("river"); 540 DGMAccess access = new DGMAccess(artifact);
540 String geoJSON = artifact.getDataAsString("uesk.barriers"); 541 String geoJSON = access.getGeoJSON();
541 String srid = RiverUtils.getRiverDGMSrid(river);
542 String srs = "EPSG:" + srid;
543 542
544 if (geoJSON == null || geoJSON.length() == 0) { 543 if (geoJSON == null || geoJSON.length() == 0) {
545 logger.debug("No barrier features in parameterization existing."); 544 logger.debug("No barrier features in parameterization existing.");
546 return; 545 return;
547 } 546 }
547
548 String srid = String.valueOf(access.getDGM().getSrid());
549
550 String srs = "EPSG:" + srid;
548 551
549 SimpleFeatureType ft = getBarriersFeatureType( 552 SimpleFeatureType ft = getBarriersFeatureType(
550 "barriers", srs, Geometry.class); 553 "barriers", srs, Geometry.class);
551 554
552 List<SimpleFeature> features = GeometryUtils.parseGeoJSON(geoJSON, ft); 555 List<SimpleFeature> features = GeometryUtils.parseGeoJSON(geoJSON, ft);
746 return list; 749 return list;
747 } 750 }
748 751
749 752
750 protected void setAxis(D4EArtifact artifact, File dir, WSPLGENJob job) { 753 protected void setAxis(D4EArtifact artifact, File dir, WSPLGENJob job) {
751 String river = artifact.getDataAsString("river"); 754 DGMAccess access = new DGMAccess(artifact);
752 String srid = RiverUtils.getRiverDGMSrid(river); 755 String river = access.getRiver();
753 String srs = "EPSG:" + srid; 756 String srid = String.valueOf(access.getDGM().getSrid());
757 String srs = "EPSG:" + srid;
754 758
755 List<RiverAxis> axes = null; 759 List<RiverAxis> axes = null;
756 try { 760 try {
757 axes = RiverAxis.getRiverAxis(river); 761 axes = RiverAxis.getRiverAxis(river);
758 } 762 }
792 } 796 }
793 } 797 }
794 798
795 799
796 protected void setPro(D4EArtifact artifact, File dir, WSPLGENJob job) { 800 protected void setPro(D4EArtifact artifact, File dir, WSPLGENJob job) {
797 String river = artifact.getDataAsString("river"); 801 DGMAccess access = new DGMAccess(artifact);
798 String srid = RiverUtils.getRiverDGMSrid(river); 802 String river = access.getRiver();
799 String srs = "EPSG:" + srid; 803 String srid = String.valueOf(access.getDGM().getSrid());
804 String srs = "EPSG:" + srid;
800 805
801 List<CrossSectionTrack> cst = 806 List<CrossSectionTrack> cst =
802 CrossSectionTrack.getCrossSectionTrack(river, WSPLGEN_QPS_NAME); 807 CrossSectionTrack.getCrossSectionTrack(river, WSPLGEN_QPS_NAME);
803 808
804 logger.debug("Found " + cst.size() + " CrossSectionTracks."); 809 logger.debug("Found " + cst.size() + " CrossSectionTracks.");
836 } 841 }
837 842
838 843
839 protected void setDgm( 844 protected void setDgm(
840 D4EArtifact artifact, 845 D4EArtifact artifact,
841 WSPLGENJob job, 846 WSPLGENJob job,
842 CallContext context 847 CallContext context
843 ) { 848 ) {
844 String dgm_id = artifact.getDataAsString("dgm"); 849 DGMAccess access = new DGMAccess(artifact);
845 850 DGM dgm = access.getDGM();
846 int id = -1;
847 try {
848 id = Integer.parseInt(dgm_id);
849 }
850 catch (NumberFormatException nfe) { /* do nothing */ }
851
852 DGM dgm = DGM.getDGM(id);
853 851
854 if (dgm == null) { 852 if (dgm == null) {
855 logger.warn("Could not find specified DGM."); 853 logger.warn("Could not find specified DGM.");
856
857 return; 854 return;
858 } 855 }
859 856
860 File dgmPath = new File (dgm.getPath()); 857 File dgmPath = new File(dgm.getPath());
861 if (dgmPath.isAbsolute()) { 858 if (dgmPath.isAbsolute()) {
862 job.setDgm(dgm.getPath()); 859 job.setDgm(dgm.getPath());
863 } 860 }
864 else { 861 else {
865 RiverContext fc = (RiverContext)context.globalContext(); 862 RiverContext fc = (RiverContext)context.globalContext();
866 String prefix = (String) fc.get("dgm-path"); 863 File prefix = new File((String)fc.get("dgm-path"));
867 job.setDgm(prefix.trim() + dgm.getPath().trim()); 864 job.setDgm(new File(prefix, dgm.getPath()).getAbsolutePath());
868 } 865 }
869 } 866 }
870 867
871 868
872 protected void setArea(D4EArtifact artifact, File dir, WSPLGENJob job) { 869 protected void setArea(D4EArtifact artifact, File dir, WSPLGENJob job) {
874 if (!Boolean.valueOf(useFloodplain)) { 871 if (!Boolean.valueOf(useFloodplain)) {
875 logger.debug("WSPLGEN will not use floodplain."); 872 logger.debug("WSPLGEN will not use floodplain.");
876 return; 873 return;
877 } 874 }
878 875
879 String river = artifact.getDataAsString("river"); 876 DGMAccess access = new DGMAccess(artifact);
880 String srid = RiverUtils.getRiverDGMSrid(river); 877 String river = access.getRiver();
878 String srid = String.valueOf(access.getDGM().getSrid());
881 String srs = "EPSG:" + srid; 879 String srs = "EPSG:" + srid;
882 880
883 Floodplain plain = Floodplain.getFloodplain(river); 881 Floodplain plain = Floodplain.getFloodplain(river);
884 882
885 if (plain == null) { 883 if (plain == null) {
1011 } 1009 }
1012 catch (IOException ioe) { /* do nothing */ } 1010 catch (IOException ioe) { /* do nothing */ }
1013 } 1011 }
1014 } 1012 }
1015 } 1013 }
1016
1017
1018
1019 } 1014 }
1020 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 1015 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org