Merge remote branch 'upstream/master'

This commit is contained in:
Éric Lemoine
2011-11-07 17:05:19 +01:00
9 changed files with 92 additions and 33 deletions

View File

@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Basic Bing Tiles with a Subset of Resolutions Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">

View File

@@ -3,7 +3,7 @@
<head>
<title>OpenLayers Canvas Hit Detection Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0;">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">

View File

@@ -3,7 +3,7 @@
<head>
<title>OpenLayers Undo/Redo Drawing Methods</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0;">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">

View File

@@ -3,7 +3,7 @@
<head>
<title>OpenLayers Editing Methods</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0;">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Point Grid Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Snap Grid Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">

View File

@@ -114,10 +114,13 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
layer = new OpenLayers.Layer.WMTS(
OpenLayers.Util.applyDefaults(config, {
url: capabilities.operationsMetadata.GetTile.dcp.http.get,
url: config.requestEncoding === "REST" && layerDef.resourceUrl ?
layerDef.resourceUrl.tile.template :
capabilities.operationsMetadata.GetTile.dcp.http.get,
name: layerDef.title,
style: style.identifier,
matrixIds: matrixSet.matrixIds
matrixIds: matrixSet.matrixIds,
tileFullExtent: matrixSet.bounds
})
);
}

View File

@@ -38,7 +38,10 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
/**
* APIProperty: url
* {String} The base URL for the WMTS service. Must be provided.
* {String|Array(String)} The base URL or request URL template for the WMTS
* service. Must be provided. Array is only supported for base URLs, not
* for request URL templates. URL templates are only supported for
* REST <requestEncoding>.
*/
url: null,
@@ -416,39 +419,59 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
var center = bounds.getCenterLonLat();
var info = this.getTileInfo(center);
var matrixId = this.matrix.identifier;
var dimensions = this.dimensions, params;
if (this.requestEncoding.toUpperCase() === "REST") {
// include 'version', 'layer' and 'style' in tile resource url
var path = this.version + "/" + this.layer + "/" + this.style + "/";
// append optional dimension path elements
if (this.dimensions) {
for (var i=0; i<this.dimensions.length; i++) {
if (this.params[this.dimensions[i]]) {
path = path + this.params[this.dimensions[i]] + "/";
params = this.params;
if (typeof this.url === "string" && this.url.indexOf("{") !== -1) {
var template = this.url.replace(/\{/g, "${");
var context = {
// spec does not make clear if capital S or not
style: this.style, Style: this.style,
TileMatrixSet: this.matrixSet,
TileMatrix: this.matrix.identifier,
TileRow: info.row,
TileCol: info.col
};
if (dimensions) {
var dimension, i;
for (i=dimensions.length-1; i>=0; --i) {
dimension = dimensions[i];
context[dimension] = params[dimension.toUpperCase()];
}
}
}
// append other required path elements
path = path + this.matrixSet + "/" + this.matrix.identifier +
"/" + info.row + "/" + info.col + "." + this.formatSuffix;
if (OpenLayers.Util.isArray(this.url)) {
url = this.selectUrl(path, this.url);
url = OpenLayers.String.format(template, context);
} else {
url = this.url;
}
if (!url.match(/\/$/)) {
url = url + "/";
}
url = url + path;
// include 'version', 'layer' and 'style' in tile resource url
var path = this.version + "/" + this.layer + "/" + this.style + "/";
// append optional dimension path elements
if (dimensions) {
for (var i=0; i<dimensions.length; i++) {
if (params[dimensions[i]]) {
path = path + params[dimensions[i]] + "/";
}
}
}
// append other required path elements
path = path + this.matrixSet + "/" + this.matrix.identifier +
"/" + info.row + "/" + info.col + "." + this.formatSuffix;
if (OpenLayers.Util.isArray(this.url)) {
url = this.selectUrl(path, this.url);
} else {
url = this.url;
}
if (!url.match(/\/$/)) {
url = url + "/";
}
url = url + path;
}
} else if (this.requestEncoding.toUpperCase() === "KVP") {
// assemble all required parameters
var params = {
params = {
SERVICE: "WMTS",
REQUEST: "GetTile",
VERSION: this.version,

View File

@@ -220,6 +220,39 @@
t.eq(tileurl1, "http://example.com/wmts/1.0.0/world/blue_marble/arcgis_online/1/0/0.jpg", "layer1 getURL returns correct url");
map.destroy();
}
function test_getURL_resourceUrl(t) {
t.plan(2);
var xml = document.getElementById("capabilities").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
var template = "http://www.example.com/{style}/{Time}/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png";
var layer = new OpenLayers.Layer.WMTS({
requestEncoding: "REST",
url: template,
layer: "GeoWebCache_USA_WMTS",
style: "foo",
matrixSet: "arcgis-online",
params: {Time: "2011"},
dimensions: ["Time"]
});
var map = new OpenLayers.Map("map", {
layers: [layer],
projection: "EPSG:4326",
maxResolution: 0.3515625,
maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90)
});
map.setCenter(new OpenLayers.LonLat(-97.0, 38.0), 1);
t.eq(layer.getURL(new OpenLayers.Bounds(-135.0, 0.0, -90.0, 45.0)),
"http://www.example.com/foo/2011/foo/arcgis-online/1/1/1.png", "getURL returns correct url");
map.zoomIn();
t.eq(layer.getURL(new OpenLayers.Bounds(-180.0, 0.0, -90.0, 90.0)),
"http://www.example.com/foo/2011/foo/arcgis-online/2/2/2.png", "getURL returns correct url");
map.destroy();
}
function test_destroy (t) {
t.plan(3);