001 // $HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/ogcwebservices/wfs/capabilities/WFSFeatureType.java $
002 /*----------------------------------------------------------------------------
003 This file is part of deegree, http://deegree.org/
004 Copyright (C) 2001-2009 by:
005 Department of Geography, University of Bonn
006 and
007 lat/lon GmbH
008
009 This library is free software; you can redistribute it and/or modify it under
010 the terms of the GNU Lesser General Public License as published by the Free
011 Software Foundation; either version 2.1 of the License, or (at your option)
012 any later version.
013 This library is distributed in the hope that it will be useful, but WITHOUT
014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016 details.
017 You should have received a copy of the GNU Lesser General Public License
018 along with this library; if not, write to the Free Software Foundation, Inc.,
019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020
021 Contact information:
022
023 lat/lon GmbH
024 Aennchenstr. 19, 53177 Bonn
025 Germany
026 http://lat-lon.de/
027
028 Department of Geography, University of Bonn
029 Prof. Dr. Klaus Greve
030 Postfach 1147, 53001 Bonn
031 Germany
032 http://www.geographie.uni-bonn.de/deegree/
033
034 e-mail: info@deegree.org
035 ----------------------------------------------------------------------------*/
036
037 package org.deegree.ogcwebservices.wfs.capabilities;
038
039 import static org.deegree.framework.log.LoggerFactory.getLogger;
040 import static org.deegree.model.crs.CRSFactory.create;
041
042 import java.net.URI;
043
044 import org.deegree.datatypes.QualifiedName;
045 import org.deegree.framework.log.ILogger;
046 import org.deegree.model.crs.CoordinateSystem;
047 import org.deegree.model.crs.UnknownCRSException;
048 import org.deegree.model.metadata.iso19115.Keywords;
049 import org.deegree.model.spatialschema.Envelope;
050 import org.deegree.ogcwebservices.getcapabilities.MetadataURL;
051
052 /**
053 * Represents a feature type in the context of an OGC-WFS 1.1.0 capabilities document.
054 *
055 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a>
056 * @author last edited by: $Author: mschneider $
057 *
058 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
059 */
060 public class WFSFeatureType {
061
062 private static final ILogger LOG = getLogger( WFSFeatureType.class );
063
064 private QualifiedName name;
065
066 private String title;
067
068 private String abstract_;
069
070 private Keywords[] keywords;
071
072 // null -> noSRS in document
073 private URI defaultSrs;
074
075 private URI[] otherSrs;
076
077 private Operation[] operations;
078
079 private FormatType[] outputFormats;
080
081 private Envelope[] wgs84BoundingBoxes;
082
083 private MetadataURL[] metadataUrls;
084
085 /**
086 * Creates a new instance of <code>WFSFeatureType</code> from the given parameters.
087 *
088 * @param name
089 * @param title
090 * @param abstract_
091 * @param keywords
092 * @param defaultSrs
093 * @param otherSrs
094 * @param operations
095 * @param outputFormats
096 * @param wgs84BoundingBoxes
097 * @param metadataUrls
098 */
099 public WFSFeatureType( QualifiedName name, String title, String abstract_, Keywords[] keywords, URI defaultSrs,
100 URI[] otherSrs, Operation[] operations, FormatType[] outputFormats,
101 Envelope[] wgs84BoundingBoxes, MetadataURL[] metadataUrls ) {
102 this.name = name;
103 this.title = title;
104 if (title == null || title.length() == 0) {
105 this.title = name.getLocalName();
106 }
107 this.abstract_ = abstract_;
108 this.keywords = keywords;
109 this.defaultSrs = defaultSrs;
110 this.otherSrs = otherSrs;
111 this.operations = operations;
112 this.outputFormats = outputFormats;
113 this.wgs84BoundingBoxes = wgs84BoundingBoxes;
114 this.metadataUrls = metadataUrls;
115 }
116
117 /**
118 * @return Returns the abstract.
119 */
120 public String getAbstract() {
121 return abstract_;
122 }
123
124 /**
125 * @param abstract_
126 * The abstract to set.
127 */
128 public void setAbstract( String abstract_ ) {
129 this.abstract_ = abstract_;
130 }
131
132 /**
133 * @return Returns the name.
134 */
135 public QualifiedName getName() {
136 return name;
137 }
138
139 /**
140 * @param name
141 * The name to set.
142 */
143 public void setName( QualifiedName name ) {
144 this.name = name;
145 }
146
147 /**
148 * @return Returns the title.
149 */
150 public String getTitle() {
151 return title;
152 }
153
154 /**
155 * @param title
156 * The title to set.
157 */
158 public void setTitle( String title ) {
159 this.title = title;
160 }
161
162 /**
163 * @return Returns the keywords.
164 */
165 public Keywords[] getKeywords() {
166 return keywords;
167 }
168
169 /**
170 * @param keywords
171 * The keywords to set.
172 */
173 public void setKeywords( Keywords[] keywords ) {
174 this.keywords = keywords;
175 }
176
177 /**
178 * @return Returns the defaultSrs.
179 */
180 public URI getDefaultSRS() {
181 return defaultSrs;
182 }
183
184 /**
185 * @param defaultSrs
186 * The defaultSrs to set.
187 */
188 public void setDefaultSrs( URI defaultSrs ) {
189 this.defaultSrs = defaultSrs;
190 }
191
192 /**
193 * @return Returns the otherSrs.
194 */
195 public URI[] getOtherSrs() {
196 return otherSrs;
197 }
198
199 /**
200 * @param otherSrs
201 * The otherSrs to set.
202 */
203 public void setOtherSrs( URI[] otherSrs ) {
204 this.otherSrs = otherSrs;
205 }
206
207 /**
208 * @return Returns the operations.
209 */
210 public Operation[] getOperations() {
211 return operations;
212 }
213
214 /**
215 * @param operations
216 * The operations to set.
217 */
218 public void setOperations( Operation[] operations ) {
219 this.operations = operations;
220 }
221
222 /**
223 * @return Returns the outputFormats.
224 */
225 public FormatType[] getOutputFormats() {
226 return outputFormats;
227 }
228
229 /**
230 * Returns the outputFormat with the given name.
231 *
232 * @param name
233 * name of requested format
234 * @return the outputFormat with the given name if it exists, null otherwise
235 */
236 public FormatType getOutputFormat( String name ) {
237 FormatType formatType = null;
238 for ( FormatType outputFormat : this.outputFormats ) {
239 if ( outputFormat.getValue().equals( name ) ) {
240 formatType = outputFormat;
241 }
242 }
243 return formatType;
244 }
245
246 /**
247 * @param outputFormats
248 * The outputFormats to set.
249 */
250 public void setOutputFormats( FormatType[] outputFormats ) {
251 this.outputFormats = outputFormats;
252 }
253
254 /**
255 * @return Returns the wgs84BoundingBoxes.
256 */
257 public Envelope[] getWgs84BoundingBoxes() {
258 return wgs84BoundingBoxes;
259 }
260
261 /**
262 * @param wgs84BoundingBoxes
263 * The wgs84BoundingBoxes to set.
264 */
265 public void setWgs84BoundingBoxes( Envelope[] wgs84BoundingBoxes ) {
266 this.wgs84BoundingBoxes = wgs84BoundingBoxes;
267 }
268
269 /**
270 * @return Returns the metadataUrls.
271 */
272 public MetadataURL[] getMetadataUrls() {
273 return metadataUrls;
274 }
275
276 /**
277 * @param metadataUrls
278 * The metadataUrls to set.
279 */
280 public void setMetadataUrls( MetadataURL[] metadataUrls ) {
281 this.metadataUrls = metadataUrls;
282 }
283
284 /**
285 * Returns whether the feature type definition is virtual, i.e. all of it's output formats are processed using an
286 * (input) XSLT-script.
287 *
288 * @return true, if all formats are processed using an XSL input script
289 */
290 public boolean isVirtual() {
291
292 boolean isVirtual = true;
293 FormatType[] outputFormats = getOutputFormats();
294
295 for ( int i = 0; i < outputFormats.length; i++ ) {
296 if ( !outputFormats[i].isVirtual() ) {
297 isVirtual = false;
298 break;
299 }
300 }
301 return isVirtual;
302 }
303
304 /**
305 * Returns whether the feature type supports the given spatial reference system.
306 *
307 * @param srsName
308 * name of the srs, usually <code>EPSG:xyz</code>
309 * @return true, if srs is supported, false otherwise
310 */
311 public boolean supportsSrs( String srsName ) {
312 try {
313 CoordinateSystem other = create( srsName );
314
315 if ( this.defaultSrs != null ) {
316 CoordinateSystem crs = create( defaultSrs.toString() );
317 if ( other.equals( crs ) ) {
318 return true;
319 }
320 if ( this.otherSrs != null ) {
321 for ( URI srs : this.otherSrs ) {
322 CoordinateSystem crs2 = create( srs.toString() );
323 if ( crs2.equals( other ) ) {
324 return true;
325 }
326 }
327 }
328 }
329 } catch ( UnknownCRSException e ) {
330 LOG.logError( "Unknown error", e ); // they really should exist
331 }
332 return false;
333 }
334 }