Mercurial > dive4elements > river
changeset 1830:7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
flys-artifacts/trunk@3161 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 Nov 2011 10:58:44 +0000 |
parents | f5c561abc6ca |
children | 490ab097f58c 48e9c3a44420 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java |
diffstat | 2 files changed, 64 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Nov 04 10:57:47 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Nov 04 10:58:44 2011 +0000 @@ -1,3 +1,8 @@ +2011-11-04 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/utils/MapfileGenerator.java: Create + line and polygon layers for barriers only if they are really existing. + 2011-11-04 Felix Wolfsteller <felix.wolfsteller@intevation.de> Disable mainvalue-recommendations for discharge curves as they trigger
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java Fri Nov 04 10:57:47 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java Fri Nov 04 10:58:44 2011 +0000 @@ -410,9 +410,29 @@ String uuid = flys.identifier(); File dir = new File(getShapefileBaseDir(), uuid); + createBarriersLineLayer(flys, wms); + createBarriersPolygonLayer(flys, wms); + } + + + protected void createBarriersLineLayer( + FLYSArtifact flys, + WMSLayerFacet wms + ) + throws FileNotFoundException, IOException + { + String uuid = flys.identifier(); String group = uuid + MS_BARRIERS_POSTFIX; String groupTitle = "I18N_BARRIERS_TITLE"; + File dir = new File(getShapefileBaseDir(), uuid); + File test = new File(dir, WSPLGEN_LINES_SHAPE); + + if (!test.exists() || !test.canRead()) { + logger.debug("No barrier line layer existing."); + return; + } + LayerInfo lineInfo = new LayerInfo(); lineInfo.setName(uuid + MS_LINE_POSTFIX); lineInfo.setType("LINE"); @@ -422,17 +442,7 @@ lineInfo.setGroup(group); lineInfo.setGroupTitle(groupTitle); - LayerInfo polygonInfo = new LayerInfo(); - polygonInfo.setName(uuid + MS_POLYGONS_POSTFIX); - polygonInfo.setType("POLYGON"); - polygonInfo.setDirectory(uuid); - polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE); - polygonInfo.setTitle("I18N_POLYGON_SHAPE"); - polygonInfo.setGroup(group); - polygonInfo.setGroupTitle(groupTitle); - - String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines"; - String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons"; + String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines"; Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); if (tpl == null) { @@ -447,13 +457,50 @@ logger.error(fnfe, fnfe); logger.warn("Unable to write layer: " + nameLines); } + } + + + protected void createBarriersPolygonLayer( + FLYSArtifact flys, + WMSLayerFacet wms + ) + throws FileNotFoundException, IOException + { + String uuid = flys.identifier(); + String group = uuid + MS_BARRIERS_POSTFIX; + String groupTitle = "I18N_BARRIERS_TITLE"; + + File dir = new File(getShapefileBaseDir(), uuid); + File test = new File(dir, WSPLGEN_POLYGONS_SHAPE); + + if (!test.exists() || !test.canRead()) { + logger.debug("No barrier line layer existing."); + return; + } + + LayerInfo polygonInfo = new LayerInfo(); + polygonInfo.setName(uuid + MS_POLYGONS_POSTFIX); + polygonInfo.setType("POLYGON"); + polygonInfo.setDirectory(uuid); + polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE); + polygonInfo.setTitle("I18N_POLYGON_SHAPE"); + polygonInfo.setGroup(group); + polygonInfo.setGroupTitle(groupTitle); + + String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons"; + + Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); + if (tpl == null) { + logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); + return; + } try { writeLayer(polygonInfo, dir, namePolygons, tpl); } catch (FileNotFoundException fnfe) { logger.error(fnfe, fnfe); - logger.warn("Unable to write layer: " + nameLines); + logger.warn("Unable to write layer: " + namePolygons); } }