[OpenLayers-Commits] r3120 - in sandbox/crschmidt/arcwebservices: examples lib lib/OpenLayers/Layer
commits at openlayers.org
commits at openlayers.org
Thu May 3 09:44:36 EDT 2007
Author: crschmidt
Date: 2007-05-03 09:44:35 -0400 (Thu, 03 May 2007)
New Revision: 3120
Added:
sandbox/crschmidt/arcwebservices/examples/aws.html
sandbox/crschmidt/arcwebservices/lib/OpenLayers/Layer/ArcWebServices.js
Modified:
sandbox/crschmidt/arcwebservices/lib/OpenLayers.js
Log:
ArcWebServices Layer, and example of how to use it. Note that this requires
a token to be fetched from the server, which by default expires after 60
minutes, so this is not a complete implementation, merely a jumping off point
for someone interested in workign on an ArcWebServices layer.
Added: sandbox/crschmidt/arcwebservices/examples/aws.html
===================================================================
--- sandbox/crschmidt/arcwebservices/examples/aws.html (rev 0)
+++ sandbox/crschmidt/arcwebservices/examples/aws.html 2007-05-03 13:44:35 UTC (rev 3120)
@@ -0,0 +1,30 @@
+<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' );
+ layer = new OpenLayers.Layer.ArcWebServices( "AWS", 'http://www.arcwebservices.com/services/v2006_1/restmap', {tkn: 'foo'} );
+ map.addLayer(layer);
+ map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+ }
+ // -->
+ </script>
+ </head>
+ <body onload="init()">
+ <div id="map"></div>
+ </body>
+</html>
Added: sandbox/crschmidt/arcwebservices/lib/OpenLayers/Layer/ArcWebServices.js
===================================================================
--- sandbox/crschmidt/arcwebservices/lib/OpenLayers/Layer/ArcWebServices.js (rev 0)
+++ sandbox/crschmidt/arcwebservices/lib/OpenLayers/Layer/ArcWebServices.js 2007-05-03 13:44:35 UTC (rev 3120)
@@ -0,0 +1,161 @@
+/* Copyright (c) 2006 - 2007 MetaCarta, Inc., published under the BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
+ * text of the license. */
+
+/**
+ * @class
+ *
+ * An ArcWeb Services REST implementation
+ *
+ * @requires OpenLayers/Layer/Grid.js
+ */
+OpenLayers.Layer.ArcWebServices = OpenLayers.Class.create();
+OpenLayers.Layer.ArcWebServices.prototype =
+ OpenLayers.Util.extend( new OpenLayers.Layer.Grid(), {
+
+ /** Hashtable of default parameter key/value pairs
+ * @final @type Object */
+ DEFAULT_PARAMS: {
+ actn: "getMap",
+ ds: "bam",
+ fmt: "png"
+ },
+
+ /**
+ * @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, params, options) {
+ var newArguments = new Array();
+ if (arguments.length > 0) {
+ newArguments.push(name, url, params, options);
+ }
+
+ OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
+
+ if (arguments.length > 0) {
+ OpenLayers.Util.applyDefaults(
+ this.params,
+ this.DEFAULT_PARAMS
+ );
+ }
+
+ this.isBaseLayer = true;
+
+ if (!this.params.tkn) {
+ alert("You did not provide a 'tkn' parameter. The ArcWebServices layer requires a token for usage.");
+ }
+ },
+
+ /**
+ *
+ */
+ 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.ArcWebServices
+ * @type OpenLayers.ArcWebServices
+ */
+ clone: function (obj) {
+
+ if (obj == null) {
+ obj = new OpenLayers.ArcWebServices(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 sf = Math.round((this.map.getScale() * 10000)) / 10000;
+
+ var pX = (bounds.left + bounds.right) / 2;
+ var pY = (bounds.top + bounds.bottom) / 2;
+
+ sf *= 4/3;
+ var c = pX + "|" + pY
+
+ return this.getFullRequestString(
+ {c: c,
+ sf: sf,
+ w: this.tileSize.w,
+ h: this.tileSize.h});
+ },
+
+ /**
+ * 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);
+ },
+
+ /**
+ * Catch changeParams and uppercase the new params to be merged in
+ * before calling changeParams on the super class.
+ *
+ * Once params have been changed, we will need to re-init our tiles
+ *
+ * @param {Object} newParams Hashtable of new params to use
+ */
+ mergeNewParams:function(newParams) {
+ var newArguments = [newParams];
+ OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
+ newArguments);
+
+ if (this.map != null) {
+ this._initTiles();
+ }
+ },
+
+ /** combine the layer's url with its params and these newParams.
+ *
+ * Add the SRS parameter from projection -- this is probably
+ * more eloquently done via a setProjection() method, but this
+ * works for now and always.
+ *
+ * @param {Object} newParams
+ *
+ * @type String
+ */
+ getFullRequestString:function(newParams) {
+ // var projection = this.map.getProjection();
+ // this.params.SRS = (projection == "none") ? null : projection;
+
+ return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
+ this, arguments);
+ },
+ /** @final @type String */
+ CLASS_NAME: "OpenLayers.Layer.ArcWebServices"
+});
Modified: sandbox/crschmidt/arcwebservices/lib/OpenLayers.js
===================================================================
--- sandbox/crschmidt/arcwebservices/lib/OpenLayers.js 2007-05-03 13:27:11 UTC (rev 3119)
+++ sandbox/crschmidt/arcwebservices/lib/OpenLayers.js 2007-05-03 13:44:35 UTC (rev 3120)
@@ -87,6 +87,7 @@
"OpenLayers/Layer/WorldWind.js",
"OpenLayers/Layer/WMS.js",
"OpenLayers/Layer/WMS/Untiled.js",
+ "OpenLayers/Layer/ArcWebServices.js",
"OpenLayers/Layer/GeoRSS.js",
"OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/Canvas.js",
More information about the Commits
mailing list