001 //$HeadURL: http://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/wms/XMLFactory_1_3_0.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 package org.deegree.ogcwebservices.wms;
037
038 import static org.deegree.ogcbase.CommonNamespaces.WMSNS;
039 import static org.deegree.ogcbase.CommonNamespaces.WMS_PREFIX;
040 import static org.deegree.ogcbase.CommonNamespaces.getNamespaceContext;
041
042 import java.io.IOException;
043 import java.util.List;
044
045 import org.deegree.datatypes.QualifiedName;
046 import org.deegree.datatypes.values.TypedLiteral;
047 import org.deegree.framework.log.ILogger;
048 import org.deegree.framework.log.LoggerFactory;
049 import org.deegree.framework.util.StringTools;
050 import org.deegree.framework.xml.NamespaceContext;
051 import org.deegree.framework.xml.XMLParsingException;
052 import org.deegree.framework.xml.XMLTools;
053 import org.deegree.model.metadata.iso19115.Address;
054 import org.deegree.model.metadata.iso19115.Keywords;
055 import org.deegree.model.metadata.iso19115.OnlineResource;
056 import org.deegree.model.metadata.iso19115.Phone;
057 import org.deegree.model.spatialschema.Envelope;
058 import org.deegree.ogcbase.CommonNamespaces;
059 import org.deegree.ogcwebservices.getcapabilities.MetadataURL;
060 import org.deegree.ogcwebservices.wms.capabilities.Attribution;
061 import org.deegree.ogcwebservices.wms.capabilities.AuthorityURL;
062 import org.deegree.ogcwebservices.wms.capabilities.DataURL;
063 import org.deegree.ogcwebservices.wms.capabilities.Dimension;
064 import org.deegree.ogcwebservices.wms.capabilities.Extent;
065 import org.deegree.ogcwebservices.wms.capabilities.FeatureListURL;
066 import org.deegree.ogcwebservices.wms.capabilities.Identifier;
067 import org.deegree.ogcwebservices.wms.capabilities.Layer;
068 import org.deegree.ogcwebservices.wms.capabilities.LayerBoundingBox;
069 import org.deegree.ogcwebservices.wms.capabilities.LegendURL;
070 import org.deegree.ogcwebservices.wms.capabilities.LogoURL;
071 import org.deegree.ogcwebservices.wms.capabilities.ScaleHint;
072 import org.deegree.ogcwebservices.wms.capabilities.Style;
073 import org.deegree.ogcwebservices.wms.capabilities.StyleSheetURL;
074 import org.deegree.ogcwebservices.wms.capabilities.StyleURL;
075 import org.deegree.ogcwebservices.wms.capabilities.WMSCapabilitiesDocument_1_3_0;
076 import org.deegree.ogcwebservices.wms.capabilities.WMSCapabilities_1_3_0;
077 import org.deegree.owscommon.XMLFactory;
078 import org.deegree.owscommon_new.DCP;
079 import org.deegree.owscommon_new.DomainType;
080 import org.deegree.owscommon_new.HTTP;
081 import org.deegree.owscommon_new.Operation;
082 import org.deegree.owscommon_new.OperationsMetadata;
083 import org.deegree.owscommon_new.ServiceIdentification;
084 import org.deegree.owscommon_new.ServiceProvider;
085 import org.w3c.dom.Element;
086 import org.xml.sax.SAXException;
087
088 /**
089 * <code>XMLFactory_1_3_0</code> is an XML factory that outputs valid WMS 1.3.0 documents. It is not intended for direct
090 * use but is used automatically by the standard <code>XMLFactory</code>.
091 *
092 * @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
093 * @author last edited by: $Author: aschmitz $
094 *
095 * @version $Revision: 31355 $, $Date: 2011-07-26 09:13:38 +0200 (Di, 26 Jul 2011) $
096 */
097
098 public class XMLFactory_1_3_0 extends XMLFactory {
099
100 private static final ILogger LOG = LoggerFactory.getLogger( XMLFactory.class );
101
102 private static NamespaceContext nsContext = getNamespaceContext();
103
104 private static final String PWMS = WMS_PREFIX + ":";
105
106 /**
107 * Builds a 1.3.0 WMS capabilities document.
108 *
109 * @param capabilities
110 * @return the XML document
111 * @throws IOException
112 */
113 public static WMSCapabilitiesDocument_1_3_0 export( WMSCapabilities_1_3_0 capabilities )
114 throws IOException {
115 WMSCapabilitiesDocument_1_3_0 capabilitiesDocument = new WMSCapabilitiesDocument_1_3_0();
116 try {
117 capabilitiesDocument.createEmptyDocument();
118
119 Element root = capabilitiesDocument.getRootElement();
120
121 root.setAttribute( "version", "1.3.0" );
122 root.setAttribute( "updateSequence", capabilities.getUpdateSequence() );
123
124 appendService( root, capabilities.getServiceIdentification(), capabilities.getServiceProvider() );
125
126 appendCapabilityRequests( root, capabilities.getOperationMetadata() );
127
128 appendCapabilityLayer( (Element) XMLTools.getNode( root, PWMS + "Capability", nsContext ),
129 capabilities.getLayer() );
130
131 Element exc = XMLTools.getRequiredElement( root, PWMS + "Capability/" + PWMS + "Exception", nsContext );
132 for ( String f : capabilities.getExceptions() ) {
133 XMLTools.appendElement( exc, WMSNS, "Format", f );
134 }
135
136 Element serviceElement = (Element) XMLTools.getRequiredNode( root, PWMS + "Service", nsContext );
137
138 if ( capabilities.getLayerLimit() != 0 )
139 XMLTools.appendElement( serviceElement, WMSNS, "LayerLimit", "" + capabilities.getLayerLimit() );
140
141 if ( capabilities.getMaxWidth() != 0 )
142 XMLTools.appendElement( serviceElement, WMSNS, "MaxWidth", "" + capabilities.getMaxWidth() );
143
144 if ( capabilities.getMaxHeight() != 0 )
145 XMLTools.appendElement( serviceElement, WMSNS, "MaxHeight", "" + capabilities.getMaxHeight() );
146 } catch ( SAXException e ) {
147 LOG.logError( e.getMessage(), e );
148 } catch ( XMLParsingException e ) {
149 LOG.logError( e.getMessage(), e );
150 }
151
152 return capabilitiesDocument;
153 }
154
155 private static String boolean2Number( boolean bool ) {
156 if ( bool ) {
157 return "1";
158 }
159 return "0";
160 }
161
162 /**
163 *
164 * @param root
165 * @param identification
166 * @param provider
167 * @throws XMLParsingException
168 */
169 protected static void appendService( Element root, ServiceIdentification identification, ServiceProvider provider )
170 throws XMLParsingException {
171
172 root = (Element) XMLTools.getRequiredNode( root, PWMS + "Service", nsContext );
173
174 Element node = (Element) XMLTools.getRequiredNode( root, PWMS + "Name", nsContext );
175 node.setTextContent( identification.getServiceType().getCode() );
176
177 node = (Element) XMLTools.getRequiredNode( root, PWMS + "Title", nsContext );
178 node.setTextContent( identification.getTitle() );
179
180 String serviceAbstract = identification.getAbstractString();
181 if ( serviceAbstract != null ) {
182 XMLTools.appendElement( root, WMSNS, "Abstract", serviceAbstract );
183 }
184
185 List<Keywords> keywords = identification.getKeywords();
186 if ( keywords.size() > 0 ) {
187 String[] kw = keywords.get( 0 ).getKeywords();
188 Element kwl = XMLTools.appendElement( root, WMSNS, "KeywordList" );
189 for ( int i = 0; i < kw.length; i++ ) {
190 XMLTools.appendElement( kwl, WMSNS, "Keyword", kw[i] );
191 }
192 }
193
194 Element elem = XMLTools.appendElement( root, WMSNS, "OnlineResource" );
195 OnlineResource sLink = provider.getProviderSite();
196 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( elem, sLink );
197
198 appendContactInformation( root, provider );
199
200 String fee = null;
201 if ( identification.getAccessConstraints().size() > 0 )
202 fee = identification.getAccessConstraints().get( 0 ).getFees();
203 if ( fee != null ) {
204 XMLTools.appendElement( root, WMSNS, "Fees", fee );
205 } else {
206 XMLTools.appendElement( root, WMSNS, "Fees", "none" );
207 }
208
209 if ( identification.getAccessConstraints().size() > 0 ) {
210 XMLTools.appendElement( root, WMSNS, "AccessConstraints",
211 identification.getAccessConstraints().get( 0 ).getUseLimitations().get( 0 ) );
212 } else {
213 XMLTools.appendElement( root, WMSNS, "AccessConstraints", "none" );
214 }
215
216 }
217
218 /**
219 *
220 * @param root
221 * @param provider
222 */
223 protected static void appendContactInformation( Element root, ServiceProvider provider ) {
224
225 Element ciNode = XMLTools.appendElement( root, WMSNS, "ContactInformation" );
226 Element cppNode = XMLTools.appendElement( ciNode, WMSNS, "ContactPersonPrimary" );
227 if ( provider.getServiceContact().getIndividualName().length > 0 ) {
228 XMLTools.appendElement( cppNode, WMSNS, "ContactPerson",
229 provider.getServiceContact().getIndividualName()[0] );
230 }
231 if ( provider.getServiceContact().getOrganisationName().length > 0 ) {
232 XMLTools.appendElement( cppNode, WMSNS, "ContactOrganization",
233 provider.getServiceContact().getOrganisationName()[0] );
234 }
235 if ( provider.getServiceContact().getPositionName().length > 0 ) {
236 XMLTools.appendElement( ciNode, WMSNS, "ContactPosition", provider.getServiceContact().getPositionName()[0] );
237 }
238 Element caNode = XMLTools.appendElement( ciNode, WMSNS, "ContactAddress" );
239
240 XMLTools.appendElement( caNode, WMSNS, "AddressType", "postal" );
241
242 if ( provider.getServiceContact().getContactInfo().length > 0 ) {
243 Address addr = provider.getServiceContact().getContactInfo()[0].getAddress();
244 String[] dp = addr.getDeliveryPoint();
245 if ( dp.length > 0 ) {
246 XMLTools.appendElement( caNode, WMSNS, "Address", dp[0] );
247 }
248 if ( addr.getCity() != null ) {
249 XMLTools.appendElement( caNode, WMSNS, "City", addr.getCity() );
250 }
251 if ( addr.getAdministrativeArea() != null ) {
252 XMLTools.appendElement( caNode, WMSNS, "StateOrProvince", addr.getAdministrativeArea() );
253 }
254 if ( addr.getPostalCode() != null ) {
255 XMLTools.appendElement( caNode, WMSNS, "PostCode", addr.getPostalCode() );
256 }
257 if ( addr.getCountry() != null ) {
258 XMLTools.appendElement( caNode, WMSNS, "Country", addr.getCountry() );
259 }
260
261 Phone phone = provider.getServiceContact().getContactInfo()[0].getPhone();
262 if ( phone.getVoice().length > 0 ) {
263 XMLTools.appendElement( ciNode, WMSNS, "ContactVoiceTelephone", phone.getVoice()[0] );
264 }
265 if ( phone.getFacsimile().length > 0 ) {
266 XMLTools.appendElement( ciNode, WMSNS, "ContactFacsimileTelephone", phone.getFacsimile()[0] );
267 }
268 if ( addr.getElectronicMailAddress().length > 0 ) {
269 XMLTools.appendElement( ciNode, WMSNS, "ContactElectronicMailAddress",
270 addr.getElectronicMailAddress()[0] );
271 }
272 }
273
274 }
275
276 /**
277 *
278 * @param root
279 * @param operationsMetadata
280 * @throws XMLParsingException
281 */
282 protected static void appendCapabilityRequests( Element root, OperationsMetadata operationsMetadata )
283 throws XMLParsingException {
284
285 root = (Element) XMLTools.getRequiredNode( root, PWMS + "Capability/" + PWMS + "Request", nsContext );
286
287 operationsMetadata.getOperations();
288
289 // just append all operations
290 for ( Operation operation : operationsMetadata.getOperations() ) {
291 appendOperation( root, operation );
292 }
293
294 // maybe we have to check for mandatory operations?
295
296 }
297
298 /**
299 *
300 * @param root
301 * @param operation
302 */
303 protected static void appendOperation( Element root, Operation operation ) {
304
305 String name = operation.getName().getPrefixedName();
306
307 if ( "sld:GetLegendGraphic".equals( name ) ) {
308 root = XMLTools.appendElement( root, CommonNamespaces.SLDNS, name );
309 // root.setAttribute( "xsi:type", "wms:_ExtendedOperation" );
310 } else {
311 root = XMLTools.appendElement( root, WMSNS, operation.getName().getLocalName() );
312 }
313
314 DomainType odt = (DomainType) operation.getParameter( new QualifiedName( "Format" ) );
315
316 List<TypedLiteral> values = odt.getValues();
317 for ( TypedLiteral value : values )
318 XMLTools.appendElement( root, WMSNS, "Format", value.getValue() );
319
320 List<DCP> dcps = operation.getDCP();
321 for ( DCP dcp : dcps ) {
322 Element http = XMLTools.appendElement( root, WMSNS, "DCPType" );
323 http = XMLTools.appendElement( http, WMSNS, "HTTP" );
324 HTTP ht = (HTTP) dcp;
325 List<HTTP.Type> types = ht.getTypes();
326 List<OnlineResource> links = ht.getLinks();
327 for ( int i = 0; i < types.size(); ++i ) {
328 Element elem = null;
329 if ( types.get( i ) == HTTP.Type.Get )
330 elem = XMLTools.appendElement( http, WMSNS, "Get" );
331 if ( types.get( i ) == HTTP.Type.Post )
332 elem = XMLTools.appendElement( http, WMSNS, "Post" );
333 if ( elem != null ) {
334 elem = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
335 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( elem, links.get( i ) );
336 }
337 }
338 }
339
340 }
341
342 // /**
343 // * @param http
344 // * @param urls
345 // */
346 // protected static void appendURLs( Element http, URL[] urls, String type ) {
347 // for ( int j = 0; j < urls.length; j++ ) {
348 // Element olr = XMLTools.appendElement( http, null, type );
349 // appendOnlineResource( olr, urls[j], "Get".equalsIgnoreCase( type ) );
350 // }
351 // }
352
353 /**
354 *
355 * @param root
356 * @param layer
357 * @throws XMLParsingException
358 */
359 protected static void appendCapabilityLayer( Element root, Layer layer )
360 throws XMLParsingException {
361
362 root = XMLTools.appendElement( root, WMSNS, "Layer" );
363 root.setAttribute( "queryable", boolean2Number( layer.isQueryable() ) );
364 root.setAttribute( "cascaded", Integer.toString( layer.getCascaded() ) );
365 root.setAttribute( "opaque", boolean2Number( layer.isOpaque() ) );
366 root.setAttribute( "noSubsets", boolean2Number( layer.hasNoSubsets() ) );
367 if ( layer.getFixedWidth() > 0 ) {
368 root.setAttribute( "fixedWidth", Integer.toString( layer.getFixedWidth() ) );
369 }
370 if ( layer.getFixedHeight() > 0 ) {
371 root.setAttribute( "fixedHeight", Integer.toString( layer.getFixedHeight() ) );
372 }
373
374 if ( layer.getName() != null ) {
375 XMLTools.appendElement( root, WMSNS, "Name", layer.getName() );
376 }
377 XMLTools.appendElement( root, WMSNS, "Title", layer.getTitle() );
378
379 if ( layer.getAbstract() != null ) {
380 XMLTools.appendElement( root, WMSNS, "Abstract", layer.getAbstract() );
381 }
382
383 String[] keywords = layer.getKeywordList();
384 if ( keywords.length > 0 ) {
385 Element elem = XMLTools.appendElement( root, WMSNS, "KeywordList" );
386 for ( int i = 0; i < keywords.length; i++ ) {
387 XMLTools.appendElement( elem, WMSNS, "Keyword", keywords[i] );
388 }
389 }
390
391 String[] srs = layer.getSrs();
392 for ( int i = 0; i < srs.length; i++ ) {
393 XMLTools.appendElement( root, WMSNS, "CRS", srs[i] );
394 }
395
396 Envelope llBox = layer.getLatLonBoundingBox();
397 appendLatLonBoundingBox( root, llBox );
398
399 LayerBoundingBox[] lBoxes = layer.getBoundingBoxes();
400 for ( int i = 0; i < lBoxes.length; i++ ) {
401 appendLayerBoundingBox( root, lBoxes[i] );
402 }
403
404 Dimension[] dims = layer.getDimension();
405 for ( int i = 0; i < dims.length; i++ ) {
406 appendDimension( root, dims[i] );
407 }
408
409 Extent[] extents = layer.getExtent();
410 for ( int i = 0; i < extents.length; i++ ) {
411 appendExtent( root, extents[i] );
412 }
413
414 Attribution attr = layer.getAttribution();
415 if ( attr != null ) {
416 appendAttribution( root, attr );
417 }
418
419 AuthorityURL[] authorityURLs = layer.getAuthorityURL();
420 for ( int i = 0; i < authorityURLs.length; i++ ) {
421 appendAuthorityURL( root, authorityURLs[i] );
422 }
423
424 Identifier[] identifiers = layer.getIdentifier();
425 for ( int i = 0; i < identifiers.length; i++ ) {
426 appendIdentifier( root, identifiers[i] );
427 }
428
429 MetadataURL[] metadataURLs = layer.getMetadataURL();
430 for ( int i = 0; i < metadataURLs.length; i++ ) {
431 appendMetadataURL( root, metadataURLs[i] );
432 }
433
434 DataURL[] dataURLs = layer.getDataURL();
435 for ( int i = 0; i < dataURLs.length; i++ ) {
436 appendDataURL( root, dataURLs[i] );
437 }
438
439 FeatureListURL[] featureListURLs = layer.getFeatureListURL();
440 for ( int i = 0; i < featureListURLs.length; i++ ) {
441 appendFeatureListURL( root, featureListURLs[i] );
442 }
443
444 if ( layer.getName() != null && layer.getName().length() > 0 ) {
445 Style[] styles = layer.getStyles();
446 for ( int i = 0; i < styles.length; i++ ) {
447 appendStyle( root, styles[i] );
448 }
449 }
450
451 ScaleHint scaleHint = layer.getScaleHint();
452 XMLTools.appendElement( root, WMSNS, "MinScaleDenominator", "" + scaleHint.getMin() );
453 XMLTools.appendElement( root, WMSNS, "MaxScaleDenominator", "" + scaleHint.getMax() );
454
455 Layer[] layers = layer.getLayer();
456 for ( int i = 0; i < layers.length; i++ ) {
457 appendCapabilityLayer( root, layers[i] );
458 }
459
460 }
461
462 /**
463 *
464 * @param root
465 * @param style
466 */
467 protected static void appendStyle( Element root, Style style ) {
468
469 String nm = style.getName();
470 String tlt = style.getTitle();
471 if ( nm.startsWith( "default:" ) ) {
472 nm = "default";
473 if ( tlt != null ) {
474 tlt = StringTools.replace( tlt, "default:", "", false ) + " (default)";
475 }
476 }
477
478 root = XMLTools.appendElement( root, WMSNS, "Style" );
479 XMLTools.appendElement( root, WMSNS, "Name", nm );
480 if ( style.getTitle() != null ) {
481 XMLTools.appendElement( root, WMSNS, "Title", tlt );
482 }
483 if ( style.getAbstract() != null ) {
484 XMLTools.appendElement( root, WMSNS, "Abstract", style.getAbstract() );
485 }
486 LegendURL[] legendURLs = style.getLegendURL();
487
488 for ( int i = 0; i < legendURLs.length; i++ ) {
489 appendLegendURL( root, legendURLs[i] );
490 }
491
492 StyleSheetURL styleSheetURL = style.getStyleSheetURL();
493 if ( styleSheetURL != null ) {
494 appendStyleSheetURL( root, styleSheetURL );
495 }
496
497 StyleURL styleURL = style.getStyleURL();
498 if ( styleURL != null ) {
499 appendStyleURL( root, styleURL );
500 }
501
502 }
503
504 /**
505 * @param root
506 * @param styleURL
507 */
508 protected static void appendStyleURL( Element root, StyleURL styleURL ) {
509 Element elem = XMLTools.appendElement( root, WMSNS, "StyleURL" );
510 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", styleURL.getFormat() );
511 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
512 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, styleURL.getOnlineResource() );
513 }
514
515 /**
516 * @param root
517 * @param styleSheetURL
518 */
519 protected static void appendStyleSheetURL( Element root, StyleSheetURL styleSheetURL ) {
520 Element elem = XMLTools.appendElement( root, WMSNS, "StyleSheetURL" );
521 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", styleSheetURL.getFormat() );
522 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
523 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, styleSheetURL.getOnlineResource() );
524 }
525
526 /**
527 * @param root
528 * @param legendURL
529 */
530 protected static void appendLegendURL( Element root, LegendURL legendURL ) {
531 Element elem = XMLTools.appendElement( root, WMSNS, "LegendURL" );
532 elem.setAttribute( "width", "" + legendURL.getWidth() );
533 elem.setAttribute( "height", "" + legendURL.getHeight() );
534 XMLTools.appendElement( elem, WMSNS, "Format", legendURL.getFormat() );
535
536 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
537 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, legendURL.getOnlineResource() );
538 }
539
540 /**
541 * @param root
542 * @param featureListURL
543 */
544 protected static void appendFeatureListURL( Element root, FeatureListURL featureListURL ) {
545 Element elem = XMLTools.appendElement( root, WMSNS, "FeatureListURL" );
546 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", featureListURL.getFormat() );
547 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
548 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, featureListURL.getOnlineResource() );
549 }
550
551 /**
552 * @param root
553 * @param dataURL
554 */
555 protected static void appendDataURL( Element root, DataURL dataURL ) {
556 Element elem = XMLTools.appendElement( root, WMSNS, "DataURL" );
557 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", dataURL.getFormat() );
558 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
559 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, dataURL.getOnlineResource() );
560 }
561
562 /**
563 * @param root
564 * @param metadataURL
565 */
566 protected static void appendMetadataURL( Element root, MetadataURL metadataURL ) {
567 Element elem = XMLTools.appendElement( root, WMSNS, "MetadataURL" );
568 elem.setAttribute( "type", metadataURL.getType() );
569 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", metadataURL.getFormat() );
570 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
571 res.setAttributeNS( XLNNS.toASCIIString(), "xlink:type", "simple" );
572 res.setAttributeNS( XLNNS.toASCIIString(), "xlink:href", metadataURL.getOnlineResource().toExternalForm() );
573 }
574
575 /**
576 * @param root
577 * @param identifier
578 */
579 protected static void appendIdentifier( Element root, Identifier identifier ) {
580 Element elem = XMLTools.appendElement( root, WMSNS, "Identifier" );
581 elem.setAttribute( "authority", identifier.getAuthority() );
582 elem.setTextContent( identifier.getValue() );
583 }
584
585 /**
586 * @param root
587 * @param authorityURL
588 */
589 protected static void appendAuthorityURL( Element root, AuthorityURL authorityURL ) {
590 Element elem = XMLTools.appendElement( root, WMSNS, "AuthorityURL" );
591 elem.setAttribute( "name", authorityURL.getName() );
592 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
593 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, authorityURL.getOnlineResource() );
594 }
595
596 /**
597 * @param root
598 * @param attr
599 */
600 protected static void appendAttribution( Element root, Attribution attr ) {
601 Element elem = XMLTools.appendElement( root, WMSNS, "Attribution" );
602 XMLTools.appendElement( elem, WMSNS, PWMS + "Title", attr.getTitle() );
603 Element res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
604 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, attr.getOnlineResource() );
605 LogoURL logoURL = attr.getLogoURL();
606 if ( logoURL != null ) {
607 elem = XMLTools.appendElement( elem, WMSNS, "LogoURL" );
608 elem.setAttribute( "width", "" + logoURL.getWidth() );
609 elem.setAttribute( "height", "" + logoURL.getHeight() );
610 XMLTools.appendElement( elem, WMSNS, "Format", logoURL.getFormat() );
611 res = XMLTools.appendElement( elem, WMSNS, "OnlineResource" );
612 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, logoURL.getOnlineResource() );
613 }
614 }
615
616 /**
617 * @param root
618 * @param extent
619 */
620 protected static void appendExtent( Element root, Extent extent ) {
621 Element exNode = XMLTools.appendElement( root, WMSNS, "Extent" );
622 exNode.setAttribute( "name", extent.getName() );
623 exNode.setAttribute( "default", extent.getDefault() );
624 exNode.setAttribute( "nearestValue", boolean2Number( extent.useNearestValue() ) );
625 exNode.setTextContent( extent.getValue() );
626 }
627
628 /**
629 * @param root
630 * @param dim
631 */
632 protected static void appendDimension( Element root, Dimension dim ) {
633 Element dimNode = XMLTools.appendElement( root, WMSNS, "Dimension", dim.getValues() );
634 dimNode.setAttribute( "name", dim.getName() );
635 dimNode.setAttribute( "units", dim.getUnits() );
636 maybeSetAttribute( dimNode, "unitSymbol", dim.getUnitSymbol() );
637 maybeSetAttribute( dimNode, "default", dim.getDefaultValue() );
638 maybeSetAttribute( dimNode, "current", dim.isCurrent() ? "1" : null );
639 maybeSetAttribute( dimNode, "nearestValue", dim.isNearestValue() ? "1" : null );
640 maybeSetAttribute( dimNode, "multipleValues", dim.isMultipleValues() ? "1" : null );
641 }
642
643 /**
644 * @param root
645 * @param lBox
646 */
647 protected static void appendLayerBoundingBox( Element root, LayerBoundingBox lBox ) {
648 Element bbNode = XMLTools.appendElement( root, WMSNS, "BoundingBox" );
649 if ( lBox.getSRS().equalsIgnoreCase( "EPSG:4326" ) ) {
650 bbNode.setAttribute( "miny", "" + lBox.getMin().getX() );
651 bbNode.setAttribute( "minx", "" + lBox.getMin().getY() );
652 bbNode.setAttribute( "maxy", "" + lBox.getMax().getX() );
653 bbNode.setAttribute( "maxx", "" + lBox.getMax().getY() );
654 bbNode.setAttribute( "resx", "" + lBox.getResx() );
655 bbNode.setAttribute( "resy", "" + lBox.getResy() );
656 bbNode.setAttribute( "CRS", "" + lBox.getSRS() );
657 } else {
658 bbNode.setAttribute( "minx", "" + lBox.getMin().getX() );
659 bbNode.setAttribute( "miny", "" + lBox.getMin().getY() );
660 bbNode.setAttribute( "maxx", "" + lBox.getMax().getX() );
661 bbNode.setAttribute( "maxy", "" + lBox.getMax().getY() );
662 bbNode.setAttribute( "resx", "" + lBox.getResx() );
663 bbNode.setAttribute( "resy", "" + lBox.getResy() );
664 bbNode.setAttribute( "CRS", "" + lBox.getSRS() );
665 }
666 }
667
668 /**
669 * @param root
670 * @param llBox
671 */
672 protected static void appendLatLonBoundingBox( Element root, Envelope llBox ) {
673 Element bbNode = XMLTools.appendElement( root, WMSNS, "EX_GeographicBoundingBox" );
674 XMLTools.appendElement( bbNode, WMSNS, "westBoundLongitude", "" + llBox.getMin().getX() );
675 XMLTools.appendElement( bbNode, WMSNS, "eastBoundLongitude", "" + llBox.getMax().getX() );
676 XMLTools.appendElement( bbNode, WMSNS, "southBoundLatitude", "" + llBox.getMin().getY() );
677 XMLTools.appendElement( bbNode, WMSNS, "northBoundLatitude", "" + llBox.getMax().getY() );
678 }
679
680 }