Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java @ 1650:aaf8d32f85bd
Improved Facet creation for floodmaps - WSPLGEN and barriers Facets are only created if the calculation was successful.
flys-artifacts/trunk@2837 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 27 Sep 2011 12:40:42 +0000 |
parents | |
children | 092e1e5020bc |
comparison
equal
deleted
inserted
replaced
1649:74142aa5d938 | 1650:aaf8d32f85bd |
---|---|
1 package de.intevation.flys.wsplgen; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import de.intevation.artifacts.CallContext; | |
7 | |
8 import de.intevation.artifactdatabase.state.Facet; | |
9 | |
10 import de.intevation.flys.model.CrossSectionTrack; | |
11 | |
12 import de.intevation.flys.artifacts.FLYSArtifact; | |
13 import de.intevation.flys.artifacts.model.FacetTypes; | |
14 import de.intevation.flys.artifacts.model.WMSLayerFacet; | |
15 import de.intevation.flys.artifacts.resources.Resources; | |
16 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
17 import de.intevation.flys.utils.FLYSUtils; | |
18 import de.intevation.flys.utils.GeometryUtils; | |
19 import de.intevation.flys.utils.MapfileGenerator; | |
20 | |
21 | |
22 public class FacetCreator implements FacetTypes { | |
23 | |
24 public static final String I18N_WSPLGEN_RESULT = "floodmap.uesk"; | |
25 public static final String I18N_WSPLGEN_DEFAULT = "floodmap.uesk"; | |
26 public static final String I18N_BARRIERS = "floodmap.barriers"; | |
27 public static final String I18N_BARRIERS_DEFAULT = "floodmap.barriers"; | |
28 | |
29 protected FLYSArtifact artifact; | |
30 | |
31 protected CallContext cc; | |
32 | |
33 protected List<Facet> facets; | |
34 protected List<Facet> tmpFacets; | |
35 | |
36 protected String url; | |
37 protected String hash; | |
38 protected String stateId; | |
39 | |
40 public FacetCreator( | |
41 FLYSArtifact artifact, | |
42 CallContext cc, | |
43 String hash, | |
44 String sId, | |
45 List<Facet> facets | |
46 ) { | |
47 this.tmpFacets = new ArrayList<Facet>(2); | |
48 this.facets = facets; | |
49 this.artifact = artifact; | |
50 this.cc = cc; | |
51 this.hash = hash; | |
52 this.stateId = sId; | |
53 } | |
54 | |
55 protected String getRiver() { | |
56 return artifact.getDataAsString("river"); | |
57 } | |
58 | |
59 protected String getUrl() { | |
60 String url = FLYSUtils.getXPathString(FLYSUtils.XPATH_MAPSERVER_URL); | |
61 url = url + "user-wms"; | |
62 return url; | |
63 } | |
64 | |
65 protected String getSrid() { | |
66 return FLYSUtils.getRiverSrid(artifact); | |
67 } | |
68 | |
69 protected String getWSPLGENBounds() { | |
70 String river = getRiver(); | |
71 double kms[] = FLYSUtils.getKmRange(artifact); | |
72 | |
73 CrossSectionTrack a = | |
74 CrossSectionTrack.getCrossSectionTrack(river, kms[0]); | |
75 | |
76 CrossSectionTrack b = | |
77 CrossSectionTrack.getCrossSectionTrack(river, kms[1]); | |
78 | |
79 if (a == null || b == null) { | |
80 return null; | |
81 } | |
82 | |
83 return GeometryUtils.createOLBounds(a.getGeom(), b.getGeom()); | |
84 } | |
85 | |
86 protected String getBounds() { | |
87 return GeometryUtils.getRiverBounds(getRiver()); | |
88 } | |
89 | |
90 public List<Facet> getFacets() { | |
91 return tmpFacets; | |
92 } | |
93 | |
94 public void createWSPLGENFacet() { | |
95 WMSLayerFacet wsplgen = new WMSLayerFacet( | |
96 0, | |
97 FLOODMAP_WSPLGEN, | |
98 Resources.getMsg( | |
99 cc.getMeta(), | |
100 I18N_WSPLGEN_RESULT, | |
101 I18N_WSPLGEN_DEFAULT), | |
102 ComputeType.ADVANCE, | |
103 stateId, | |
104 hash, | |
105 getUrl()); | |
106 | |
107 String bounds = getWSPLGENBounds(); | |
108 | |
109 if (bounds == null || bounds.length() == 0) { | |
110 bounds = getBounds(); | |
111 } | |
112 | |
113 wsplgen.addLayer( | |
114 artifact.identifier() + MapfileGenerator.MS_WSPLGEN_POSTFIX); | |
115 wsplgen.setSrid(getSrid()); | |
116 wsplgen.setExtent(bounds); | |
117 | |
118 tmpFacets.add(wsplgen); | |
119 } | |
120 | |
121 public void createBarrierFacet() { | |
122 WMSLayerFacet barriers = new WMSLayerFacet( | |
123 1, | |
124 FLOODMAP_WSPLGEN, | |
125 Resources.getMsg( | |
126 cc.getMeta(), | |
127 I18N_BARRIERS, | |
128 I18N_BARRIERS_DEFAULT), | |
129 ComputeType.ADVANCE, | |
130 stateId, | |
131 hash, | |
132 getUrl()); | |
133 | |
134 barriers.addLayer( | |
135 artifact.identifier() + MapfileGenerator.MS_BARRIERS_POSTFIX); | |
136 barriers.setSrid(getSrid()); | |
137 barriers.setExtent(getBounds()); | |
138 | |
139 tmpFacets.add(barriers); | |
140 } | |
141 | |
142 | |
143 public void finish() { | |
144 facets.addAll(getFacets()); | |
145 } | |
146 } // end of FacetCreator |