comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.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 06c157848c8f
children 007a8f5ed9f1
comparison
equal deleted inserted replaced
1491:2a00f4849738 3814:8083f6384023
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.DefaultOutput;
16 import de.intevation.artifactdatabase.state.Facet;
17 import de.intevation.artifactdatabase.state.State;
18
19 import de.intevation.flys.model.River;
20
21 import de.intevation.flys.artifacts.model.FacetTypes;
22 import de.intevation.flys.artifacts.model.RiverFactory;
23 import de.intevation.flys.artifacts.resources.Resources;
24 import de.intevation.flys.utils.FLYSUtils;
25 import de.intevation.flys.utils.GeometryUtils;
26
27
28 public class RiverAxisArtifact extends WMSDBArtifact {
29
30 public static final String NAME = "riveraxis";
31
32
33 private static final Logger logger =
34 Logger.getLogger(RiverAxisArtifact.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("RiverAxisArtifact.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 RiverAxisState(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 public static class RiverAxisState extends WMSDBState implements FacetTypes
77 {
78 private static final Logger logger =
79 Logger.getLogger(RiverAxisState.class);
80
81 protected Geometry geom;
82 protected int riverId;
83
84 public RiverAxisState(WMSDBArtifact artifact) {
85 super(artifact);
86 riverId = 0;
87 }
88
89 public int getRiverId() {
90 if (riverId == 0) {
91 String ids = artifact.getDataAsString("ids");
92
93 try {
94 riverId = Integer.valueOf(ids);
95 }
96 catch (NumberFormatException nfe) {
97 logger.error("Cannot parse river id from '" + ids + "'");
98 }
99 }
100
101 return riverId;
102 }
103
104 @Override
105 protected String getFacetType() {
106 return FLOODMAP_RIVERAXIS;
107 }
108
109 @Override
110 protected String getTitle(CallMeta meta) {
111 return Resources.getMsg(
112 meta,
113 FLOODMAP_RIVERAXIS,
114 FLOODMAP_RIVERAXIS);
115 }
116
117 @Override
118 protected String getUrl() {
119 return FLYSUtils.getUserWMSUrl(artifact.identifier());
120 }
121
122 @Override
123 protected String getSrid() {
124 River river = RiverFactory.getRiver(getRiverId());
125 return FLYSUtils.getRiverSrid(river.getName());
126 }
127
128 @Override
129 protected Envelope getExtent() {
130 River river = RiverFactory.getRiver(getRiverId());
131 return GeometryUtils.getRiverBoundary(river.getName());
132 }
133
134 @Override
135 protected String getFilter() {
136 return "river_id=" + String.valueOf(getRiverId());
137 }
138
139 @Override
140 protected String getDataString() {
141 String srid = getSrid();
142
143 if (FLYSUtils.isUsingOracle()) {
144 return "geom FROM river_axes USING SRID " + srid;
145 }
146 else {
147 return "geom FROM river_axes USING UNIQUE id USING SRID " + srid;
148 }
149 }
150
151 @Override
152 protected String getGeometryType() {
153 return "LINE";
154 }
155 } // end of WMSKmState
156 }
157 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org