/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the Clear BSD license. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ /** * @requires Geoportal/Format/WMC.js */ /** * Class: Geoportal.Format.WMC.v1_1_0_AutoConf * Read and write WMC version 1.1.0. * * Inherits from: * - * - */ Geoportal.Format.WMC.v1_1_0_AutoConf = OpenLayers.Class( Geoportal.Format.WMC, OpenLayers.Format.WMC.v1_1_0, { /** * APIProperty: profile * {String} If provided, use a custom profile. */ profile: "AutoConf", /** * Property: schemaLocation * {String} http://www.opengis.net/context * http://schemas.opengis.net/context/1.1.0/context.xsd */ schemaLocation: "http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd", /** * Constructor: Geoportal.Format.WMC.v1_1_0_AutoConf * Create a new parser for Geoportal Context document. * * Parameters: * options - {Object} An optional object whose properties will be set on * this instance. */ initialize: function(options) { OpenLayers.Format.WMC.v1_1_0.prototype.initialize.apply( this, [options] ); }, /** * Property: namespaces * {Object} Mapping of namespace aliases to namespace URIs. */ namespaces: { ol: "http://openlayers.org/context", wmc: "http://www.opengis.net/context", sld: "http://www.opengis.net/sld", xlink: "http://www.w3.org/1999/xlink", xsi: "http://www.w3.org/2001/XMLSchema-instance", wmts:"http://www.opengis.net/wmts/1.0", gpp: "http://api.ign.fr/geoportail" }, /** * Property: servicesMap * {Object} Mapping of service values (OGC:WMS, etc ...) to classes * (, etc ...). */ servicesMap:{ "OGC:WMTS" : OpenLayers.Layer.WMTS, "OGC:WFS" : OpenLayers.Layer.WFS }, /** * Method: read_gpp_GeneralType * Read a gpp:GeneralType node. * * Parameters: * context - {Object} An object representing a context. * node - {Element} An element node. */ read_gpp_GPP_GeneralType: function(context, node) { var generalType = {}; this.runChildNodes(generalType, node); context.generalType = generalType; }, read_gpp_GeneralType: function(context, node) { this.read_gpp_GPP_GeneralType(context, node); }, read_gpp_DefaultTerritory: function(generalType, node) { var territory = []; this.runChildNodes(territory, node); generalType.territory = territory; }, read_gpp_Territory: function(territories, node) { var territory={}; territory.name = node.getAttribute("name"); territory.id=node.getAttribute("id"); if (territory.name) { this.runChildNodes(territory, node); } territories.push(territory); }, read_gpp_defaultCRS: function(territory, node) { territory.defaultCRS = this.getChildValue(node).trim(); }, read_gpp_CRS: function(territory, node) { territory.CRS = this.getChildValue(node).trim(); }, read_gpp_WGS84BoundingBox: function(territory, node) { var bb = this.getChildValue(node).trim(); var bb_tab = bb.split(","); if (bb_tab.length != 4) { bb_tab = [-180,-90,180,90]; } else { bb_tab = [parseFloat(bb_tab[0]),parseFloat(bb_tab[1]),parseFloat(bb_tab[2]),parseFloat(bb_tab[3])]; } territory.boundingBox = bb_tab; }, read_gpp_Resolution: function(territory, node) { territory.resolution = parseFloat(this.getChildValue(node)); }, read_gpp_Center: function(territory, node) { var center = new OpenLayers.LonLat(); this.runChildNodes(center, node); territory.center = center; }, read_gpp_x: function(center, node) { center.lon=parseFloat(this.getChildValue(node)); }, read_gpp_y: function(center, node) { center.lat=parseFloat(this.getChildValue(node)); }, read_gpp_Theme: function(territory, node) { territory.theme = this.getChildValue(node).trim(); }, read_gpp_Territories:function(context, node) { var territories=[]; this.runChildNodes(territories, node); context.territories=territories; }, read_gpp_TileMatrixSets:function(context, node) { var tileMatrixSets=[]; var wmts = new OpenLayers.Format.WMTSCapabilities.v1_0_0({namespaces: { ows: "http://www.opengis.net/ows/2.0", wmts: "http://www.opengis.net/wmts/1.0", xlink: "http://www.w3.org/1999/xlink" }} ); var obj={}; obj.layers={}; obj.tileMatrixSets={}; var tmp=wmts.readChildNodes(node,obj); context.tileMatrixSets=tmp.tileMatrixSets; }, read_wmts_TileMatrixSetLink:function(context, node) { var tileMatrixSets=[]; var wmts = new OpenLayers.Format.WMTSCapabilities.v1_0_0({namespaces: { ows: "http://www.opengis.net/ows/2.0", wmts: "http://www.opengis.net/wmts/1.0", xlink: "http://www.w3.org/1999/xlink" }} ); var obj={}; context.tileMatrixSetLink=wmts.readChildNodes(node,obj); }, read_gpp_TileMatrixSet:function(tileMatrixSets, node) { var tileMatrixSet={}; this.runChildNodes(tileMatrixSet, node); tileMatrixSets.push(tileMatrixSet); }, read_gpp_Identifier:function(tileMatrixSet, node) { tileMatrixSet.identifier = this.getChildValue(node).trim(); }, read_gpp_DefaultLayers: function(context, node) { var defaultLayers={}; defaultLayers.layersContext=[]; this.runChildNodes(defaultLayers, node); context.defaultLayers=defaultLayers.layersContext; }, read_gpp_Layer: function(defaultLayers, node) { var layer={}; layer.formats=[]; this.runChildNodes(layer, node); defaultLayers.push(layer); }, read_gpp_GppLayer: function(layer, node) { //var gppLayer={}; layer.options=layer.options||{}; layer.options.order = node.getAttribute("order"); this.runChildNodes(layer.options, node); //layer.gppLayer=gppLayer; }, read_gpp_GppId: function(options, node) { options.Gppid = this.getChildValue(node).trim(); }, read_gpp_BoundingBox: function(options, node) { var box = this.getChildValue(node).split(','); options.boundingBox = new OpenLayers.Bounds(parseFloat(box[0]),parseFloat(box[1]),parseFloat(box[2]),parseFloat(box[3])); }, read_gpp_Originators: function(options, node) { var originators=[]; this.runChildNodes(originators, node); options.originators=originators; }, read_gpp_Originator: function(originators, node) { var originator={}; originator.name = node.getAttribute("name"); this.runChildNodes(originator, node); originators.push(originator); }, read_gpp_Logo: function(originator, node) { originator.pictureUrl = this.getChildValue(node).trim(); }, read_gpp_URL: function(originator, node) { originator.url = this.getChildValue(node).trim(); }, /** * Method : read_gpp_Attribution * Read the attribution property of an originator * * Parameters: * originator - {Object} An object representing an originator. * node - {Element} An element node. */ read_gpp_Attribution: function(originator, node) { originator.attribution = this.getChildValue(node).trim(); }, read_gpp_Constraints: function(originator, node) { var constraints=[]; this.runChildNodes(constraints, node); originator.constraints=constraints; }, read_gpp_Constraint: function(constraints, node) { var constraint={}; this.runChildNodes(constraint, node); constraints.push(constraint); }, read_gpp_QuickLook:function(originator, node) { originator.quickLook = this.getChildValue(node).trim(); }, read_gpp_Opacity:function(originator, node) { originator.opacity = parseFloat(this.getChildValue(node).trim()); }, read_gpp_Thematics: function(originator, node) { var thematics=[]; this.runChildNodes(thematics, node); originator.thematics=thematics; }, read_gpp_Thematic: function(thematics, node) { thematics.push(this.getChildValue(node).trim()); }, read_gpp_InspireThematic: function(originator, node) { originator.inspireThematic = this.getChildValue(node).trim(); }, read_gpp_Titles: function(layer, node) { var titles=[]; this.runChildNodes(titles, node); layer.titles=titles; }, read_gpp_Title: function(titles, node) { titles[node.getAttribute("I18N_LOCALE")]=this.getChildValue(node).trim(); }, read_gpp_Descriptions: function(layer, node) { var descriptions=[]; this.runChildNodes(descriptions, node); layer.descriptions=descriptions; }, read_gpp_Description: function(descriptions, node) { descriptions[node.getAttribute("I18N_LOCALE")]=this.getChildValue(node).trim(); }, read_ows_WGS84BoundingBox: function (a, node) { a.WGS84BoundingBox=this.getChildValue(node).trim(); }, read_gpp_Resolutions: function(territory, node) { territory.resolutions = []; var tab = this.getChildValue(node).trim().split(","); for (var x in tab) { territory.resolutions.push(parseFloat(tab[x].trim())); } }, /** * Method : read_gpp_Legends * Read a list of legends */ read_gpp_Legends: function(gppLayer, node) { gppLayer.legends = []; this.runChildNodes(gppLayer.legends, node); }, /** * Method : read_gpp_Legend * Read options of legend */ read_gpp_Legend: function(legends, node) { var legend = {}; this.runChildNodes(legend, node); if(legend.legend){ legend.legend.maxScale = legend.maxScale; legends.push(legend.legend); } }, /** * Method : read_gpp_Keys * Read a list of keys */ read_gpp_Keys: function(gppLayer, node) { gppLayer.keys = {}; this.runChildNodes(gppLayer.keys, node); }, /** * Method : read_gpp_key * Read one key of gpp:Keys node */ read_gpp_key: function(keys, node) { keys[node.getAttribute("id")] = this.getChildValue(node).trim(); }, /** * Method: read_gpp_OnlineResource */ read_gpp_OnlineResource: function(obj, node) { obj.url = this.getAttributeNS( node, this.namespaces.xlink, "href" ); }, /** * Method : read_gpp_Server * Read a server */ read_gpp_Server: function(services, node) { var server = {}; server.id = node.getAttribute("service"); server.name = node.getAttribute("title"); this.runChildNodes(server, node); services[server.id] = server; }, /** * Method : read_gpp_Services * Read a list of services */ read_gpp_Services: function(context, node) { var services = []; this.runChildNodes(services, node); context.services = services; }, CLASS_NAME: "Geoportal.Format.WMC.v1_1_0_AutoConf" });