comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WMSLayerFacet.java@9fac337192c9
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.artifacts.model.map;
2
3 import com.vividsolutions.jts.geom.Envelope;
4
5 import org.dive4elements.artifactdatabase.state.DefaultFacet;
6 import org.dive4elements.artifactdatabase.state.Facet;
7 import org.dive4elements.artifacts.Artifact;
8 import org.dive4elements.artifacts.ArtifactNamespaceContext;
9 import org.dive4elements.artifacts.CallContext;
10 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
11 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
12 import org.dive4elements.river.utils.GeometryUtils;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.apache.log4j.Logger;
18 import org.w3c.dom.Document;
19 import org.w3c.dom.Element;
20 import org.w3c.dom.Node;
21
22
23 public class WMSLayerFacet
24 extends DefaultFacet
25 {
26 protected ComputeType type;
27 protected List<String> layers;
28 protected String stateId;
29 protected String hash;
30 protected String url;
31 protected Envelope extent;
32 protected Envelope originalExtent;
33 protected String srid;
34
35
36 private static final Logger logger = Logger.getLogger(WMSLayerFacet.class);
37
38 public WMSLayerFacet() {
39 }
40
41
42 public WMSLayerFacet(int index, String name, String description) {
43 this(index, name, description, ComputeType.FEED, null, null);
44 }
45
46
47 public WMSLayerFacet(
48 int index,
49 String name,
50 String description,
51 ComputeType type,
52 String stateId,
53 String hash
54
55 ) {
56 super(index, name, description);
57 this.layers = new ArrayList<String>();
58 this.type = type;
59 this.stateId = stateId;
60 this.hash = hash;
61 }
62
63
64 public WMSLayerFacet(
65 int index,
66 String name,
67 String description,
68 ComputeType type,
69 String stateId,
70 String hash,
71 String url
72 ) {
73 this(index, name, description, type, stateId, hash);
74 this.url = url;
75 }
76
77
78 public void addLayer(String name) {
79 if (name != null && name.length() > 0) {
80 layers.add(name);
81 }
82 }
83
84
85 public List<String> getLayers() {
86 return layers;
87 }
88
89
90 public void removeLayer(String layer) {
91 if (layers != null) {
92 layers.remove(layer);
93 }
94 }
95
96
97 public void setExtent(Envelope extent) {
98 if (extent != null) {
99 this.extent = extent;
100 }
101 else {
102 logger.debug("setExtent(): extent is null");
103 }
104 }
105
106
107 public Envelope getExtent() {
108 return extent;
109 }
110
111
112 public void setOriginalExtent(Envelope originalExtent) {
113 this.originalExtent = originalExtent;
114 }
115
116
117 public Envelope getOriginalExtent() {
118 return originalExtent;
119 }
120
121
122 public void setSrid(String srid) {
123 if (srid != null) {
124 this.srid = srid;
125 }
126 }
127
128
129 public String getSrid() {
130 return srid;
131 }
132
133
134 @Override
135 public Object getData(Artifact artifact, CallContext context) {
136 return null;
137 }
138
139
140 @Override
141 public Node toXML(Document doc) {
142 ElementCreator ec = new ElementCreator(
143 doc,
144 ArtifactNamespaceContext.NAMESPACE_URI,
145 ArtifactNamespaceContext.NAMESPACE_PREFIX);
146
147 Element facet = ec.create("facet");
148 ec.addAttr(facet, "description", description, true);
149 ec.addAttr(facet, "index", String.valueOf(index), true);
150 ec.addAttr(facet, "name", name, true);
151 ec.addAttr(facet, "url", url, true);
152 ec.addAttr(facet, "layers", layers.get(0), true);
153 ec.addAttr(facet, "srid", srid != null ? srid : "", true);
154 ec.addAttr(facet, "extent", originalExtent != null
155 ? GeometryUtils.jtsBoundsToOLBounds(originalExtent)
156 : "", true);
157 ec.addAttr(facet, "queryable", String.valueOf(isQueryable()), true);
158
159 return facet;
160 }
161
162
163 public boolean isQueryable() {
164 return false;
165 }
166
167
168 @Override
169 public Facet deepCopy() {
170 WMSLayerFacet copy = new WMSLayerFacet();
171 copy.set(this);
172
173 copy.type = type;
174 copy.layers = new ArrayList<String>(layers);
175 copy.stateId = stateId;
176 copy.hash = hash;
177 copy.url = url;
178 copy.extent = extent;
179 copy.srid = srid;
180
181 return copy;
182 }
183 }
184 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org