001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/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: 21334 $, $Date: 2009-12-09 11:52:08 +0100 (Mi, 09 Dez 2009) $ 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, PWMS + "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, PWMS + "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, PWMS + "KeywordList" ); 189 for ( int i = 0; i < kw.length; i++ ) { 190 XMLTools.appendElement( kwl, WMSNS, PWMS + "Keyword", kw[i] ); 191 } 192 } 193 194 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "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, PWMS + "Fees", fee ); 205 } else { 206 XMLTools.appendElement( root, WMSNS, PWMS + "Fees", "none" ); 207 } 208 209 if ( identification.getAccessConstraints().size() > 0 ) { 210 XMLTools.appendElement( root, WMSNS, PWMS + "AccessConstraints", 211 identification.getAccessConstraints().get( 0 ).getUseLimitations().get( 0 ) ); 212 } else { 213 XMLTools.appendElement( root, WMSNS, PWMS + "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, PWMS + "ContactInformation" ); 226 Element cppNode = XMLTools.appendElement( ciNode, WMSNS, PWMS + "ContactPersonPrimary" ); 227 if ( provider.getServiceContact().getIndividualName().length > 0 ) { 228 XMLTools.appendElement( cppNode, WMSNS, PWMS + "ContactPerson", 229 provider.getServiceContact().getIndividualName()[0] ); 230 } 231 if ( provider.getServiceContact().getOrganisationName().length > 0 ) { 232 XMLTools.appendElement( cppNode, WMSNS, PWMS + "ContactOrganization", 233 provider.getServiceContact().getOrganisationName()[0] ); 234 } 235 if ( provider.getServiceContact().getPositionName().length > 0 ) { 236 XMLTools.appendElement( ciNode, WMSNS, PWMS + "ContactPosition", 237 provider.getServiceContact().getPositionName()[0] ); 238 } 239 Element caNode = XMLTools.appendElement( ciNode, WMSNS, PWMS + "ContactAddress" ); 240 241 XMLTools.appendElement( caNode, WMSNS, PWMS + "AddressType", "postal" ); 242 243 if ( provider.getServiceContact().getContactInfo().length > 0 ) { 244 Address addr = provider.getServiceContact().getContactInfo()[0].getAddress(); 245 String[] dp = addr.getDeliveryPoint(); 246 if ( dp.length > 0 ) { 247 XMLTools.appendElement( caNode, WMSNS, PWMS + "Address", dp[0] ); 248 } 249 if ( addr.getCity() != null ) { 250 XMLTools.appendElement( caNode, WMSNS, PWMS + "City", addr.getCity() ); 251 } 252 if ( addr.getAdministrativeArea() != null ) { 253 XMLTools.appendElement( caNode, WMSNS, PWMS + "StateOrProvince", addr.getAdministrativeArea() ); 254 } 255 if ( addr.getPostalCode() != null ) { 256 XMLTools.appendElement( caNode, WMSNS, PWMS + "PostCode", addr.getPostalCode() ); 257 } 258 if ( addr.getCountry() != null ) { 259 XMLTools.appendElement( caNode, WMSNS, PWMS + "Country", addr.getCountry() ); 260 } 261 262 Phone phone = provider.getServiceContact().getContactInfo()[0].getPhone(); 263 if ( phone.getVoice().length > 0 ) { 264 XMLTools.appendElement( ciNode, WMSNS, PWMS + "ContactVoiceTelephone", phone.getVoice()[0] ); 265 } 266 if ( phone.getFacsimile().length > 0 ) { 267 XMLTools.appendElement( ciNode, WMSNS, PWMS + "ContactFacsimileTelephone", phone.getFacsimile()[0] ); 268 } 269 if ( addr.getElectronicMailAddress().length > 0 ) { 270 XMLTools.appendElement( ciNode, WMSNS, PWMS + "ContactElectronicMailAddress", 271 addr.getElectronicMailAddress()[0] ); 272 } 273 } 274 275 } 276 277 /** 278 * 279 * @param root 280 * @param operationsMetadata 281 * @throws XMLParsingException 282 */ 283 protected static void appendCapabilityRequests( Element root, OperationsMetadata operationsMetadata ) 284 throws XMLParsingException { 285 286 root = (Element) XMLTools.getRequiredNode( root, PWMS + "Capability/" + PWMS + "Request", nsContext ); 287 288 operationsMetadata.getOperations(); 289 290 // just append all operations 291 for ( Operation operation : operationsMetadata.getOperations() ) { 292 appendOperation( root, operation ); 293 } 294 295 // maybe we have to check for mandatory operations? 296 297 } 298 299 /** 300 * 301 * @param root 302 * @param operation 303 */ 304 protected static void appendOperation( Element root, Operation operation ) { 305 306 String name = operation.getName().getPrefixedName(); 307 308 if ( "sld:GetLegendGraphic".equals( name ) ) { 309 root = XMLTools.appendElement( root, CommonNamespaces.SLDNS, name ); 310 // root.setAttribute( "xsi:type", "wms:_ExtendedOperation" ); 311 } else { 312 root = XMLTools.appendElement( root, WMSNS, name ); 313 } 314 315 DomainType odt = (DomainType) operation.getParameter( new QualifiedName( "Format" ) ); 316 317 List<TypedLiteral> values = odt.getValues(); 318 for ( TypedLiteral value : values ) 319 XMLTools.appendElement( root, WMSNS, PWMS + "Format", value.getValue() ); 320 321 List<DCP> dcps = operation.getDCP(); 322 for ( DCP dcp : dcps ) { 323 Element http = XMLTools.appendElement( root, WMSNS, PWMS + "DCPType" ); 324 http = XMLTools.appendElement( http, WMSNS, PWMS + "HTTP" ); 325 HTTP ht = (HTTP) dcp; 326 List<HTTP.Type> types = ht.getTypes(); 327 List<OnlineResource> links = ht.getLinks(); 328 for ( int i = 0; i < types.size(); ++i ) { 329 Element elem = null; 330 if ( types.get( i ) == HTTP.Type.Get ) 331 elem = XMLTools.appendElement( http, WMSNS, PWMS + "Get" ); 332 if ( types.get( i ) == HTTP.Type.Post ) 333 elem = XMLTools.appendElement( http, WMSNS, PWMS + "Post" ); 334 if ( elem != null ) { 335 elem = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 336 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( elem, links.get( i ) ); 337 } 338 } 339 } 340 341 } 342 343 // /** 344 // * @param http 345 // * @param urls 346 // */ 347 // protected static void appendURLs( Element http, URL[] urls, String type ) { 348 // for ( int j = 0; j < urls.length; j++ ) { 349 // Element olr = XMLTools.appendElement( http, null, type ); 350 // appendOnlineResource( olr, urls[j], "Get".equalsIgnoreCase( type ) ); 351 // } 352 // } 353 354 /** 355 * 356 * @param root 357 * @param layer 358 * @throws XMLParsingException 359 */ 360 protected static void appendCapabilityLayer( Element root, Layer layer ) 361 throws XMLParsingException { 362 363 root = XMLTools.appendElement( root, WMSNS, PWMS + "Layer" ); 364 root.setAttribute( "queryable", boolean2Number( layer.isQueryable() ) ); 365 root.setAttribute( "cascaded", Integer.toString( layer.getCascaded() ) ); 366 root.setAttribute( "opaque", boolean2Number( layer.isOpaque() ) ); 367 root.setAttribute( "noSubsets", boolean2Number( layer.hasNoSubsets() ) ); 368 if ( layer.getFixedWidth() > 0 ) { 369 root.setAttribute( "fixedWidth", Integer.toString( layer.getFixedWidth() ) ); 370 } 371 if ( layer.getFixedHeight() > 0 ) { 372 root.setAttribute( "fixedHeight", Integer.toString( layer.getFixedHeight() ) ); 373 } 374 375 if ( layer.getName() != null ) { 376 XMLTools.appendElement( root, WMSNS, PWMS + "Name", layer.getName() ); 377 } 378 XMLTools.appendElement( root, WMSNS, PWMS + "Title", layer.getTitle() ); 379 380 if ( layer.getAbstract() != null ) { 381 XMLTools.appendElement( root, WMSNS, PWMS + "Abstract", layer.getAbstract() ); 382 } 383 384 String[] keywords = layer.getKeywordList(); 385 if ( keywords.length > 0 ) { 386 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "KeywordList" ); 387 for ( int i = 0; i < keywords.length; i++ ) { 388 XMLTools.appendElement( elem, WMSNS, PWMS + "Keyword", keywords[i] ); 389 } 390 } 391 392 String[] srs = layer.getSrs(); 393 for ( int i = 0; i < srs.length; i++ ) { 394 XMLTools.appendElement( root, WMSNS, PWMS + "CRS", srs[i] ); 395 } 396 397 Envelope llBox = layer.getLatLonBoundingBox(); 398 appendLatLonBoundingBox( root, llBox ); 399 400 LayerBoundingBox[] lBoxes = layer.getBoundingBoxes(); 401 for ( int i = 0; i < lBoxes.length; i++ ) { 402 appendLayerBoundingBox( root, lBoxes[i] ); 403 } 404 405 Dimension[] dims = layer.getDimension(); 406 for ( int i = 0; i < dims.length; i++ ) { 407 appendDimension( root, dims[i] ); 408 } 409 410 Extent[] extents = layer.getExtent(); 411 for ( int i = 0; i < extents.length; i++ ) { 412 appendExtent( root, extents[i] ); 413 } 414 415 Attribution attr = layer.getAttribution(); 416 if ( attr != null ) { 417 appendAttribution( root, attr ); 418 } 419 420 AuthorityURL[] authorityURLs = layer.getAuthorityURL(); 421 for ( int i = 0; i < authorityURLs.length; i++ ) { 422 appendAuthorityURL( root, authorityURLs[i] ); 423 } 424 425 Identifier[] identifiers = layer.getIdentifier(); 426 for ( int i = 0; i < identifiers.length; i++ ) { 427 appendIdentifier( root, identifiers[i] ); 428 } 429 430 MetadataURL[] metadataURLs = layer.getMetadataURL(); 431 for ( int i = 0; i < metadataURLs.length; i++ ) { 432 appendMetadataURL( root, metadataURLs[i] ); 433 } 434 435 DataURL[] dataURLs = layer.getDataURL(); 436 for ( int i = 0; i < dataURLs.length; i++ ) { 437 appendDataURL( root, dataURLs[i] ); 438 } 439 440 FeatureListURL[] featureListURLs = layer.getFeatureListURL(); 441 for ( int i = 0; i < featureListURLs.length; i++ ) { 442 appendFeatureListURL( root, featureListURLs[i] ); 443 } 444 445 if ( layer.getName() != null && layer.getName().length() > 0 ) { 446 Style[] styles = layer.getStyles(); 447 for ( int i = 0; i < styles.length; i++ ) { 448 appendStyle( root, styles[i] ); 449 } 450 } 451 452 ScaleHint scaleHint = layer.getScaleHint(); 453 XMLTools.appendElement( root, WMSNS, PWMS + "MinScaleDenominator", "" + scaleHint.getMin() ); 454 XMLTools.appendElement( root, WMSNS, PWMS + "MaxScaleDenominator", "" + scaleHint.getMax() ); 455 456 Layer[] layers = layer.getLayer(); 457 for ( int i = 0; i < layers.length; i++ ) { 458 appendCapabilityLayer( root, layers[i] ); 459 } 460 461 } 462 463 /** 464 * 465 * @param root 466 * @param style 467 */ 468 protected static void appendStyle( Element root, Style style ) { 469 470 String nm = style.getName(); 471 String tlt = style.getTitle(); 472 if ( nm.startsWith( "default:" ) ) { 473 nm = "default"; 474 if ( tlt != null ) { 475 tlt = StringTools.replace( tlt, "default:", "", false ) + " (default)"; 476 } 477 } 478 479 root = XMLTools.appendElement( root, WMSNS, PWMS + "Style" ); 480 XMLTools.appendElement( root, WMSNS, PWMS + "Name", nm ); 481 if ( style.getTitle() != null ) { 482 XMLTools.appendElement( root, WMSNS, PWMS + "Title", tlt ); 483 } 484 if ( style.getAbstract() != null ) { 485 XMLTools.appendElement( root, WMSNS, PWMS + "Abstract", style.getAbstract() ); 486 } 487 LegendURL[] legendURLs = style.getLegendURL(); 488 489 for ( int i = 0; i < legendURLs.length; i++ ) { 490 appendLegendURL( root, legendURLs[i] ); 491 } 492 493 StyleSheetURL styleSheetURL = style.getStyleSheetURL(); 494 if ( styleSheetURL != null ) { 495 appendStyleSheetURL( root, styleSheetURL ); 496 } 497 498 StyleURL styleURL = style.getStyleURL(); 499 if ( styleURL != null ) { 500 appendStyleURL( root, styleURL ); 501 } 502 503 } 504 505 /** 506 * @param root 507 * @param styleURL 508 */ 509 protected static void appendStyleURL( Element root, StyleURL styleURL ) { 510 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "StyleURL" ); 511 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", styleURL.getFormat() ); 512 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 513 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, styleURL.getOnlineResource() ); 514 } 515 516 /** 517 * @param root 518 * @param styleSheetURL 519 */ 520 protected static void appendStyleSheetURL( Element root, StyleSheetURL styleSheetURL ) { 521 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "StyleSheetURL" ); 522 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", styleSheetURL.getFormat() ); 523 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 524 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, styleSheetURL.getOnlineResource() ); 525 } 526 527 /** 528 * @param root 529 * @param legendURL 530 */ 531 protected static void appendLegendURL( Element root, LegendURL legendURL ) { 532 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "LegendURL" ); 533 elem.setAttribute( "width", "" + legendURL.getWidth() ); 534 elem.setAttribute( "height", "" + legendURL.getHeight() ); 535 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", legendURL.getFormat() ); 536 537 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 538 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, legendURL.getOnlineResource() ); 539 } 540 541 /** 542 * @param root 543 * @param featureListURL 544 */ 545 protected static void appendFeatureListURL( Element root, FeatureListURL featureListURL ) { 546 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "FeatureListURL" ); 547 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", featureListURL.getFormat() ); 548 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 549 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, featureListURL.getOnlineResource() ); 550 } 551 552 /** 553 * @param root 554 * @param dataURL 555 */ 556 protected static void appendDataURL( Element root, DataURL dataURL ) { 557 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "DataURL" ); 558 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", dataURL.getFormat() ); 559 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 560 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, dataURL.getOnlineResource() ); 561 } 562 563 /** 564 * @param root 565 * @param metadataURL 566 */ 567 protected static void appendMetadataURL( Element root, MetadataURL metadataURL ) { 568 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "MetadataURL" ); 569 elem.setAttribute( "type", metadataURL.getType() ); 570 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", metadataURL.getFormat() ); 571 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 572 res.setAttributeNS( XLNNS.toASCIIString(), "xlink:type", "simple" ); 573 res.setAttributeNS( XLNNS.toASCIIString(), "xlink:href", metadataURL.getOnlineResource().toExternalForm() ); 574 } 575 576 /** 577 * @param root 578 * @param identifier 579 */ 580 protected static void appendIdentifier( Element root, Identifier identifier ) { 581 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "Identifier" ); 582 elem.setAttribute( "authority", identifier.getAuthority() ); 583 elem.setTextContent( identifier.getValue() ); 584 } 585 586 /** 587 * @param root 588 * @param authorityURL 589 */ 590 protected static void appendAuthorityURL( Element root, AuthorityURL authorityURL ) { 591 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "AuthorityURL" ); 592 elem.setAttribute( "name", authorityURL.getName() ); 593 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 594 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, authorityURL.getOnlineResource() ); 595 } 596 597 /** 598 * @param root 599 * @param attr 600 */ 601 protected static void appendAttribution( Element root, Attribution attr ) { 602 Element elem = XMLTools.appendElement( root, WMSNS, PWMS + "Attribution" ); 603 XMLTools.appendElement( elem, WMSNS, PWMS + "Title", attr.getTitle() ); 604 Element res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 605 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, attr.getOnlineResource() ); 606 LogoURL logoURL = attr.getLogoURL(); 607 if ( logoURL != null ) { 608 elem = XMLTools.appendElement( elem, WMSNS, PWMS + "LogoURL" ); 609 elem.setAttribute( "width", "" + logoURL.getWidth() ); 610 elem.setAttribute( "height", "" + logoURL.getHeight() ); 611 XMLTools.appendElement( elem, WMSNS, PWMS + "Format", logoURL.getFormat() ); 612 res = XMLTools.appendElement( elem, WMSNS, PWMS + "OnlineResource" ); 613 org.deegree.model.metadata.iso19115.XMLFactory.appendOnlineResource( res, logoURL.getOnlineResource() ); 614 } 615 } 616 617 /** 618 * @param root 619 * @param extent 620 */ 621 protected static void appendExtent( Element root, Extent extent ) { 622 Element exNode = XMLTools.appendElement( root, WMSNS, PWMS + "Extent" ); 623 exNode.setAttribute( "name", extent.getName() ); 624 exNode.setAttribute( "default", extent.getDefault() ); 625 exNode.setAttribute( "nearestValue", boolean2Number( extent.useNearestValue() ) ); 626 exNode.setTextContent( extent.getValue() ); 627 } 628 629 /** 630 * @param root 631 * @param dim 632 */ 633 protected static void appendDimension( Element root, Dimension dim ) { 634 Element dimNode = XMLTools.appendElement( root, WMSNS, PWMS + "Dimension", dim.getValues() ); 635 dimNode.setAttribute( "name", dim.getName() ); 636 dimNode.setAttribute( "units", dim.getUnits() ); 637 maybeSetAttribute( dimNode, "unitSymbol", dim.getUnitSymbol() ); 638 maybeSetAttribute( dimNode, "default", dim.getDefaultValue() ); 639 maybeSetAttribute( dimNode, "current", dim.isCurrent() ? "1" : null ); 640 maybeSetAttribute( dimNode, "nearestValue", dim.isNearestValue() ? "1" : null ); 641 maybeSetAttribute( dimNode, "multipleValues", dim.isMultipleValues() ? "1" : null ); 642 } 643 644 /** 645 * @param root 646 * @param lBox 647 */ 648 protected static void appendLayerBoundingBox( Element root, LayerBoundingBox lBox ) { 649 Element bbNode = XMLTools.appendElement( root, WMSNS, PWMS + "BoundingBox" ); 650 if ( lBox.getSRS().equalsIgnoreCase( "EPSG:4326" ) ) { 651 bbNode.setAttribute( "miny", "" + lBox.getMin().getX() ); 652 bbNode.setAttribute( "minx", "" + lBox.getMin().getY() ); 653 bbNode.setAttribute( "maxy", "" + lBox.getMax().getX() ); 654 bbNode.setAttribute( "maxx", "" + lBox.getMax().getY() ); 655 bbNode.setAttribute( "resx", "" + lBox.getResx() ); 656 bbNode.setAttribute( "resy", "" + lBox.getResy() ); 657 bbNode.setAttribute( "CRS", "" + lBox.getSRS() ); 658 } else { 659 bbNode.setAttribute( "minx", "" + lBox.getMin().getX() ); 660 bbNode.setAttribute( "miny", "" + lBox.getMin().getY() ); 661 bbNode.setAttribute( "maxx", "" + lBox.getMax().getX() ); 662 bbNode.setAttribute( "maxy", "" + lBox.getMax().getY() ); 663 bbNode.setAttribute( "resx", "" + lBox.getResx() ); 664 bbNode.setAttribute( "resy", "" + lBox.getResy() ); 665 bbNode.setAttribute( "CRS", "" + lBox.getSRS() ); 666 } 667 } 668 669 /** 670 * @param root 671 * @param llBox 672 */ 673 protected static void appendLatLonBoundingBox( Element root, Envelope llBox ) { 674 Element bbNode = XMLTools.appendElement( root, WMSNS, PWMS + "EX_GeographicBoundingBox" ); 675 XMLTools.appendElement( bbNode, WMSNS, PWMS + "westBoundLongitude", "" + llBox.getMin().getX() ); 676 XMLTools.appendElement( bbNode, WMSNS, PWMS + "eastBoundLongitude", "" + llBox.getMax().getX() ); 677 XMLTools.appendElement( bbNode, WMSNS, PWMS + "southBoundLatitude", "" + llBox.getMin().getY() ); 678 XMLTools.appendElement( bbNode, WMSNS, PWMS + "northBoundLatitude", "" + llBox.getMax().getY() ); 679 } 680 681 }