[Dive4elements-commits] [PATCH] Re-add layer generation for floodmap layers (somewhat buggy though)
Wald Commits
scm-commit at wald.intevation.org
Wed Mar 6 14:14:21 CET 2013
# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1362575655 -3600
# Branch mapgenfix
# Node ID cfc5540a4eecb3429c3dada2831b72953ece4d27
# Parent 2b24073e80d9f0bc23a04fb46df2d72689a4d787
Re-add layer generation for floodmap layers (somewhat buggy though).
diff -r 2b24073e80d9 -r cfc5540a4eec flys-artifacts/doc/conf/mapserver/layer.vm
--- a/flys-artifacts/doc/conf/mapserver/layer.vm Mon Feb 25 11:55:34 2013 +0100
+++ b/flys-artifacts/doc/conf/mapserver/layer.vm Wed Mar 06 14:14:15 2013 +0100
@@ -19,7 +19,8 @@
END
PROJECTION
- "init=epsg:$LAYER.getSrid()"
+ #"init=epsg:$LAYER.getSrid()"
+ "init=epsg:31467"
END
#if ( !$LAYER.getStyle() )
diff -r 2b24073e80d9 -r cfc5540a4eec flys-artifacts/doc/conf/mapserver/shapefile_layer.vm
--- a/flys-artifacts/doc/conf/mapserver/shapefile_layer.vm Mon Feb 25 11:55:34 2013 +0100
+++ b/flys-artifacts/doc/conf/mapserver/shapefile_layer.vm Wed Mar 06 14:14:15 2013 +0100
@@ -11,7 +11,8 @@
#end
PROJECTION
- "init=epsg:$LAYER.getSrid()"
+ #"init=epsg:$LAYER.getSrid()"
+ "init=epsg:31467"
END
METADATA
diff -r 2b24073e80d9 -r cfc5540a4eec flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java Mon Feb 25 11:55:34 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java Wed Mar 06 14:14:15 2013 +0100
@@ -3,7 +3,6 @@
import com.vividsolutions.jts.geom.Envelope;
import de.intevation.artifactdatabase.state.ArtifactAndFacet;
-import de.intevation.artifactdatabase.state.Facet;
import de.intevation.artifactdatabase.state.Settings;
import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallContext;
@@ -17,6 +16,7 @@
import de.intevation.flys.collections.FLYSArtifactCollection;
import de.intevation.flys.mapserver.ArtifactMapfileGenerator;
import de.intevation.flys.utils.GeometryUtils;
+import de.intevation.flys.utils.ThemeUtil;
import java.io.File;
import java.io.FileNotFoundException;
@@ -83,7 +83,7 @@
logger.debug("MapGenerator.doOut: " +
artifactFacet.getArtifact().identifier() + " | " + name);
FLYSArtifact flys = (FLYSArtifact) artifactFacet.getArtifact();
-
+ /*
Facet nativeFacet = artifactFacet.getFacet();
if (nativeFacet instanceof WMSLayerFacet) {
@@ -112,6 +112,13 @@
}
else {
logger.warn("Facet not supported: " + nativeFacet.getClass());
+ }*/
+ ArtifactMapfileGenerator amfg = new ArtifactMapfileGenerator();
+ try {
+ amfg.generate(ThemeUtil.createDynamicMapserverStyle(attr), context, flys);
+ }
+ catch (IOException e) {
+ logger.error(e.getMessage(), e);
}
}
@@ -124,11 +131,11 @@
//try {
if(wms instanceof WSPLGENLayerFacet) {
ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
- /*mfg.createUeskLayer(
+ /* mfg.createUeskLayer(
flys,
(WSPLGENLayerFacet) wms,
ThemeUtil.createDynamicMapserverStyle(attr),
- context);*/ // FIXME
+ context);*/
}
else {
logger.warn("Cannot create WSPLGEN layer from: " +
diff -r 2b24073e80d9 -r cfc5540a4eec flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java Mon Feb 25 11:55:34 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java Wed Mar 06 14:14:15 2013 +0100
@@ -6,7 +6,6 @@
import de.intevation.flys.artifacts.model.LayerInfo;
import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet;
import de.intevation.flys.artifacts.model.map.WMSLayerFacet;
-import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet;
import de.intevation.flys.artifacts.resources.Resources;
import de.intevation.flys.utils.FLYSUtils;
import de.intevation.flys.utils.GeometryUtils;
@@ -46,8 +45,7 @@
* Generates flys.map file that contains layers of all
* projects and types (floodmap, user defined, barriers).
*/
- @Override
- public void generate() throws IOException
+ public void generate(String style, CallContext context, FLYSArtifact flys) throws IOException
{
// Get all directories below "shapefiles/"
File[] prjDirs = getProjectDirs();
@@ -59,44 +57,47 @@
// Generate layer snippet for each shapefile
for (File layerShape : layerShapes) {
- String fileName = layerShape.getName();
+ String fileName = layerShape.getName();
+ File layerFile = null;
+
if (fileName.startsWith(MS_PREFIX_BARRIERS)) {
}
else if (fileName.startsWith(MS_PREFIX_USER)) {
- File userLayer = createUserShapeLayer(layerShape);
- if (userLayer != null) {
- layerSnippets.add(userLayer.getCanonicalPath());
- }
+ layerFile = createUserShapeLayer(layerShape);
}
- else if (fileName.startsWith(MS_PREFIX_WSPLGEN)) {
+ else if (fileName.startsWith(MS_PREFIX_WSPLGEN) &&
+ style != null && context != null && flys != null) {
+ layerFile = createFloodmapLayer(layerShape, style, context, flys);
+ }
+ if (layerFile != null) {
+ layerSnippets.add(layerFile.getCanonicalPath());
}
}
writeMapfile(layerSnippets);
}
+ @Override
+ public void generate() throws IOException {
+ generate(null, null, null);
+ }
+
/**
* Creates a layer file used for Mapserver's mapfile which represents the
* floodmap.
- *
- * @param flys The FLYSArtifact that owns <i>wms</i>.
- * @param wms The WMSLayerFacet that contains information for the layer.
*/
- protected void createUeskLayer(
- FLYSArtifact flys,
- WSPLGENLayerFacet wms,
- String style,
- CallContext context
- ) throws FileNotFoundException, IOException
+ protected File createFloodmapLayer(File file, String style, CallContext context, FLYSArtifact flys)
+ throws FileNotFoundException, IOException
{
+ String uuid = uuidFromPath(file.getAbsolutePath());
logger.debug("createUeskLayer");
LayerInfo layerinfo = new LayerInfo();
- layerinfo.setName(MS_PREFIX_WSPLGEN + flys.identifier());
+ layerinfo.setName(MS_PREFIX_WSPLGEN + "-" + uuid);
layerinfo.setType("POLYGON");
- layerinfo.setDirectory(flys.identifier());
+ layerinfo.setDirectory(uuid);
layerinfo.setData(WSPLGEN_RESULT_SHAPE);
layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()),
"floodmap.uesk",
@@ -106,21 +107,24 @@
String river = access.getRiver();
layerinfo.setSrid(FLYSUtils.getRiverDGMSrid(river));
- String name = MS_LAYER_PREFIX + wms.getName();
+ String name = "floodmap.layer"; //MS_LAYER_PREFIX + wms.getName();
Template template = getTemplateByName(WSPLGEN_LAYER_TEMPLATE);
if (template == null) {
logger.warn("Template '" + WSPLGEN_LAYER_TEMPLATE + "' found.");
- return;
+ return null;
}
try {
- File dir = new File(getShapefileBaseDir(), flys.identifier());
- writeLayer(layerinfo, new File(dir, name), template);
+ File dir = new File(getShapefileBaseDir(), uuid);
+ File layerFile = new File(dir, name);
+ writeLayer(layerinfo, layerFile, template);
+ return layerFile;
}
catch (FileNotFoundException fnfe) {
logger.error(fnfe, fnfe);
logger.warn("Unable to write layer: " + name);
+ return null;
}
}
diff -r 2b24073e80d9 -r cfc5540a4eec flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Mon Feb 25 11:55:34 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Wed Mar 06 14:14:15 2013 +0100
@@ -39,7 +39,7 @@
public static final String DB_LAYER_TEMPLATE = "db_layer.vm";
public static final String RIVERAXIS_LAYER_TEMPLATE = "riveraxis-layer.vm";
- public static final String MS_PREFIX_WSPLGEN = "wsplgen-";
+ public static final String MS_PREFIX_WSPLGEN = "wsplgen";
public static final String MS_PREFIX_BARRIERS = "barriers-";
public static final String MS_LINE_PREFIX = "lines-";
public static final String MS_POLYGONS_PREFIX = "polygons-";
More information about the Dive4elements-commits
mailing list