Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSGaugeLocationArtifact.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | c8f670ae96e8 |
children | 2fdbe78a8fc2 |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.w3c.dom.Document; | |
6 | |
7 import org.apache.log4j.Logger; | |
8 | |
9 import com.vividsolutions.jts.geom.Envelope; | |
10 import com.vividsolutions.jts.geom.Geometry; | |
11 | |
12 import de.intevation.artifacts.ArtifactFactory; | |
13 import de.intevation.artifacts.CallMeta; | |
14 | |
15 import de.intevation.artifactdatabase.state.Facet; | |
16 import de.intevation.artifactdatabase.state.DefaultOutput; | |
17 import de.intevation.artifactdatabase.state.State; | |
18 | |
19 import de.intevation.flys.model.River; | |
20 import de.intevation.flys.model.GaugeLocation; | |
21 | |
22 import de.intevation.flys.artifacts.WMSDBArtifact.WMSDBState; | |
23 import de.intevation.flys.artifacts.model.FacetTypes; | |
24 import de.intevation.flys.artifacts.model.RiverFactory; | |
25 import de.intevation.flys.utils.FLYSUtils; | |
26 import de.intevation.flys.utils.GeometryUtils; | |
27 | |
28 | |
29 public class WMSGaugeLocationArtifact extends WMSDBArtifact { | |
30 | |
31 public static final String NAME = "wmsgaugelocation"; | |
32 | |
33 | |
34 private static final Logger logger = | |
35 Logger.getLogger(WMSGaugeLocationArtifact.class); | |
36 | |
37 | |
38 @Override | |
39 public void setup( | |
40 String identifier, | |
41 ArtifactFactory factory, | |
42 Object context, | |
43 CallMeta callMeta, | |
44 Document data) | |
45 { | |
46 logger.debug("WMSGaugeLocationArtifact.setup"); | |
47 | |
48 super.setup(identifier, factory, context, callMeta, data); | |
49 } | |
50 | |
51 | |
52 @Override | |
53 public String getName() { | |
54 return NAME; | |
55 } | |
56 | |
57 | |
58 @Override | |
59 public State getCurrentState(Object cc) { | |
60 State s = new WMSGaugeLocationState(this); | |
61 | |
62 List<Facet> fs = facets.get(getCurrentStateId()); | |
63 | |
64 DefaultOutput o = new DefaultOutput( | |
65 "floodmap", | |
66 "floodmap", | |
67 "image/png", | |
68 fs, | |
69 "map"); | |
70 | |
71 s.getOutputs().add(o); | |
72 | |
73 return s; | |
74 } | |
75 | |
76 | |
77 | |
78 public static class WMSGaugeLocationState extends WMSDBState implements FacetTypes { | |
79 | |
80 private static final Logger logger = | |
81 Logger.getLogger(WMSGaugeLocationState.class); | |
82 | |
83 protected Geometry geom; | |
84 | |
85 public WMSGaugeLocationState(WMSDBArtifact artifact) { | |
86 super(artifact); | |
87 } | |
88 | |
89 @Override | |
90 protected String getFacetType() { | |
91 return FLOODMAP_GAUGE_LOCATION; | |
92 } | |
93 | |
94 @Override | |
95 protected String getUrl() { | |
96 return FLYSUtils.getUserWMSUrl(artifact.identifier()); | |
97 } | |
98 | |
99 @Override | |
100 protected String getSrid() { | |
101 River river = RiverFactory.getRiver(getRiverId()); | |
102 return FLYSUtils.getRiverSrid(river.getName()); | |
103 } | |
104 | |
105 @Override | |
106 protected Envelope getExtent() { | |
107 List<GaugeLocation> gauges = | |
108 GaugeLocation.getGaugeLocations(getRiverId(), getName()); | |
109 | |
110 Envelope max = null; | |
111 | |
112 for (GaugeLocation gauge: gauges) { | |
113 Envelope env = gauge.getGeom().getEnvelopeInternal(); | |
114 | |
115 if (max == null) { | |
116 max = env; | |
117 continue; | |
118 } | |
119 | |
120 max.expandToInclude(env); | |
121 } | |
122 | |
123 return max != null | |
124 ? GeometryUtils.transform(max, getSrid()) | |
125 : max; | |
126 } | |
127 | |
128 @Override | |
129 protected String getFilter() { | |
130 return "river_id=" + String.valueOf(getRiverId()) + | |
131 " and name='" + getName() + "'"; | |
132 } | |
133 | |
134 @Override | |
135 protected String getDataString() { | |
136 String srid = getSrid(); | |
137 | |
138 if (FLYSUtils.isUsingOracle()) { | |
139 return "geom FROM gauge_location USING SRID " + srid; | |
140 } | |
141 else { | |
142 return "geom FROM gauge_location " + | |
143 "USING UNIQUE id USING SRID " + srid; | |
144 } | |
145 } | |
146 | |
147 @Override | |
148 protected String getGeometryType() { | |
149 return "POINT"; | |
150 } | |
151 } | |
152 } | |
153 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |