Compare commits

..

2 Commits

Author SHA1 Message Date
Schuyler Erle
604f458a6b Tagging 2.2-rc1.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.2-rc1@1709 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-20 18:38:25 +00:00
Schuyler Erle
d4d843e57f Branching OpenLayers 2.2 release.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.2@1708 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-20 18:36:39 +00:00
88 changed files with 1190 additions and 2438 deletions

View File

@@ -1,27 +0,0 @@
#!/usr/bin/env python
import sys
sys.path.append("../tools")
import jsmin, mergejs
sourceDirectory = "../lib"
configFilename = "library.cfg"
outputFilename = "OpenLayers.js"
if len(sys.argv) > 1:
configFilename = sys.argv[1] + ".cfg"
if len(sys.argv) > 2:
outputFilename = sys.argv[2]
print "Adding license file."
merged = file("license.txt").read()
print "Merging libraries."
merged += mergejs.run(sourceDirectory, None, configFilename)
print "Compressing."
minimized = jsmin.jsmin(merged)
print "Writing to %s." % outputFilename
file(outputFilename, "w").write(minimized)
print "Done."

44
build/build.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# Script to build compressed single file version of OpenLayers library
#
OUTPUT_FILENAME=OpenLayers.js
TMP_OUTPUT_FILENAME=tmp.${OUTPUT_FILENAME}
TOOLS_DIR=../tools
if [ "$1" != "" ]; then
CFG_FILENAME="$1.cfg"
else
CFG_FILENAME=library.cfg
fi
SRC_DIR=../lib
CMD_MERGE_JS=${TOOLS_DIR}/mergejs.py
CMD_SHRINKSAFE=${TOOLS_DIR}/shrinksafe.py
CMD_JSMIN=${TOOLS_DIR}/jsmin.py
LICENSE_HEADER_FILENAME=license.txt
## Generate "fat" single file library version
${CMD_MERGE_JS} -c ${CFG_FILENAME} ${TMP_OUTPUT_FILENAME} ${SRC_DIR}
## Compress ("shrink") the single file library version
echo
echo Shrinking and post-processing...
# (We also append the license header here.)
cat ${LICENSE_HEADER_FILENAME} > ${OUTPUT_FILENAME}
${CMD_JSMIN} <${TMP_OUTPUT_FILENAME} >> ${OUTPUT_FILENAME}
echo Cleaning up...
rm $TMP_OUTPUT_FILENAME
echo
echo Done.

View File

@@ -1,7 +1,7 @@
#!/bin/sh
rm ../doc/reference.html
CLASSES="Map Layer Layer.Image Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Layer.TMS Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MousePosition Control.MouseToolbar Control.OverviewMap Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util Ajax"
CLASSES="Map Layer Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MousePosition Control.MouseToolbar Control.OverviewMap Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util Ajax"
echo "<html>
<head>
<title>OpenLayers Class Reference Documentation</title>

View File

@@ -10,4 +10,5 @@ Rico/Corner.js
[include]
[exclude]
OpenLayers/Layer/Yahoo.js
OpenLayers/Control/KeyboardDefaults.js

View File

@@ -2,8 +2,8 @@
OpenLayers.js -- OpenLayers Map Viewer Library
Copyright 2005-2006 MetaCarta, Inc., released under the BSD license.
Please see http://svn.openlayers.org/trunk/openlayers/release-license.txt
Copyright 2005-2006 MetaCarta, Inc., released under the BSD License.
Please see http://svn.openlayers.org/trunk/openlayers/license.txt
for the full text of the license.
Includes compressed code under the following licenses:

View File

@@ -13,7 +13,7 @@ A small control which displays the Longitude and Latitude of the current mouse p
separator -- html to separate the longitude and latitude values (default: '<br />')
suffix -- html to follow the latitude value (default: '')
numdigits -- number of digits to the right of the decimal (default: 5)
granularity -- Don't refresh display if mouse has moved more than this (default: 10)
granularity -- a change of how many pixels is considered a mouse move (default: 1)
prefix, separator, and suffix are used to format the lon/lat values.

View File

@@ -1,38 +0,0 @@
OpenLayers.Control.OverviewMap
This control provides a locator or overview map linked to another map. By default, the overview map shows up in the lower right of the main map and can be expdaned with the '+' button.
* Constructor
OpenLayers.Control.OverviewMap(opts?) -- Creates a new overview map. The opts variable is an object with various options, as described in the options section below.
* Methods
isSuitableOverview() -- {Boolean} -- Determines if the overview map is suitable given the extent and resolution of the main map.
getRectPxBounds() -- {OpenLayers.Bounds|bounds} -- An OpenLayers.Bounds which is the extent rectangle's pixel bounds (relative to the parent element).
setRectPxBounds({OpenLayers.Bounds|bounds}) -- none -- Set extent rectangle pixel bounds.
getRectBoundsFromMapBounds({OpenLayers.Bounds|lonLatBounds}) -- {OpenLayers.Bounds|bounds} -- An OpenLayers.Bounds which is the passed-in map lon/lat extent translated into pixel bounds for the overview map.
getMapBoundsFromRectBounds({OpenLayers.Bounds|pxBounds]}) -- {OpenLayers.Bounds|bounds} -- An OpenLayers.Bounds which is the passed-in overview rect bounds translated into lon/lat bounds for the overview map.
getLonLatFromOverviewPx({OpenLayers.Pixel|pixel}) -- {OpenLayers.LonLat|lonlat} -- An OpenLayers.LonLat which is the passed-in overview map OpenLayers.Pixel translated into lon/lat by the overview map.
getOverviewPxFromLonLat({OpenLayers.LonLat|lonlat}) -- {OpenLayers.Pixel|pixel} -- An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into overview map pixels
* Events
* Rectangle events
They are defined on OverviewMap.rectEvents
mouseover -- rectangle is moused over
mouseout -- rectangle is no longer mousedout
mousemove -- mouse moves inside rectangle
mousedown -- mouse button is pressed over the rectangle.
mouseup -- mouse button is released over the rectangle.
click -- mouse clicked
dblclick -- mouse double clicked
* Map events
They are defined on OverviewMap.mapDivEvents
click -- mouse clicked
* Options:
* minRatio -- The ratio of the overview map resolution to the main map resolution at which to zoom farther out on the overview map.
* maxRatio -- The ratio of the overview map resolution to the main map resolution at which to zoom farther in on the overview map.
* layers -- Ordered list of layers in the overview map. If none, then the map base layer is used.

View File

@@ -1,4 +1,4 @@
OpenLayers.Control.PanZoomBar
OpenLayers.Control.PanZoom
Creates a small toolset for controlling the location of the map with panning and zooming, including four directional arrows, a zoom in and zoom out, and a bar on which a slider can be moved to zoom in or out by multiple stops at once.

View File

@@ -12,5 +12,5 @@ The Google Layer in OpenLayers allows you to include Google Maps functionality i
getGPointFromOLPixel({OpenLayers.Pixel|pixel}) -- GPoint -- Create GPoint from OpenLayers Pixel.
* Parameters
type -- one of G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, used to choose the type of map to display. (See <a href="http://www.google.com/apis/maps/documentation/reference.html#GMapType">GMapType in the Google documentation</a> for more.)
type -- one of G_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, used to choose the type of map to display.

View File

@@ -1,9 +0,0 @@
OpenLayers.Layer.Image
The Image Layer allows you to load a single image and use it as a layer in your
map.
* Constructor
OpenLayers.Layer(name, url, {OpenLayers.Bounds|bounds}, {OpenLayers.Size|size}, {options}) -- Image Layer constructor requires a name, URL of the image, geographic bounds of the image, pixel size of the image, and an optional options parameter.

View File

@@ -1,15 +0,0 @@
OpenLayers.Layer.TMS
The TMS layer allows one to connect to a TMS -- Tiled Map Service -- server to obtain images.
* Constructor
OpenLayers.Layer.TMS(name, url, options) -- URL is the base URL to the layer. Options is a set of options, extending the parameters of the layer.
* Methods
getURL({OpenLayers.Bounds|bounds}) -- {String} -- Returns a TMS URL for the given bounds based on the properties of the layer.
All other methods are inherited from {OpenLayers.Layer.Grid}
* Options
tileOrigin -- The tileOrigin option will allow you to set your tileOrigin to something other than the lower left extent of your map.
layername -- Name of the layer in the TMS request.
type -- The extension images have.

View File

@@ -2,13 +2,14 @@
<head>
<style type="text/css">
body { font-family: sans-serif; font-weight: bold; font-size: .8em; }
body {
border: 0px;
margin: 0px;
padding: 0px;
}
#map {
width: 100%;
width: 65%;
height: 100%;
border: 0px;
padding: 0px;
@@ -21,29 +22,86 @@
var lat = 900863;
var lon = 235829;
var zoom = 6;
var map, layer;
var map, layer;
function init(){
// these should be object methods or something
map = new OpenLayers.Map( $('map') );
var basemap = new OpenLayers.Layer.WMS( "Boston",
"http://boston.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/boston/map/gmaps.map', layers: 'border,water,roads,rapid_transit,buildings', format: 'png', 'transparent': 'off'},
// These are the important parts for creating a non-epsg:4326
// map: Maxextent is the boundary of the map/tile loading area,
// maxResolution is the units/pixel at the highest zoom, and
// projection is the projection to be used in WMS/WFS Requests.
{map: '/www/freemap.in/boston/map/gmaps.map', layers: 'border,water,roads', format: 'png', 'transparent': 'off'},
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
var rapid = new OpenLayers.Layer.WMS( "Rapid Transit",
"http://boston.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/boston/map/mass.map', layers: 'rapid_transit', format: 'png', transparent:'true'} );
var buildings = new OpenLayers.Layer.WMS( "Buildings",
"http://boston.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/boston/map/mass.map', layers: 'buildings', format: 'png', transparent:'true'} );
map.addLayer(basemap);
map.addLayer(rapid);
map.addLayer(buildings);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl(new OpenLayers.Control.LayerSwitcher());
}
function getaddress() {
if (!document.getElementById('address').value) {return; }
document.getElementById('status').innerHTML = "Finding address...";
var address = document.getElementById('address').value;
address = escape(address);
addr = "/geocode.cgi?address="+address;
var handler = XMLrequest();
if (handler) {
handler.onreadystatechange=function() {
if (handler.readyState == 4 && handler.status == 200) {
var latlon = handler.responseText;
latlon = latlon.split(",");
if (latlon[1]) {
map.setCenter(new OpenLayers.LonLat(parseFloat(latlon[1]), parseFloat(latlon[0])), 15);
document.getElementById('status').innerHTML = "";
} else {
document.getElementById('status').innerHTML = "Could not find address, sorry.";
}
}
}
handler.open("GET", addr, true);
handler.send('');
}
}
function XMLrequest() {
xmlhttp={};
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) { }
}
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {}
return xmlhttp;
}
function setLink() {
var link = document.getElementById("link");
var center = map.getCenter();
var zoom = map.getZoom();
link.innerHTML="http://boston.freemap.in/?zoom="+zoom+"&amp;lat="+center.lat+"&amp;lon="+center.lon;
}
// -->
</script>
</head>
<body onload="init()">
<div id="right" style="float:right;width:30%;padding:10px;" ><h1>Boston Free Map</h1><!--Search: <input type="text" id='address' name="address"><input type="submit" value="Go!" onclick="javascript:getaddress()"/>--><div id="status" style="height:20px;min-height:20px;">&nbsp;</div>
<div>Map powered by <a href="http://www.openlayers.org/">OpenLayers</a>
and <a href="http://mapserver.gis.umn.edu/">MapServer</a>.
Data downloaded from
<a href="http://www.mass.gov/mgis/">Office of Geographic and Environmental Information (MassGIS)</a>.</div>
<!--<a onclick="setLink(); return false" href="#" id="update">Update Link</a>
<div id="link"></div>-->
</div>
<div id="map"></div>
</body>
</html>

View File

@@ -14,7 +14,7 @@
var map = new OpenLayers.Map('map');
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com:80/wms/vmap0?", {layers: 'basic'});
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi",

View File

@@ -1,51 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
p {
width: 512px;
}
#map {
width: 512px;
height: 256px;
border: 1px solid gray;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map');
var options = {maxResolution: 'auto', numZoomLevels: 3};
var graphic = new OpenLayers.Layer.Image(
'City Lights',
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288),
options);
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi",
{layers: "modis,global_mosaic"}, options);
map.addLayers([graphic, jpl_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Image Layer Example</h1>
<div id="map"></div>
<p>
The "City Lights" layer above is created from a single web accessible
image. If you construct it without any resolution related options,
the layer will be given a single resolution based on the extent/size.
Otherwise, it behaves much like a regular layer. This is primarily
intended to be used in an overview map - where another layer type
might not make a good overview.
</p>
</body>
</html>

View File

@@ -59,7 +59,7 @@
"http://terraservice.net/ogcmap.ashx",
{layers: "DRG"});
shade = new OpenLayers.Layer.WMS("Shaded Relief",
"http://ims.cr.usgs.gov/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3",
"http://ims.cr.usgs.gov:80/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3",
{layers: "HR-NED.IMAGE", reaspect: "false", transparent: 'true'},
{isBaseLayer: false, opacity: 0.3});
map.addLayers([drg, shade]);

View File

@@ -1,43 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Cursor Example</title>
<style type="text/css">
#map {
width: 700px;
height: 400px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map', { controls: [] });
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.MousePosition());
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'} );
map.addLayers([ol_wms]);
OpenLayers.Event.observe($('map'),"click",mapclicked.bindAsEventListener(map));
function mapclicked(e){
var lonlat = map.getLonLatFromPixel(e.xy);
alert("Lat: " + lonlat.lat + " (Pixel.x:" + e.xy.x + ")" + "\n" + "Lon: " + lonlat.lon + " (Pixel.y:" + e.xy.y + ")" );
};
if (!map.getCenter()) map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Cursor Example</h1>
<div id="map"></div>
</body>
</html>

View File

@@ -1,35 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
var urlArray = ["http://labs.metacarta.com/wms-c/Basic.py",
"http://monitor.metacarta.com/wms-c/Basic.py"];
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
urlArray,
{layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -1,47 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Overview Map Example</title>
<script src="../lib/OpenLayers.js" type="text/javascript"></script>
<style>
#map{
width:100%;
height:500px;
border:1px solid;
}
</style>
</head>
<body>
<div id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
// my city
var constantina = new OpenLayers.LonLat(-5.6165,37.8623);
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
var nasa_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"} );
map.addLayers([
nasa_wms,
wms
]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var options = {
layers: [wms.clone()],
minRatio: 8,
maxRatio: 128
};
var overview = new OpenLayers.Control.OverviewMap(options);
map.addControl(overview);
map.setCenter(constantina, 4);
overview.maximizeControl();
</script>
</body>
</html>

View File

@@ -1,4 +1,4 @@
point title description icon
10,20 my orange title my orange description
2,4 my aqua title my aqua description
42,-71 my purple title my purple description<br/>is great. http://www.openlayers.org/api/img/zoom-world-mini.png
point title description iconSize
10,20 my orange title my orange description 21,25
2,4 my aqua title my aqua description 21,25
42,-71 my purple title my purple description<br/>is great. 21,25

View File

@@ -1,39 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map'), {maxResolution:1.40625/2} );
layer = new OpenLayers.Layer.TMS( "TMS",
"http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png'} );
map.addLayer(layer);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
function addTMS() {
l=new OpenLayers.Layer.TMS($('layer').value, $('url').value, {layername: $('layer').value, type:$('type').value});
map.addLayer(l);
map.setBaseLayer(l);
}
// -->
</script>
</head>
<body onload="init()">
URL of TMS (Should end in /): <input type="text" id="url" size="60" /> layer_name <input type="text" id="layer" /> <select id="type"><option>png</option><option>jpg</option></select> <input type="submit" onclick="addTMS()"/><br />
Example: http://mapserver.refractions.net/cgi-bin/tms/, global_mosaic, jpg
<div id="map"></div>
</body>
</html>

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
////
/// This blob sucks in all the files in uncompressed form for ease of use
///
@@ -66,7 +65,6 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Feature/WFS.js",
"OpenLayers/Tile/Image.js",
"OpenLayers/Tile/WFS.js",
"OpenLayers/Layer/Image.js",
"OpenLayers/Layer/EventPane.js",
"OpenLayers/Layer/FixedZoomLevels.js",
"OpenLayers/Layer/Google.js",
@@ -86,7 +84,6 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Layer/GeoRSS.js",
"OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/Canvas.js",
"OpenLayers/Layer/TMS.js",
"OpenLayers/Popup/Anchored.js",
"OpenLayers/Popup/AnchoredBubble.js",
"OpenLayers/Control.js",

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
OpenLayers.ProxyHost = "";
//OpenLayers.ProxyHost = "examples/proxy.cgi?url=";

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/* OpenLayers.Class metaclass */
OpenLayers.Class = {

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,6 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -354,12 +354,12 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.div.appendChild(this.layersDiv);
OpenLayers.Rico.Corner.round(this.div, {corners: "tl bl",
bgColor: "transparent",
color: this.activeColor,
blend: false});
Rico.Corner.round(this.div, {corners: "tl bl",
bgColor: "transparent",
color: this.activeColor,
blend: false});
OpenLayers.Rico.Corner.changeOpacity(this.layersDiv, 0.75);
Rico.Corner.changeOpacity(this.layersDiv, 0.75);
var imgLocation = OpenLayers.Util.getImagesLocation();
var sz = new OpenLayers.Size(18,18);

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -20,6 +19,14 @@ OpenLayers.Control.MouseDefaults.prototype =
*/
initialize: function() {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
//register mousewheel events specifically on the window and document
OpenLayers.Event.observe(window, "DOMMouseScroll",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(window, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(document, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
},
/**
@@ -32,24 +39,6 @@ OpenLayers.Control.MouseDefaults.prototype =
this.map.events.register( "mouseup", this, this.defaultMouseUp );
this.map.events.register( "mousemove", this, this.defaultMouseMove );
this.map.events.register( "mouseout", this, this.defaultMouseOut );
this.registerWheelEvents();
},
/**
*
*/
registerWheelEvents: function() {
//register mousewheel events specifically on the window and document
OpenLayers.Event.observe(window, "DOMMouseScroll",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(window, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(document, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
},
/**
@@ -104,9 +93,6 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt
*/
defaultMouseMove: function (evt) {
// record the mouse position, used in onWheelEvent
this.mousePosition = evt.xy.clone();
if (this.mouseDragStart != null) {
if (this.zoomBox) {
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
@@ -168,21 +154,15 @@ OpenLayers.Control.MouseDefaults.prototype =
/** User spun scroll wheel up
*
*/
defaultWheelUp: function(evt) {
if (this.map.getZoom() <= this.map.getNumZoomLevels()) {
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
this.map.getZoom() + 1);
}
defaultWheelUp: function() {
this.map.zoomIn();
},
/** User spun scroll wheel down
*
*/
defaultWheelDown: function(evt) {
if (this.map.getZoom() > 0) {
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
this.map.getZoom() - 1);
}
defaultWheelDown: function() {
this.map.zoomOut();
},
/** Zoombox function.
@@ -257,15 +237,10 @@ OpenLayers.Control.MouseDefaults.prototype =
delta = -e.detail / 3;
}
if (delta) {
// add the mouse position to the event because mozilla has a bug
// with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
// getLonLatFromViewPortPx(e) returns wrong values
e.xy = this.mousePosition;
if (delta < 0) {
this.defaultWheelDown(e);
this.defaultWheelDown();
} else {
this.defaultWheelUp(e);
this.defaultWheelUp();
}
}

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -28,7 +27,7 @@ OpenLayers.Control.MousePosition.prototype =
numdigits: 5,
/** @type int */
granularity: 10,
granularity: 1,
/** @type OpenLayers.LonLat */
lastXy: null,

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -48,10 +47,8 @@ OpenLayers.Control.MouseToolbar.prototype =
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this.switchModeTo("pan");
this.registerWheelEvents();
return this.div;
},
_addButton:function(id, img, activeImg, xy, sz, title) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
OpenLayers.Event = {
KEY_BACKSPACE: 8,
@@ -96,9 +95,9 @@ OpenLayers.Event = {
|| element.detachEvent))
name = 'keydown';
if (element && element.removeEventListener) {
if (element.removeEventListener) {
element.removeEventListener(name, observer, useCapture);
} else if (element && element.detachEvent) {
} else if (element.detachEvent) {
element.detachEvent('on' + name, observer);
}
}

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -508,8 +507,8 @@ OpenLayers.Layer.prototype = {
var center = this.map.getCenter();
var res = this.map.getResolution();
var delta_x = viewPortPx.x - Math.ceil(size.w / 2);
var delta_y = viewPortPx.y - Math.ceil(size.h / 2);
var delta_x = viewPortPx.x - (size.w / 2);
var delta_y = viewPortPx.y - (size.h / 2);
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res);

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -45,7 +44,7 @@ OpenLayers.Layer.GeoRSS.prototype =
},
/**
* @param {XMLHttpRequest} ajaxRequest
* @param {?} ajaxRequest
*/
parseData: function(ajaxRequest) {
var doc = ajaxRequest.responseXML;

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -227,7 +226,7 @@ OpenLayers.Layer.Google.prototype =
html += " correct API key for your site.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/Google' "
html += "<a href='http://trac.openlayers.org/wiki/GoogleMapsLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -107,33 +106,21 @@ OpenLayers.Layer.Grid.prototype =
|| !this.getGridBounds().containsBounds(bounds, true)) {
this._initTiles();
} else {
var buffer = (this.buffer) ? this.buffer*1.5 : 1;
while (true) {
var tlLayer = this.grid[0][0].position;
var tlViewPort =
this.map.getViewPortPxFromLayerPx(tlLayer);
if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) {
if (tlViewPort.x > -this.tileSize.w * (this.buffer - 1)) {
this.shiftColumn(true);
} else if (tlViewPort.x < -this.tileSize.w * buffer) {
} else if (tlViewPort.x < -this.tileSize.w * this.buffer) {
this.shiftColumn(false);
} else if (tlViewPort.y > -this.tileSize.h * (buffer - 1)) {
} else if (tlViewPort.y > -this.tileSize.h * (this.buffer - 1)) {
this.shiftRow(true);
} else if (tlViewPort.y < -this.tileSize.h * buffer) {
} else if (tlViewPort.y < -this.tileSize.h * this.buffer) {
this.shiftRow(false);
} else {
break;
}
};
if (this.buffer == 0) {
for (var r=0, rl=this.grid.length; r<rl; r++) {
var row = this.grid[r];
for (var c=0, cl=row.length; c<cl; c++) {
var tile = row[c];
if (!tile.drawn && tile.bounds.intersectsBounds(bounds, false)) {
tile.draw();
}
}
}
}
}
}
@@ -165,13 +152,7 @@ OpenLayers.Layer.Grid.prototype =
* @private
*/
_initTiles:function() {
// work out mininum number of rows and columns; this is the number of
// tiles required to cover the viewport plus one for panning
var viewSize = this.map.getSize();
var minRows = Math.ceil(viewSize.h/this.tileSize.h) + 1;
var minCols = Math.ceil(viewSize.w/this.tileSize.w) + 1;
var bounds = this.map.getExtent();
var extent = this.map.getMaxExtent();
var resolution = this.map.getResolution();
@@ -234,31 +215,12 @@ OpenLayers.Layer.Grid.prototype =
tileoffsetlon += tilelon;
tileoffsetx += this.tileSize.w;
} while ((tileoffsetlon <= bounds.right + tilelon * this.buffer)
|| colidx < minCols)
} while (tileoffsetlon <= bounds.right + tilelon * this.buffer)
tileoffsetlat -= tilelat;
tileoffsety += this.tileSize.h;
} while((tileoffsetlat >= bounds.bottom - tilelat * this.buffer)
|| rowidx < minRows)
// remove extra rows
while (this.grid.length > rowidx) {
var row = this.grid.pop();
for (var i=0, l=row.length; i<l; i++) {
row[i].destroy();
}
}
// remove extra columns
while (this.grid[0].length > colidx) {
for (var i=0, l=this.grid.length; i<l; i++) {
var row = this.grid[i];
var tile = row.pop();
tile.destroy();
}
}
} while(tileoffsetlat >= bounds.bottom - tilelat * this.buffer)
//now actually draw the tiles
this.spiralTileLoad();
},
@@ -362,9 +324,8 @@ OpenLayers.Layer.Grid.prototype =
for(var iRow=0; iRow < this.grid.length; iRow++) {
var row = this.grid[iRow];
for(var iCol=0; iCol < row.length; iCol++) {
row[iCol].destroy();
OpenLayers.Util.clearArray(row[iCol]);
}
this.grid = [];
}
}
},

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -109,34 +108,21 @@ OpenLayers.Layer.HTTPRequest.prototype =
// use layer's url unless altUrl passed in
var url = (altUrl == null) ? this.url : altUrl;
// if url is not a string, it should be an array of strings,
// in which case we will randomly select one of them in order
// to evenly distribute requests to different urls.
if (typeof url == "object") {
url = url[Math.floor(Math.random()*url.length)];
}
// requestString always starts with url
var requestString = url;
// create a new params hashtable with all the layer params and the
// new params together. then convert to string
var allParams = OpenLayers.Util.extend(new Object(), this.params);
allParams = OpenLayers.Util.extend(allParams, newParams);
// ignore parameters that are already in the url search string
var urlParams = OpenLayers.Util.upperCaseObject(
OpenLayers.Util.getArgs(url));
for(var key in allParams) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
var allParams = OpenLayers.Util.extend(allParams, newParams);
var paramsString = OpenLayers.Util.getParameterString(allParams);
if (paramsString != "") {
var lastServerChar = url.charAt(url.length - 1);
var lastServerChar = this.url.charAt(this.url.length - 1);
if ((lastServerChar == "&") || (lastServerChar == "?")) {
requestString += paramsString;
} else {
if (url.indexOf('?') == -1) {
if (this.url.indexOf('?') == -1) {
//serverPath has no ? -- add one
requestString += '?' + paramsString;
} else {

View File

@@ -1,161 +0,0 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
/**
* @fileoverview Image Layer
* @author Tim Schaub
*/
/**
* @class
*
* @requires OpenLayers/Layer.js
*/
OpenLayers.Layer.Image = OpenLayers.Class.create();
OpenLayers.Layer.Image.prototype =
OpenLayers.Class.inherit(OpenLayers.Layer, {
/** By default, Layer.Image will be a baselayer
*
* @type Boolean */
isBaseLayer: true,
/** @type String */
url: null,
/** @type OpenLayers.Bounds */
extent: null,
/** @type OpenLayers.Size */
size: null,
/** @type OpenLayers.Tile.Image */
tile: null,
/** The ratio of height/width represented by a single pixel in the graphic
*
* @type Float */
aspectRatio: null,
/**
* @constructor
*
* @param {String} name
* @param {String} url Relative or absolute path to the image
* @param {OpenLayers.Bounds} extent The extent represented by the image
* @param {OpenLayers.Size} size The size (in pixels) of the image
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, extent, size, options) {
this.url = url;
this.extent = extent;
this.size = size;
OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
this.aspectRatio = (this.extent.getHeight() / this.size.h) /
(this.extent.getWidth() / this.size.w);
},
/**
*
*/
destroy: function() {
this.tile.destroy();
this.tile = null;
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.Image
* @type OpenLayers.Layer.Image
*/
clone: function(obj) {
if(obj == null) {
obj = new OpenLayers.Layer.Image(this.name,
this.url,
this.extent,
this.size,
this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
return obj;
},
/**
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
// If nothing to do with resolutions has been set, assume a single
// resolution determined by extent/size
if( this.options.maxResolution == null ) {
this.options.maxResolution = this.extent.getWidth() / this.size.w;
}
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
},
/** Create the tile for the image or resize it for the new resolution
*
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
var firstRendering = (this.tile == null);
if(zoomChanged || firstRendering) {
//determine new tile size
var tileWidth = this.extent.getWidth() / this.map.getResolution();
var tileHeight = this.extent.getHeight() /
(this.map.getResolution() * this.aspectRatio);
var tileSize = new OpenLayers.Size(tileWidth, tileHeight);
//determine new position (upper left corner of new bounds)
var ul = new OpenLayers.LonLat(this.extent.left, this.extent.top);
var ulPx = this.map.getLayerPxFromLonLat(ul);
if(firstRendering) {
//create the new tile
this.tile = new OpenLayers.Tile.Image(this, ulPx, this.extent,
this.url, tileSize);
} else {
//just resize the tile and set it's new position
this.tile.size = tileSize.clone();
this.tile.position = ulPx.clone();
}
this.tile.draw();
}
},
/**
* @param {String} newUrl
*/
setUrl: function(newUrl) {
this.url = newUrl;
this.draw();
},
/** The url we return is always the same (the image itself never changes)
* so we can ignore the bounds parameter (it will always be the same,
* anyways)
*
* @param {OpenLayers.Bounds} bounds
*/
getURL: function(bounds) {
return this.url;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Image"
});

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,101 +1,101 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
// @requires OpenLayers/Layer/Grid.js
/**
* @class
*/
OpenLayers.Layer.MapServer = OpenLayers.Class.create();
OpenLayers.Layer.MapServer.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
/** @final @type hash */
DEFAULT_PARAMS: {
mode: "map",
map_imagetype: "png"
},
/**
* @constructor
*
* @param {str} name
* @param {str} url
* @param {hash} params
*/
initialize: function(name, url, params) {
var newArguments = new Array();
//uppercase params
params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) {
OpenLayers.Util.applyDefaults(
this.params,
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
},
/**
* @type Boolean
*/
isBaseLayer: function() {
return (this.params.TRANSPARENT != 'true');
},
/**
* @param {String} name
* @param {hash} params
*
* @returns A clone of this OpenLayers.Layer.MapServer, with the passed-in
* parameters merged in.
* @type OpenLayers.Layer.MapServer
*/
clone: function (name, params) {
var mergedParams = {};
OpenLayers.Util.extend(mergedParams, this.params);
OpenLayers.Util.extend(mergedParams, params);
var obj = new OpenLayers.Layer.MapServer(name, this.url, mergedParams);
obj.setTileSize(this.tileSize);
return obj;
},
/**
* addTile creates a tile, initializes it (via 'draw' in this case), and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.Image
* @type OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
var url = this.getURL(bounds);
return new OpenLayers.Tile.Image(this, position, bounds, url, this.tileSize);
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
* @type String
*/
getURL: function (bounds) {
var url = this.getFullRequestString(
{mapext:bounds.toBBOX().replace(/,/g,"+"),
imgext:bounds.toBBOX().replace(/,/g,"+"),
map_size:this.tileSize.w+'+'+this.tileSize.h,
imgx: this.tileSize.w/2,
imgy: this.tileSize.h/2,
imgxy: this.tileSize.w+"+"+this.tileSize.h
});
return url;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MapServer"
});
/* Copyright (c) 2006 MetaCarta, Inc., published under the 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.MapServer = OpenLayers.Class.create();
OpenLayers.Layer.MapServer.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
/** @final @type hash */
DEFAULT_PARAMS: {
mode: "map",
map_imagetype: "png"
},
/**
* @constructor
*
* @param {str} name
* @param {str} url
* @param {hash} params
*/
initialize: function(name, url, params) {
var newArguments = new Array();
//uppercase params
params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) {
OpenLayers.Util.applyDefaults(
this.params,
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
},
/**
* @type Boolean
*/
isBaseLayer: function() {
return (this.params.TRANSPARENT != 'true');
},
/**
* @param {String} name
* @param {hash} params
*
* @returns A clone of this OpenLayers.Layer.MapServer, with the passed-in
* parameters merged in.
* @type OpenLayers.Layer.MapServer
*/
clone: function (name, params) {
var mergedParams = {};
OpenLayers.Util.extend(mergedParams, this.params);
OpenLayers.Util.extend(mergedParams, params);
var obj = new OpenLayers.Layer.MapServer(name, this.url, mergedParams);
obj.setTileSize(this.tileSize);
return obj;
},
/**
* addTile creates a tile, initializes it (via 'draw' in this case), and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.Image
* @type OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
var url = this.getURL(bounds);
return new OpenLayers.Tile.Image(this, position, bounds, url, this.tileSize);
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
* @type String
*/
getURL: function (bounds) {
var url = this.getFullRequestString(
{mapext:bounds.toBBOX().replace(/,/g,"+"),
imgext:bounds.toBBOX().replace(/,/g,"+"),
map_size:this.tileSize.w+'+'+this.tileSize.h,
imgx: this.tileSize.w/2,
imgy: this.tileSize.h/2,
imgxy: this.tileSize.w+"+"+this.tileSize.h
});
return url;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MapServer"
});

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,6 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -65,7 +65,7 @@ OpenLayers.Layer.MultiMap.prototype =
html += " script was either not correctly included.<br>";
html += "<br>";
html += "Demmlopers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/MultiMap' "
html += "<a href='http://trac.openlayers.org/wiki/MultiMapLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";

View File

@@ -1,112 +0,0 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD licence.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Layer/Grid.js
*/
OpenLayers.Layer.TMS = OpenLayers.Class.create();
OpenLayers.Layer.TMS.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
reproject: false,
isBaseLayer: true,
tileOrigin: null,
/**
* @constructor
*
* @param {String} name
* @param {String} url
* @param {Object} params
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, options) {
var newArguments = new Array();
newArguments.push(name, url, {}, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
},
/**
*
*/
destroy: function() {
// for now, nothing special to do here.
OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
},
/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.TMS
* @type OpenLayers.Layer.TMS
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer.TMS(this.name,
this.url,
this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
return obj;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
* @type String
*/
getURL: function (bounds) {
var res = this.map.getResolution();
var x = (bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w);
var y = (bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h);
var z = this.map.getZoom();
return this.url + "1.0.0" + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
},
/**
* addTile creates a tile, initializes it, and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.Image
* @type OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
var url = this.getURL(bounds);
return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize);
},
/** When the layer is added to a map, then we can fetch our origin
* (if we don't have one.)
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);
if (!this.tileOrigin) {
this.tileOrigin = new OpenLayers.LonLat(this.map.maxExtent.left,
this.map.maxExtent.bottom);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.TMS"
});

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -49,7 +48,7 @@ OpenLayers.Layer.Text.prototype =
/**
* @param {XMLHttpRequest} ajaxRequest
* @param {?} ajaxRequest
*/
parseData: function(ajaxRequest) {
var text = ajaxRequest.responseText;

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -81,7 +80,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
html += " script was either not correctly included.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/VirtualEarth' "
html += "<a href='http://trac.openlayers.org/wiki/VirtualEarthLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -125,7 +124,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
//clear out the old tile
if (this.tile) {
this.tile.clear();
OpenLayers.Util.clearArray(this.tile);
}
//determine new tile bounds
@@ -150,11 +149,6 @@ OpenLayers.Layer.WMS.Untiled.prototype =
var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);
var pos = this.map.getLayerPxFromLonLat(ul);
if ( this.tile && !this.tile.size.equals(tileSize)) {
this.tile.destroy();
this.tile = null;
}
if (!this.tile) {
this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds,
url, tileSize);
@@ -193,7 +187,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
newArguments);
//redraw
this.moveTo(null, true);
this.moveTo();
},
/** combine the layer's url with its params and these newParams.

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -95,7 +94,7 @@ OpenLayers.Layer.Yahoo.prototype =
html += " script was either not correctly included.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/Yahoo' "
html += "<a href='http://trac.openlayers.org/wiki/YahooLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -483,12 +482,9 @@ OpenLayers.Map.prototype = {
control.setMap(this);
var div = control.draw(px);
if (div) {
// only elements without parents should be appended to the viewport
if(!div.parentNode) {
div.style.zIndex = this.Z_INDEX_BASE['Control'] +
this.controls.length;
this.viewPortDiv.appendChild( div );
}
div.style.zIndex = this.Z_INDEX_BASE['Control'] +
this.controls.length;
this.viewPortDiv.appendChild( div );
}
},
@@ -789,10 +785,8 @@ OpenLayers.Map.prototype = {
var originPx = this.getViewPortPxFromLonLat(this.layerContainerOrigin);
var newPx = this.getViewPortPxFromLonLat(lonlat);
if ((originPx != null) && (newPx != null)) {
this.layerContainerDiv.style.left = (originPx.x - newPx.x) + "px";
this.layerContainerDiv.style.top = (originPx.y - newPx.y) + "px";
}
this.layerContainerDiv.style.left = (originPx.x - newPx.x) + "px";
this.layerContainerDiv.style.top = (originPx.y - newPx.y) + "px";
},
/**

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -9,22 +8,18 @@
* @requires OpenLayers/Marker.js
*/
OpenLayers.Marker.Box = OpenLayers.Class.create();
OpenLayers.Marker.Box.prototype =
OpenLayers.Class.inherit( OpenLayers.Marker, {
/** @type OpenLayers.Bounds */
OpenLayers.Marker.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Marker, {
/** @type OpenLayers.LonLat */
bounds: null,
/** @type DOMElement */
div: null,
/**
* @constructor
*
* @param {OpenLayers.Bounds} bounds
* @param {String} borderColor
* @param {int} borderWidth
*/
* @constructor
*
* @param {OpenLayers.Icon} icon
* @param {OpenLayers.LonLat lonlat
*/
initialize: function(bounds, borderColor, borderWidth) {
this.bounds = bounds;
this.div = OpenLayers.Util.createDiv();
@@ -33,24 +28,14 @@ OpenLayers.Marker.Box.prototype =
this.setBorder(borderColor, borderWidth);
},
/** Allow the user to change the box's color and border width
*
* @param {String} color Default is "red"
* @param {int} width Default is 2
*/
setBorder: function (color, width) {
if (!color) {
color = "red";
}
if (!width) {
width = 2;
}
if (!color) color = "red";
if (!width) width = 2;
this.div.style.border = width + "px solid " + color;
},
/**
* @param {OpenLayers.Pixel} px
* @param {OpenLayers.Size} sz
*
* @return A new DOM Image with this marker<65>s icon set at the
* location passed-in

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -207,10 +206,6 @@ OpenLayers.Popup.prototype = {
this.div.style.width = this.size.w + "px";
this.div.style.height = this.size.h + "px";
}
if (this.contentDiv != null){
this.contentDiv.style.width = this.size.w + "px";
this.contentDiv.style.height = this.size.h + "px";
}
},
/**

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -70,13 +69,10 @@ OpenLayers.Popup.AnchoredBubble.prototype =
contentSize.h -= (2 * this.padding);
this.contentDiv.style.height = contentSize.h + "px";
this.contentDiv.style.width = contentSize.w + "px";
if (this.map) {
//size has changed - must redo corners
this.setRicoCorners(!this.rounded);
this.rounded = true;
}
//size has changed - must redo corners
this.setRicoCorners(!this.rounded);
this.rounded = true;
}
},
@@ -91,7 +87,7 @@ OpenLayers.Popup.AnchoredBubble.prototype =
if (this.div != null) {
if (this.contentDiv != null) {
this.div.style.background = "transparent";
OpenLayers.Rico.Corner.changeColor(this.contentDiv, this.backgroundColor);
Rico.Corner.changeColor(this.contentDiv, this.backgroundColor);
}
}
},
@@ -106,7 +102,7 @@ OpenLayers.Popup.AnchoredBubble.prototype =
if (this.div != null) {
if (this.contentDiv != null) {
OpenLayers.Rico.Corner.changeOpacity(this.contentDiv, this.opacity);
Rico.Corner.changeOpacity(this.contentDiv, this.opacity);
}
}
},
@@ -137,9 +133,9 @@ OpenLayers.Popup.AnchoredBubble.prototype =
blend: false};
if (firstTime) {
OpenLayers.Rico.Corner.round(this.div, options);
Rico.Corner.round(this.div, options);
} else {
OpenLayers.Rico.Corner.reRound(this.contentDiv, options);
Rico.Corner.reRound(this.contentDiv, options);
//set the popup color and opacity
this.setBackgroundColor();
this.setOpacity();

View File

@@ -1,6 +1,5 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
_OPENLAYERS_SFL_=true;
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
_OPENLAYERS_SFL_=true

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/*
* @class
@@ -69,12 +68,7 @@ OpenLayers.Tile.prototype = {
/**
*/
draw:function() {
this.clear();
return ((this.layer.displayOutsideMaxExtent
|| (this.layer.maxExtent
&& this.bounds.intersectsBounds(this.layer.maxExtent, false)))
&& !(this.layer.buffer == 0
&& !this.bounds.intersectsBounds(this.layer.map.getExtent(), false)));
this.drawn = true;
},
/**
@@ -88,7 +82,7 @@ OpenLayers.Tile.prototype = {
redraw = true;
}
this.clear();
OpenLayers.Util.clearArray(this);
this.bounds = bounds.clone();
this.position = position.clone();
if (redraw) {
@@ -104,8 +98,8 @@ OpenLayers.Tile.prototype = {
},
getBoundsFromBaseLayer: function(position) {
var topLeft = this.layer.map.getLonLatFromLayerPx(position);
var bottomRightPx = position.clone();
var topLeft = this.layer.map.getLonLatFromLayerPx(this.position);
var bottomRightPx = this.position.clone();
bottomRightPx.x += this.size.w;
bottomRightPx.y += this.size.h;
var bottomRight = this.layer.map.getLonLatFromLayerPx(bottomRightPx);
@@ -117,7 +111,7 @@ OpenLayers.Tile.prototype = {
} else {
bottomRight.lon = 180+bottomRight.lon+180;
}
}
}
bounds = new OpenLayers.Bounds(topLeft.lon, bottomRight.lat, bottomRight.lon, topLeft.lat);
return bounds;
},
@@ -126,4 +120,3 @@ OpenLayers.Tile.prototype = {
CLASS_NAME: "OpenLayers.Tile"
};

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -43,28 +42,29 @@ OpenLayers.Tile.Image.prototype =
*
*/
draw:function() {
if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {
this.bounds = this.getBoundsFromBaseLayer(this.position);
}
if (!OpenLayers.Tile.prototype.draw.apply(this, arguments)) {
return false;
}
OpenLayers.Tile.prototype.draw.apply(this, arguments);
if (this.imgDiv == null) {
this.initImgDiv();
}
this.url = this.layer.getURL(this.bounds);
if (this.layer.alpha) {
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, this.position, this.size, this.url);
} else {
this.imgDiv.src = this.url;
OpenLayers.Util.modifyDOMElement(this.imgDiv,
null, this.position, this.size) ;
if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {
this.bounds = this.getBoundsFromBaseLayer(this.position);
}
this.url = this.layer.getURL(this.bounds);
this.imgDiv.style.display = "none";
if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent &&
(this.bounds.intersectsBounds(this.layer.maxExtent,false))
)) {
if (this.layer.alpha) {
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, this.position, this.size, this.url);
} else {
this.imgDiv.src = this.url;
OpenLayers.Util.modifyDOMElement(this.imgDiv,
null, this.position, this.size) ;
}
}
this.drawn = true;
return true;
},
/** Clear the tile of any bounds/position-related data so that it can
@@ -143,13 +143,9 @@ OpenLayers.Tile.Image.prototype =
* @private
*/
checkImgURL: function () {
// Sometimes our image will load after it has already been removed
// from the map, in which case this check is not needed.
if (this.layer) {
var loaded = this.layer.alpha ? this.imgDiv.firstChild.src : this.imgDiv.src;
if (!OpenLayers.Util.isEquivalentUrl(loaded, this.url)) {
this.imgDiv.style.display = "none";
}
var loaded = this.layer.alpha ? this.imgDiv.firstChild.src : this.imgDiv.src;
if (loaded != this.url) {
this.imgDiv.style.display = "none";
}
},

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -57,12 +56,14 @@ OpenLayers.Tile.WFS.prototype =
*
*/
draw:function() {
if (!OpenLayers.Tile.prototype.draw.apply(this, arguments)) {
return false;
if (this.drawn) {
OpenLayers.Util.clearArray(this);
}
this.loadFeaturesForRegion(this.requestSuccess);
this.drawn = true;
return true;
OpenLayers.Tile.prototype.draw.apply(this, arguments);
if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent &&
this.layer.maxExtent.intersectsBounds(this.bounds, false))) {
this.loadFeaturesForRegion(this.requestSuccess);
}
},
/** get the full request string from the ds and the tile params
@@ -88,7 +89,7 @@ OpenLayers.Tile.WFS.prototype =
/** Return from AJAX request
*
* @param {XMLHttpRequest} request
* @param {} request
*/
requestSuccess:function(request) {
var doc = request.responseXML;
@@ -129,4 +130,3 @@ OpenLayers.Tile.WFS.prototype =
}
);

View File

@@ -1,7 +1,6 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
@@ -222,14 +221,9 @@ OpenLayers.Util.onImageLoad = function() {
};
OpenLayers.Util.onImageLoadErrorColor = "pink";
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 0;
OpenLayers.Util.onImageLoadError = function() {
this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
if(this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
this.src = this.src;
} else {
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
}
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
this.style.display = "";
};
@@ -385,8 +379,7 @@ OpenLayers.Util.getParameterString = function(params) {
for (var key in params) {
var value = params[key];
if ((value != null) && (typeof value != 'function')) {
paramsArray.push(encodeURIComponent(key) + "=" +
encodeURIComponent(value));
paramsArray.push(key + "=" + value);
}
}
@@ -558,32 +551,21 @@ OpenLayers.Util.distVincenty=function(p1, p2) {
var d = s.toFixed(3)/1000; // round to 1mm precision
return d;
};
/**
* @param {String} url Optional url used to extract the query string.
* If null, query string is taken from page location.
*
* @returns An object of key/value pairs from the query string.
* @type Object
*/
OpenLayers.Util.getArgs = function(url) {
if(url == null) {
var query = window.location.search.substring(1);
} else {
var query = (url.indexOf('?') == -1) ?
'' : url.substring(url.indexOf('?') + 1);
}
OpenLayers.Util.getArgs = function() {
var args = new Object();
pairs = query.split(/[&;]/);
for(var i = 0; i < pairs.length; ++i) {
keyValue = pairs[i].split(/=/);
if(keyValue.length == 2) {
args[decodeURIComponent(keyValue[0])] =
decodeURIComponent(keyValue[1]);
}
var query = location.search.substring(1); // Get query string.
var pairs = query.split("&"); // Break at ampersand. //+pjl
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('='); // Look for "name=value".
if (pos == -1) continue; // If not found, skip.
var argname = pairs[i].substring(0,pos); // Extract the name.
var value = pairs[i].substring(pos+1); // Extract the value.
args[argname] = unescape(value); // Store as a property.
}
return args;
}
return args; // Return the object.
};
/**
* @param {String} prefix String to prefix random id. If null, default
@@ -709,112 +691,3 @@ OpenLayers.Util.pagePosition = function(forElement) {
return [valueL, valueT];
};
/** Test two URLs for equivalence.
*
* Setting 'ignoreCase' allows for case-independent comparison.
*
* Comparison is based on:
* - Protocol
* - Host (evaluated without the port)
* - Port (set 'ignorePort80' to ignore "80" values)
* - Hash ( set 'ignoreHash' to disable)
* - Pathname (for relative <-> absolute comparison)
* - Arguments (so they can be out of order)
*
*
*
* @param {String} url1
* @param {String} url2
* @param {Object} options allows for customization of comparison:
* 'ignoreCase' - Default is True
* 'ignorePort80' - Default is True
* 'ignoreHash' - Default is True
*
* @returns Whether or not the two URLs are equivalent
* @type Boolean
*/
OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
options = options || new Object();
OpenLayers.Util.applyDefaults(options, {
ignoreCase: true,
ignorePort80: true,
ignoreHash: true
});
urlObj1 = OpenLayers.Util.createUrlObject(url1, options);
urlObj2 = OpenLayers.Util.createUrlObject(url2, options);
//compare keys (host, port, etc)
for(var key in urlObj1) {
if ( (key != "args") && (urlObj1[key] != urlObj2[key]) ) {
return false;
}
}
// compare search args - irrespective of order
for(var key in urlObj1.args) {
if(urlObj1.args[key] != urlObj2.args[key]) {
return false;
}
delete urlObj2.args[key];
}
// urlObj2 shouldn't have any args left
for(var key in urlObj2.args) {
return false;
}
return true;
};
/**
* @private
*
* @param {String} url
* @param {Object} options
*
* @returns An object with separate url, a, port, host, and args parsed out
* and ready for comparison
* @type Object
*/
OpenLayers.Util.createUrlObject = function(url, options) {
options = options || new Object();
var urlObject = new Object();
if (options.ignoreCase) {
url = url.toLowerCase();
}
var a = document.createElement('a');
a.href = url;
//protocol
urlObject.protocol = a.protocol;
//pathname (this part allows for relative <-> absolute comparison)
urlObject.pathname = a.pathname;
//hash
urlObject.hash = (options.ignoreHash) ? "" : a.hash;
//host (without port)
urlObject.host = a.host;
var port = a.port;
if (port.length <= 0) {
var newHostLength = urlObject.host.length - (port.length);
urlObject.host = urlObject.host.substring(0, newHostLength);
}
//port
urlObject.port = ((port == "80") && (options.ignorePort80)) ? "" : port;
//args
urlObject.args = OpenLayers.Util.getArgs(a.search);
return urlObject;
};

View File

@@ -1,6 +1,6 @@
OpenLayers.Rico.Color = OpenLayers.Class.create();
Rico.Color = OpenLayers.Class.create();
OpenLayers.Rico.Color.prototype = {
Rico.Color.prototype = {
initialize: function(red, green, blue) {
this.rgb = { r: red, g : green, b : blue };
@@ -25,7 +25,7 @@ OpenLayers.Rico.Color.prototype = {
hsb.h = h;
// convert back to RGB...
this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
},
setSaturation: function(s) {
@@ -34,7 +34,7 @@ OpenLayers.Rico.Color.prototype = {
hsb.s = s;
// convert back to RGB and set values...
this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
},
setBrightness: function(b) {
@@ -43,17 +43,17 @@ OpenLayers.Rico.Color.prototype = {
hsb.b = b;
// convert back to RGB and set values...
this.rgb = OpenLayers.Rico.Color.HSBtoRGB( hsb.h, hsb.s, hsb.b );
this.rgb = Rico.Color.HSBtoRGB( hsb.h, hsb.s, hsb.b );
},
darken: function(percent) {
var hsb = this.asHSB();
this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.max(hsb.b - percent,0));
this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.max(hsb.b - percent,0));
},
brighten: function(percent) {
var hsb = this.asHSB();
this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.min(hsb.b + percent,1));
this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.min(hsb.b + percent,1));
},
blend: function(other) {
@@ -80,7 +80,7 @@ OpenLayers.Rico.Color.prototype = {
},
asHSB: function() {
return OpenLayers.Rico.Color.RGBtoHSB(this.rgb.r, this.rgb.g, this.rgb.b);
return Rico.Color.RGBtoHSB(this.rgb.r, this.rgb.g, this.rgb.b);
},
toString: function() {
@@ -89,7 +89,7 @@ OpenLayers.Rico.Color.prototype = {
};
OpenLayers.Rico.Color.createFromHex = function(hexCode) {
Rico.Color.createFromHex = function(hexCode) {
if(hexCode.length==4) {
var shortHexCode = hexCode;
var hexCode = '#';
@@ -101,39 +101,39 @@ shortHexCode.charAt(i));
var red = hexCode.substring(0,2);
var green = hexCode.substring(2,4);
var blue = hexCode.substring(4,6);
return new OpenLayers.Rico.Color( parseInt(red,16), parseInt(green,16), parseInt(blue,16) );
return new Rico.Color( parseInt(red,16), parseInt(green,16), parseInt(blue,16) );
}
/**
* Factory method for creating a color from the background of
* an HTML element.
*/
OpenLayers.Rico.Color.createColorFromBackground = function(elem) {
Rico.Color.createColorFromBackground = function(elem) {
var actualColor = RicoUtil.getElementsComputedStyle($(elem), "backgroundColor", "background-color");
if ( actualColor == "transparent" && elem.parentNode )
return OpenLayers.Rico.Color.createColorFromBackground(elem.parentNode);
return Rico.Color.createColorFromBackground(elem.parentNode);
if ( actualColor == null )
return new OpenLayers.Rico.Color(255,255,255);
return new Rico.Color(255,255,255);
if ( actualColor.indexOf("rgb(") == 0 ) {
var colors = actualColor.substring(4, actualColor.length - 1 );
var colorArray = colors.split(",");
return new OpenLayers.Rico.Color( parseInt( colorArray[0] ),
return new Rico.Color( parseInt( colorArray[0] ),
parseInt( colorArray[1] ),
parseInt( colorArray[2] ) );
}
else if ( actualColor.indexOf("#") == 0 ) {
return OpenLayers.Rico.Color.createFromHex(actualColor);
return Rico.Color.createFromHex(actualColor);
}
else
return new OpenLayers.Rico.Color(255,255,255);
return new Rico.Color(255,255,255);
}
OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
var red = 0;
var green = 0;
@@ -188,7 +188,7 @@ OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
return { r : parseInt(red), g : parseInt(green) , b : parseInt(blue) };
}
OpenLayers.Rico.Color.RGBtoHSB = function(r, g, b) {
Rico.Color.RGBtoHSB = function(r, g, b) {
var hue;
var saturation;

View File

@@ -14,8 +14,8 @@
**/
OpenLayers.Rico = new Object();
OpenLayers.Rico.Corner = {
var Rico = new Object();
Rico.Corner = {
round: function(e, options) {
var e = $(e);
@@ -305,8 +305,8 @@ OpenLayers.Rico.Corner = {
},
_hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) return true; return false; },
_blend: function(c1, c2) { var cc1 = OpenLayers.Rico.Color.createFromHex(c1); cc1.blend(OpenLayers.Rico.Color.createFromHex(c2)); return cc1; },
_background: function(el) { try { return OpenLayers.Rico.Color.createColorFromBackground(el).asHex(); } catch(err) { return "#ffffff"; } },
_blend: function(c1, c2) { var cc1 = Rico.Color.createFromHex(c1); cc1.blend(Rico.Color.createFromHex(c2)); return cc1; },
_background: function(el) { try { return Rico.Color.createColorFromBackground(el).asHex(); } catch(err) { return "#ffffff"; } },
_isTransparent: function() { return this.options.color == "transparent"; },
_isTopRounded: function() { return this._hasString(this.options.corners, "all", "top", "tl", "tr"); },
_isBottomRounded: function() { return this._hasString(this.options.corners, "all", "bottom", "bl", "br"); },

View File

@@ -1,5 +1,3 @@
This license applies to official code releases at www.openlayers.org:
Copyright (c) 2005-2006 MetaCarta, Inc.
All rights reserved.

View File

@@ -1,35 +0,0 @@
This license applies to all code and content in the OpenLayers code
repository at svn.openlayers.org:
Copyright (c) 2005-2006 MetaCarta, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of MetaCarta, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
This license grants no rights to any components related to natural language
processing, free text querying, or unstructured information retrieval. This
license grants no rights to components that implement inventions on which
MetaCarta has patents or has filed applications for patents.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -11,7 +11,6 @@
<li>test_Events.html</li>
<li>test_Util.html</li>
<li>test_Layer.html</li>
<li>test_Layer_Image.html</li>
<li>test_Layer_EventPane.html</li>
<li>test_Layer_FixedZoomLevels.html</li>
<li>test_Layer_HTTPRequest.html</li>
@@ -21,7 +20,6 @@
<li>test_Layer_GeoRSS.html</li>
<li>test_Layer_KaMap.html</li>
<li>test_Layer_WMS.html</li>
<li>test_Layer_TMS.html</li>
<li>test_Tile.html</li>
<li>test_Tile_Image.html</li>
<li>test_Control.html</li>

View File

@@ -108,6 +108,6 @@
</script>
</head>
<body>
<div id="map" style="height:500px;width:500px"></div>
<div id="map"></div>
</body>
</html>

View File

@@ -89,64 +89,56 @@
tParams = { layers: 'basic',
format: 'image/png'};
t.plan( 9 );
t.plan( 8 );
// without ?
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
str = layer.getFullRequestString();
t.eq(str, tUrl + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url sans ?");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?layers=basic&format=image/png", "getFullRequestString() works for url sans ?");
// with ?
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?";
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
str = layer.getFullRequestString();
t.eq(str, tUrl + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url with ?");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?layers=basic&format=image/png", "getFullRequestString() works for url with ?");
// with ?param1=5
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?param1=5";
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
str = layer.getFullRequestString();
t.eq(str, tUrl + '&' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url with ?param1=5");
// with ?param1=5&
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&format=image/jpeg";
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
str = layer.getFullRequestString();
t.eq(str, tUrl + '&' + OpenLayers.Util.getParameterString({'layers':'basic'}), "getFullRequestString() doesn't override already-existing params in URL");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&layers=basic&format=image/png", "getFullRequestString() works for url with ?param1=5");
// with ?param1=5&
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&";
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
str = layer.getFullRequestString();
t.eq(str, tUrl + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url with ?param1=5&");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&layers=basic&format=image/png", "getFullRequestString() works for url with ?param1=5&");
// passing in new params
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
str = layer.getFullRequestString( { chicken: 6,
layers:"road" } );
t.eq(str, tUrl + OpenLayers.Util.getParameterString({layers: 'road', format: "image/png", chicken: 6}), "getFullRequestString() works for passing in new params");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&layers=road&format=image/png&chicken=6", "getFullRequestString() works for passing in new params");
// layer with null params
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, null, null);
str = layer.getFullRequestString();
t.eq(str, tUrl + OpenLayers.Util.getParameterString({}), "getFullRequestString() works for layer with null params");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&", "getFullRequestString() works for layer with null params");
// layer with null params passing in new params
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, null, null);
str = layer.getFullRequestString( { chicken: 6,
layers:"road" } );
t.eq(str, tUrl + OpenLayers.Util.getParameterString({chicken: 6, layers: "road"}), "getFullRequestString() works for layer with null params passing in new params");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&chicken=6&layers=road", "getFullRequestString() works for layer with null params passing in new params");
// with specified altUrl parameter
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.HTTPRequest(name, "chicken", tParams, null);
str = layer.getFullRequestString(null, tUrl);
t.eq(str, tUrl + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url sans ?");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?layers=basic&format=image/png", "getFullRequestString() works for url sans ?");
}

View File

@@ -1,96 +0,0 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var layer;
function test_01_Layer_Image_constructor (t) {
t.plan( 13 );
var options = { chicken: 151, foo: "bar", projection: "none" };
var layer = new OpenLayers.Layer.Image('Test Layer',
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288), options);
t.ok( layer instanceof OpenLayers.Layer.Image, "new OpenLayers.Layer.Image returns object" );
t.eq( layer.CLASS_NAME, "OpenLayers.Layer.Image", "CLASS_NAME variable set correctly");
t.eq( layer.name, "Test Layer", "layer.name is correct" );
t.ok( layer.id != null, "Layer is given an id");
t.ok( layer.projection, "none", "default layer projection correctly set");
t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
options.chicken = 552;
t.eq( layer.options["chicken"], 151 , "layer.options correctly made fresh copy" );
t.eq( layer.isBaseLayer, true, "Default img layer is base layer" );
layer = new OpenLayers.Layer.Image('Test Layer',
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288));
t.ok( layer instanceof OpenLayers.Layer.Image, "new OpenLayers.Layer.Image returns object" );
t.eq( layer.name, "Test Layer", "layer.name is correct" );
t.ok( layer.projection == null, "default layer projection correctly set");
t.ok( layer.options instanceof Object, "layer.options correctly initialized as a non-null Object" );
}
function test_50_Layer_Image_tileTests (t) {
t.plan(4);
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Image('Test Layer',
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288));
map.addLayer(layer);
map.zoomToMaxExtent();
t.eq(layer.tile.position.x,-40, "Tile x positioned correctly at maxextent");
t.eq(layer.tile.position.y,107, "Tile y positioned correctly at maxextent");
t.eq(layer.tile.imgDiv.src, "http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif", "URL is correct");
map.zoomIn();
t.eq(layer.tile.imgDiv.src, "http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif", "URL is correct");
}
/******
*
*
* HERE IS WHERE SOME TESTS SHOULD BE PUT TO CHECK ON THE LONLAT-PX TRANSLATION
* FUNCTIONS AND RESOLUTION AND GETEXTENT GETZOOMLEVEL, ETC
*
*
*/
function test_99_Layer_Image_destroy (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Image('Test Layer',
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288));
map.addLayer(layer);
map.zoomToMaxExtent();
layer.destroy();
t.eq( layer.name, null, "layer.name is null after destroy" );
t.eq( layer.div, null, "layer.div is null after destroy" );
t.eq( layer.map, null, "layer.map is null after destroy" );
t.eq( layer.options, null, "layer.options is null after destroy" );
}
// -->
</script>
</head>
<body>
<div id="map" style="width:500px;height:500px"></div>
<div id="map2" style="width:100px;height:100px"></div>
</body>
</html>

View File

@@ -1,164 +0,0 @@
<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/";
var options = {'layername':'basic', 'type':'png'};
function test_01_Layer_TMS_constructor (t) {
t.plan( 1 );
layer = new OpenLayers.Layer.TMS(name, url, options);
t.ok( layer instanceof OpenLayers.Layer.TMS, "returns OpenLayers.Layer.TMS object" );
}
function test_03_Layer_TMS_clearTiles (t) {
t.plan( 1 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.TMS(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" );
}
function test_04_Layer_TMS_getTMSBounds(t) {
t.plan( 1 );
layer = new OpenLayers.Layer.TMS(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.getGridBounds();
var testBounds = new OpenLayers.Bounds(1,2,3,4);
t.ok( bounds.equals(testBounds), "getTMSBounds() returns correct bounds")
layer.grid = null;
}
function test_05_Layer_TMS_getResolution(t) {
t.plan( 1 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.TMS(name, url, options);
map.addLayer(layer);
map.zoom = 5;
t.eq( layer.getResolution(), 0.0439453125, "getResolution() returns correct value");
}
function test_06_Layer_TMS_getZoomForExtent(t) {
t.plan( 2 );
var bounds, zoom;
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.TMS(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");
}
/** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
*
* -moveTo
* -insertColumn
* -insertRow
function 07_Layer_TMS_moveTo(t) {
}
function 08_Layer_TMS_insertColumn(t) {
}
function 09_Layer_TMS_insertRow(t) {
}
*
*/
function test_10_Layer_TMS_getURL(t) {
t.plan(1);
var map = new OpenLayers.Map('map', options);
var options = {'layername':'basic', 'type':'png'};
layer = new OpenLayers.Layer.TMS(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/192.png", "Tile URL is correct");
}
function test_11_Layer_TMS_setMap(t) {
t.plan(3);
var map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.TMS(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");
}
function test_99_Layer_TMS_destroy (t) {
t.plan( 3 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.TMS(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.TMS(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");
}
// -->
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>

View File

@@ -38,18 +38,8 @@
tile.draw();
var img = tile.imgDiv;
var tParams = OpenLayers.Util.extend({},
OpenLayers.Util.upperCaseObject(params));
tParams = OpenLayers.Util.extend(tParams, {
SERVICE: "WMS", VERSION: "1.1.1",
REQUEST: "GetMap", STYLES: "",
EXCEPTIONS: "application/vnd.ogc.se_inimage",
SRS: "EPSG:4326", BBOX: "1,2,3,4",
WIDTH: "256", HEIGHT: "256"
});
t.eq( img.src,
url + "?" + OpenLayers.Util.getParameterString(tParams),
"image src is created correctly via addtile" );
t.eq( img.src, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "image src is created correctly via addtile" );
t.eq( tile.imgDiv.style.top, "6px", "image top is set correctly via addtile" );
t.eq( tile.imgDiv.style.left, "5px", "image top is set correctly via addtile" );
@@ -58,9 +48,7 @@
t.ok( true, "skipping element test outside of Mozilla");
else
t.ok( firstChild instanceof HTMLElement, "div first child is an image object" );
t.eq( firstChild.src,
url + "?" + OpenLayers.Util.getParameterString(tParams),
"div first child is correct image object" );
t.eq( firstChild.src, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "div first child is correct image object" );
t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." );
}
@@ -142,6 +130,7 @@
t.plan( 2 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
@@ -150,21 +139,11 @@
var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams);
map.addLayer(tLayer);
str = tLayer.getFullRequestString();
var tParams = {
LAYERS: "basic", FORMAT: "image/png", SERVICE: "WMS",
VERSION: "1.1.1", REQUEST: "GetMap", STYLES: "",
EXCEPTIONS: "application/vnd.ogc.se_inimage", SRS: "xx"
};
t.eq(str,
tUrl + "?" + OpenLayers.Util.getParameterString(tParams),
"getFullRequestString() adds SRS value");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?LAYERS=basic&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=xx", "getFullRequestString() adds SRS value");
tLayer.projection = "none";
str = tLayer.getFullRequestString();
delete tParams['SRS'];
t.eq(str,
tUrl + "?" + OpenLayers.Util.getParameterString(tParams),
"getFullRequestString() by default does *not* add SRS value if projection is 'none'");
t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?LAYERS=basic&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage", "getFullRequestString() by default does *not* add SRS value if projection is 'none'");
}

View File

@@ -52,7 +52,7 @@
function test_03_Popup_draw(t) {
t.plan( 17 );
t.plan( 11 );
var id = "chicken";
var x = 50;
@@ -78,17 +78,7 @@
t.eq(popup.div.style.top, y + "px", "top position of popup.div set correctly");
t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly");
t.eq(popup.div.style.height, h + "px", "heightposition of popup.div set correctly");
var contentDiv = popup.div.childNodes[0];
t.eq(contentDiv.className, "olPopupContent", "correct content div className");
t.eq(contentDiv.id, "chicken_contentDiv", "correct content div id");
t.eq(contentDiv.style.width, "500px", "correct content div width");
t.eq(contentDiv.style.height, "400px", "correct content div height");
t.eq(contentDiv.style.position, "relative", "correct content div position");
t.eq(contentDiv.style.overflow, "hidden", "correct content div overflow");
t.eq(contentDiv.innerHTML, content, "correct content div content");
t.eq(popup.div.innerHTML, '<div class="olPopupContent" style="overflow: hidden; width: 200px; height: 200px; position: relative;" id="chicken_contentDiv">charlie</div>', "good default popup.contentHTML");
t.eq(popup.div.style.backgroundColor, color, "good default popup.backgroundColor");
if (navigator.appName.indexOf("Microsoft") == -1) {

View File

@@ -48,16 +48,7 @@
t.ok( true, "skipping element test outside of Mozilla");
else
t.ok( img instanceof HTMLImageElement, "tile.draw creates an image");
var tParams = {
SERVICE: "WMS", VERSION: "1.1.1",
REQUEST: "GetMap", STYLES: "",
EXCEPTIONS: "application/vnd.ogc.se_inimage", FORMAT: "image/jpeg",
SRS: "EPSG:4326", BBOX: "1,2,3,4",
WIDTH: "256", HEIGHT: "256"
};
t.eq( img.src,
"http://labs.metacarta.com/TESTURL?" + OpenLayers.Util.getParameterString(tParams),
"tile.draw creates an image");
t.eq( img.src, "http://labs.metacarta.com/TESTURL?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "tile.draw creates an image");
t.eq( tile.imgDiv.style.width, "5px", "Image width is correct" );
t.eq( tile.imgDiv.style.height, "6px", "Image height is correct" );
}
@@ -73,78 +64,42 @@
map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw()
t.eq(tile.imgDiv, null, "Images against side of maxextent don't load");
t.eq(tile.imgDiv.src, "", "Images against side of maxextent don't load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-91,180,90), url, size);
tile.draw()
var tParams = {
LAYERS: "basic", SERVICE: "WMS", VERSION: "1.1.1",
REQUEST: "GetMap", STYLES: "",
EXCEPTIONS: "application/vnd.ogc.se_inimage", FORMAT: "image/jpeg",
SRS: "EPSG:4326", BBOX: "-181,-91,180,90",
WIDTH: "256", HEIGHT: "256"
};
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Images over edges of maxextent do load");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-181,-91,180,90&WIDTH=256&HEIGHT=256", "Images over edges of maxextent do load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-90,180,90), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-181,-90,180,90"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Images over edges of maxextent do load");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-181,-90,180,90&WIDTH=256&HEIGHT=256", "Images over edges of maxextent do load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-180,-90,180,90), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-180,-90,180,90"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Image covering all of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=256&HEIGHT=256", "Image covering all of extent loads");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-80,-45,80,45), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-80,-45,80,45"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Image covering small part of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-80,-45,80,45&WIDTH=256&HEIGHT=256", "Image covering small part of extent loads");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-95,185,95), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-185,-95,185,95"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Image covering more than all of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-185,-95,185,95&WIDTH=256&HEIGHT=256", "Image covering more than all of extent loads");
layer.displayOutsideMaxExtent=1;
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-185,-90,-180,90"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Images against side of maxextent do load with displayOutsideMaxExtent");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-185,-90,-180,90&WIDTH=256&HEIGHT=256", "Images against side of maxextent do load with displayOutsideMaxExtent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-90,180,90), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-181,-90,180,90"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Images over edges of maxextent do load with displayOutsideMaxExtent set");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-181,-90,180,90&WIDTH=256&HEIGHT=256", "Images over edges of maxextent do load with displayOutsideMaxExtent set");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-180,-90,180,90), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-180,-90,180,90"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Image covering all of extent loads with display outside max extent");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=256&HEIGHT=256", "Image covering all of extent loads with display outside max extent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-80,-45,80,45), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-80,-45,80,45"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Image covering small part of extent loads with display outside max extent");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-80,-45,80,45&WIDTH=256&HEIGHT=256", "Image covering small part of extent loads with display outside max extent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-95,185,95), url, size);
tile.draw()
tParams = OpenLayers.Util.extend(tParams, {BBOX: "-185,-95,185,95"});
t.eq(tile.imgDiv.src,
"http://labs.metacarta.com/wms/vmap0?" + OpenLayers.Util.getParameterString(tParams),
"Image covering more than all of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-185,-95,185,95&WIDTH=256&HEIGHT=256", "Image covering more than all of extent loads");
}
function test_04_Tile_Image_Display_After_Move(t) {
t.plan(2);
t.plan(3);
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
var url = "http://www.openlayers.org/dev/tests/tileimage";
@@ -157,21 +112,22 @@
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
tile.draw();
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true);
t.delay_call( 1, function() { t.eq(tile.imgDiv, null, "Tile imgDiv is null.") } );
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, 'none', "Tile display is set to none.") } );
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'alpha':true});
map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
tile.draw();
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true)
t.delay_call( 1, function() { t.eq(tile.imgDiv, null, "Alpha tile imgDiv is null.") } );
t.ok(tile.imgDiv.firstChild.src != tile.url, "Check to make sure that the alpha image URL really is different");
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, 'none', "Alpha tile display is set to none.") } );
}
// -->
</script>
</head>
<body>
<div id="map" style="height:500px;width:500px"></div>
<div id="map"></div>
</body>
</html>

View File

@@ -174,14 +174,13 @@
}
function test_07_Util_getParameterString(t) {
t.plan( 2 );
t.plan( 1 );
var params = { foo: "bar",
chicken: 1.5
}
t.eq( OpenLayers.Util.getParameterString(params), "foo=bar&chicken=1.5", "getParameterString returns correctly");
t.eq( OpenLayers.Util.getParameterString({'a:':'b='}), "a%3A=b%3D", "getParameterString returns correctly with non-ascii keys/values");
}
function test_08_Util_createAlphaImageDiv(t) {
@@ -490,71 +489,7 @@
OpenLayers.ImgPath = '';
t.eq(OpenLayers.Util.getImagesLocation().substr(OpenLayers.Util.getImagesLocation().length-4,4), "img/", "ImgPath works as expected when set to ''.");
}
function test_15_Util_isEquivalentUrl(t) {
t.plan(8);
var url1, url2, options;
//CASE
url1 = "http://www.openlayers.org";
url2 = "HTTP://WWW.OPENLAYERS.ORG";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignoreCase works");
//ARGS
url1 = "http://www.openlayers.org?foo=5;bar=6";
url2 = "http://www.openlayers.org?bar=6;foo=5";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "shuffled arguments works");
//PORT
url1 = "http://www.openlayers.org:80";
url2 = "http://www.openlayers.org";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignorePort80 works");
options = {
'ignorePort80': false
}
url1 = "http://www.openlayers.org:80";
url2 = "http://www.openlayers.org:50";
t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2), "port check works");
//HASH
url1 = "http://www.openlayers.org#barf";
url2 = "http://www.openlayers.org";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignoreHash works");
options = {
'ignoreHash': false
}
t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2, options), "ignoreHash FALSE works");
//PROTOCOL
url1 = "http://www.openlayers.org";
url2 = "ftp://www.openlayers.org";
t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignoreHash works");
//PATHNAME
url1 = "foo.html";
url2 = "../tests/foo.html";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "relative vs. absolute paths works");
}
// -->
// -->
</script>
</head>
<body>

View File

@@ -33,180 +33,180 @@
from StringIO import StringIO
def jsmin(js):
ins = StringIO(js)
outs = StringIO()
JavascriptMinify().minify(ins, outs)
str = outs.getvalue()
if len(str) > 0 and str[0] == '\n':
str = str[1:]
return str
ins = StringIO(js)
outs = StringIO()
JavascriptMinify().minify(ins, outs)
str = outs.getvalue()
if len(str) > 0 and str[0] == '\n':
str = str[1:]
return str
def isAlphanum(c):
"""return true if the character is a letter, digit, underscore,
"""return true if the character is a letter, digit, underscore,
dollar sign, or non-ASCII character.
"""
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126));
"""
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126));
class UnterminatedComment(Exception):
pass
pass
class UnterminatedStringLiteral(Exception):
pass
pass
class UnterminatedRegularExpression(Exception):
pass
pass
class JavascriptMinify(object):
def _outA(self):
self.outstream.write(self.theA)
def _outB(self):
self.outstream.write(self.theB)
def _outA(self):
self.outstream.write(self.theA)
def _outB(self):
self.outstream.write(self.theB)
def _get(self):
"""return the next character from stdin. Watch out for lookahead. If
the character is a control character, translate it to a space or
linefeed.
"""
c = self.theLookahead
self.theLookahead = None
if c == None:
c = self.instream.read(1)
if c >= ' ' or c == '\n':
return c
if c == '': # EOF
return '\000'
if c == '\r':
return '\n'
return ' '
def _get(self):
"""return the next character from stdin. Watch out for lookahead. If
the character is a control character, translate it to a space or
linefeed.
"""
c = self.theLookahead
self.theLookahead = None
if c == None:
c = self.instream.read(1)
if c >= ' ' or c == '\n':
return c
if c == '': # EOF
return '\000'
if c == '\r':
return '\n'
return ' '
def _peek(self):
self.theLookahead = self._get()
return self.theLookahead
def _peek(self):
self.theLookahead = self._get()
return self.theLookahead
def _next(self):
"""get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'.
"""
c = self._get()
if c == '/':
p = self._peek()
if p == '/':
c = self._get()
while c > '\n':
c = self._get()
return c
if p == '*':
c = self._get()
while 1:
c = self._get()
if c == '*':
if self._peek() == '/':
self._get()
return ' '
if c == '\000':
raise UnterminatedComment()
def _next(self):
"""get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'.
"""
c = self._get()
if c == '/':
p = self._peek()
if p == '/':
c = self._get()
while c > '\n':
c = self._get()
return c
if p == '*':
c = self._get()
while 1:
c = self._get()
if c == '*':
if self._peek() == '/':
self._get()
return ' '
if c == '\000':
raise UnterminatedComment()
return c
return c
def _action(self, action):
"""do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
action recognizes a regular expression if it is preceded by ( or , or =.
"""
if action <= 1:
self._outA()
if action <= 2:
self.theA = self.theB
if self.theA == "'" or self.theA == '"':
while 1:
self._outA()
self.theA = self._get()
if self.theA == self.theB:
break
if self.theA <= '\n':
raise UnterminatedStringLiteral()
if self.theA == '\\':
self._outA()
self.theA = self._get()
def _action(self, action):
"""do something! What you do is determined by the argument:
1 Output A. Copy B to A. Get the next B.
2 Copy B to A. Get the next B. (Delete A).
3 Get the next B. (Delete B).
action treats a string as a single character. Wow!
action recognizes a regular expression if it is preceded by ( or , or =.
"""
if action <= 1:
self._outA()
if action <= 2:
self.theA = self.theB
if self.theA == "'" or self.theA == '"':
while 1:
self._outA()
self.theA = self._get()
if self.theA == self.theB:
break
if self.theA <= '\n':
raise UnterminatedStringLiteral()
if self.theA == '\\':
self._outA()
self.theA = self._get()
if action <= 3:
self.theB = self._next()
if self.theB == '/' and (self.theA == '(' or self.theA == ',' or self.theA == '='):
self._outA()
self._outB()
while 1:
self.theA = self._get()
if self.theA == '/':
break
elif self.theA == '\\':
self._outA()
self.theA = self._get()
elif self.theA <= '\n':
raise UnterminatedRegularExpression()
self._outA()
self.theB = self._next()
if action <= 3:
self.theB = self._next()
if self.theB == '/' and (self.theA == '(' or self.theA == ',' or self.theA == '='):
self._outA()
self._outB()
while 1:
self.theA = self._get()
if self.theA == '/':
break
elif self.theA == '\\':
self._outA()
self.theA = self._get()
elif self.theA <= '\n':
raise UnterminatedRegularExpression()
self._outA()
self.theB = self._next()
def _jsmin(self):
"""Copy the input to the output, deleting the characters which are
insignificant to JavaScript. Comments will be removed. Tabs will be
replaced with spaces. Carriage returns will be replaced with linefeeds.
Most spaces and linefeeds will be removed.
"""
self.theA = '\n'
self._action(3)
def _jsmin(self):
"""Copy the input to the output, deleting the characters which are
insignificant to JavaScript. Comments will be removed. Tabs will be
replaced with spaces. Carriage returns will be replaced with linefeeds.
Most spaces and linefeeds will be removed.
"""
self.theA = '\n'
self._action(3)
while self.theA != '\000':
if self.theA == ' ':
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
elif self.theA == '\n':
if self.theB in ['{', '[', '(', '+', '-']:
self._action(1)
elif self.theB == ' ':
self._action(3)
else:
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
else:
if self.theB == ' ':
if isAlphanum(self.theA):
self._action(1)
else:
self._action(3)
elif self.theB == '\n':
if self.theA in ['}', ']', ')', '+', '-', '"', '\'']:
self._action(1)
else:
if isAlphanum(self.theA):
self._action(1)
else:
self._action(3)
else:
self._action(1)
while self.theA != '\000':
if self.theA == ' ':
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
elif self.theA == '\n':
if self.theB in ['{', '[', '(', '+', '-']:
self._action(1)
elif self.theB == ' ':
self._action(3)
else:
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
else:
if self.theB == ' ':
if isAlphanum(self.theA):
self._action(1)
else:
self._action(3)
elif self.theB == '\n':
if self.theA in ['}', ']', ')', '+', '-', '"', '\'']:
self._action(1)
else:
if isAlphanum(self.theA):
self._action(1)
else:
self._action(3)
else:
self._action(1)
def minify(self, instream, outstream):
self.instream = instream
self.outstream = outstream
self.theA = None
self.thaB = None
self.theLookahead = None
def minify(self, instream, outstream):
self.instream = instream
self.outstream = outstream
self.theA = None
self.thaB = None
self.theLookahead = None
self._jsmin()
self.instream.close()
self._jsmin()
self.instream.close()
if __name__ == '__main__':
import sys
jsm = JavascriptMinify()
jsm.minify(sys.stdin, sys.stdout)
import sys
jsm = JavascriptMinify()
jsm.minify(sys.stdin, sys.stdout)

View File

@@ -127,25 +127,42 @@ class Config:
self.include = lines[lines.index("[include]") + 1:lines.index("[exclude]")]
self.exclude = lines[lines.index("[exclude]") + 1:]
def run (sourceDirectory, outputFilename = None, configFile = None):
if __name__ == "__main__":
import getopt
options, args = getopt.getopt(sys.argv[1:], "-c:")
try:
outputFilename = args[0]
except IndexError:
usage(sys.argv[0])
raise SystemExit
else:
sourceDirectory = args[1]
if not sourceDirectory:
usage(sys.argv[0])
raise SystemExit
cfg = None
if configFile:
cfg = Config(configFile)
if options and options[0][0] == "-c":
filename = options[0][1]
print "Parsing configuration file: %s" % filename
cfg = Config(filename)
print cfg.include
allFiles = []
## Find all the Javascript source files
for root, dirs, files in os.walk(sourceDirectory):
for filename in files:
if filename.endswith(SUFFIX_JAVASCRIPT) and not filename.startswith("."):
filepath = os.path.join(root, filename)[len(sourceDirectory)+1:]
filepath = filepath.replace("\\", "/")
for filename in files:
if filename.endswith(SUFFIX_JAVASCRIPT) and not filename.startswith("."):
filepath = os.path.join(root, filename)[len(sourceDirectory)+1:]
if cfg and cfg.include:
if filepath in cfg.include or filepath in cfg.forceFirst:
allFiles.append(filepath)
elif (not cfg) or (filepath not in cfg.exclude):
allFiles.append(filepath)
allFiles.append(filepath)
## Header inserted at the start of each file in the output
HEADER = "/* " + "=" * 70 + " %s\n" + " " + "=" * 70 + " */\n\n"
@@ -158,7 +175,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None):
## TODO: Do import when we walk the directories above?
for filepath in allFiles:
print "Importing: %s" % filepath
fullpath = os.path.join(sourceDirectory, filepath)
fullpath = os.path.join(sourceDirectory, filepath)
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
files[filepath] = SourceFile(filepath, content) # TODO: Chop path?
@@ -210,30 +227,6 @@ def run (sourceDirectory, outputFilename = None, configFile = None):
print "\nTotal files merged: %d " % len(allFiles)
if outputFilename:
print "\nGenerating: %s" % (outputFilename)
open(outputFilename, "w").write("".join(result))
return "".join(result)
print "\nGenerating: %s" % (outputFilename)
if __name__ == "__main__":
import getopt
options, args = getopt.getopt(sys.argv[1:], "-c:")
try:
outputFilename = args[0]
except IndexError:
usage(sys.argv[0])
raise SystemExit
else:
sourceDirectory = args[1]
if not sourceDirectory:
usage(sys.argv[0])
raise SystemExit
configFile = None
if options and options[0][0] == "-c":
configFile = options[0][1]
print "Parsing configuration file: %s" % filename
run( sourceDirectory, outputFilename, configFile )
open(outputFilename, "w").write("".join(result))

View File

@@ -12,5 +12,4 @@ cp -a theme/ /www/openlayers/htdocs/api/$VERSION
rm tools/*.pyc
cd ..
tar -zvcf OpenLayers-$VERSION.tar.gz OpenLayers-$VERSION
zip -9r OpenLayers-$VERSION.zip OpenLayers-$VERSION
cp OpenLayers-$VERSION.{tar.gz,zip} /www/openlayers/htdocs/download/
cp OpenLayers-$VERSION.tar.gz /www/openlayers/htdocs/download/