Mercurial > dive4elements > river
changeset 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 | f4d6ef50665a |
children | 4713bc0cc0ee |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/access/DGMAccess.java artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java artifacts/src/main/java/org/dive4elements/river/exports/XYChartGenerator.java artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java |
diffstat | 6 files changed, 66 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/DGMAccess.java Thu Sep 19 16:27:33 2013 +0200 @@ -0,0 +1,35 @@ +package org.dive4elements.river.artifacts.access; + +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.model.DGM; + +public class DGMAccess +extends RangeAccess +{ + private DGM dgm; + + private String geoJSON; + + public DGMAccess() { + } + + public DGMAccess(D4EArtifact artifact) { + super(artifact); + } + + public DGM getDGM() { + if (dgm == null) { + Integer sridId = getInteger("dgm"); + dgm = DGM.getDGM(sridId); + } + return dgm; + } + + public String getGeoJSON() { + if (geoJSON == null) { + geoJSON = getString("uesk.barriers"); + } + return geoJSON; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java Thu Sep 19 12:51:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java Thu Sep 19 16:27:33 2013 +0200 @@ -37,6 +37,8 @@ private KM_MODE mode; + public RangeAccess() { + } public RangeAccess(D4EArtifact artifact) { super(artifact);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java Thu Sep 19 12:51:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java Thu Sep 19 16:27:33 2013 +0200 @@ -30,6 +30,7 @@ import org.dive4elements.artifacts.GlobalContext; import org.dive4elements.artifacts.common.utils.FileTools; import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.DGMAccess; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.context.RiverContext; import org.dive4elements.river.artifacts.model.CalculationMessage; @@ -412,7 +413,7 @@ MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, HWS_LINES_SHAPE, "LINE", - "31467", + "31467", // XXX: This should be dynamically fetched from database. "hws"); job.addLin(artifactDir + "/" + HWS_LINES_SHAPE); facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL, @@ -536,16 +537,18 @@ File dir, WSPLGENJob job ) { - String river = artifact.getDataAsString("river"); - String geoJSON = artifact.getDataAsString("uesk.barriers"); - String srid = RiverUtils.getRiverDGMSrid(river); - String srs = "EPSG:" + srid; + DGMAccess access = new DGMAccess(artifact); + String geoJSON = access.getGeoJSON(); if (geoJSON == null || geoJSON.length() == 0) { logger.debug("No barrier features in parameterization existing."); return; } + String srid = String.valueOf(access.getDGM().getSrid()); + + String srs = "EPSG:" + srid; + SimpleFeatureType ft = getBarriersFeatureType( "barriers", srs, Geometry.class); @@ -748,9 +751,10 @@ protected void setAxis(D4EArtifact artifact, File dir, WSPLGENJob job) { - String river = artifact.getDataAsString("river"); - String srid = RiverUtils.getRiverDGMSrid(river); - String srs = "EPSG:" + srid; + DGMAccess access = new DGMAccess(artifact); + String river = access.getRiver(); + String srid = String.valueOf(access.getDGM().getSrid()); + String srs = "EPSG:" + srid; List<RiverAxis> axes = null; try { @@ -794,9 +798,10 @@ protected void setPro(D4EArtifact artifact, File dir, WSPLGENJob job) { - String river = artifact.getDataAsString("river"); - String srid = RiverUtils.getRiverDGMSrid(river); - String srs = "EPSG:" + srid; + DGMAccess access = new DGMAccess(artifact); + String river = access.getRiver(); + String srid = String.valueOf(access.getDGM().getSrid()); + String srs = "EPSG:" + srid; List<CrossSectionTrack> cst = CrossSectionTrack.getCrossSectionTrack(river, WSPLGEN_QPS_NAME); @@ -838,33 +843,25 @@ protected void setDgm( D4EArtifact artifact, - WSPLGENJob job, + WSPLGENJob job, CallContext context ) { - String dgm_id = artifact.getDataAsString("dgm"); - - int id = -1; - try { - id = Integer.parseInt(dgm_id); - } - catch (NumberFormatException nfe) { /* do nothing */ } - - DGM dgm = DGM.getDGM(id); + DGMAccess access = new DGMAccess(artifact); + DGM dgm = access.getDGM(); if (dgm == null) { logger.warn("Could not find specified DGM."); - return; } - File dgmPath = new File (dgm.getPath()); + File dgmPath = new File(dgm.getPath()); if (dgmPath.isAbsolute()) { job.setDgm(dgm.getPath()); } else { RiverContext fc = (RiverContext)context.globalContext(); - String prefix = (String) fc.get("dgm-path"); - job.setDgm(prefix.trim() + dgm.getPath().trim()); + File prefix = new File((String)fc.get("dgm-path")); + job.setDgm(new File(prefix, dgm.getPath()).getAbsolutePath()); } } @@ -876,8 +873,9 @@ return; } - String river = artifact.getDataAsString("river"); - String srid = RiverUtils.getRiverDGMSrid(river); + DGMAccess access = new DGMAccess(artifact); + String river = access.getRiver(); + String srid = String.valueOf(access.getDGM().getSrid()); String srs = "EPSG:" + srid; Floodplain plain = Floodplain.getFloodplain(river); @@ -1013,8 +1011,5 @@ } } } - - - } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/XYChartGenerator.java Thu Sep 19 12:51:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/XYChartGenerator.java Thu Sep 19 16:27:33 2013 +0200 @@ -66,7 +66,7 @@ */ public abstract class XYChartGenerator extends ChartGenerator { - public class XYAxisDataset implements AxisDataset { + public static class XYAxisDataset implements AxisDataset { /** Symbolic integer, but also coding the priority (0 goes first). */ protected int axisSymbol;
--- a/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java Thu Sep 19 12:51:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java Thu Sep 19 16:27:33 2013 +0200 @@ -10,7 +10,7 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.access.RangeAccess; +import org.dive4elements.river.artifacts.access.DGMAccess; import org.dive4elements.river.artifacts.model.LayerInfo; import org.dive4elements.river.artifacts.model.map.WMSDBLayerFacet; import org.dive4elements.river.artifacts.model.map.WMSLayerFacet; @@ -86,7 +86,7 @@ String identifier = flys.identifier(); - RangeAccess access = new RangeAccess(flys); + DGMAccess access = new DGMAccess(flys); LayerInfo layerinfo = new LayerInfo(); layerinfo.setName(MS_WSPLGEN_PREFIX + identifier); @@ -110,7 +110,7 @@ layerinfo.setTitle(title); layerinfo.setStyle(style); - layerinfo.setSrid(RiverUtils.getRiverDGMSrid(river)); + layerinfo.setSrid(String.valueOf(access.getDGM().getSrid())); String name = MS_LAYER_PREFIX + wms.getName();
--- a/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java Thu Sep 19 12:51:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java Thu Sep 19 16:27:33 2013 +0200 @@ -427,24 +427,6 @@ variables); } - public static String getRiverDGMSrid(String rivername) { - Map<String, String> variables = new HashMap<String, String>(1); - variables.put("name", rivername); - - Document cfg = Config.getConfig(); - - String dgm = (String) XMLUtils.xpath( - cfg, - XPATH_FLOODMAP_DGM_PROJECTION, - XPathConstants.STRING, - null, - variables); - if (logger.isDebugEnabled()) { - logger.debug("Use EPSG:" + dgm + " for DGM"); - } - return dgm; - } - /** * Return the (first) Gauge corresponding to the given location(s) of * the artifact.