comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSGaugeLocationArtifact.java @ 2793:6310b1582f2d

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

http://dive4elements.wald.intevation.org