Merge branch 'master' of https://github.com/openlayers/openlayers into control-inheritance
This commit is contained in:
@@ -7,4 +7,5 @@
|
|||||||
[include]
|
[include]
|
||||||
|
|
||||||
[exclude]
|
[exclude]
|
||||||
|
Firebug
|
||||||
OpenLayers.js
|
OpenLayers.js
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ var hybrid = new OpenLayers.Layer.Bing({
|
|||||||
|
|
||||||
map.addLayers([road, aerial, hybrid]);
|
map.addLayers([road, aerial, hybrid]);
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
// Zoom level numbering depends on metadata from Bing, which is not yet loaded.
|
||||||
|
var zoom = map.getZoomForResolution(76.43702827453613);
|
||||||
map.setCenter(new OpenLayers.LonLat(-71.147, 42.472).transform(
|
map.setCenter(new OpenLayers.LonLat(-71.147, 42.472).transform(
|
||||||
new OpenLayers.Projection("EPSG:4326"),
|
new OpenLayers.Projection("EPSG:4326"),
|
||||||
map.getProjectionObject()
|
map.getProjectionObject()
|
||||||
), 11);
|
), zoom);
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Reading Features From CartoDB using GeoJSON</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="style.css" type="text/css">
|
||||||
|
<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">
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 id="title">Reading Features From CartoDB using GeoJSON</h1>
|
||||||
|
<div id="tags">
|
||||||
|
protocol, script, cartodb
|
||||||
|
</div>
|
||||||
|
<p id="shortdesc">
|
||||||
|
Demonstrates how to load features on OpenLayers using CartoDB SQL API.
|
||||||
|
</p>
|
||||||
|
<div id="map" class="smallmap"></div>
|
||||||
|
<div id="docs">
|
||||||
|
<p>
|
||||||
|
<a href="http://cartodb.com/">CartoDB</a> is an Open Source
|
||||||
|
Geopatial Database on the cloud. It allows you to import your
|
||||||
|
data in shapefiles, KML, OpenStreeMap files, CSV, etc. and
|
||||||
|
then analyze and visualize it. Internally CartoDB uses PostGIS
|
||||||
|
2.0 so all functionality in PostGIS can be used straight
|
||||||
|
away. CartoDB exposes two APIS. One
|
||||||
|
to <a href="http://developers.cartodb.com/documentation/cartodb-apis.html#maps_api">generate maps</a>
|
||||||
|
as tiles with interactivity, and another <a href="http://developers.cartodb.com/documentation/cartodb-apis.html#sql_api">SQL API</a>
|
||||||
|
to retrieve vector data using among other formats, GeoJSON. In
|
||||||
|
this example we do a very simple query to obtain all protected
|
||||||
|
areas in Costa Rica from a public table. You can adapt the SQL
|
||||||
|
to include where clauses or complicate geospatial queries.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
View the source code of this page to see how this is done. And
|
||||||
|
check the table on CartoDB
|
||||||
|
for <a href="https://examples.cartodb.com/tables/costa_rica_pa/public#/map">Protected Areas in Costa Rica</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
var map = new OpenLayers.Map({
|
||||||
|
div: "map",
|
||||||
|
layers: [
|
||||||
|
new OpenLayers.Layer.OSM(),
|
||||||
|
new OpenLayers.Layer.Vector("Vectors", {
|
||||||
|
projection: new OpenLayers.Projection("EPSG:4326"),
|
||||||
|
strategies: [new OpenLayers.Strategy.Fixed()],
|
||||||
|
protocol: new OpenLayers.Protocol.Script({
|
||||||
|
url: "http://examples.cartodb.com/api/v2/sql",
|
||||||
|
params: {
|
||||||
|
q: "select * from costa_rica_pa LIMIT 50",
|
||||||
|
format: "geojson"
|
||||||
|
},
|
||||||
|
format: new OpenLayers.Format.GeoJSON({
|
||||||
|
ignoreExtraDims: true
|
||||||
|
}),
|
||||||
|
callbackKey: "callback"
|
||||||
|
}),
|
||||||
|
eventListeners: {
|
||||||
|
"featuresadded": function() {
|
||||||
|
this.map.zoomToExtent(this.getDataExtent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -68,8 +68,6 @@
|
|||||||
highlightCtrl.activate();
|
highlightCtrl.activate();
|
||||||
selectCtrl.activate();
|
selectCtrl.activate();
|
||||||
|
|
||||||
map.addControl(new OpenLayers.Control.EditingToolbar(vectors));
|
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0, 0), 1);
|
map.setCenter(new OpenLayers.LonLat(0, 0), 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ function init() {
|
|||||||
|
|
||||||
// create the select feature control
|
// create the select feature control
|
||||||
var selector = new OpenLayers.Control.SelectFeature(vector,{
|
var selector = new OpenLayers.Control.SelectFeature(vector,{
|
||||||
|
hover:true,
|
||||||
autoActivate:true
|
autoActivate:true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -414,4 +414,4 @@
|
|||||||
/**
|
/**
|
||||||
* Constant: VERSION_NUMBER
|
* Constant: VERSION_NUMBER
|
||||||
*/
|
*/
|
||||||
OpenLayers.VERSION_NUMBER="Release 2.12-rc1";
|
OpenLayers.VERSION_NUMBER="Release 2.12-rc3";
|
||||||
|
|||||||
@@ -15,6 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
OpenLayers.Date = {
|
OpenLayers.Date = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: dateRegEx
|
||||||
|
* The regex to be used for validating dates. You can provide your own
|
||||||
|
* regex for instance for adding support for years before BC. Default
|
||||||
|
* value is: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/
|
||||||
|
*/
|
||||||
|
dateRegEx: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: toISOString
|
* APIMethod: toISOString
|
||||||
* Generates a string representing a date. The format of the string follows
|
* Generates a string representing a date. The format of the string follows
|
||||||
@@ -91,7 +99,7 @@ OpenLayers.Date = {
|
|||||||
*/
|
*/
|
||||||
parse: function(str) {
|
parse: function(str) {
|
||||||
var date;
|
var date;
|
||||||
var match = str.match(/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/);
|
var match = str.match(this.dateRegEx);
|
||||||
if (match && (match[1] || match[7])) { // must have at least year or time
|
if (match && (match[1] || match[7])) { // must have at least year or time
|
||||||
var year = parseInt(match[1], 10) || 0;
|
var year = parseInt(match[1], 10) || 0;
|
||||||
var month = (parseInt(match[2], 10) - 1) || 0;
|
var month = (parseInt(match[2], 10) - 1) || 0;
|
||||||
|
|||||||
@@ -172,11 +172,18 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
updateLink: function() {
|
updateLink: function() {
|
||||||
var separator = this.anchor ? '#' : '?';
|
var separator = this.anchor ? '#' : '?';
|
||||||
var href = this.base;
|
var href = this.base;
|
||||||
|
var anchor = null;
|
||||||
|
if (href.indexOf("#") != -1 && this.anchor == false) {
|
||||||
|
anchor = href.substring( href.indexOf("#"), href.length);
|
||||||
|
}
|
||||||
if (href.indexOf(separator) != -1) {
|
if (href.indexOf(separator) != -1) {
|
||||||
href = href.substring( 0, href.indexOf(separator) );
|
href = href.substring( 0, href.indexOf(separator) );
|
||||||
}
|
}
|
||||||
|
var splits = href.split("#");
|
||||||
href += separator + OpenLayers.Util.getParameterString(this.createParams());
|
href = splits[0] + separator+ OpenLayers.Util.getParameterString(this.createParams());
|
||||||
|
if (anchor) {
|
||||||
|
href += anchor;
|
||||||
|
}
|
||||||
if (this.anchor && !this.element) {
|
if (this.anchor && !this.element) {
|
||||||
window.location.href = href;
|
window.location.href = href;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Format/WKT.js
|
* @requires OpenLayers/Format/WKT.js
|
||||||
|
* @requires OpenLayers/Filter/Comparison.js
|
||||||
|
* @requires OpenLayers/Filter/Logical.js
|
||||||
|
* @requires OpenLayers/Filter/Spatial.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+24
-26
@@ -275,16 +275,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
* {Float}
|
* {Float}
|
||||||
*/
|
*/
|
||||||
minResolution: null,
|
minResolution: null,
|
||||||
|
|
||||||
/**
|
|
||||||
* Property: resolution
|
|
||||||
* {Float} Current resolution that the layer is drawn in. This is
|
|
||||||
* used to determine whether the zoom has changed when calling
|
|
||||||
* <moveTo> from <redraw>. Subclasses may set this.resolution to
|
|
||||||
* null prior to calling redraw to force passing zoomChanged
|
|
||||||
* true to moveTo.
|
|
||||||
*/
|
|
||||||
resolution: null,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: numZoomLevels
|
* APIProperty: numZoomLevels
|
||||||
@@ -338,6 +328,11 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
|
|
||||||
this.metadata = {};
|
this.metadata = {};
|
||||||
|
|
||||||
|
options = OpenLayers.Util.extend({}, options);
|
||||||
|
// make sure we respect alwaysInRange if set on the prototype
|
||||||
|
if (this.alwaysInRange != null) {
|
||||||
|
options.alwaysInRange = this.alwaysInRange;
|
||||||
|
}
|
||||||
this.addOptions(options);
|
this.addOptions(options);
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -561,8 +556,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
var extent = this.getExtent();
|
var extent = this.getExtent();
|
||||||
|
|
||||||
if (extent && this.inRange && this.visibility) {
|
if (extent && this.inRange && this.visibility) {
|
||||||
var zoomChanged = this.resolution == null ||
|
var zoomChanged = true;
|
||||||
this.resolution !== this.map.getResolution();
|
|
||||||
this.moveTo(extent, zoomChanged, false);
|
this.moveTo(extent, zoomChanged, false);
|
||||||
this.events.triggerEvent("moveend",
|
this.events.triggerEvent("moveend",
|
||||||
{"zoomChanged": zoomChanged});
|
{"zoomChanged": zoomChanged});
|
||||||
@@ -587,7 +581,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
display = display && this.inRange;
|
display = display && this.inRange;
|
||||||
}
|
}
|
||||||
this.display(display);
|
this.display(display);
|
||||||
this.resolution = this.map.getResolution();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -643,8 +636,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
|
|
||||||
// deal with gutters
|
// deal with gutters
|
||||||
this.setTileSize();
|
this.setTileSize();
|
||||||
|
|
||||||
this.resolution = null;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -858,7 +849,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
alwaysInRange = false;
|
alwaysInRange = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.alwaysInRange == null) {
|
if(this.options.alwaysInRange == null) {
|
||||||
this.alwaysInRange = alwaysInRange;
|
this.alwaysInRange = alwaysInRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -884,16 +875,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
props.resolutions = this.resolutionsFromScales(props.scales);
|
props.resolutions = this.resolutionsFromScales(props.scales);
|
||||||
}
|
}
|
||||||
if(props.resolutions == null) {
|
if(props.resolutions == null) {
|
||||||
var maxExtent = this.maxExtent;
|
|
||||||
if (!props.maxResolution && maxExtent) {
|
|
||||||
// maxResolution for default grid sets assumes that at zoom
|
|
||||||
// level zero, the whole world fits on one tile.
|
|
||||||
var tileSize = this.tileSize || this.map.getTileSize();
|
|
||||||
props.maxResolution = Math.max(
|
|
||||||
maxExtent.getWidth() / tileSize.w,
|
|
||||||
maxExtent.getHeight() / tileSize.h
|
|
||||||
);
|
|
||||||
}
|
|
||||||
props.resolutions = this.calculateResolutions(props);
|
props.resolutions = this.calculateResolutions(props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1029,6 +1010,18 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
minResolution = Math.max(wRes, hRes);
|
minResolution = Math.max(wRes, hRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeof maxResolution !== "number" &&
|
||||||
|
typeof minResolution !== "number" &&
|
||||||
|
this.maxExtent != null) {
|
||||||
|
// maxResolution for default grid sets assumes that at zoom
|
||||||
|
// level zero, the whole world fits on one tile.
|
||||||
|
var tileSize = this.map.getTileSize();
|
||||||
|
maxResolution = Math.max(
|
||||||
|
this.maxExtent.getWidth() / tileSize.w,
|
||||||
|
this.maxExtent.getHeight() / tileSize.h
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// determine numZoomLevels
|
// determine numZoomLevels
|
||||||
var maxZoomLevel = props.maxZoomLevel;
|
var maxZoomLevel = props.maxZoomLevel;
|
||||||
var numZoomLevels = props.numZoomLevels;
|
var numZoomLevels = props.numZoomLevels;
|
||||||
@@ -1299,6 +1292,11 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
var childNodes = this.div.childNodes;
|
var childNodes = this.div.childNodes;
|
||||||
for(var i = 0, len = childNodes.length; i < len; ++i) {
|
for(var i = 0, len = childNodes.length; i < len; ++i) {
|
||||||
var element = childNodes[i].firstChild || childNodes[i];
|
var element = childNodes[i].firstChild || childNodes[i];
|
||||||
|
var lastChild = childNodes[i].lastChild;
|
||||||
|
//TODO de-uglify this
|
||||||
|
if (lastChild && lastChild.nodeName.toLowerCase() === "iframe") {
|
||||||
|
element = lastChild.parentNode;
|
||||||
|
}
|
||||||
OpenLayers.Util.modifyDOMElement(element, null, null, null,
|
OpenLayers.Util.modifyDOMElement(element, null, null, null,
|
||||||
null, null, null, opacity);
|
null, null, null, opacity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,18 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
res.zoomMax + 1 - res.zoomMin, this.numZoomLevels
|
res.zoomMax + 1 - res.zoomMin, this.numZoomLevels
|
||||||
)
|
)
|
||||||
}, true);
|
}, true);
|
||||||
|
this.updateAttribution();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: drawTileFromQueue
|
||||||
|
* Draws the first tile from the tileQueue, and unqueues that tile
|
||||||
|
*/
|
||||||
|
drawTileFromQueue: function() {
|
||||||
|
// don't start working on the queue before we have a url from initLayer
|
||||||
|
if (this.url) {
|
||||||
|
OpenLayers.Layer.XYZ.prototype.drawTileFromQueue.apply(this, arguments);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,9 +197,6 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
* bounds - {<OpenLayers.Bounds>}
|
* bounds - {<OpenLayers.Bounds>}
|
||||||
*/
|
*/
|
||||||
getURL: function(bounds) {
|
getURL: function(bounds) {
|
||||||
if (!this.url) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var xyz = this.getXYZ(bounds), x = xyz.x, y = xyz.y, z = xyz.z;
|
var xyz = this.getXYZ(bounds), x = xyz.x, y = xyz.y, z = xyz.z;
|
||||||
var quadDigits = [];
|
var quadDigits = [];
|
||||||
for (var i = z; i > 0; --i) {
|
for (var i = z; i > 0; --i) {
|
||||||
@@ -223,7 +232,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
this.map.getProjectionObject(),
|
this.map.getProjectionObject(),
|
||||||
new OpenLayers.Projection("EPSG:4326")
|
new OpenLayers.Projection("EPSG:4326")
|
||||||
);
|
);
|
||||||
var providers = res.imageryProviders, zoom = this.map.getZoom() + 1,
|
var providers = res.imageryProviders,
|
||||||
|
zoom = this.serverResolutions.indexOf(this.getServerResolution()),
|
||||||
copyrights = "", provider, i, ii, j, jj, bbox, coverage;
|
copyrights = "", provider, i, ii, j, jj, bbox, coverage;
|
||||||
for (i=0,ii=providers.length; i<ii; ++i) {
|
for (i=0,ii=providers.length; i<ii; ++i) {
|
||||||
provider = providers[i];
|
provider = providers[i];
|
||||||
@@ -253,7 +263,6 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
*/
|
*/
|
||||||
setMap: function() {
|
setMap: function() {
|
||||||
OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments);
|
OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments);
|
||||||
this.updateAttribution();
|
|
||||||
this.map.events.register("moveend", this, this.updateAttribution);
|
this.map.events.register("moveend", this, this.updateAttribution);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -651,14 +651,18 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getServerZoom
|
* Method: getServerZoom
|
||||||
* Return the zoom value corresponding to the best zoom supported by the server
|
* Return the zoom value corresponding to the best matching server
|
||||||
* resolution.
|
* resolution, taking into account <serverResolutions> and <zoomOffset>.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Number} The closest server supported zoom.
|
* {Number} The closest server supported zoom. This is not the map zoom
|
||||||
|
* level, but an index of the server's resolutions array.
|
||||||
*/
|
*/
|
||||||
getServerZoom: function() {
|
getServerZoom: function() {
|
||||||
return this.map.getZoomForResolution(this.getServerResolution());
|
var resolution = this.getServerResolution();
|
||||||
|
return this.serverResolutions ?
|
||||||
|
OpenLayers.Util.indexOf(this.serverResolutions, resolution) :
|
||||||
|
this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
*/
|
*/
|
||||||
mergeNewParams:function(newParams) {
|
mergeNewParams:function(newParams) {
|
||||||
this.params = OpenLayers.Util.extend(this.params, newParams);
|
this.params = OpenLayers.Util.extend(this.params, newParams);
|
||||||
this.resolution = null;
|
|
||||||
var ret = this.redraw();
|
var ret = this.redraw();
|
||||||
if(this.map != null) {
|
if(this.map != null) {
|
||||||
this.map.events.triggerEvent("changelayer", {
|
this.map.events.triggerEvent("changelayer", {
|
||||||
@@ -147,7 +146,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
if (force) {
|
if (force) {
|
||||||
return this.mergeNewParams({"_olSalt": Math.random()});
|
return this.mergeNewParams({"_olSalt": Math.random()});
|
||||||
} else {
|
} else {
|
||||||
return OpenLayers.Layer.prototype.redraw.call(this);
|
return OpenLayers.Layer.prototype.redraw.apply(this, []);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -173,9 +173,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
var res = this.getServerResolution();
|
var res = this.getServerResolution();
|
||||||
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
|
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
|
||||||
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
|
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
|
||||||
var z = this.serverResolutions != null ?
|
var z = this.getServerZoom();
|
||||||
OpenLayers.Util.indexOf(this.serverResolutions, res) :
|
|
||||||
this.getServerZoom() + this.zoomOffset;
|
|
||||||
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
|
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
|
||||||
var url = this.url;
|
var url = this.url;
|
||||||
if (OpenLayers.Util.isArray(url)) {
|
if (OpenLayers.Util.isArray(url)) {
|
||||||
|
|||||||
@@ -520,20 +520,6 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* APIMethod: redraw
|
|
||||||
* Redraws the layer. Returns true if the layer was redrawn, false if not.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* {Boolean} The layer was redrawn.
|
|
||||||
*/
|
|
||||||
redraw: function() {
|
|
||||||
// this is to force Layer.redraw set zoomChanged
|
|
||||||
// to true in the moveTo call
|
|
||||||
this.resolution = null;
|
|
||||||
return OpenLayers.Layer.prototype.redraw.apply(this, arguments);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: display
|
* APIMethod: display
|
||||||
* Hide or show the Layer
|
* Hide or show the Layer
|
||||||
|
|||||||
@@ -332,10 +332,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
* Get the current index in the matrixIds array.
|
* Get the current index in the matrixIds array.
|
||||||
*/
|
*/
|
||||||
getIdentifier: function() {
|
getIdentifier: function() {
|
||||||
return this.serverResolutions != null ?
|
return this.getServerZoom();
|
||||||
OpenLayers.Util.indexOf(this.serverResolutions,
|
|
||||||
this.getServerResolution()) :
|
|
||||||
this.getServerZoom() + this.zoomOffset;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,10 +143,7 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
(res * this.tileSize.w));
|
(res * this.tileSize.w));
|
||||||
var y = Math.round((this.maxExtent.top - bounds.top) /
|
var y = Math.round((this.maxExtent.top - bounds.top) /
|
||||||
(res * this.tileSize.h));
|
(res * this.tileSize.h));
|
||||||
var resolutions = this.serverResolutions || this.resolutions;
|
var z = this.getServerZoom();
|
||||||
var z = this.zoomOffset == 0 ?
|
|
||||||
OpenLayers.Util.indexOf(resolutions, res) :
|
|
||||||
this.getServerZoom() + this.zoomOffset;
|
|
||||||
|
|
||||||
if (this.wrapDateLine) {
|
if (this.wrapDateLine) {
|
||||||
var limit = Math.pow(2, z);
|
var limit = Math.pow(2, z);
|
||||||
|
|||||||
@@ -580,8 +580,8 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
|
|
||||||
// Because Mozilla does not support the "resize" event for elements
|
// Because Mozilla does not support the "resize" event for elements
|
||||||
// other than "window", we need to put a hack here.
|
// other than "window", we need to put a hack here.
|
||||||
if (OpenLayers.String.contains(navigator.appName, "Microsoft")) {
|
if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) {
|
||||||
// If IE, register the resize on the div
|
// If IE < 9, register the resize on the div
|
||||||
this.events.register("resize", this, this.updateSize);
|
this.events.register("resize", this, this.updateSize);
|
||||||
} else {
|
} else {
|
||||||
// Else updateSize on catching the window's resize
|
// Else updateSize on catching the window's resize
|
||||||
@@ -1634,8 +1634,10 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
this.panTo(newCenterLonLat);
|
this.panTo(newCenterLonLat);
|
||||||
} else {
|
} else {
|
||||||
this.moveTo(newCenterLonLat);
|
this.moveTo(newCenterLonLat);
|
||||||
this.dragging = false;
|
if(this.dragging) {
|
||||||
this.events.triggerEvent("moveend");
|
this.dragging = false;
|
||||||
|
this.events.triggerEvent("moveend");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -799,7 +799,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
|||||||
if (data[3] === 255) { // antialiased
|
if (data[3] === 255) { // antialiased
|
||||||
var id = data[2] + (256 * (data[1] + (256 * data[0])));
|
var id = data[2] + (256 * (data[1] + (256 * data[0])));
|
||||||
if (id) {
|
if (id) {
|
||||||
featureId = "OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow);
|
featureId = "OpenLayers_Feature_Vector_" + (id - 1 + this.hitOverflow);
|
||||||
try {
|
try {
|
||||||
feature = this.features[featureId][0];
|
feature = this.features[featureId][0];
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Events.js
|
* @requires OpenLayers/Events.js
|
||||||
|
* @requires OpenLayers/Request/XMLHttpRequest.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +20,14 @@ OpenLayers.ProxyHost = "";
|
|||||||
* with XMLHttpRequests. These methods work with a cross-browser
|
* with XMLHttpRequests. These methods work with a cross-browser
|
||||||
* W3C compliant <OpenLayers.Request.XMLHttpRequest> class.
|
* W3C compliant <OpenLayers.Request.XMLHttpRequest> class.
|
||||||
*/
|
*/
|
||||||
OpenLayers.Request = {
|
if (!OpenLayers.Request) {
|
||||||
|
/**
|
||||||
|
* This allows for OpenLayers/Request/XMLHttpRequest.js to be included
|
||||||
|
* before or after this script.
|
||||||
|
*/
|
||||||
|
OpenLayers.Request = {};
|
||||||
|
}
|
||||||
|
OpenLayers.Util.extend(OpenLayers.Request, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant: DEFAULT_CONFIG
|
* Constant: DEFAULT_CONFIG
|
||||||
@@ -419,4 +427,4 @@ OpenLayers.Request = {
|
|||||||
return OpenLayers.Request.issue(config);
|
return OpenLayers.Request.issue(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
});
|
||||||
|
|||||||
@@ -447,5 +447,12 @@
|
|||||||
* XMLHttpRequest object. From
|
* XMLHttpRequest object. From
|
||||||
* http://code.google.com/p/xmlhttprequest/.
|
* http://code.google.com/p/xmlhttprequest/.
|
||||||
*/
|
*/
|
||||||
|
if (!OpenLayers.Request) {
|
||||||
|
/**
|
||||||
|
* This allows for OpenLayers/Request.js to be included
|
||||||
|
* before or after this script.
|
||||||
|
*/
|
||||||
|
OpenLayers.Request = {};
|
||||||
|
}
|
||||||
OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;
|
OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ var OpenLayers = {
|
|||||||
/**
|
/**
|
||||||
* Constant: VERSION_NUMBER
|
* Constant: VERSION_NUMBER
|
||||||
*/
|
*/
|
||||||
VERSION_NUMBER: "Release 2.12-rc1",
|
VERSION_NUMBER: "Release 2.12-rc3",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant: singleFile
|
* Constant: singleFile
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ OpenLayers.Style = OpenLayers.Class({
|
|||||||
rules: null,
|
rules: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: context
|
* APIProperty: context
|
||||||
* {Object} An optional object with properties that symbolizers' property
|
* {Object} An optional object with properties that symbolizers' property
|
||||||
* values should be evaluated against. If no context is specified,
|
* values should be evaluated against. If no context is specified,
|
||||||
* feature.attributes will be used
|
* feature.attributes will be used
|
||||||
|
|||||||
@@ -211,7 +211,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
*/
|
*/
|
||||||
positionTile: function() {
|
positionTile: function() {
|
||||||
var style = this.getTile().style,
|
var style = this.getTile().style,
|
||||||
size = this.layer.getImageSize(this.bounds);
|
size = this.frame ? this.size :
|
||||||
|
this.layer.getImageSize(this.bounds);
|
||||||
style.left = this.position.x + "%";
|
style.left = this.position.x + "%";
|
||||||
style.top = this.position.y + "%";
|
style.top = this.position.y + "%";
|
||||||
style.width = size.w + "%";
|
style.width = size.w + "%";
|
||||||
@@ -254,11 +255,16 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
this.imgDiv.galleryImg = "no";
|
this.imgDiv.galleryImg = "no";
|
||||||
|
|
||||||
var style = this.imgDiv.style;
|
var style = this.imgDiv.style;
|
||||||
if (this.layer.gutter) {
|
if (this.frame) {
|
||||||
var left = this.layer.gutter / this.layer.tileSize.w * 100;
|
var left = 0, top = 0;
|
||||||
var top = this.layer.gutter / this.layer.tileSize.h * 100;
|
if (this.layer.gutter) {
|
||||||
|
left = this.layer.gutter / this.layer.tileSize.w * 100;
|
||||||
|
top = this.layer.gutter / this.layer.tileSize.h * 100;
|
||||||
|
}
|
||||||
style.left = -left + "%";
|
style.left = -left + "%";
|
||||||
style.top = -top + "%";
|
style.top = -top + "%";
|
||||||
|
style.width = (2 * left + 100) + "%";
|
||||||
|
style.height = (2 * top + 100) + "%";
|
||||||
}
|
}
|
||||||
style.visibility = "hidden";
|
style.visibility = "hidden";
|
||||||
style.opacity = 0;
|
style.opacity = 0;
|
||||||
@@ -275,8 +281,6 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
style.width = "100%";
|
style.width = "100%";
|
||||||
}
|
}
|
||||||
if (this.frame) {
|
if (this.frame) {
|
||||||
style.width = "100%";
|
|
||||||
style.height = "100%";
|
|
||||||
this.frame.appendChild(this.imgDiv);
|
this.frame.appendChild(this.imgDiv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,6 +196,19 @@ OpenLayers.Tile.Image.IFrame = {
|
|||||||
OpenLayers.Tile.Image.prototype.setImgSrc.apply(this, arguments);
|
OpenLayers.Tile.Image.prototype.setImgSrc.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: onImageLoad
|
||||||
|
* Handler for the image onload event
|
||||||
|
*/
|
||||||
|
onImageLoad: function() {
|
||||||
|
//TODO de-uglify opacity handling
|
||||||
|
OpenLayers.Tile.Image.prototype.onImageLoad.apply(this, arguments);
|
||||||
|
if (this.useIFrame === true) {
|
||||||
|
this.imgDiv.style.opacity = 1;
|
||||||
|
this.frame.style.opacity = this.layer.opacity;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: createBackBuffer
|
* Method: createBackBuffer
|
||||||
|
|||||||
+21
-5
@@ -71,7 +71,7 @@ OpenLayers.Util.isElement = function(o) {
|
|||||||
* {Boolean} true if the object is an array.
|
* {Boolean} true if the object is an array.
|
||||||
*/
|
*/
|
||||||
OpenLayers.Util.isArray = function(a) {
|
OpenLayers.Util.isArray = function(a) {
|
||||||
return (Object.prototype.toString.call(a) === '[object Array]');
|
return (Object.prototype.toString.call(a) === '[object Array]');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +112,7 @@ OpenLayers.Util.removeItem = function(array, item) {
|
|||||||
* obj - {*}
|
* obj - {*}
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Integer} The index at, which the first object was found in the array.
|
* {Integer} The index at which the first object was found in the array.
|
||||||
* If not found, returns -1.
|
* If not found, returns -1.
|
||||||
*/
|
*/
|
||||||
OpenLayers.Util.indexOf = function(array, obj) {
|
OpenLayers.Util.indexOf = function(array, obj) {
|
||||||
@@ -130,6 +130,17 @@ OpenLayers.Util.indexOf = function(array, obj) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property: dotless
|
||||||
|
* {RegExp}
|
||||||
|
* Compiled regular expression to match dots ("."). This is used for replacing
|
||||||
|
* dots in identifiers. Because object identifiers are frequently used for
|
||||||
|
* DOM element identifiers by the library, we avoid using dots to make for
|
||||||
|
* more sensible CSS selectors.
|
||||||
|
*
|
||||||
|
* TODO: Use a module pattern to avoid bloating the API with stuff like this.
|
||||||
|
*/
|
||||||
|
OpenLayers.Util.dotless = /\./g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function: modifyDOMElement
|
* Function: modifyDOMElement
|
||||||
@@ -139,7 +150,8 @@ OpenLayers.Util.indexOf = function(array, obj) {
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* element - {DOMElement} DOM element to modify.
|
* element - {DOMElement} DOM element to modify.
|
||||||
* id - {String} The element id attribute to set.
|
* id - {String} The element id attribute to set. Note that dots (".") will be
|
||||||
|
* replaced with underscore ("_") in setting the element id.
|
||||||
* px - {<OpenLayers.Pixel>|Object} The element left and top position,
|
* px - {<OpenLayers.Pixel>|Object} The element left and top position,
|
||||||
* OpenLayers.Pixel or an object with
|
* OpenLayers.Pixel or an object with
|
||||||
* a 'x' and 'y' properties.
|
* a 'x' and 'y' properties.
|
||||||
@@ -157,7 +169,7 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
|||||||
border, overflow, opacity) {
|
border, overflow, opacity) {
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
element.id = id;
|
element.id = id.replace(OpenLayers.Util.dotless, "_");
|
||||||
}
|
}
|
||||||
if (px) {
|
if (px) {
|
||||||
element.style.left = px.x + "px";
|
element.style.left = px.x + "px";
|
||||||
@@ -195,7 +207,8 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* id - {String} An identifier for this element. If no id is
|
* id - {String} An identifier for this element. If no id is
|
||||||
* passed an identifier will be created
|
* passed an identifier will be created
|
||||||
* automatically.
|
* automatically. Note that dots (".") will be replaced with
|
||||||
|
* underscore ("_") when generating ids.
|
||||||
* px - {<OpenLayers.Pixel>|Object} The element left and top position,
|
* px - {<OpenLayers.Pixel>|Object} The element left and top position,
|
||||||
* OpenLayers.Pixel or an object with
|
* OpenLayers.Pixel or an object with
|
||||||
* a 'x' and 'y' properties.
|
* a 'x' and 'y' properties.
|
||||||
@@ -928,6 +941,7 @@ OpenLayers.Util.lastSeqID = 0;
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* prefix - {String} Optional string to prefix unique id. Default is "id_".
|
* prefix - {String} Optional string to prefix unique id. Default is "id_".
|
||||||
|
* Note that dots (".") in the prefix will be replaced with underscore ("_").
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {String} A unique id string, built on the passed in prefix.
|
* {String} A unique id string, built on the passed in prefix.
|
||||||
@@ -935,6 +949,8 @@ OpenLayers.Util.lastSeqID = 0;
|
|||||||
OpenLayers.Util.createUniqueID = function(prefix) {
|
OpenLayers.Util.createUniqueID = function(prefix) {
|
||||||
if (prefix == null) {
|
if (prefix == null) {
|
||||||
prefix = "id_";
|
prefix = "id_";
|
||||||
|
} else {
|
||||||
|
prefix = prefix.replace(OpenLayers.Util.dotless, "_");
|
||||||
}
|
}
|
||||||
OpenLayers.Util.lastSeqID += 1;
|
OpenLayers.Util.lastSeqID += 1;
|
||||||
return prefix + OpenLayers.Util.lastSeqID;
|
return prefix + OpenLayers.Util.lastSeqID;
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Enhancements and Additions
|
||||||
|
|
||||||
|
## Dotless identifiers
|
||||||
|
|
||||||
|
Previously, objects generated by the library were given id properties with values that contained dots (e.g. "OpenLayers.Control.Navigation_2"). These same identifiers are also used for DOM elements in some case. Though uncommon, a developer may want to access these elements with a CSS selector. To facilitate this, we now always generate ids with underscore instead of dot.
|
||||||
|
|
||||||
|
Corresponding issues/pull requests:
|
||||||
|
|
||||||
|
* https://github.com/openlayers/openlayers/pull/416
|
||||||
@@ -175,6 +175,15 @@
|
|||||||
t.ok(isNaN(invalid.getTime()), "invalid has no time");
|
t.ok(isNaN(invalid.getTime()), "invalid has no time");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_regex(t) {
|
||||||
|
t.plan(1);
|
||||||
|
var regex = OpenLayers.Date.dateRegEx;
|
||||||
|
OpenLayers.Date.dateRegEx = /^(?:(-?\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/;
|
||||||
|
var date = OpenLayers.Date.parse("-0501-03-01T00:00:00.000Z");
|
||||||
|
t.ok(!isNaN(date.getTime()), "date with negative year is parsed when providing alternative regex");
|
||||||
|
OpenLayers.Date.dateRegEx = regex;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -139,7 +139,7 @@
|
|||||||
}
|
}
|
||||||
function test_Control_Permalink_base_with_query (t) {
|
function test_Control_Permalink_base_with_query (t) {
|
||||||
t.plan( 3 );
|
t.plan( 3 );
|
||||||
|
|
||||||
control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar" );
|
control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar" );
|
||||||
map = new OpenLayers.Map('map');
|
map = new OpenLayers.Map('map');
|
||||||
layer = new OpenLayers.Layer.WMS('Test Layer', "http://example.com" );
|
layer = new OpenLayers.Layer.WMS('Test Layer', "http://example.com" );
|
||||||
@@ -162,7 +162,38 @@
|
|||||||
map.pan(-5, 0, {animate:false});
|
map.pan(-5, 0, {animate:false});
|
||||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
|
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_Control_Permalink_base_with_anchor (t) {
|
||||||
|
t.plan( 4 );
|
||||||
|
control = new OpenLayers.Control.Permalink('permalink', "./edit.html#foo" );
|
||||||
|
map = new OpenLayers.Map('map');
|
||||||
|
layer = new OpenLayers.Layer.WMS('Test Layer', "http://example.com" );
|
||||||
|
map.addLayer(layer);
|
||||||
|
if (!map.getCenter()) map.zoomToMaxExtent();
|
||||||
|
map.addControl(control);
|
||||||
|
map.pan(5, 0, {animate:false});
|
||||||
|
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B#foo';
|
||||||
|
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and anchor");
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.Permalink('permalink', "./edit.html#" );
|
||||||
|
map.addControl(control);
|
||||||
|
map.pan(0, 0, {animate:false});
|
||||||
|
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B#';
|
||||||
|
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and an empty anchor");
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar#test" );
|
||||||
|
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?foo=bar&zoom=2&lat=0&lon=1.75781&layers=B#test';
|
||||||
|
map.addControl(control);
|
||||||
|
map.pan(5, 0, {animate:false});
|
||||||
|
map.pan(-5, 0, {animate:false});
|
||||||
|
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base, querystring and an anchor");
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.Permalink('permalink', "./edit.html#foo", {anchor : true} );
|
||||||
|
map.addControl(control);
|
||||||
|
map.pan(0, 0, {animate:false});
|
||||||
|
OpenLayers.Util.getElement('edit_permalink').href = './edit.html#zoom=2&lat=0&lon=1.75781&layers=B';
|
||||||
|
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and an empty anchor");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Control_Permalink_nonRepeating (t) {
|
function test_Control_Permalink_nonRepeating (t) {
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
|
t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
|
||||||
t.eq( feature.layer, layer, "feature.layer set correctly" );
|
t.eq( feature.layer, layer, "feature.layer set correctly" );
|
||||||
t.ok(OpenLayers.String.startsWith(feature.id, "OpenLayers.Feature_"),
|
t.ok(OpenLayers.String.startsWith(feature.id, "OpenLayers_Feature_"),
|
||||||
"feature.id set correctly");
|
"feature.id set correctly");
|
||||||
t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" );
|
t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" );
|
||||||
t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" );
|
t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" );
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@
|
|||||||
var g = new OpenLayers.Geometry();
|
var g = new OpenLayers.Geometry();
|
||||||
|
|
||||||
t.eq(g.CLASS_NAME, "OpenLayers.Geometry", "correct CLASS_NAME")
|
t.eq(g.CLASS_NAME, "OpenLayers.Geometry", "correct CLASS_NAME")
|
||||||
t.ok(OpenLayers.String.startsWith(g.id, "OpenLayers.Geometry_"),
|
t.ok(OpenLayers.String.startsWith(g.id, "OpenLayers_Geometry_"),
|
||||||
"id correctly set");
|
"id correctly set");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
var clone = geometry.clone();
|
var clone = geometry.clone();
|
||||||
|
|
||||||
t.eq(clone.CLASS_NAME, "OpenLayers.Geometry", "correct CLASS_NAME")
|
t.eq(clone.CLASS_NAME, "OpenLayers.Geometry", "correct CLASS_NAME")
|
||||||
t.ok(OpenLayers.String.startsWith(clone.id, "OpenLayers.Geometry_"),
|
t.ok(OpenLayers.String.startsWith(clone.id, "OpenLayers_Geometry_"),
|
||||||
"id correctly set");
|
"id correctly set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-68
@@ -174,6 +174,16 @@
|
|||||||
t.eq(log, 0, "addOptions doesn't call initResolutions when layer is not in map");
|
t.eq(log, 0, "addOptions doesn't call initResolutions when layer is not in map");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_addOptionsScale(t) {
|
||||||
|
t.plan(1);
|
||||||
|
var map = new OpenLayers.Map("map");
|
||||||
|
var layer = new OpenLayers.Layer.WMS();
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.zoomToMaxExtent();
|
||||||
|
layer.addOptions({maxResolution: 0.5, numZoomLevels: 15});
|
||||||
|
t.eq(layer.alwaysInRange, false, "alwaysInRange should not be true anymore");
|
||||||
|
}
|
||||||
|
|
||||||
function test_Layer_StandardOptionsAccessors (t) {
|
function test_Layer_StandardOptionsAccessors (t) {
|
||||||
|
|
||||||
t.plan( 4 );
|
t.plan( 4 );
|
||||||
@@ -398,6 +408,9 @@
|
|||||||
"1.20", null, {maxScale: 100000, numZoomLevels: 3, units: "m"},
|
"1.20", null, {maxScale: 100000, numZoomLevels: 3, units: "m"},
|
||||||
[141.11103491115225, 70.55551745557612, 35.27775872778806], 35.27775872778806, 141.11103491115225
|
[141.11103491115225, 70.55551745557612, 35.27775872778806], 35.27775872778806, 141.11103491115225
|
||||||
], [
|
], [
|
||||||
|
"1.21", null, {numZoomLevels: 2}, // maxResolution calculated based on the projection's maxExtent here
|
||||||
|
[1.40625, 0.703125], 0.703125, 1.40625
|
||||||
|
], [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Batch 2: custom map options map and sensible layer options
|
* Batch 2: custom map options map and sensible layer options
|
||||||
@@ -541,8 +554,8 @@
|
|||||||
/*
|
/*
|
||||||
* Batch 2.8: numZoomLevels set in the layer options
|
* Batch 2.8: numZoomLevels set in the layer options
|
||||||
*/
|
*/
|
||||||
"2.8.0", {maxResolution: 80}, {numZoomLevels: 4},
|
"2.8.0", {maxResolution: 80}, {numZoomLevels: 4}, // maxResolution calculated based on the projection's maxExtent here
|
||||||
[80, 40, 20, 10], 10, 80
|
[1.40625, 0.703125, 0.3515625, 0.17578125], 0.17578125, 1.40625
|
||||||
], [
|
], [
|
||||||
"2.8.1", {maxResolution: 80, numZoomLevels: 4}, {numZoomLevels: null},
|
"2.8.1", {maxResolution: 80, numZoomLevels: 4}, {numZoomLevels: null},
|
||||||
[80, 40, 20, 10], 10, 80
|
[80, 40, 20, 10], 10, 80
|
||||||
@@ -672,82 +685,19 @@
|
|||||||
// test that the moveend event was triggered
|
// test that the moveend event was triggered
|
||||||
t.ok(log.event, "an event was logged");
|
t.ok(log.event, "an event was logged");
|
||||||
t.eq(log.event.type, "moveend", "moveend was triggered");
|
t.eq(log.event.type, "moveend", "moveend was triggered");
|
||||||
t.eq(log.event.zoomChanged, false, "event says zoomChanged false");
|
t.eq(log.event.zoomChanged, true, "event says zoomChanged true - poor name");
|
||||||
|
|
||||||
layer.moveTo = function(bounds, zoomChanged, dragging) {
|
layer.moveTo = function(bounds, zoomChanged, dragging) {
|
||||||
var extent = layer.map.getExtent();
|
var extent = layer.map.getExtent();
|
||||||
t.ok(bounds.equals(extent),
|
t.ok(bounds.equals(extent),
|
||||||
"redraw calls moveTo with the map extent");
|
"redraw calls moveTo with the map extent");
|
||||||
t.ok(!zoomChanged,
|
t.ok(zoomChanged,
|
||||||
"redraw calls moveTo with zoomChanged false");
|
"redraw calls moveTo with zoomChanged true");
|
||||||
t.ok(!dragging,
|
t.ok(!dragging,
|
||||||
"redraw calls moveTo with dragging false");
|
"redraw calls moveTo with dragging false");
|
||||||
}
|
}
|
||||||
layer.redraw();
|
layer.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function includes integration tests to verify that the
|
|
||||||
// layer's moveTo function is called with the expected value
|
|
||||||
// for zoomChanged
|
|
||||||
function test_moveTo_zoomChanged(t) {
|
|
||||||
t.plan(6);
|
|
||||||
|
|
||||||
var log = {};
|
|
||||||
var map = new OpenLayers.Map('map');
|
|
||||||
|
|
||||||
var l1 = new OpenLayers.Layer('l1', {isBaseLayer: true});
|
|
||||||
l1.moveTo = function(bounds, zoomChanged, dragging) {
|
|
||||||
log.moveTo = {zoomChanged: zoomChanged};
|
|
||||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
map.addLayer(l1);
|
|
||||||
map.zoomToMaxExtent();
|
|
||||||
|
|
||||||
log = {};
|
|
||||||
l1.redraw();
|
|
||||||
t.eq(log.moveTo.zoomChanged, false,
|
|
||||||
"[a] redraw calls moveTo with zoomChanged false");
|
|
||||||
|
|
||||||
log = {};
|
|
||||||
l1.resolution = null;
|
|
||||||
l1.redraw();
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[b] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
l1.setVisibility(false);
|
|
||||||
log = {};
|
|
||||||
l1.setVisibility(true);
|
|
||||||
t.eq(log.moveTo.zoomChanged, false,
|
|
||||||
"[c] redraw calls moveTo with zoomChanged false");
|
|
||||||
|
|
||||||
l1.setVisibility(false);
|
|
||||||
map.zoomIn();
|
|
||||||
log = {};
|
|
||||||
l1.setVisibility(true);
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[d] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
l1.moveTo = OpenLayers.Layer.prototype.moveTo;
|
|
||||||
|
|
||||||
var l2 = new OpenLayers.Layer('l2');
|
|
||||||
l2.moveTo = function(bounds, zoomChanged, dragging) {
|
|
||||||
log.moveTo = {zoomChanged: zoomChanged};
|
|
||||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
|
||||||
};
|
|
||||||
log = {};
|
|
||||||
map.addLayer(l2);
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[e] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
map.removeLayer(l2);
|
|
||||||
log = {};
|
|
||||||
map.addLayer(l2);
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[f] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
map.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_layer_setIsBaseLayer(t) {
|
function test_layer_setIsBaseLayer(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* Because browsers that implement requestAnimationFrame may not execute
|
||||||
|
* animation functions while a window is not displayed (e.g. in a hidden
|
||||||
|
* iframe as in these tests), we mask the native implementations here. The
|
||||||
|
* native requestAnimationFrame functionality is tested in Util.html and
|
||||||
|
* in PanZoom.html (where a popup is opened before panning).
|
||||||
|
*/
|
||||||
|
window.requestAnimationFrame =
|
||||||
|
window.webkitRequestAnimationFrame =
|
||||||
|
window.mozRequestAnimationFrame =
|
||||||
|
window.oRequestAnimationFrame =
|
||||||
|
window.msRequestAnimationFrame = null;
|
||||||
|
</script>
|
||||||
<script src="../OLLoader.js"></script>
|
<script src="../OLLoader.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var map, layer;
|
var map, layer;
|
||||||
@@ -82,6 +96,26 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_initLayer_notempty(t) {
|
||||||
|
t.plan(1);
|
||||||
|
|
||||||
|
map = new OpenLayers.Map("map", {
|
||||||
|
projection: "EPSG:3857",
|
||||||
|
layers: [new OpenLayers.Layer("dummy", {isBaseLayer: true})]
|
||||||
|
});
|
||||||
|
map.zoomToExtent([-14768652, 4492113, -12263964, 5744457]);
|
||||||
|
var layer = new OpenLayers.Layer.Bing(OpenLayers.Util.extend({
|
||||||
|
isBaseLayer: false
|
||||||
|
}, options));
|
||||||
|
map.addLayer(layer);
|
||||||
|
var tile = layer.tileQueue[0];
|
||||||
|
|
||||||
|
t.delay_call(5, function() {
|
||||||
|
t.ok(tile.url, "Tile not empty");
|
||||||
|
map.destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function test_attribution(t) {
|
function test_attribution(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
|
||||||
|
|||||||
@@ -837,12 +837,12 @@
|
|||||||
layer.serverResolutions = [2, 1];
|
layer.serverResolutions = [2, 1];
|
||||||
resolution = 1;
|
resolution = 1;
|
||||||
zoom = layer.getServerZoom();
|
zoom = layer.getServerZoom();
|
||||||
t.eq(zoom, 3, '[3] getServerZoom return value is correct');
|
t.eq(zoom, 1, '[3] getServerZoom return value is correct');
|
||||||
|
|
||||||
layer.serverResolutions = [2];
|
layer.serverResolutions = [2];
|
||||||
resolution = 0.5;
|
resolution = 0.5;
|
||||||
zoom = layer.getServerZoom();
|
zoom = layer.getServerZoom();
|
||||||
t.eq(zoom, 2, '[4] getServerZoom return value is correct');
|
t.eq(zoom, 0, '[4] getServerZoom return value is correct');
|
||||||
|
|
||||||
var exc;
|
var exc;
|
||||||
layer.serverResolutions = [0.5];
|
layer.serverResolutions = [0.5];
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Layer_HTTPRequest_mergeNewParams (t) {
|
function test_Layer_HTTPRequest_mergeNewParams (t) {
|
||||||
t.plan( 9 );
|
t.plan( 8 );
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
|
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
|
||||||
@@ -100,9 +100,7 @@
|
|||||||
|
|
||||||
layer.redraw = function() {
|
layer.redraw = function() {
|
||||||
t.ok(true, "layer.mergeNewParams calls layer.redraw");
|
t.ok(true, "layer.mergeNewParams calls layer.redraw");
|
||||||
t.ok(layer.resolution === null, "layer.mergeNewParams sets resolution to null");
|
}
|
||||||
};
|
|
||||||
layer.resolution = 'fake';
|
|
||||||
layer.mergeNewParams();
|
layer.mergeNewParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,10 +175,9 @@
|
|||||||
// test offset of 2
|
// test offset of 2
|
||||||
offset = 2;
|
offset = 2;
|
||||||
zoom = 3;
|
zoom = 3;
|
||||||
|
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map"
|
||||||
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
|
|
||||||
});
|
});
|
||||||
var layer = new OpenLayers.Layer.TMS("TMS", "", {
|
var layer = new OpenLayers.Layer.TMS("TMS", "", {
|
||||||
layername: "basic",
|
layername: "basic",
|
||||||
@@ -189,7 +188,6 @@
|
|||||||
map.setCenter(new OpenLayers.LonLat(0, 0), zoom);
|
map.setCenter(new OpenLayers.LonLat(0, 0), zoom);
|
||||||
|
|
||||||
var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
|
var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
|
||||||
level = parseInt(tileurl.split("/")[2]);
|
|
||||||
t.eq(parseInt(tileurl.split("/")[2]), zoom + offset, "correct level for offset 2");
|
t.eq(parseInt(tileurl.split("/")[2]), zoom + offset, "correct level for offset 2");
|
||||||
|
|
||||||
map.destroy();
|
map.destroy();
|
||||||
@@ -199,8 +197,7 @@
|
|||||||
zoom = 3;
|
zoom = 3;
|
||||||
|
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map"
|
||||||
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
|
|
||||||
});
|
});
|
||||||
var layer = new OpenLayers.Layer.TMS("TMS", "", {
|
var layer = new OpenLayers.Layer.TMS("TMS", "", {
|
||||||
layername: "basic",
|
layername: "basic",
|
||||||
@@ -211,12 +208,9 @@
|
|||||||
map.setCenter(new OpenLayers.LonLat(0, 0), zoom);
|
map.setCenter(new OpenLayers.LonLat(0, 0), zoom);
|
||||||
|
|
||||||
var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
|
var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
|
||||||
level = parseInt(tileurl.split("/")[2]);
|
|
||||||
t.eq(parseInt(tileurl.split("/")[2]), zoom + offset, "correct level for offset -1");
|
t.eq(parseInt(tileurl.split("/")[2]), zoom + offset, "correct level for offset -1");
|
||||||
|
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Layer_TMS_setMap(t) {
|
function test_Layer_TMS_setMap(t) {
|
||||||
|
|||||||
@@ -869,32 +869,7 @@
|
|||||||
"featuresadded event received expected number of features");
|
"featuresadded event received expected number of features");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_redraw(t) {
|
|
||||||
t.plan(2);
|
|
||||||
|
|
||||||
// test that when redraw is called on a vector layer then
|
|
||||||
// moveTo gets called on the layer and receives zoomChanged
|
|
||||||
// true
|
|
||||||
|
|
||||||
var log = [];
|
|
||||||
|
|
||||||
var map = new OpenLayers.Map("map");
|
|
||||||
var layer = new OpenLayers.Layer.Vector("vector", {isBaseLayer: true});
|
|
||||||
map.addLayer(layer);
|
|
||||||
map.setCenter([0, 0], 5);
|
|
||||||
|
|
||||||
layer.moveTo = function(extent, zoomChanged) {
|
|
||||||
log.push(zoomChanged);
|
|
||||||
};
|
|
||||||
|
|
||||||
layer.redraw();
|
|
||||||
t.eq(log.length, 1, "redraw makes moveTo be called once");
|
|
||||||
if (log.length == 1) {
|
|
||||||
t.eq(log[0], true, "redraw makes moveTo be called with zoomChanged true");
|
|
||||||
}
|
|
||||||
|
|
||||||
map.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
+30
-1
@@ -1712,7 +1712,36 @@
|
|||||||
t.eq(log[1], "move", "followed by move,");
|
t.eq(log[1], "move", "followed by move,");
|
||||||
t.eq(log[log.length-2], "move", "move again before we stop panning,");
|
t.eq(log[log.length-2], "move", "move again before we stop panning,");
|
||||||
t.eq(log[log.length-1], "moveend", "and moveend when we're done.");
|
t.eq(log[log.length-1], "moveend", "and moveend when we're done.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_pan_no_anim_event_sequence(t) {
|
||||||
|
t.plan(4);
|
||||||
|
|
||||||
|
var log = [];
|
||||||
|
var map = new OpenLayers.Map("map");
|
||||||
|
map.addLayer(
|
||||||
|
new OpenLayers.Layer(null, {isBaseLayer: true})
|
||||||
|
);
|
||||||
|
map.setCenter(new OpenLayers.LonLat(0, 0), 5);
|
||||||
|
map.events.on({
|
||||||
|
"movestart": function() {
|
||||||
|
log.push("movestart");
|
||||||
|
},
|
||||||
|
"move": function() {
|
||||||
|
log.push("move");
|
||||||
|
},
|
||||||
|
"moveend": function() {
|
||||||
|
log.push("moveend");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
map.pan(5,5, {animate: false});
|
||||||
|
t.eq(log.length, 3, "no more than 3 events happen.");
|
||||||
|
t.eq(log[0], "movestart", "pan sequence starts with movestart");
|
||||||
|
t.eq(log[1], "move", "followed by move,");
|
||||||
|
t.eq(log[2], "moveend", "and moveend when we're done.");
|
||||||
|
|
||||||
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test if we can call updateSize before document.body is ready. updateOk
|
// test if we can call updateSize before document.body is ready. updateOk
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
popup = new OpenLayers.Popup();
|
popup = new OpenLayers.Popup();
|
||||||
|
|
||||||
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
|
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
|
||||||
t.ok(OpenLayers.String.startsWith(popup.id, "OpenLayers.Popup"),
|
t.ok(OpenLayers.String.startsWith(popup.id, "OpenLayers_Popup"),
|
||||||
"valid default popupid");
|
"valid default popupid");
|
||||||
var firstID = popup.id;
|
var firstID = popup.id;
|
||||||
t.ok(popup.contentSize.equals(size), "good default popup.size");
|
t.ok(popup.contentSize.equals(size), "good default popup.size");
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
popup = new OpenLayers.Popup.Anchored();
|
popup = new OpenLayers.Popup.Anchored();
|
||||||
|
|
||||||
t.ok( popup instanceof OpenLayers.Popup.Anchored, "new OpenLayers.Popup.Anchored returns Popup.Anchored object" );
|
t.ok( popup instanceof OpenLayers.Popup.Anchored, "new OpenLayers.Popup.Anchored returns Popup.Anchored object" );
|
||||||
t.ok(OpenLayers.String.startsWith(popup.id, "OpenLayers.Popup.Anchored"), "valid default popupid");
|
t.ok(OpenLayers.String.startsWith(popup.id, "OpenLayers_Popup_Anchored"), "valid default popupid");
|
||||||
var firstID = popup.id;
|
var firstID = popup.id;
|
||||||
t.eq(popup.contentHTML, null, "good default popup.contentHTML");
|
t.eq(popup.contentHTML, null, "good default popup.contentHTML");
|
||||||
|
|
||||||
|
|||||||
+92
-48
@@ -374,53 +374,6 @@
|
|||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test for https://github.com/openlayers/openlayers/pull/36
|
|
||||||
// (more an integration test than a unit test)
|
|
||||||
function test_olImageLoadError(t) {
|
|
||||||
t.plan(6);
|
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
|
||||||
var layer = new OpenLayers.Layer.WMS("invalid", "foo", {layers: 'basic'});
|
|
||||||
map.addLayer(layer);
|
|
||||||
|
|
||||||
var size = new OpenLayers.Size(5, 6);
|
|
||||||
var position = new OpenLayers.Pixel(20, 30);
|
|
||||||
var bounds = new OpenLayers.Bounds(1, 2, 3, 4);
|
|
||||||
|
|
||||||
var tile = new OpenLayers.Tile.Image(layer, position, bounds, null, size);
|
|
||||||
var log = [];
|
|
||||||
tile.events.register("loaderror", this, function(e) {
|
|
||||||
log.push([
|
|
||||||
e.object.imgDiv.style.visibility,
|
|
||||||
OpenLayers.Element.hasClass(e.object.imgDiv, 'olImageLoadError')
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
tile.events.register("loadend", this, function(e) {
|
|
||||||
log.push(e);
|
|
||||||
})
|
|
||||||
tile.draw();
|
|
||||||
|
|
||||||
t.delay_call(0.1, function() {
|
|
||||||
|
|
||||||
t.eq(log.length, 2, "loaderror and loadend events triggered");
|
|
||||||
t.eq(log[0][0], "hidden", "tile still hidden when loaderror is triggered");
|
|
||||||
t.eq(log[0][1], true, "tile has olImageLoadError class already when loaderror is triggered");
|
|
||||||
t.ok(log[1].object === tile, "loadend event triggered after loaderror");
|
|
||||||
|
|
||||||
// check initial state
|
|
||||||
t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'),
|
|
||||||
'tile image has the olImageLoadError class (init state)');
|
|
||||||
|
|
||||||
layer.setVisibility(false);
|
|
||||||
layer.setVisibility(true);
|
|
||||||
|
|
||||||
t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'),
|
|
||||||
'tile image still has the olImageLoadError class');
|
|
||||||
|
|
||||||
map.destroy();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_getCanvasContext(t) {
|
function test_getCanvasContext(t) {
|
||||||
if (!OpenLayers.CANVAS_SUPPORTED) {
|
if (!OpenLayers.CANVAS_SUPPORTED) {
|
||||||
t.plan(0);
|
t.plan(0);
|
||||||
@@ -445,7 +398,98 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A series of tests to verify the dimensions and positions
|
||||||
|
* of the tile frame and img after draw.
|
||||||
|
|
||||||
|
* Written for https://github.com/openlayers/openlayers/issues/441
|
||||||
|
*/
|
||||||
|
function test_draw_without_gutter_without_frame(t) {
|
||||||
|
t.plan(5);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.WMS('blank',
|
||||||
|
'../../img/blank.gif',
|
||||||
|
{layers: 'fake'},
|
||||||
|
{isBaseLayer: true});
|
||||||
|
map.addLayer(layer);
|
||||||
|
var tile = new OpenLayers.Tile.Image(
|
||||||
|
layer,
|
||||||
|
new OpenLayers.Pixel(6, 6),
|
||||||
|
new OpenLayers.Bounds(5, 45, 6, 46),
|
||||||
|
null,
|
||||||
|
new OpenLayers.Size(256, 256));
|
||||||
|
|
||||||
|
tile.draw();
|
||||||
|
t.eq(tile.frame, null, 'no frame');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.left, 10), 6, 'correct tile img left');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.top, 10), 6, 'correct tile img top');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.width, 10), 256, 'correct tile img width');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.height, 10), 256, 'correct tile img height');
|
||||||
|
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
function test_draw_without_gutter_with_frame(t) {
|
||||||
|
t.plan(8);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.WMS('blank',
|
||||||
|
'../../img/blank.gif',
|
||||||
|
{layers: 'fake'},
|
||||||
|
{isBaseLayer: true});
|
||||||
|
map.addLayer(layer);
|
||||||
|
layer.gutter = 1; // this is just for a frame to be created for
|
||||||
|
// the tile
|
||||||
|
var tile = new OpenLayers.Tile.Image(
|
||||||
|
layer,
|
||||||
|
new OpenLayers.Pixel(6, 6),
|
||||||
|
new OpenLayers.Bounds(5, 45, 6, 46),
|
||||||
|
null,
|
||||||
|
new OpenLayers.Size(256, 256));
|
||||||
|
layer.gutter = null;
|
||||||
|
|
||||||
|
tile.draw();
|
||||||
|
t.eq(parseInt(tile.frame.style.left, 10), 6, 'correct tile frame left');
|
||||||
|
t.eq(parseInt(tile.frame.style.top, 10), 6, 'correct tile frame top');
|
||||||
|
t.eq(parseInt(tile.frame.style.width, 10), 256, 'correct tile frame width');
|
||||||
|
t.eq(parseInt(tile.frame.style.height, 10), 256, 'correct tile frame height');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.left, 10), 0, 'correct tile img left');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.top, 10), 0, 'correct tile img top');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.width, 10), 100, 'correct tile img width');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.height, 10), 100, 'correct tile img height');
|
||||||
|
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
function test_draw_with_gutter(t) {
|
||||||
|
t.plan(8);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.WMS('blank',
|
||||||
|
'../../img/blank.gif',
|
||||||
|
{layers: 'fake'},
|
||||||
|
{isBaseLayer: true, gutter: 15});
|
||||||
|
map.addLayer(layer);
|
||||||
|
var tile = new OpenLayers.Tile.Image(
|
||||||
|
layer,
|
||||||
|
new OpenLayers.Pixel(6, 6),
|
||||||
|
new OpenLayers.Bounds(5, 45, 6, 46),
|
||||||
|
null,
|
||||||
|
new OpenLayers.Size(256, 256));
|
||||||
|
|
||||||
|
tile.draw();
|
||||||
|
t.eq(parseInt(tile.frame.style.left, 10), 6, 'correct tile frame left');
|
||||||
|
t.eq(parseInt(tile.frame.style.top, 10), 6, 'correct tile frame top');
|
||||||
|
t.eq(parseInt(tile.frame.style.width, 10), 256, 'correct tile frame width');
|
||||||
|
t.eq(parseInt(tile.frame.style.height, 10), 256, 'correct tile frame height');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.left, 10), -5, 'correct tile img left');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.top, 10), -5, 'correct tile img top');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.width, 10), 111, 'correct tile img width');
|
||||||
|
t.eq(parseInt(tile.imgDiv.style.height, 10), 111, 'correct tile img height');
|
||||||
|
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
+2
-3
@@ -507,9 +507,8 @@
|
|||||||
|
|
||||||
t.eq(element.style.opacity, '',
|
t.eq(element.style.opacity, '',
|
||||||
"element.style.opacity is removed when opacity = " + opacity);
|
"element.style.opacity is removed when opacity = " + opacity);
|
||||||
//Safari 3 returns null for this value, which is okay
|
// Some browser returns null instead of '', which is okay
|
||||||
var filterString = (OpenLayers.BROWSER_NAME == 'safari') ? null : '';
|
t.ok(element.style.filter == '' || element.style.filter == null,
|
||||||
t.eq(element.style.filter, filterString,
|
|
||||||
"element.style.filter is removed when opacity = " + opacity);
|
"element.style.filter is removed when opacity = " + opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+36
-47
@@ -3,7 +3,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import urllib2
|
|
||||||
import time
|
import time
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
|
|
||||||
@@ -35,18 +34,6 @@ except ImportError, E:
|
|||||||
feedName = "example-list.xml"
|
feedName = "example-list.xml"
|
||||||
feedPath = "http://openlayers.org/dev/examples/"
|
feedPath = "http://openlayers.org/dev/examples/"
|
||||||
|
|
||||||
def getListOfOnlineExamples(baseUrl):
|
|
||||||
"""
|
|
||||||
useful if you want to get a list of examples a url. not used by default.
|
|
||||||
"""
|
|
||||||
html = urllib2.urlopen(baseUrl)
|
|
||||||
soup = BeautifulSoup(html)
|
|
||||||
examples = soup.findAll('li')
|
|
||||||
examples = [example.find('a').get('href') for example in examples]
|
|
||||||
examples = [example for example in examples if example.endswith('.html')]
|
|
||||||
examples = [example for example in examples]
|
|
||||||
return examples
|
|
||||||
|
|
||||||
def getListOfExamples(relPath):
|
def getListOfExamples(relPath):
|
||||||
"""
|
"""
|
||||||
returns list of .html filenames within a given path - excludes example-list.html
|
returns list of .html filenames within a given path - excludes example-list.html
|
||||||
@@ -56,18 +43,15 @@ def getListOfExamples(relPath):
|
|||||||
return examples
|
return examples
|
||||||
|
|
||||||
|
|
||||||
def getExampleHtml(location):
|
def getExampleHtml(path):
|
||||||
"""
|
"""
|
||||||
returns html of a specific example that is available online or locally
|
returns html of a specific example
|
||||||
"""
|
"""
|
||||||
print '.',
|
print '.',
|
||||||
if location.startswith('http'):
|
f = open(path)
|
||||||
return urllib2.urlopen(location).read()
|
html = f.read()
|
||||||
else:
|
f.close()
|
||||||
f = open(location)
|
return html
|
||||||
html = f.read()
|
|
||||||
f.close()
|
|
||||||
return html
|
|
||||||
|
|
||||||
|
|
||||||
def extractById(soup, tagId, value=None):
|
def extractById(soup, tagId, value=None):
|
||||||
@@ -103,15 +87,20 @@ def parseHtml(html,ids):
|
|||||||
d['classes'] = classes
|
d['classes'] = classes
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def getSvnInfo(path):
|
def getGitInfo(exampleDir, exampleName):
|
||||||
h = os.popen("svn info %s --xml" % path)
|
orig = os.getcwd()
|
||||||
tree = ElementTree.fromstring(h.read())
|
os.chdir(exampleDir)
|
||||||
|
h = os.popen("git log -n 1 --pretty=format:'%an|%ai' " + exampleName)
|
||||||
|
os.chdir(orig)
|
||||||
|
log = h.read()
|
||||||
h.close()
|
h.close()
|
||||||
d = {
|
d = {}
|
||||||
'url': tree.findtext('entry/url'),
|
parts = log.split("|")
|
||||||
'author': tree.findtext('entry/commit/author'),
|
d["author"] = parts[0]
|
||||||
'date': tree.findtext('entry/commit/date')
|
# compensate for spaces in git log time
|
||||||
}
|
td = parts[1].split(" ")
|
||||||
|
td.insert(1, "T")
|
||||||
|
d["date"] = "".join(td)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def createFeed(examples):
|
def createFeed(examples):
|
||||||
@@ -206,34 +195,33 @@ if __name__ == "__main__":
|
|||||||
print "This script requires json or simplejson and BeautifulSoup. You don't have them. \n(%s)" % E
|
print "This script requires json or simplejson and BeautifulSoup. You don't have them. \n(%s)" % E
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) == 3:
|
||||||
outFile = open(sys.argv[1],'w')
|
inExampleDir = sys.argv[1]
|
||||||
|
outExampleDir = sys.argv[2]
|
||||||
else:
|
else:
|
||||||
outFile = open('../examples/example-list.js','w')
|
inExampleDir = "../examples"
|
||||||
|
outExampleDir = "../examples"
|
||||||
|
|
||||||
examplesLocation = '../examples'
|
outFile = open(os.path.join(outExampleDir, "example-list.js"), "w")
|
||||||
print 'Reading examples from %s and writing out to %s' % (examplesLocation, outFile.name)
|
|
||||||
|
print 'Reading examples from %s and writing out to %s' % (inExampleDir, outFile.name)
|
||||||
|
|
||||||
exampleList = []
|
exampleList = []
|
||||||
docIds = ['title','shortdesc','tags']
|
docIds = ['title','shortdesc','tags']
|
||||||
|
|
||||||
#comment out option to create docs from online resource
|
examples = getListOfExamples(inExampleDir)
|
||||||
#examplesLocation = 'http://svn.openlayers.org/sandbox/docs/examples/'
|
|
||||||
#examples = getListOfOnlineExamples(examplesLocation)
|
|
||||||
|
|
||||||
examples = getListOfExamples(examplesLocation)
|
|
||||||
|
|
||||||
modtime = time.strftime("%Y-%m-%dT%I:%M:%SZ", time.gmtime())
|
modtime = time.strftime("%Y-%m-%dT%I:%M:%SZ", time.gmtime())
|
||||||
|
|
||||||
for example in examples:
|
for example in examples:
|
||||||
url = os.path.join(examplesLocation,example)
|
path = os.path.join(inExampleDir, example)
|
||||||
html = getExampleHtml(url)
|
html = getExampleHtml(path)
|
||||||
tagvalues = parseHtml(html,docIds)
|
tagvalues = parseHtml(html,docIds)
|
||||||
tagvalues['example'] = example
|
tagvalues['example'] = example
|
||||||
# add in svn info
|
# add in author/date info
|
||||||
d = getSvnInfo(url)
|
d = getGitInfo(inExampleDir, example)
|
||||||
tagvalues["modified"] = d["date"] or modtime
|
|
||||||
tagvalues["author"] = d["author"] or "anonymous"
|
tagvalues["author"] = d["author"] or "anonymous"
|
||||||
|
tagvalues["modified"] = d["date"] or modtime
|
||||||
tagvalues['link'] = example
|
tagvalues['link'] = example
|
||||||
|
|
||||||
exampleList.append(tagvalues)
|
exampleList.append(tagvalues)
|
||||||
@@ -250,8 +238,9 @@ if __name__ == "__main__":
|
|||||||
outFile.write(json)
|
outFile.write(json)
|
||||||
outFile.close()
|
outFile.close()
|
||||||
|
|
||||||
print "writing feed to ../examples/%s " % feedName
|
outFeedPath = os.path.join(outExampleDir, feedName);
|
||||||
atom = open('../examples/%s' % feedName, 'w')
|
print "writing feed to %s " % outFeedPath
|
||||||
|
atom = open(outFeedPath, 'w')
|
||||||
doc = createFeed(exampleList)
|
doc = createFeed(exampleList)
|
||||||
atom.write(doc.toxml())
|
atom.write(doc.toxml())
|
||||||
atom.close()
|
atom.close()
|
||||||
|
|||||||
+5
-5
@@ -33,10 +33,10 @@ mkdir doc/devdocs
|
|||||||
mkdir doc/apidocs
|
mkdir doc/apidocs
|
||||||
rm tools/*.pyc
|
rm tools/*.pyc
|
||||||
|
|
||||||
mkdir -p /osgeo/openlayers/docs/api/$VERSION
|
mkdir -p /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||||
cp OpenLayers*.js /osgeo/openlayers/docs/api/$VERSION
|
cp OpenLayers*.js /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||||
cp -a img/ /osgeo/openlayers/docs/api/$VERSION
|
cp -a img/ /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||||
cp -a theme/ /osgeo/openlayers/docs/api/$VERSION
|
cp -a theme/ /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
@@ -46,4 +46,4 @@ naturaldocs -i OpenLayers-$VERSION/lib -o HTML OpenLayers-$VERSION/doc/apidocs -
|
|||||||
tar cvfz OpenLayers-$VERSION.tar.gz OpenLayers-$VERSION/
|
tar cvfz OpenLayers-$VERSION.tar.gz OpenLayers-$VERSION/
|
||||||
zip -9r OpenLayers-$VERSION.zip OpenLayers-$VERSION/
|
zip -9r OpenLayers-$VERSION.zip OpenLayers-$VERSION/
|
||||||
|
|
||||||
cp OpenLayers-$VERSION.* /osgeo/openlayers/docs/download
|
cp OpenLayers-$VERSION.* /osgeo/openlayers/sites/openlayers.org/download
|
||||||
|
|||||||
+96
-53
@@ -1,69 +1,112 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Used to update http://openlayers.org/dev/
|
# check to see if the hosted examples or API docs need an update
|
||||||
|
cd /osgeo/openlayers/repos/openlayers
|
||||||
|
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/openlayers/ | grep HEAD | awk '{print $1}'`
|
||||||
|
OLD_REMOTE_HEAD=`git rev-parse HEAD`
|
||||||
|
|
||||||
|
# if there's something different in the remote, update and build
|
||||||
|
if [ ! o$REMOTE_HEAD = o$OLD_REMOTE_HEAD ]; then
|
||||||
|
|
||||||
|
git checkout master
|
||||||
|
git clean -f
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# copy everything over to the dev dir within the website (keep the clone clean)
|
||||||
|
rsync -r --exclude=.git . /osgeo/openlayers/sites/openlayers.org/dev
|
||||||
|
|
||||||
|
# make examples use built lib
|
||||||
|
cd /osgeo/openlayers/sites/openlayers.org/dev/tools
|
||||||
|
|
||||||
# Get current 'Last Changed Rev'
|
python exampleparser.py /osgeo/openlayers/repos/openlayers/examples /osgeo/openlayers/sites/openlayers.org/dev/examples
|
||||||
GITREV=`svn info https://github.com/openlayers/openlayers/ | grep 'Revision' | awk '{print $2}'`
|
|
||||||
SVNREV=`svn info http://svn.openlayers.org/ | grep 'Revision' | awk '{print $2}'`
|
if [ ! -f closure-compiler.jar ]; then
|
||||||
|
wget -c http://closure-compiler.googlecode.com/files/compiler-latest.zip
|
||||||
|
unzip compiler-latest.zip
|
||||||
|
mv compiler.jar closure-compiler.jar
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the last svn rev
|
cd /osgeo/openlayers/sites/openlayers.org/dev/build
|
||||||
touch /tmp/ol_git_rev
|
|
||||||
touch /tmp/ol_svn_rev
|
|
||||||
OLD_GITREV="o`cat /tmp/ol_git_rev`"
|
|
||||||
OLD_SVNREV="o`cat /tmp/ol_svn_rev`"
|
|
||||||
|
|
||||||
# If they're not equal, do some work.
|
|
||||||
if [ ! o$GITREV = $OLD_GITREV ]; then
|
|
||||||
svn revert -R /osgeo/openlayers/docs/dev
|
|
||||||
svn up /osgeo/openlayers/docs/dev
|
|
||||||
|
|
||||||
# Also update website
|
|
||||||
svn up /osgeo/openlayers/docs/
|
|
||||||
|
|
||||||
cd /osgeo/openlayers/docs/dev/tools/
|
|
||||||
python exampleparser.py
|
|
||||||
cd /osgeo/openlayers/docs/dev/build
|
|
||||||
./build.py -c closure tests.cfg
|
./build.py -c closure tests.cfg
|
||||||
./build.py -c closure mobile.cfg OpenLayers.mobile.js
|
./build.py -c closure mobile.cfg OpenLayers.mobile.js
|
||||||
./build.py -c closure light.cfg OpenLayers.light.js
|
./build.py -c closure light.cfg OpenLayers.light.js
|
||||||
./build.py -c none tests.cfg OpenLayers.debug.js
|
./build.py -c none tests.cfg OpenLayers.debug.js
|
||||||
./build.py -c none mobile.cfg OpenLayers.mobile.debug.js
|
./build.py -c none mobile.cfg OpenLayers.mobile.debug.js
|
||||||
./build.py -c none light.cfg OpenLayers.light.debug.js
|
./build.py -c none light.cfg OpenLayers.light.debug.js
|
||||||
|
cp OpenLayers*.js ..
|
||||||
cp OpenLayers.js ..
|
|
||||||
cp OpenLayers.*.js ..
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
for i in google ie6-style style; do
|
|
||||||
csstidy theme/default/$i.css --template=highest theme/default/$i.tidy.css
|
|
||||||
cp theme/default/$i.tidy.css theme/default/$i.css
|
|
||||||
done
|
|
||||||
|
|
||||||
|
cd /osgeo/openlayers/sites/openlayers.org/dev
|
||||||
sed -i -e 's!../lib/OpenLayers.js?mobile!../OpenLayers.mobile.js!' examples/*.html
|
sed -i -e 's!../lib/OpenLayers.js?mobile!../OpenLayers.mobile.js!' examples/*.html
|
||||||
sed -i -e 's!../lib/OpenLayers.js!../OpenLayers.js!' examples/*.html
|
sed -i -e 's!../lib/OpenLayers.js!../OpenLayers.js!' examples/*.html
|
||||||
naturaldocs -i /osgeo/openlayers/docs/dev/lib -o HTML /osgeo/openlayers/dev/apidocs -p /osgeo/openlayers/docs/dev/apidoc_config -s Default OL >/dev/null
|
|
||||||
naturaldocs -i /osgeo/openlayers/docs/dev/lib -o HTML /osgeo/openlayers/dev/docs -p /osgeo/openlayers/docs/dev/doc_config -s Default OL >/dev/null
|
# update the API docs
|
||||||
# Record the revision
|
if [ ! -d /osgeo/openlayers/sites/dev.openlayers.org/apidocs ]; then
|
||||||
echo -n $GITREV > /tmp/ol_git_rev
|
mkdir -p /osgeo/openlayers/sites/dev.openlayers.org/apidocs
|
||||||
|
fi
|
||||||
|
if [ ! -d /osgeo/openlayers/sites/dev.openlayers.org/docs ]; then
|
||||||
|
mkdir -p /osgeo/openlayers/sites/dev.openlayers.org/docs
|
||||||
|
fi
|
||||||
|
naturaldocs --input lib --output HTML /osgeo/openlayers/sites/dev.openlayers.org/apidocs -p apidoc_config -s Default OL
|
||||||
|
naturaldocs --input lib --output HTML /osgeo/openlayers/sites/dev.openlayers.org/docs -p doc_config -s Default OL
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check to see if the website needs an update
|
||||||
|
cd /osgeo/openlayers/repos/website
|
||||||
|
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/website/ | grep HEAD | awk '{print $1}'`
|
||||||
|
OLD_REMOTE_HEAD=`git rev-parse HEAD`
|
||||||
|
|
||||||
|
# if there's something different in the remote, update the clone
|
||||||
|
if [ ! o$REMOTE_HEAD = o$OLD_REMOTE_HEAD ]; then
|
||||||
|
|
||||||
|
git checkout master
|
||||||
|
git clean -f
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# copy everything over to the website dir (keep the clone clean)
|
||||||
|
# can't use --delete here because of nested dev dir from above
|
||||||
|
rsync -r --exclude=.git . /osgeo/openlayers/sites/openlayers.org
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check to see if prose docs need an update
|
||||||
|
cd /osgeo/openlayers/repos/docs
|
||||||
|
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/docs/ | grep HEAD | awk '{print $1}'`
|
||||||
|
OLD_REMOTE_HEAD=`git rev-parse HEAD`
|
||||||
|
|
||||||
|
# if there's something different in the remote, update the clone
|
||||||
|
if [ ! o$REMOTE_HEAD = o$OLD_REMOTE_HEAD ]; then
|
||||||
|
|
||||||
|
git checkout master
|
||||||
|
git clean -f
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
mkdir -p /tmp/ol/docs/build/html /tmp/ol/docs/build/doctrees
|
||||||
|
sphinx-build -b html -d /tmp/ol/docs/build/doctrees . /tmp/ol/docs/build/html
|
||||||
|
|
||||||
|
rsync -r --delete /tmp/ol/docs/build/html/ /osgeo/openlayers/sites/docs.openlayers.org
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
## UPDATES FROM THE OLD SVN REPO
|
||||||
|
|
||||||
|
# Get current 'Last Changed Rev'
|
||||||
|
SVNREV=`svn info http://svn.openlayers.org/ | grep 'Revision' | awk '{print $2}'`
|
||||||
|
|
||||||
|
# Get the last svn rev
|
||||||
|
touch /tmp/ol_svn_rev
|
||||||
|
OLD_SVNREV="o`cat /tmp/ol_svn_rev`"
|
||||||
|
|
||||||
|
# If they're not equal, do some work.
|
||||||
if [ ! o$SVNREV = $OLD_SVNREV ]; then
|
if [ ! o$SVNREV = $OLD_SVNREV ]; then
|
||||||
svn up /osgeo/openlayers/dev/sandbox/
|
svn up /osgeo/openlayers/repos/old_svn_repo/
|
||||||
svn up /osgeo/openlayers/dev/addins/
|
|
||||||
# Record the revision
|
# Record the revision
|
||||||
echo -n $SVNREV > /tmp/ol_svn_rev
|
echo -n $SVNREV > /tmp/ol_svn_rev
|
||||||
fi
|
|
||||||
|
|
||||||
svn up /osgeo/openlayers/documentation-checkout
|
|
||||||
REV=`svn info /osgeo/openlayers/documentation-checkout | grep 'Last Changed Rev' | awk '{print $4}'`
|
|
||||||
# Get the last svn rev
|
|
||||||
touch /tmp/ol_doc_rev
|
|
||||||
OLD_REV="o`cat /tmp/ol_doc_rev`"
|
|
||||||
# If they're not equal, do some work.
|
|
||||||
if [ ! o$REV = $OLD_REV ]; then
|
|
||||||
cd /osgeo/openlayers/documentation-checkout
|
|
||||||
make html > /dev/null
|
|
||||||
cp -r _build/html/* /osgeo/openlayers/documentation
|
|
||||||
|
|
||||||
echo -n $REV > /tmp/ol_doc_rev
|
# update the hosted sandboxes
|
||||||
fi
|
rsync -r --delete --exclude=.svn --delete-excluded /osgeo/openlayers/repos/old_svn_repo/sandbox /osgeo/openlayers/sites/dev.openlayers.org/
|
||||||
|
|
||||||
|
# update the hosted addins
|
||||||
|
rsync -r --delete --exclude=.svn --delete-excluded /osgeo/openlayers/repos/old_svn_repo/addins /osgeo/openlayers/sites/dev.openlayers.org/
|
||||||
|
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user