Mercurial > dive4elements > river
changeset 5076:cc50e1b9fc60 mapgenfix
Work on ArtifactMapfileGenerator.createUserShapefileLayer()
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 20 Feb 2013 21:00:33 +0100 (2013-02-20) |
parents | 1da61095040c |
children | cbfdd7376009 |
files | flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java |
diffstat | 4 files changed, 43 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java Tue Feb 19 14:25:38 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java Wed Feb 20 21:00:33 2013 +0100 @@ -12,13 +12,11 @@ import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.FacetTypes; -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.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; @@ -123,29 +121,29 @@ WMSLayerFacet wms, Document attr ) { - try { + //try { if(wms instanceof WSPLGENLayerFacet) { ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator(); - mfg.createUeskLayer( + /*mfg.createUeskLayer( flys, (WSPLGENLayerFacet) wms, ThemeUtil.createDynamicMapserverStyle(attr), - context); + context);*/ // FIXME } else { logger.warn("Cannot create WSPLGEN layer from: " + wms.getClass()); } - } - catch (IOException ioe) { + //} + /*catch (IOException ioe) { logger.error(ioe, ioe); - } + }*/ } protected void createBarriersLayer(FLYSArtifact flys, WMSLayerFacet wms) { ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator(); - +/* try { mfg.createBarriersLayer(flys, wms); } @@ -154,13 +152,13 @@ } catch (IOException ioe) { logger.error(ioe, ioe); - } + }*/ // FIXME } protected void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms) { ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator(); - +/* try { mfg.createUserShapeLayer(flys, wms); } @@ -169,7 +167,7 @@ } catch (IOException ioe) { logger.error(ioe, ioe); - } + }*/ // FIXME } @@ -191,7 +189,7 @@ artDir.mkdir(); } - if (wms instanceof WMSDBLayerFacet) { + /*if (wms instanceof WMSDBLayerFacet) { mfg.createDatabaseLayer( flys, (WMSDBLayerFacet) wms, @@ -199,7 +197,7 @@ } else { logger.warn("Cannot create DB layer from: " + wms.getClass()); - } + }*/ // FIXME } catch (FileNotFoundException fnfe) { logger.error(fnfe, fnfe);
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java Tue Feb 19 14:25:38 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java Wed Feb 20 21:00:33 2013 +0100 @@ -64,7 +64,7 @@ } else if (fileName.startsWith(MS_PREFIX_USER)) { - + createUserShapeLayer(layerShape); } else if (fileName.startsWith(MS_PREFIX_WSPLGEN)) { @@ -91,7 +91,7 @@ logger.debug("createUeskLayer"); LayerInfo layerinfo = new LayerInfo(); - layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier()); + layerinfo.setName(MS_PREFIX_WSPLGEN + flys.identifier()); layerinfo.setType("POLYGON"); layerinfo.setDirectory(flys.identifier()); layerinfo.setData(WSPLGEN_RESULT_SHAPE); @@ -149,7 +149,7 @@ throws FileNotFoundException, IOException { String uuid = flys.identifier(); - String group = MS_BARRIERS_PREFIX + uuid; + String group = MS_PREFIX_BARRIERS + uuid; String groupTitle = "I18N_BARRIERS_TITLE"; File dir = new File(getShapefileBaseDir(), uuid); @@ -194,7 +194,7 @@ throws FileNotFoundException, IOException { String uuid = flys.identifier(); - String group = uuid + MS_BARRIERS_PREFIX; + String group = uuid + MS_PREFIX_BARRIERS; String groupTitle = "I18N_BARRIERS_TITLE"; File dir = new File(getShapefileBaseDir(), uuid); @@ -232,20 +232,33 @@ } } + protected String uuidFromPath(String path) { + logger.debug("uuidFromPath(" + path + ")"); + int i1 = 0; + int i2 = 0; + + for(;;) { + int i = path.indexOf('/', i2 + 1); + if (i == -1) { + return path.substring(i1 + 1, i2); + } + else { + i1 = i2; + i2 = i; + } + } + } /** * Creates a layer file used for Mapserver's mapfile which represents the * shape files uploaded by the user. - * - * @param flys The FLYSArtifact that owns <i>wms</i>. - * @param wms The WMSLayerFacet that contains information for the layer. */ - protected void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms) + protected void createUserShapeLayer(File file) throws FileNotFoundException, IOException { - logger.debug("createUserShapeLayer"); + String uuid = uuidFromPath(file.getAbsolutePath()); + logger.debug("createUserShapeLayer(): uuid=" + uuid); - String uuid = flys.identifier(); File dir = new File(getShapefileBaseDir(), uuid); File test = new File(dir, WSPLGEN_USER_SHAPE); @@ -259,11 +272,11 @@ ShapefileReader sfr = new ShapefileReader(sf, true, false, null); ShapefileHeader sfh = sfr.getHeader(); - String group = uuid + MS_USERSHAPE_PREFIX; + String group = uuid + MS_PREFIX_USER; String groupTitle = "I18N_USER_SHAPE_TITLE"; LayerInfo info = new LayerInfo(); - info.setName(MS_USERSHAPE_PREFIX + uuid); + info.setName(MS_PREFIX_USER + uuid); if (sfh.getShapeType().isLineType()) { info.setType("LINE"); } @@ -278,9 +291,9 @@ info.setTitle("I18N_USER_SHAPE"); info.setGroup(group); info.setGroupTitle(groupTitle); - info.setSrid(wms.getSrid()); + //info.setSrid(wms.getSrid()); // FIXME: Required? - String nameUser = MS_LAYER_PREFIX + wms.getName(); + String nameUser = "user.layer"; //MS_LAYER_PREFIX + wms.getName(); Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); if (tpl == null) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Tue Feb 19 14:25:38 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Wed Feb 20 21:00:33 2013 +0100 @@ -41,9 +41,9 @@ 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-"; -// public static final String MS_LAYER_PREFIX = "ms_layer-"; + public static final String MS_LINE_PREFIX = "lines-"; + public static final String MS_POLYGONS_PREFIX = "polygons-"; + public static final String MS_LAYER_PREFIX = "ms_layer-"; public static final String MS_PREFIX_USER = "user-"; private static Logger logger = Logger.getLogger(MapfileGenerator.class);
--- a/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java Tue Feb 19 14:25:38 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java Wed Feb 20 21:00:33 2013 +0100 @@ -182,7 +182,7 @@ getUrl()); shape.addLayer( - MapfileGenerator.MS_USERSHAPE_PREFIX + artifact.identifier()); + MapfileGenerator.MS_PREFIX_USER + artifact.identifier()); shape.setSrid(getSrid()); shape.setExtent(getBounds());