comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WMSLayerFacet.java @ 3300:e1cf76b3ecb4

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

http://dive4elements.wald.intevation.org