001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/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 08:22:25 -0800 (Thu, 27 Dec 2007) $
101: */
102:
103: public class XMLFactory_1_3_0 extends XMLFactory {
104: private static final ILogger LOG = LoggerFactory
105: .getLogger(XMLFactory.class);
106:
107: private static NamespaceContext nsContext = CommonNamespaces
108: .getNamespaceContext();
109:
110: private static final String PWMS = CommonNamespaces.WMS_PREFIX
111: + ":";
112:
113: private static final URI WMSNS = CommonNamespaces.WMSNS;
114:
115: /**
116: * Builds a 1.3.0 WMS capabilities document.
117: *
118: * @param capabilities
119: * @return the XML document
120: * @throws IOException
121: */
122: public static WMSCapabilitiesDocument_1_3_0 export(
123: WMSCapabilities_1_3_0 capabilities) throws IOException {
124: WMSCapabilitiesDocument_1_3_0 capabilitiesDocument = new WMSCapabilitiesDocument_1_3_0();
125: try {
126: capabilitiesDocument.createEmptyDocument();
127:
128: Element root = capabilitiesDocument.getRootElement();
129:
130: root.setAttribute("version", "1.3.0");
131: root.setAttribute("updateSequence", capabilities
132: .getUpdateSequence());
133:
134: appendService(root,
135: capabilities.getServiceIdentification(),
136: capabilities.getServiceProvider());
137:
138: appendCapabilityRequests(root, capabilities
139: .getOperationMetadata());
140:
141: appendCapabilityLayer((Element) XMLTools.getNode(root, PWMS
142: + "Capability", nsContext), capabilities.getLayer());
143:
144: Element exc = XMLTools.getRequiredElement(root, PWMS
145: + "Capability/" + PWMS + "Exception", nsContext);
146: for (String f : capabilities.getExceptions()) {
147: XMLTools.appendElement(exc, WMSNS, PWMS + "Format", f);
148: }
149:
150: Element serviceElement = (Element) XMLTools
151: .getRequiredNode(root, PWMS + "Service", nsContext);
152:
153: if (capabilities.getLayerLimit() != 0)
154: XMLTools
155: .appendElement(serviceElement, WMSNS,
156: "LayerLimit", ""
157: + capabilities.getLayerLimit());
158:
159: if (capabilities.getMaxWidth() != 0)
160: XMLTools.appendElement(serviceElement, WMSNS,
161: "MaxWidth", "" + capabilities.getMaxWidth());
162:
163: if (capabilities.getMaxHeight() != 0)
164: XMLTools.appendElement(serviceElement, WMSNS,
165: "MaxHeight", "" + capabilities.getMaxHeight());
166: } catch (SAXException e) {
167: LOG.logError(e.getMessage(), e);
168: } catch (XMLParsingException e) {
169: LOG.logError(e.getMessage(), e);
170: }
171:
172: return capabilitiesDocument;
173: }
174:
175: private static String boolean2Number(boolean bool) {
176: if (bool) {
177: return "1";
178: }
179: return "0";
180: }
181:
182: /**
183: *
184: * @param root
185: * @param identification
186: * @param provider
187: * @throws XMLParsingException
188: */
189: protected static void appendService(Element root,
190: ServiceIdentification identification,
191: ServiceProvider provider) throws XMLParsingException {
192:
193: root = (Element) XMLTools.getRequiredNode(root, PWMS
194: + "Service", nsContext);
195:
196: Element node = (Element) XMLTools.getRequiredNode(root, PWMS
197: + "Name", nsContext);
198: node.setTextContent(identification.getServiceType().getCode());
199:
200: node = (Element) XMLTools.getRequiredNode(root, PWMS + "Title",
201: nsContext);
202: node.setTextContent(identification.getTitle());
203:
204: String serviceAbstract = identification.getAbstractString();
205: if (serviceAbstract != null) {
206: XMLTools.appendElement(root, WMSNS, PWMS + "Abstract",
207: serviceAbstract);
208: }
209:
210: List<Keywords> keywords = identification.getKeywords();
211: if (keywords.size() > 0) {
212: String[] kw = keywords.get(0).getKeywords();
213: Element kwl = XMLTools.appendElement(root, WMSNS, PWMS
214: + "KeywordList");
215: for (int i = 0; i < kw.length; i++) {
216: XMLTools.appendElement(kwl, WMSNS, PWMS + "Keyword",
217: kw[i]);
218: }
219: }
220:
221: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
222: + "OnlineResource");
223: OnlineResource sLink = provider.getProviderSite();
224: org.deegree.model.metadata.iso19115.XMLFactory
225: .appendOnlineResource(elem, sLink);
226:
227: appendContactInformation(root, provider);
228:
229: String fee = null;
230: if (identification.getAccessConstraints().size() > 0)
231: fee = identification.getAccessConstraints().get(0)
232: .getFees();
233: if (fee != null) {
234: XMLTools.appendElement(root, WMSNS, PWMS + "Fees", fee);
235: } else {
236: XMLTools.appendElement(root, WMSNS, PWMS + "Fees", "none");
237: }
238:
239: if (identification.getAccessConstraints().size() > 0) {
240: XMLTools.appendElement(root, WMSNS, PWMS
241: + "AccessConstraints", identification
242: .getAccessConstraints().get(0).getUseLimitations()
243: .get(0));
244: } else {
245: XMLTools.appendElement(root, WMSNS, PWMS
246: + "AccessConstraints", "none");
247: }
248:
249: }
250:
251: /**
252: *
253: * @param root
254: * @param provider
255: */
256: protected static void appendContactInformation(Element root,
257: ServiceProvider provider) {
258:
259: Element ciNode = XMLTools.appendElement(root, WMSNS, PWMS
260: + "ContactInformation");
261: Element cppNode = XMLTools.appendElement(ciNode, WMSNS, PWMS
262: + "ContactPersonPrimary");
263: if (provider.getServiceContact().getIndividualName().length > 0) {
264: XMLTools.appendElement(cppNode, WMSNS, PWMS
265: + "ContactPerson", provider.getServiceContact()
266: .getIndividualName()[0]);
267: }
268: if (provider.getServiceContact().getOrganisationName().length > 0) {
269: XMLTools.appendElement(cppNode, WMSNS, PWMS
270: + "ContactOrganization", provider
271: .getServiceContact().getOrganisationName()[0]);
272: }
273: if (provider.getServiceContact().getPositionName().length > 0) {
274: XMLTools.appendElement(ciNode, WMSNS, PWMS
275: + "ContactPosition", provider.getServiceContact()
276: .getPositionName()[0]);
277: }
278: Element caNode = XMLTools.appendElement(ciNode, WMSNS, PWMS
279: + "ContactAddress");
280:
281: XMLTools.appendElement(caNode, WMSNS, PWMS + "AddressType",
282: "postal");
283:
284: if (provider.getServiceContact().getContactInfo().length > 0) {
285: Address addr = provider.getServiceContact()
286: .getContactInfo()[0].getAddress();
287: String[] dp = addr.getDeliveryPoint();
288: if (dp.length > 0) {
289: XMLTools.appendElement(caNode, WMSNS, PWMS + "Address",
290: dp[0]);
291: }
292: if (addr.getCity() != null) {
293: XMLTools.appendElement(caNode, WMSNS, PWMS + "City",
294: addr.getCity());
295: }
296: if (addr.getAdministrativeArea() != null) {
297: XMLTools.appendElement(caNode, WMSNS, PWMS
298: + "StateOrProvince", addr
299: .getAdministrativeArea());
300: }
301: if (addr.getPostalCode() != null) {
302: XMLTools.appendElement(caNode, WMSNS,
303: PWMS + "PostCode", addr.getPostalCode());
304: }
305: if (addr.getCountry() != null) {
306: XMLTools.appendElement(caNode, WMSNS, PWMS + "Country",
307: addr.getCountry());
308: }
309:
310: Phone phone = provider.getServiceContact().getContactInfo()[0]
311: .getPhone();
312: if (phone.getVoice().length > 0) {
313: XMLTools.appendElement(ciNode, WMSNS, PWMS
314: + "ContactVoiceTelephone", phone.getVoice()[0]);
315: }
316: if (phone.getFacsimile().length > 0) {
317: XMLTools.appendElement(ciNode, WMSNS, PWMS
318: + "ContactFacsimileTelephone", phone
319: .getFacsimile()[0]);
320: }
321: if (addr.getElectronicMailAddress().length > 0) {
322: XMLTools.appendElement(ciNode, WMSNS, PWMS
323: + "ContactElectronicMailAddress", addr
324: .getElectronicMailAddress()[0]);
325: }
326: }
327:
328: }
329:
330: /**
331: *
332: * @param root
333: * @param operationsMetadata
334: * @throws XMLParsingException
335: */
336: protected static void appendCapabilityRequests(Element root,
337: OperationsMetadata operationsMetadata)
338: throws XMLParsingException {
339:
340: root = (Element) XMLTools.getRequiredNode(root, PWMS
341: + "Capability/" + PWMS + "Request", nsContext);
342:
343: operationsMetadata.getOperations();
344:
345: // just append all operations
346: for (Operation operation : operationsMetadata.getOperations()) {
347: appendOperation(root, operation);
348: }
349:
350: // maybe we have to check for mandatory operations?
351:
352: }
353:
354: /**
355: *
356: * @param root
357: * @param operation
358: */
359: protected static void appendOperation(Element root,
360: Operation operation) {
361:
362: String name = operation.getName().getPrefixedName();
363:
364: if ("sld:GetLegendGraphic".equals(name)) {
365: root = XMLTools.appendElement(root, CommonNamespaces.SLDNS,
366: name);
367: // root.setAttribute( "xsi:type", "wms:_ExtendedOperation" );
368: } else {
369: root = XMLTools.appendElement(root, WMSNS, name);
370: }
371:
372: DomainType odt = (DomainType) operation
373: .getParameter(new QualifiedName("Format"));
374:
375: List<TypedLiteral> values = odt.getValues();
376: for (TypedLiteral value : values)
377: XMLTools.appendElement(root, WMSNS, PWMS + "Format", value
378: .getValue());
379:
380: List<DCP> dcps = operation.getDCP();
381: for (DCP dcp : dcps) {
382: Element http = XMLTools.appendElement(root, WMSNS, PWMS
383: + "DCPType");
384: http = XMLTools.appendElement(http, WMSNS, PWMS + "HTTP");
385: HTTP ht = (HTTP) dcp;
386: List<HTTP.Type> types = ht.getTypes();
387: List<OnlineResource> links = ht.getLinks();
388: for (int i = 0; i < types.size(); ++i) {
389: Element elem = null;
390: if (types.get(i) == HTTP.Type.Get)
391: elem = XMLTools.appendElement(http, WMSNS, PWMS
392: + "Get");
393: if (types.get(i) == HTTP.Type.Post)
394: elem = XMLTools.appendElement(http, WMSNS, PWMS
395: + "Post");
396: if (elem != null) {
397: elem = XMLTools.appendElement(elem, WMSNS, PWMS
398: + "OnlineResource");
399: org.deegree.model.metadata.iso19115.XMLFactory
400: .appendOnlineResource(elem, links.get(i));
401: }
402: }
403: }
404:
405: }
406:
407: // /**
408: // * @param http
409: // * @param urls
410: // */
411: // protected static void appendURLs( Element http, URL[] urls, String type ) {
412: // for ( int j = 0; j < urls.length; j++ ) {
413: // Element olr = XMLTools.appendElement( http, null, type );
414: // appendOnlineResource( olr, urls[j], "Get".equalsIgnoreCase( type ) );
415: // }
416: // }
417:
418: /**
419: *
420: * @param root
421: * @param layer
422: * @throws XMLParsingException
423: */
424: protected static void appendCapabilityLayer(Element root,
425: Layer layer) throws XMLParsingException {
426:
427: root = XMLTools.appendElement(root, WMSNS, PWMS + "Layer");
428: root.setAttribute("queryable", boolean2Number(layer
429: .isQueryable()));
430: root.setAttribute("cascaded", Integer.toString(layer
431: .getCascaded()));
432: root.setAttribute("opaque", boolean2Number(layer.isOpaque()));
433: root.setAttribute("noSubsets", boolean2Number(layer
434: .hasNoSubsets()));
435: if (layer.getFixedWidth() > 0) {
436: root.setAttribute("fixedWidth", Integer.toString(layer
437: .getFixedWidth()));
438: }
439: if (layer.getFixedHeight() > 0) {
440: root.setAttribute("fixedHeight", Integer.toString(layer
441: .getFixedHeight()));
442: }
443:
444: if (layer.getName() != null) {
445: XMLTools.appendElement(root, WMSNS, PWMS + "Name", layer
446: .getName());
447: }
448: XMLTools.appendElement(root, WMSNS, PWMS + "Title", layer
449: .getTitle());
450:
451: if (layer.getAbstract() != null) {
452: XMLTools.appendElement(root, WMSNS, PWMS + "Abstract",
453: layer.getAbstract());
454: }
455:
456: String[] keywords = layer.getKeywordList();
457: if (keywords.length > 0) {
458: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
459: + "KeywordList");
460: for (int i = 0; i < keywords.length; i++) {
461: XMLTools.appendElement(elem, WMSNS, PWMS + "Keyword",
462: keywords[i]);
463: }
464: }
465:
466: String[] srs = layer.getSrs();
467: for (int i = 0; i < srs.length; i++) {
468: XMLTools.appendElement(root, WMSNS, PWMS + "CRS", srs[i]);
469: }
470:
471: Envelope llBox = layer.getLatLonBoundingBox();
472: appendLatLonBoundingBox(root, llBox);
473:
474: LayerBoundingBox[] lBoxes = layer.getBoundingBoxes();
475: for (int i = 0; i < lBoxes.length; i++) {
476: appendLayerBoundingBox(root, lBoxes[i]);
477: }
478:
479: Dimension[] dims = layer.getDimension();
480: for (int i = 0; i < dims.length; i++) {
481: appendDimension(root, dims[i]);
482: }
483:
484: Extent[] extents = layer.getExtent();
485: for (int i = 0; i < extents.length; i++) {
486: appendExtent(root, extents[i]);
487: }
488:
489: Attribution attr = layer.getAttribution();
490: if (attr != null) {
491: appendAttribution(root, attr);
492: }
493:
494: AuthorityURL[] authorityURLs = layer.getAuthorityURL();
495: for (int i = 0; i < authorityURLs.length; i++) {
496: appendAuthorityURL(root, authorityURLs[i]);
497: }
498:
499: Identifier[] identifiers = layer.getIdentifier();
500: for (int i = 0; i < identifiers.length; i++) {
501: appendIdentifier(root, identifiers[i]);
502: }
503:
504: MetadataURL[] metadataURLs = layer.getMetadataURL();
505: for (int i = 0; i < metadataURLs.length; i++) {
506: appendMetadataURL(root, metadataURLs[i]);
507: }
508:
509: DataURL[] dataURLs = layer.getDataURL();
510: for (int i = 0; i < dataURLs.length; i++) {
511: appendDataURL(root, dataURLs[i]);
512: }
513:
514: FeatureListURL[] featureListURLs = layer.getFeatureListURL();
515: for (int i = 0; i < featureListURLs.length; i++) {
516: appendFeatureListURL(root, featureListURLs[i]);
517: }
518:
519: if (layer.getName() != null && layer.getName().length() > 0) {
520: Style[] styles = layer.getStyles();
521: for (int i = 0; i < styles.length; i++) {
522: appendStyle(root, styles[i]);
523: }
524: }
525:
526: ScaleHint scaleHint = layer.getScaleHint();
527: XMLTools.appendElement(root, WMSNS, PWMS
528: + "MinScaleDenominator", "" + scaleHint.getMin());
529: XMLTools.appendElement(root, WMSNS, PWMS
530: + "MaxScaleDenominator", "" + scaleHint.getMax());
531:
532: Layer[] layers = layer.getLayer();
533: for (int i = 0; i < layers.length; i++) {
534: appendCapabilityLayer(root, layers[i]);
535: }
536:
537: }
538:
539: /**
540: *
541: * @param root
542: * @param style
543: */
544: protected static void appendStyle(Element root, Style style) {
545:
546: String nm = style.getName();
547: String tlt = style.getTitle();
548: if (nm.startsWith("default:")) {
549: nm = "default";
550: if (tlt != null) {
551: tlt = StringTools.replace(tlt, "default:", "", false)
552: + " (default)";
553: }
554: }
555:
556: root = XMLTools.appendElement(root, WMSNS, PWMS + "Style");
557: XMLTools.appendElement(root, WMSNS, PWMS + "Name", nm);
558: if (style.getTitle() != null) {
559: XMLTools.appendElement(root, WMSNS, PWMS + "Title", tlt);
560: }
561: if (style.getAbstract() != null) {
562: XMLTools.appendElement(root, WMSNS, PWMS + "Abstract",
563: style.getAbstract());
564: }
565: LegendURL[] legendURLs = style.getLegendURL();
566:
567: for (int i = 0; i < legendURLs.length; i++) {
568: appendLegendURL(root, legendURLs[i]);
569: }
570:
571: StyleSheetURL styleSheetURL = style.getStyleSheetURL();
572: if (styleSheetURL != null) {
573: appendStyleSheetURL(root, styleSheetURL);
574: }
575:
576: StyleURL styleURL = style.getStyleURL();
577: if (styleURL != null) {
578: appendStyleURL(root, styleURL);
579: }
580:
581: }
582:
583: /**
584: * @param root
585: * @param styleURL
586: */
587: protected static void appendStyleURL(Element root, StyleURL styleURL) {
588: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
589: + "StyleURL");
590: XMLTools.appendElement(elem, WMSNS, PWMS + "Format", styleURL
591: .getFormat());
592: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
593: + "OnlineResource");
594: org.deegree.model.metadata.iso19115.XMLFactory
595: .appendOnlineResource(res, styleURL.getOnlineResource());
596: }
597:
598: /**
599: * @param root
600: * @param styleSheetURL
601: */
602: protected static void appendStyleSheetURL(Element root,
603: StyleSheetURL styleSheetURL) {
604: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
605: + "StyleSheetURL");
606: XMLTools.appendElement(elem, WMSNS, PWMS + "Format",
607: styleSheetURL.getFormat());
608: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
609: + "OnlineResource");
610: org.deegree.model.metadata.iso19115.XMLFactory
611: .appendOnlineResource(res, styleSheetURL
612: .getOnlineResource());
613: }
614:
615: /**
616: * @param root
617: * @param legendURL
618: */
619: protected static void appendLegendURL(Element root,
620: LegendURL legendURL) {
621: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
622: + "LegendURL");
623: elem.setAttribute("width", "" + legendURL.getWidth());
624: elem.setAttribute("height", "" + legendURL.getWidth());
625: XMLTools.appendElement(elem, WMSNS, PWMS + "Format", legendURL
626: .getFormat());
627:
628: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
629: + "OnlineResource");
630: org.deegree.model.metadata.iso19115.XMLFactory
631: .appendOnlineResource(res, legendURL
632: .getOnlineResource());
633: }
634:
635: /**
636: * @param root
637: * @param featureListURL
638: */
639: protected static void appendFeatureListURL(Element root,
640: FeatureListURL featureListURL) {
641: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
642: + "FeatureListURL");
643: XMLTools.appendElement(elem, WMSNS, PWMS + "Format",
644: featureListURL.getFormat());
645: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
646: + "OnlineResource");
647: org.deegree.model.metadata.iso19115.XMLFactory
648: .appendOnlineResource(res, featureListURL
649: .getOnlineResource());
650: }
651:
652: /**
653: * @param root
654: * @param dataURL
655: */
656: protected static void appendDataURL(Element root, DataURL dataURL) {
657: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
658: + "DataURL");
659: XMLTools.appendElement(elem, WMSNS, PWMS + "Format", dataURL
660: .getFormat());
661: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
662: + "OnlineResource");
663: org.deegree.model.metadata.iso19115.XMLFactory
664: .appendOnlineResource(res, dataURL.getOnlineResource());
665: }
666:
667: /**
668: * @param root
669: * @param metadataURL
670: */
671: protected static void appendMetadataURL(Element root,
672: MetadataURL metadataURL) {
673: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
674: + "MetadataURL");
675: elem.setAttribute("type", metadataURL.getType());
676: XMLTools.appendElement(elem, WMSNS, PWMS + "Format",
677: metadataURL.getFormat());
678: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
679: + "OnlineResource");
680: org.deegree.model.metadata.iso19115.XMLFactory
681: .appendOnlineResource(res, metadataURL
682: .getOnlineResource());
683: }
684:
685: /**
686: * @param root
687: * @param identifier
688: */
689: protected static void appendIdentifier(Element root,
690: Identifier identifier) {
691: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
692: + "Identifier");
693: elem.setAttribute("authority", identifier.getAuthority());
694: elem.setTextContent(identifier.getValue());
695: }
696:
697: /**
698: * @param root
699: * @param authorityURL
700: */
701: protected static void appendAuthorityURL(Element root,
702: AuthorityURL authorityURL) {
703: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
704: + "AuthorityURL");
705: elem.setAttribute("name", authorityURL.getName());
706: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
707: + "OnlineResource");
708: org.deegree.model.metadata.iso19115.XMLFactory
709: .appendOnlineResource(res, authorityURL
710: .getOnlineResource());
711: }
712:
713: /**
714: * @param root
715: * @param attr
716: */
717: protected static void appendAttribution(Element root,
718: Attribution attr) {
719: Element elem = XMLTools.appendElement(root, WMSNS, PWMS
720: + "Attribution");
721: XMLTools.appendElement(elem, WMSNS, PWMS + "Title", attr
722: .getTitle());
723: Element res = XMLTools.appendElement(elem, WMSNS, PWMS
724: + "OnlineResource");
725: org.deegree.model.metadata.iso19115.XMLFactory
726: .appendOnlineResource(res, attr.getOnlineResource());
727: LogoURL logoURL = attr.getLogoURL();
728: if (logoURL != null) {
729: elem = XMLTools
730: .appendElement(elem, WMSNS, PWMS + "LogoURL");
731: elem.setAttribute("width", "" + logoURL.getWidth());
732: elem.setAttribute("height", "" + logoURL.getHeight());
733: XMLTools.appendElement(elem, WMSNS, PWMS + "Format",
734: logoURL.getFormat());
735: res = XMLTools.appendElement(elem, WMSNS, PWMS
736: + "OnlineResource");
737: org.deegree.model.metadata.iso19115.XMLFactory
738: .appendOnlineResource(res, logoURL
739: .getOnlineResource());
740: }
741: }
742:
743: /**
744: * @param root
745: * @param extent
746: */
747: protected static void appendExtent(Element root, Extent extent) {
748: Element exNode = XMLTools.appendElement(root, WMSNS, PWMS
749: + "Extent");
750: exNode.setAttribute("name", extent.getName());
751: exNode.setAttribute("default", extent.getDefault());
752: exNode.setAttribute("nearestValue", boolean2Number(extent
753: .useNearestValue()));
754: exNode.setTextContent(extent.getValue());
755: }
756:
757: /**
758: * @param root
759: * @param dim
760: */
761: protected static void appendDimension(Element root, Dimension dim) {
762: Element dimNode = XMLTools.appendElement(root, WMSNS, PWMS
763: + "Dimension");
764: dimNode.setAttribute("name", dim.getName());
765: dimNode.setAttribute("units", dim.getUnits());
766: dimNode.setAttribute("unitSymbol", dim.getUnitSymbol());
767: }
768:
769: /**
770: * @param root
771: * @param lBox
772: */
773: protected static void appendLayerBoundingBox(Element root,
774: LayerBoundingBox lBox) {
775: Element bbNode = XMLTools.appendElement(root, WMSNS, PWMS
776: + "BoundingBox");
777: if (lBox.getSRS().startsWith("EPSG")) {
778: bbNode.setAttribute("miny", "" + lBox.getMin().getX());
779: bbNode.setAttribute("minx", "" + lBox.getMin().getY());
780: bbNode.setAttribute("maxy", "" + lBox.getMax().getX());
781: bbNode.setAttribute("maxx", "" + lBox.getMax().getY());
782: bbNode.setAttribute("resx", "" + lBox.getResx());
783: bbNode.setAttribute("resy", "" + lBox.getResy());
784: bbNode.setAttribute("CRS", "" + lBox.getSRS());
785: } else {
786: bbNode.setAttribute("minx", "" + lBox.getMin().getX());
787: bbNode.setAttribute("miny", "" + lBox.getMin().getY());
788: bbNode.setAttribute("maxx", "" + lBox.getMax().getX());
789: bbNode.setAttribute("maxy", "" + lBox.getMax().getY());
790: bbNode.setAttribute("resx", "" + lBox.getResx());
791: bbNode.setAttribute("resy", "" + lBox.getResy());
792: bbNode.setAttribute("CRS", "" + lBox.getSRS());
793: }
794: }
795:
796: /**
797: * @param root
798: * @param llBox
799: */
800: protected static void appendLatLonBoundingBox(Element root,
801: Envelope llBox) {
802: Element bbNode = XMLTools.appendElement(root, WMSNS, PWMS
803: + "EX_GeographicBoundingBox");
804: XMLTools.appendElement(bbNode, WMSNS, PWMS
805: + "westBoundLongitude", "" + llBox.getMin().getX());
806: XMLTools.appendElement(bbNode, WMSNS, PWMS
807: + "eastBoundLongitude", "" + llBox.getMax().getX());
808: XMLTools.appendElement(bbNode, WMSNS, PWMS
809: + "southBoundLatitude", "" + llBox.getMin().getY());
810: XMLTools.appendElement(bbNode, WMSNS, PWMS
811: + "northBoundLatitude", "" + llBox.getMax().getY());
812: }
813:
814: }
|