Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java @ 3814:8083f6384023
merged flys-artifacts/pre2.6-2012-01-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:56 +0200 |
parents | a5f87f8dbe57 |
children | 5d158f8ad080 |
comparison
equal
deleted
inserted
replaced
1491:2a00f4849738 | 3814:8083f6384023 |
---|---|
1 package de.intevation.flys.wsplgen; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import com.vividsolutions.jts.geom.Envelope; | |
7 | |
8 import de.intevation.artifacts.CallContext; | |
9 | |
10 import de.intevation.artifactdatabase.state.Facet; | |
11 | |
12 import de.intevation.flys.model.CrossSectionTrack; | |
13 | |
14 import de.intevation.flys.artifacts.FLYSArtifact; | |
15 import de.intevation.flys.artifacts.model.FacetTypes; | |
16 import de.intevation.flys.artifacts.model.WMSLayerFacet; | |
17 import de.intevation.flys.artifacts.resources.Resources; | |
18 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
19 import de.intevation.flys.utils.FLYSUtils; | |
20 import de.intevation.flys.utils.GeometryUtils; | |
21 import de.intevation.flys.utils.MapfileGenerator; | |
22 | |
23 | |
24 public class FacetCreator implements FacetTypes { | |
25 | |
26 public static final String I18N_WSPLGEN_RESULT = "floodmap.uesk"; | |
27 public static final String I18N_WSPLGEN_DEFAULT = "floodmap.uesk"; | |
28 public static final String I18N_BARRIERS = "floodmap.barriers"; | |
29 public static final String I18N_BARRIERS_DEFAULT = "floodmap.barriers"; | |
30 | |
31 protected FLYSArtifact artifact; | |
32 | |
33 protected CallContext cc; | |
34 | |
35 protected List<Facet> facets; | |
36 protected List<Facet> tmpFacets; | |
37 | |
38 protected String url; | |
39 protected String hash; | |
40 protected String stateId; | |
41 | |
42 public FacetCreator( | |
43 FLYSArtifact artifact, | |
44 CallContext cc, | |
45 String hash, | |
46 String sId, | |
47 List<Facet> facets | |
48 ) { | |
49 this.tmpFacets = new ArrayList<Facet>(2); | |
50 this.facets = facets; | |
51 this.artifact = artifact; | |
52 this.cc = cc; | |
53 this.hash = hash; | |
54 this.stateId = sId; | |
55 } | |
56 | |
57 protected String getRiver() { | |
58 return artifact.getDataAsString("river"); | |
59 } | |
60 | |
61 protected String getUrl() { | |
62 return FLYSUtils.getUserWMSUrl(artifact.identifier()); | |
63 } | |
64 | |
65 protected String getSrid() { | |
66 return FLYSUtils.getRiverSrid(artifact); | |
67 } | |
68 | |
69 protected Envelope 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 Envelope envA = a.getGeom().getEnvelopeInternal(); | |
84 Envelope envB = b.getGeom().getEnvelopeInternal(); | |
85 | |
86 envA.expandToInclude(envB); | |
87 | |
88 return envA; | |
89 } | |
90 | |
91 protected Envelope getBounds() { | |
92 return GeometryUtils.getRiverBoundary(getRiver()); | |
93 } | |
94 | |
95 public List<Facet> getFacets() { | |
96 return tmpFacets; | |
97 } | |
98 | |
99 public void createWSPLGENFacet() { | |
100 WMSLayerFacet wsplgen = new WMSLayerFacet( | |
101 0, | |
102 FLOODMAP_WSPLGEN, | |
103 Resources.getMsg( | |
104 cc.getMeta(), | |
105 I18N_WSPLGEN_RESULT, | |
106 I18N_WSPLGEN_DEFAULT), | |
107 ComputeType.ADVANCE, | |
108 stateId, | |
109 hash, | |
110 getUrl()); | |
111 | |
112 Envelope bounds = getWSPLGENBounds(); | |
113 | |
114 if (bounds == null) { | |
115 bounds = getBounds(); | |
116 } | |
117 | |
118 wsplgen.addLayer( | |
119 MapfileGenerator.MS_WSPLGEN_PREFIX + artifact.identifier()); | |
120 wsplgen.setSrid(getSrid()); | |
121 wsplgen.setExtent(bounds); | |
122 | |
123 tmpFacets.add(wsplgen); | |
124 } | |
125 | |
126 public void createBarrierFacet() { | |
127 WMSLayerFacet barriers = new WMSLayerFacet( | |
128 1, | |
129 FLOODMAP_BARRIERS, | |
130 Resources.getMsg( | |
131 cc.getMeta(), | |
132 I18N_BARRIERS, | |
133 I18N_BARRIERS_DEFAULT), | |
134 ComputeType.ADVANCE, | |
135 stateId, | |
136 hash, | |
137 getUrl()); | |
138 | |
139 barriers.addLayer( | |
140 MapfileGenerator.MS_BARRIERS_PREFIX + artifact.identifier()); | |
141 barriers.setSrid(getSrid()); | |
142 barriers.setExtent(getBounds()); | |
143 | |
144 tmpFacets.add(barriers); | |
145 } | |
146 | |
147 | |
148 public void finish() { | |
149 facets.addAll(getFacets()); | |
150 } | |
151 } // end of FacetCreator |