Gets the right url (#608 / 3)
This commit is contained in:
@@ -169,11 +169,25 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
|
||||
}
|
||||
}
|
||||
|
||||
var url;
|
||||
if (requestEncoding === "REST" && layerDef.resourceUrl) {
|
||||
url = layerDef.resourceUrl.tile.template;
|
||||
}
|
||||
else {
|
||||
var httpGet = capabilities.operationsMetadata.GetTile.dcp.http.get;
|
||||
url = httpGet[0].url;
|
||||
for (var i = 0, ii = httpGet.length; i < ii; i++) {
|
||||
if (httpGet[i].constraints && httpGet[i].constraints.
|
||||
GetEncoding.allowedValues[requestEncoding]) {
|
||||
url = httpGet[i].url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new OpenLayers.Layer.WMTS(
|
||||
OpenLayers.Util.applyDefaults(config, {
|
||||
url: requestEncoding === "REST" && layerDef.resourceUrl ?
|
||||
layerDef.resourceUrl.tile.template :
|
||||
capabilities.operationsMetadata.GetTile.dcp.http.get[0].url,
|
||||
url: url,
|
||||
requestEncoding: requestEncoding,
|
||||
name: layerDef.title,
|
||||
style: style.identifier,
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
}
|
||||
|
||||
function test_createLayer(t) {
|
||||
t.plan(34);
|
||||
t.plan(38);
|
||||
|
||||
var format = new OpenLayers.Format.WMTSCapabilities();
|
||||
|
||||
@@ -261,6 +261,39 @@
|
||||
});
|
||||
t.eq(layer.projection.getCode(), "EPSG:900913", "correct projection");
|
||||
t.eq(layer.units, "degrees", "correct units");
|
||||
|
||||
|
||||
// test get the right url #608/3
|
||||
xml = document.getElementById("multi-getile-1").firstChild.nodeValue;
|
||||
doc = new OpenLayers.Format.XML().read(xml);
|
||||
caps = format.read(doc);
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
|
||||
matrixSet: "21781",
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
t.eq(layer.url, "http://wmts.geo.admin.ch/rest", "correct rest url 1");
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
|
||||
matrixSet: "21781",
|
||||
requestEncoding: 'KVP'
|
||||
});
|
||||
t.eq(layer.url, "http://wmts.geo.admin.ch/kvp", "correct kvp url 2");
|
||||
xml = document.getElementById("multi-getile-2").firstChild.nodeValue;
|
||||
doc = new OpenLayers.Format.XML().read(xml);
|
||||
caps = format.read(doc);
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
|
||||
matrixSet: "21781",
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
t.eq(layer.url, "http://wmts.geo.admin.ch/rest", "correct rest url 2");
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
|
||||
matrixSet: "21781",
|
||||
requestEncoding: 'KVP'
|
||||
});
|
||||
t.eq(layer.url, "http://wmts.geo.admin.ch/kvp", "correct kvp url 2");
|
||||
}
|
||||
|
||||
function test_parse_projection(t) {
|
||||
@@ -733,5 +766,167 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml
|
||||
</Capabilities>
|
||||
--></div>
|
||||
|
||||
<div id="multi-getile-1"><!--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
|
||||
<ows:OperationsMetadata>
|
||||
<ows:Operation name="GetCapabilities">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>REST</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
<ows:Operation name="GetTile">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://wmts.geo.admin.ch/rest">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>REST</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
<ows:Get xlink:href="http://wmts.geo.admin.ch/kvp">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>KVP</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
</ows:OperationsMetadata>
|
||||
<Contents>
|
||||
<Layer>
|
||||
<ows:Title>Agglomérations et villes isolées</ows:Title>
|
||||
<ows:Abstract>Les agglomérations et villes isolées (communes non rattachées à une agglomération et comptant au moins 10`000 habitants) font partie des régions d’analyse de la statistique suisse. Ce niveau géographique est défini depuis plus de 100 ans, afin de mesurer l’urbanisation, phénomène fondamental structurant l’organisation du territoire. Sa fonction principale est de permettre une comparaison spatiale entre des espaces urbains inégalement délimités sur le plan institutionnel. Une version ancienne est appliquée pour la première fois en 1930, puis révisée en 1984 et 1990, toujours sur la base des recensements de la population. La version actuelle classe les 2896 communes de Suisse (état 2000) selon leur appartenance ou pas à une agglomération ou ville isolée en fonction de critères statistiques (Etat et évolution de la population, lien de continuité de la zone bâtie, rapport entre population active occupée et population résidante, structure économique et flux de pendulaires). Les agglomérations et les villes isolées forment l`espace urbain, les territoires restant l`espace rural. La définition des agglomérations de l’OFS n’a pas valeur d’obligation légale.</ows:Abstract>
|
||||
<ows:WGS84BoundingBox>
|
||||
<ows:LowerCorner>5.140242 45.398181</ows:LowerCorner>
|
||||
<ows:UpperCorner>11.47757 48.230651</ows:UpperCorner>
|
||||
</ows:WGS84BoundingBox>
|
||||
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
|
||||
<ows:Metadata xlink:href="http://www.swisstopo.admin.ch/SITiled/world/AdminBoundaries/metadata.htm"/>
|
||||
<Style>
|
||||
<ows:Title>Agglomérations et villes isolées</ows:Title>
|
||||
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
|
||||
<LegendURL format="image/png" xlink:href="http://api.geo.admin.ch/legend/ch.are.agglomerationen_isolierte_staedte-2000_fr.png" />
|
||||
</Style>
|
||||
<Format>image/png</Format>
|
||||
<Dimension>
|
||||
<ows:Identifier>Time</ows:Identifier>
|
||||
<Default>20090101</Default>
|
||||
<Value>20090101</Value>
|
||||
</Dimension>
|
||||
<TileMatrixSetLink>
|
||||
<TileMatrixSet>21781</TileMatrixSet>
|
||||
</TileMatrixSetLink>
|
||||
</Layer>
|
||||
<TileMatrixSet>
|
||||
<ows:Identifier>21781</ows:Identifier>
|
||||
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:1.0:21781</ows:SupportedCRS>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>0</ows:Identifier>
|
||||
<ScaleDenominator>14285750.5715</ScaleDenominator>
|
||||
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>1</MatrixWidth>
|
||||
<MatrixHeight>1</MatrixHeight>
|
||||
</TileMatrix>
|
||||
</TileMatrixSet>
|
||||
</Contents>
|
||||
<ServiceMetadataURL xlink:href="http://www.opengis.uab.es/SITiled/world/1.0.0/WMTSCapabilities.xml"/>
|
||||
</Capabilities>
|
||||
--></div>
|
||||
|
||||
<div id="multi-getile-2"><!--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
|
||||
<ows:OperationsMetadata>
|
||||
<ows:Operation name="GetCapabilities">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>REST</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
<ows:Operation name="GetTile">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://wmts.geo.admin.ch/kvp">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>KVP</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
<ows:Get xlink:href="http://wmts.geo.admin.ch/rest">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>REST</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
</ows:OperationsMetadata>
|
||||
<Contents>
|
||||
<Layer>
|
||||
<ows:Title>Agglomérations et villes isolées</ows:Title>
|
||||
<ows:Abstract>Les agglomérations et villes isolées (communes non rattachées à une agglomération et comptant au moins 10`000 habitants) font partie des régions d’analyse de la statistique suisse. Ce niveau géographique est défini depuis plus de 100 ans, afin de mesurer l’urbanisation, phénomène fondamental structurant l’organisation du territoire. Sa fonction principale est de permettre une comparaison spatiale entre des espaces urbains inégalement délimités sur le plan institutionnel. Une version ancienne est appliquée pour la première fois en 1930, puis révisée en 1984 et 1990, toujours sur la base des recensements de la population. La version actuelle classe les 2896 communes de Suisse (état 2000) selon leur appartenance ou pas à une agglomération ou ville isolée en fonction de critères statistiques (Etat et évolution de la population, lien de continuité de la zone bâtie, rapport entre population active occupée et population résidante, structure économique et flux de pendulaires). Les agglomérations et les villes isolées forment l`espace urbain, les territoires restant l`espace rural. La définition des agglomérations de l’OFS n’a pas valeur d’obligation légale.</ows:Abstract>
|
||||
<ows:WGS84BoundingBox>
|
||||
<ows:LowerCorner>5.140242 45.398181</ows:LowerCorner>
|
||||
<ows:UpperCorner>11.47757 48.230651</ows:UpperCorner>
|
||||
</ows:WGS84BoundingBox>
|
||||
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
|
||||
<ows:Metadata xlink:href="http://www.swisstopo.admin.ch/SITiled/world/AdminBoundaries/metadata.htm"/>
|
||||
<Style>
|
||||
<ows:Title>Agglomérations et villes isolées</ows:Title>
|
||||
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
|
||||
<LegendURL format="image/png" xlink:href="http://api.geo.admin.ch/legend/ch.are.agglomerationen_isolierte_staedte-2000_fr.png" />
|
||||
</Style>
|
||||
<Format>image/png</Format>
|
||||
<Dimension>
|
||||
<ows:Identifier>Time</ows:Identifier>
|
||||
<Default>20090101</Default>
|
||||
<Value>20090101</Value>
|
||||
</Dimension>
|
||||
<TileMatrixSetLink>
|
||||
<TileMatrixSet>21781</TileMatrixSet>
|
||||
</TileMatrixSetLink>
|
||||
</Layer>
|
||||
<TileMatrixSet>
|
||||
<ows:Identifier>21781</ows:Identifier>
|
||||
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:1.0:21781</ows:SupportedCRS>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>0</ows:Identifier>
|
||||
<ScaleDenominator>14285750.5715</ScaleDenominator>
|
||||
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>1</MatrixWidth>
|
||||
<MatrixHeight>1</MatrixHeight>
|
||||
</TileMatrix>
|
||||
</TileMatrixSet>
|
||||
</Contents>
|
||||
<ServiceMetadataURL xlink:href="http://www.opengis.uab.es/SITiled/world/1.0.0/WMTSCapabilities.xml"/>
|
||||
</Capabilities>
|
||||
--></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user