Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java @ 6826:74a437805e2a
Mapfile templates contain regex expressions to catch features more robust (#657).
Mapfile generation code is still confusing and should be refactored.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 14 Aug 2013 14:20:59 +0200 |
parents | f5bb53106ae8 |
children | 8c7433b8656d |
comparison
equal
deleted
inserted
replaced
6822:330ea2915168 | 6826:74a437805e2a |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.utils; | 9 package org.dive4elements.river.utils; |
10 | 10 |
11 import java.io.File; | |
12 import java.io.FileNotFoundException; | |
13 import java.io.IOException; | |
14 import java.util.List; | |
15 | |
16 import org.apache.log4j.Logger; | |
17 import org.apache.velocity.Template; | |
11 import org.dive4elements.artifacts.CallContext; | 18 import org.dive4elements.artifacts.CallContext; |
12 import org.dive4elements.river.artifacts.D4EArtifact; | 19 import org.dive4elements.river.artifacts.D4EArtifact; |
13 import org.dive4elements.river.artifacts.access.RiverAccess; | 20 import org.dive4elements.river.artifacts.access.RiverAccess; |
14 import org.dive4elements.river.artifacts.model.LayerInfo; | 21 import org.dive4elements.river.artifacts.model.LayerInfo; |
15 import org.dive4elements.river.artifacts.model.map.WMSDBLayerFacet; | 22 import org.dive4elements.river.artifacts.model.map.WMSDBLayerFacet; |
16 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet; | 23 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet; |
17 import org.dive4elements.river.artifacts.model.map.WSPLGENLayerFacet; | 24 import org.dive4elements.river.artifacts.model.map.WSPLGENLayerFacet; |
18 import org.dive4elements.river.artifacts.resources.Resources; | 25 import org.dive4elements.river.artifacts.resources.Resources; |
19 | 26 import org.dive4elements.river.artifacts.states.FloodMapState; |
20 import java.io.File; | |
21 import java.io.FileNotFoundException; | |
22 import java.io.IOException; | |
23 import java.util.List; | |
24 | |
25 import org.apache.log4j.Logger; | |
26 import org.apache.velocity.Template; | |
27 import org.geotools.data.shapefile.ShpFiles; | 27 import org.geotools.data.shapefile.ShpFiles; |
28 import org.geotools.data.shapefile.shp.ShapefileHeader; | 28 import org.geotools.data.shapefile.shp.ShapefileHeader; |
29 import org.geotools.data.shapefile.shp.ShapefileReader; | 29 import org.geotools.data.shapefile.shp.ShapefileReader; |
30 | 30 |
31 public class ArtifactMapfileGenerator extends MapfileGenerator { | 31 public class ArtifactMapfileGenerator extends MapfileGenerator { |
133 File userShape = new File(dir, WSPLGEN_USER_SHAPE); | 133 File userShape = new File(dir, WSPLGEN_USER_SHAPE); |
134 ShpFiles sf = new ShpFiles(userShape); | 134 ShpFiles sf = new ShpFiles(userShape); |
135 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); | 135 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); |
136 ShapefileHeader sfh = sfr.getHeader(); | 136 ShapefileHeader sfh = sfr.getHeader(); |
137 | 137 |
138 String group = uuid + MS_USERSHAPE_PREFIX; | 138 String group = MS_USERSHAPE_PREFIX + uuid; |
139 String groupTitle = "I18N_USER_SHAPE_TITLE"; | 139 String groupTitle = "I18N_USER_SHAPE_TITLE"; |
140 | 140 |
141 LayerInfo info = new LayerInfo(); | 141 LayerInfo info = new LayerInfo(); |
142 info.setName(MS_USERSHAPE_PREFIX + uuid); | 142 info.setName(MS_LAYER_PREFIX + FloodMapState.WSPLGEN_USER_RGD + uuid); |
143 if (sfh.getShapeType().isLineType()) { | 143 if (sfh.getShapeType().isLineType()) { |
144 info.setType("LINE"); | 144 info.setType("LINE"); |
145 } | 145 } |
146 else if (sfh.getShapeType().isPolygonType()) { | 146 else if (sfh.getShapeType().isPolygonType()) { |
147 info.setType("POLYGON"); | 147 info.setType("POLYGON"); |
154 info.setTitle("I18N_USER_SHAPE"); | 154 info.setTitle("I18N_USER_SHAPE"); |
155 info.setGroup(group); | 155 info.setGroup(group); |
156 info.setGroupTitle(groupTitle); | 156 info.setGroupTitle(groupTitle); |
157 info.setSrid(wms.getSrid()); | 157 info.setSrid(wms.getSrid()); |
158 | 158 |
159 String nameUser = MS_LAYER_PREFIX + wms.getName(); | 159 //String nameUser = MS_LAYER_PREFIX + wms.getName(); |
160 // TODO: This rewrites the user-rgd mapfile fragment generated by | |
161 // HWSBarrierState. Otherwise we would have to fragments with same | |
162 // layer name. Should be refactored... | |
163 String nameUser = MS_LAYER_PREFIX + "user-rgd"; | |
160 | 164 |
161 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); | 165 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
162 if (tpl == null) { | 166 if (tpl == null) { |
163 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); | 167 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
164 return; | 168 return; |