[OpenLayers-Commits] r1756 - in sandbox/crschmidt/refractions: examples lib lib/OpenLayers/Layer
commits at openlayers.org
commits at openlayers.org
Fri Nov 3 09:01:33 EST 2006
Author: crschmidt
Date: 2006-11-03 09:01:30 -0500 (Fri, 03 Nov 2006)
New Revision: 1756
Added:
sandbox/crschmidt/refractions/examples/refractions.html
sandbox/crschmidt/refractions/lib/OpenLayers/Layer/Refractions.js
Modified:
sandbox/crschmidt/refractions/lib/OpenLayers.js
Log:
Add Refractions TMS layer.
Added: sandbox/crschmidt/refractions/examples/refractions.html
===================================================================
--- sandbox/crschmidt/refractions/examples/refractions.html (rev 0)
+++ sandbox/crschmidt/refractions/examples/refractions.html 2006-11-03 14:01:30 UTC (rev 1756)
@@ -0,0 +1,31 @@
+<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.Refractions( "TMS",
+ "http://mapserver.refractions.net/cgi-bin/tms/", {layername: 'global_mosaic', type:'jpg'} );
+ map.addLayer(layer);
+ map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+ }
+ // -->
+ </script>
+ </head>
+ <body onload="init()">
+ <div id="map"></div>
+ </body>
+</html>
Copied: sandbox/crschmidt/refractions/lib/OpenLayers/Layer/Refractions.js (from rev 1755, sandbox/crschmidt/refractions/lib/OpenLayers/Layer/WMS.js)
===================================================================
--- sandbox/crschmidt/refractions/lib/OpenLayers/Layer/Refractions.js (rev 0)
+++ sandbox/crschmidt/refractions/lib/OpenLayers/Layer/Refractions.js 2006-11-03 14:01:30 UTC (rev 1756)
@@ -0,0 +1,122 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD licence.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Layer/Grid.js
+ */
+OpenLayers.Layer.Refractions = OpenLayers.Class.create();
+OpenLayers.Layer.Refractions.prototype =
+ OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
+
+ /** Hashtable of default parameter key/value pairs
+ * @final @type Object */
+ DEFAULT_PARAMS: { service: "Refractions",
+ version: "1.1.1",
+ request: "GetMap",
+ styles: "",
+ exceptions: "application/vnd.ogc.se_inimage",
+ format: "image/jpeg"
+ },
+
+ reproject: true,
+
+ /**
+ * @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();
+ //uppercase params
+ params = OpenLayers.Util.upperCaseObject(params);
+ newArguments.push(name, url, params, options);
+ OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
+ OpenLayers.Util.applyDefaults(
+ this.params,
+ OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
+ );
+
+ // unless explicitly set in options, if the layer is transparent,
+ // it will be an overlay
+ if (options == null || options.isBaseLayer == null) {
+ this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
+ (this.params.TRANSPARENT != true));
+ }
+ },
+
+ /**
+ *
+ */
+ 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.Refractions
+ * @type OpenLayers.Layer.Refractions
+ */
+ clone: function (obj) {
+
+ if (obj == null) {
+ obj = new OpenLayers.Layer.Refractions(this.name,
+ this.url,
+ this.params,
+ 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.maxExtent.left) / (res * this.tileSize.w);
+ var y = (bounds.bottom - this.maxExtent.bottom) / (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) {
+ url = this.getURL(bounds);
+ return new OpenLayers.Tile.Image(this, position, bounds,
+ url, this.tileSize);
+ },
+
+
+
+ /** @final @type String */
+ CLASS_NAME: "OpenLayers.Layer.Refractions"
+});
Modified: sandbox/crschmidt/refractions/lib/OpenLayers.js
===================================================================
--- sandbox/crschmidt/refractions/lib/OpenLayers.js 2006-11-03 13:56:57 UTC (rev 1755)
+++ sandbox/crschmidt/refractions/lib/OpenLayers.js 2006-11-03 14:01:30 UTC (rev 1756)
@@ -86,6 +86,7 @@
"OpenLayers/Layer/GeoRSS.js",
"OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/Canvas.js",
+ "OpenLayers/Layer/Refractions.js",
"OpenLayers/Popup/Anchored.js",
"OpenLayers/Popup/AnchoredBubble.js",
"OpenLayers/Control.js",
More information about the Commits
mailing list