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