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