Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/wsplgen/FacetCreator.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java@ac2746f3e75f |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.wsplgen; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import com.vividsolutions.jts.geom.Envelope; | |
9 | |
10 import org.dive4elements.artifactdatabase.state.Facet; | |
11 import org.dive4elements.artifacts.CallContext; | |
12 import org.dive4elements.river.artifacts.access.RangeAccess; | |
13 import org.dive4elements.river.artifacts.FLYSArtifact; | |
14 import org.dive4elements.river.artifacts.model.FacetTypes; | |
15 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet; | |
16 import org.dive4elements.river.artifacts.model.map.WSPLGENLayerFacet; | |
17 import org.dive4elements.river.artifacts.resources.Resources; | |
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
19 import org.dive4elements.river.model.CrossSectionTrack; | |
20 import org.dive4elements.river.utils.FLYSUtils; | |
21 import org.dive4elements.river.utils.GeometryUtils; | |
22 import org.dive4elements.river.utils.MapfileGenerator; | |
23 | |
24 | |
25 public class FacetCreator implements FacetTypes { | |
26 | |
27 public static final String I18N_WSPLGEN_RESULT = "floodmap.uesk"; | |
28 public static final String I18N_WSPLGEN_DEFAULT = "floodmap.uesk"; | |
29 public static final String I18N_BARRIERS = "floodmap.barriers"; | |
30 public static final String I18N_BARRIERS_DEFAULT = "floodmap.barriers"; | |
31 public static final String I18N_USERSHAPE = "floodmap.usershape"; | |
32 public static final String I18N_USERSHAPE_DEFAULT = "floodmap.usershape"; | |
33 | |
34 protected FLYSArtifact artifact; | |
35 | |
36 protected CallContext cc; | |
37 | |
38 protected List<Facet> facets; | |
39 protected List<Facet> tmpFacets; | |
40 | |
41 protected String url; | |
42 protected String hash; | |
43 protected String stateId; | |
44 | |
45 | |
46 private static Logger logger = Logger.getLogger(FacetCreator.class); | |
47 | |
48 | |
49 public FacetCreator( | |
50 FLYSArtifact artifact, | |
51 CallContext cc, | |
52 String hash, | |
53 String sId, | |
54 List<Facet> facets | |
55 ) { | |
56 this.tmpFacets = new ArrayList<Facet>(2); | |
57 this.facets = facets; | |
58 this.artifact = artifact; | |
59 this.cc = cc; | |
60 this.hash = hash; | |
61 this.stateId = sId; | |
62 } | |
63 | |
64 // TODO We have FLYSUtils and will have RiverAccess to do this | |
65 protected String getRiver() { | |
66 return artifact.getDataAsString("river"); | |
67 } | |
68 | |
69 protected String getUrl() { | |
70 return FLYSUtils.getUserWMSUrl(artifact.identifier()); | |
71 } | |
72 | |
73 protected String getSrid() { | |
74 return FLYSUtils.getRiverSrid(artifact); | |
75 } | |
76 | |
77 protected Envelope getWSPLGENBounds() { | |
78 String river = getRiver(); | |
79 RangeAccess rangeAccess = new RangeAccess(artifact, null); | |
80 double kms[] = rangeAccess.getKmRange(); | |
81 | |
82 logger.debug("### getWSPLGENBounds"); | |
83 logger.debug("### from km: " + kms[0]); | |
84 logger.debug("### to km: " + kms[1]); | |
85 | |
86 CrossSectionTrack a = | |
87 CrossSectionTrack.getCrossSectionTrack(river, kms[0]); | |
88 | |
89 CrossSectionTrack b = | |
90 CrossSectionTrack.getCrossSectionTrack(river, kms[1]); | |
91 | |
92 if (a == null || b == null) { | |
93 return null; | |
94 } | |
95 | |
96 Envelope envA = a.getGeom().getEnvelopeInternal(); | |
97 Envelope envB = b.getGeom().getEnvelopeInternal(); | |
98 | |
99 envA.expandToInclude(envB); | |
100 envA = GeometryUtils.transform(envA, getSrid()); | |
101 | |
102 logger.debug("### => " + envA); | |
103 | |
104 return envA; | |
105 } | |
106 | |
107 protected Envelope getBounds() { | |
108 return GeometryUtils.getRiverBoundary(getRiver()); | |
109 } | |
110 | |
111 public List<Facet> getFacets() { | |
112 return tmpFacets; | |
113 } | |
114 | |
115 public void createWSPLGENFacet() { | |
116 String river = getRiver(); | |
117 RangeAccess rangeAccess = new RangeAccess(artifact, null); | |
118 double kms[] = rangeAccess.getKmRange(); | |
119 | |
120 WSPLGENLayerFacet wsplgen = new WSPLGENLayerFacet( | |
121 0, | |
122 FLOODMAP_WSPLGEN, | |
123 Resources.format( | |
124 cc.getMeta(), | |
125 I18N_WSPLGEN_RESULT, | |
126 I18N_WSPLGEN_DEFAULT, | |
127 river, | |
128 kms[0], kms[1]), | |
129 ComputeType.ADVANCE, | |
130 stateId, | |
131 hash, | |
132 getUrl()); | |
133 | |
134 Envelope bounds = getWSPLGENBounds(); | |
135 | |
136 if (bounds == null) { | |
137 bounds = getBounds(); | |
138 } | |
139 | |
140 wsplgen.addLayer( | |
141 MapfileGenerator.MS_WSPLGEN_PREFIX + artifact.identifier()); | |
142 wsplgen.setSrid(getSrid()); | |
143 wsplgen.setOriginalExtent(bounds); | |
144 wsplgen.setExtent(bounds); | |
145 | |
146 tmpFacets.add(wsplgen); | |
147 } | |
148 | |
149 public void createBarrierFacet() { | |
150 WMSLayerFacet barriers = new WMSLayerFacet( | |
151 1, | |
152 FLOODMAP_BARRIERS, | |
153 Resources.getMsg( | |
154 cc.getMeta(), | |
155 I18N_BARRIERS, | |
156 I18N_BARRIERS_DEFAULT), | |
157 ComputeType.ADVANCE, | |
158 stateId, | |
159 hash, | |
160 getUrl()); | |
161 | |
162 barriers.addLayer(MapfileGenerator.MS_LAYER_PREFIX + | |
163 MapfileGenerator.MS_BARRIERS_PREFIX + "lines" + artifact.identifier()); | |
164 barriers.addLayer( MapfileGenerator.MS_LAYER_PREFIX + | |
165 MapfileGenerator.MS_BARRIERS_PREFIX + "poly" + artifact.identifier()); | |
166 | |
167 barriers.setSrid(getSrid()); | |
168 barriers.setExtent(getBounds()); | |
169 | |
170 tmpFacets.add(barriers); | |
171 } | |
172 | |
173 | |
174 public void createShapeFacet( | |
175 String desc, | |
176 String layer, | |
177 String type, | |
178 int ndx) { | |
179 WMSLayerFacet shape = new WMSLayerFacet( | |
180 1, | |
181 type, | |
182 Resources.getMsg( | |
183 cc.getMeta(), | |
184 desc, | |
185 I18N_USERSHAPE_DEFAULT), | |
186 ComputeType.ADVANCE, | |
187 stateId, | |
188 hash, | |
189 getUrl()); | |
190 | |
191 shape.addLayer( | |
192 layer + artifact.identifier()); | |
193 shape.setSrid(getSrid()); | |
194 shape.setExtent(getBounds()); | |
195 | |
196 tmpFacets.add(shape); | |
197 } | |
198 | |
199 | |
200 public void finish() { | |
201 facets.addAll(getFacets()); | |
202 } | |
203 } | |
204 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |