patch had added these two files twice. FIx that. (no real change.) Thanks

edgemaster for pointing it out.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9247 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-04-08 20:11:20 +00:00
parent 0e858fa4af
commit 5f335f4207
2 changed files with 0 additions and 362 deletions

View File

@@ -6,184 +6,6 @@
* @requires OpenLayers/Layer/Grid.js
*/
/**
* Class: OpenLayers.Layer.XYZ
* The XYZ class is designed to make it easier for people who have tiles
* arranged by a standard XYZ grid.
*/
OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
/**
* APIProperty: isBaseLayer
* Default is true, as this is designed to be a base tile source.
*/
isBaseLayer: true,
/**
* APIProperty: sphericalMecator
* Whether the tile extents should be set to the defaults for
* spherical mercator. Useful for things like OpenStreetMap.
* Default is false, except for the OSM subclass.
*/
sphericalMercator: false,
/**
* Constructor: OpenLayers.Layer.XYZ
*
* Parameters:
* name - {String}
* url - {String}
* options - {Object} Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, options) {
if (options && options.sphericalMercator || this.sphericalMercator) {
options = OpenLayers.Util.extend({
maxExtent: new OpenLayers.Bounds(
-128 * 156543.0339,
-128 * 156543.0339,
128 * 156543.0339,
128 * 156543.0339
),
maxResolution: 156543.0339,
numZoomLevels: 19,
units: "m",
projection: "EPSG:900913"
}, options);
}
url = url || this.url;
name = name || this.name;
var newArguments = [name, url, {}, options];
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
},
/**
* APIMethod: clone
* Create a clone of this layer
*
* Parameters:
* obj - {Object} Is this ever used?
*
* Returns:
* {<OpenLayers.Layer.Grid>} An exact clone of this OpenLayers.Layer.Grid
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer.XYZ(this.name,
this.url,
this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
if (this.tileSize != null) {
obj.tileSize = this.tileSize.clone();
}
// we do not want to copy reference to grid, so we make a new array
obj.grid = [];
return obj;
},
/**
* Method: getUrl
*
* Parameters:
* bounds - {<OpenLayers.Bounds>}
*
* Returns:
* {String} A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
*/
getURL: function (bounds) {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left)
/ (res * this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top)
/ (res * this.tileSize.h));
var z = this.map.getZoom();
var limit = Math.pow(2, z);
var url = this.url;
var s = '' + x + y + z;
if (url instanceof Array)
{
url = this.selectUrl(s, url);
}
var path = OpenLayers.String.format(url, {'x': x, 'y': y, 'z': z});
return path;
},
/**
* Method: addTile
* addTile creates a tile, initializes it, and adds it to the layer div.
*
* Parameters:
* bounds - {<OpenLayers.Bounds>}
* position - {<OpenLayers.Pixel>}
*
* Returns:
* {<OpenLayers.Tile.Image>} The added OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
return new OpenLayers.Tile.Image(this, position, bounds,
null, this.tileSize);
},
/* APIMethod: setMap
* When the layer is added to a map, then we can fetch our origin
* (if we don't have one.)
*
* Parameters:
* map - {<OpenLayers.Map>}
*/
setMap: function(map) {
OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);
if (!this.tileOrigin) {
this.tileOrigin = new OpenLayers.LonLat(this.maxExtent.left,
this.maxExtent.bottom);
}
},
CLASS_NAME: "OpenLayers.Layer.XYZ"
});
/**
* Class: OpenLayers.Layer.OSM
* A class to access OpenStreetMap tiles. By default, uses the OpenStreetMap
* hosted tile.openstreetmap.org 'Mapnik' tileset. If you wish to use
* tiles@home / osmarender layer instead, you can pass a layer like:
*
* (code)
* new OpenLayers.Layer.OSM("t@h",
* "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png");
* (end)
*
* This layer defaults to Spherical Mercator.
*/
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
name: "OpenStreetMap",
attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
sphericalMercator: true,
url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png',
CLASS_NAME: "OpenLayers.Layer.OSM"
});
/* Copyright (c) 2006-2009 MetaCarta, Inc., published under the Clear BSD
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Layer/Grid.js
*/
/**
* Class: OpenLayers.Layer.XYZ
* The XYZ class is designed to make it easier for people who have tiles

View File

@@ -174,190 +174,6 @@
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var layer;
var name = 'Test Layer';
var url = "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/${z}/${x}/${y}.png";
var options = {'layername':'basic', 'type':'png'};
function test_Layer_XYZ_constructor (t) {
t.plan( 1 );
layer = new OpenLayers.Layer.XYZ(name, url, options);
t.ok( layer instanceof OpenLayers.Layer.XYZ, "returns OpenLayers.Layer.XYZ object" );
}
function test_Layer_XYZ_clearTiles (t) {
t.plan( 1 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.XYZ(name, url, options);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0));
//grab a reference to one of the tiles
var tile = layer.grid[0][0];
layer.clearGrid();
t.ok( layer.grid != null, "layer.grid does not get nullified" );
map.destroy();
}
function test_Layer_XYZ_getXYZBounds(t) {
t.plan( 1 );
layer = new OpenLayers.Layer.XYZ(name, url, options);
var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)};
var tr = { bounds: new OpenLayers.Bounds(0,0,3,4)};
layer.grid = [ [6, tr],
[bl, 7]];
var bounds = layer.getTilesBounds();
var testBounds = new OpenLayers.Bounds(1,2,3,4);
t.ok( bounds.equals(testBounds), "getXYZBounds() returns correct bounds")
layer.grid = null;
}
function test_Layer_XYZ_getResolution(t) {
t.plan( 1 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.XYZ(name, url, options);
map.addLayer(layer);
map.zoom = 5;
t.eq( layer.getResolution(), 0.0439453125, "getResolution() returns correct value");
map.destroy();
}
function test_Layer_XYZ_getZoomForExtent(t) {
t.plan( 2 );
var bounds, zoom;
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.XYZ(name, url, options);
map.addLayer(layer);
bounds = new OpenLayers.Bounds(10,10,12,12);
zoom = layer.getZoomForExtent(bounds);
t.eq( zoom, 8, "getZoomForExtent() returns correct value");
bounds = new OpenLayers.Bounds(10,10,100,100);
zoom = layer.getZoomForExtent(bounds);
t.eq( zoom, 2, "getZoomForExtent() returns correct value");
map.destroy();
}
/** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
*
* -moveTo
* -insertColumn
* -insertRow
function 07_Layer_XYZ_moveTo(t) {
}
function 08_Layer_XYZ_insertColumn(t) {
}
function 09_Layer_XYZ_insertRow(t) {
}
*
*/
function test_Layer_XYZ_getURL(t) {
t.plan(2);
var map = new OpenLayers.Map('map', options);
var options = {'layername':'basic', 'type':'png'};
layer = new OpenLayers.Layer.XYZ(name, url, options);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 9);
var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/261/63.png", "Tile URL is correct");
layer.url = ["http://tilecache1/", "http://tilecache2/", "http://tilecache3/"];
tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
t.eq(tileurl, "http://tilecache1/", "Tile URL is deterministic");
map.destroy();
}
function test_Layer_XYZ_Rounding(t) {
t.plan(1);
m = new OpenLayers.Map("map", {'maxExtent':new OpenLayers.Bounds(-122.6579,37.4901,-122.0738,37.8795)});
layer = new OpenLayers.Layer.XYZ( "XYZ",
url, {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} );
m.addLayer(layer);
m.zoomToMaxExtent()
t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/0.png", "XYZ tiles around rounded properly.");
m.destroy();
}
function test_Layer_XYZ_setMap(t) {
t.plan(3);
var map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.XYZ(name, url, options);
t.eq(layer.tileOrigin, null, "Tile origin starts out null");
layer.setMap(map);
t.eq(layer.tileOrigin.lat, -90, "lat is -90");
t.eq(layer.tileOrigin.lon, -180, "lon is -180");
map.destroy();
}
function test_Layer_XYZ_destroy (t) {
t.plan( 3 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.XYZ(name, url, options);
map.addLayer(layer);
layer.destroy();
t.eq( layer.grid, null, "layer.grid is null after destroy" );
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
//test with tile creation
layer = new OpenLayers.Layer.XYZ(name, url, options);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
//grab a reference to one of the tiles
var tile = layer.grid[0][0];
layer.destroy();
t.ok( layer.grid == null, "tiles appropriately destroyed");
map.destroy();
}
</script>
</head>
<body>