comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBuildingsArtifact.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 b24920235944
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
11 import de.intevation.artifacts.ArtifactFactory;
12 import de.intevation.artifacts.CallMeta;
13
14 import de.intevation.artifactdatabase.state.DefaultOutput;
15 import de.intevation.artifactdatabase.state.Facet;
16 import de.intevation.artifactdatabase.state.State;
17
18 import de.intevation.flys.model.River;
19 import de.intevation.flys.model.Building;
20
21 import de.intevation.flys.artifacts.model.FacetTypes;
22 import de.intevation.flys.artifacts.model.RiverFactory;
23 import de.intevation.flys.utils.FLYSUtils;
24 import de.intevation.flys.utils.GeometryUtils;
25
26
27 public class WMSBuildingsArtifact extends WMSDBArtifact {
28
29 public static final String NAME = "buildings";
30
31
32 private static final Logger logger =
33 Logger.getLogger(WMSBuildingsArtifact.class);
34
35
36 @Override
37 public void setup(
38 String identifier,
39 ArtifactFactory factory,
40 Object context,
41 CallMeta callMeta,
42 Document data)
43 {
44 logger.debug("WMSBuildingsArtifact.setup");
45
46 super.setup(identifier, factory, context, callMeta, data);
47 }
48
49
50 @Override
51 public String getName() {
52 return NAME;
53 }
54
55
56 @Override
57 public State getCurrentState(Object cc) {
58 State s = new BuildingsState(this);
59
60 List<Facet> fs = facets.get(getCurrentStateId());
61
62 DefaultOutput o = new DefaultOutput(
63 "floodmap",
64 "floodmap",
65 "image/png",
66 fs,
67 "map");
68
69 s.getOutputs().add(o);
70
71 return s;
72 }
73
74
75 public static class BuildingsState extends WMSDBState implements FacetTypes
76 {
77 private static final Logger logger =
78 Logger.getLogger(BuildingsState.class);
79
80 protected int riverId;
81
82 public BuildingsState(WMSDBArtifact artifact) {
83 super(artifact);
84 riverId = 0;
85 }
86
87 @Override
88 protected String getFacetType() {
89 return FLOODMAP_BUILDINGS;
90 }
91
92 @Override
93 protected String getUrl() {
94 return FLYSUtils.getUserWMSUrl(artifact.identifier());
95 }
96
97 @Override
98 protected String getSrid() {
99 River river = RiverFactory.getRiver(getRiverId());
100 return FLYSUtils.getRiverSrid(river.getName());
101 }
102
103 @Override
104 protected Envelope getExtent() {
105 List<Building> buildings =
106 Building.getBuildings(getRiverId(), getName());
107
108 Envelope max = null;
109
110 for (Building b: buildings) {
111 Envelope env = b.getGeom().getEnvelopeInternal();
112
113 if (max == null) {
114 max = env;
115 continue;
116 }
117
118 max.expandToInclude(env);
119 }
120
121 return max != null
122 ? GeometryUtils.transform(max, getSrid())
123 : max;
124 }
125
126 @Override
127 protected String getFilter() {
128 return "river_id=" + String.valueOf(getRiverId()) +
129 " AND name='" + getName() + "'";
130 }
131
132 @Override
133 protected String getDataString() {
134 String srid = getSrid();
135
136 if (FLYSUtils.isUsingOracle()) {
137 return "geom FROM buildings USING SRID " + srid;
138 }
139 else {
140 return "geom FROM buildings USING UNIQUE id USING SRID " + srid;
141 }
142 }
143
144 @Override
145 protected String getGeometryType() {
146 return "LINE";
147 }
148 } // end of WMSKmState
149 }
150 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org