openscales1.2 实现加载arcgis 切片

package org.openscales.core.layer
{
	import org.openscales.core.Map;
	import org.openscales.core.tile.ImageTile;
	import org.openscales.geometry.basetypes.Bounds;
	import org.openscales.geometry.basetypes.Location;
	import org.openscales.geometry.basetypes.Pixel;
	import org.openscales.geometry.basetypes.Size;

	public class ArcGISCache extends Grid
	{
		public function ArcGISCache(name:String,url:String, layerName:String=""){
			super(name, url);
			this._layerName = layerName;
			//this._tileOrigin= new Location(-400,400);
		}
		private var _serviceVersion:String = "1.0.0";
		
		private var _tileOrigin:Location = null;
		
		private var _format:String = "png";
		
		private var _layerName:String;
		
		/**
		 * A list of all resolutions available on the server.
		 * Only set this property if the map resolutions differs from the server
		 */
		private var _serverResolutions:Array = null;
		

		
		override public function getURL(bounds:Bounds):String {
			var res:Number = this.map.resolution;
			
			var originTileX:Number =(this._tileOrigin.lon +(res * this.tileWidth/2));
			var originTileY:Number =(this._tileOrigin.lat +(res * this.tileHeight/2));
			
			var center:Location =bounds.center ;
			trace("center="+center);
			var x:Number = (Math.round(Math.abs((center.lon - originTileX) / (res * this.tileWidth)))); 
			var y:Number = (Math.round(Math.abs((originTileY - center.lat) / (res * this.tileHeight)))); 
			var z:Number = this.map.zoom;

			var url:String = this.url + "/tile/" + z + "/" + y + "/" + x + "."+this._format;
			return url ;
		}
		
		override public function addTile(bounds:Bounds, position:Pixel):ImageTile {
			return new ImageTile(this, position, bounds, this.getURL(bounds), new Size(this.tileWidth, this.tileHeight));
		}
		
		override public function set map(map:Map):void {
			super.map = map;
			if (! this._tileOrigin) {
				this._tileOrigin = new Location(this.map.maxExtent.left, this.map.maxExtent.bottom);
			}
		}
		
		/**
		 * setter for tile image format
		 * 
		 * @param value:String the tile image extention
		 */
		public function set format(value:String):void {
			if(value.length==0)
				return;
			else if(value.charAt(0)=='.')
				this._format = value.substr(1,value.length-1);
			else
				this._format = value;
		}
		/**
		 * getter for tile image format
		 * 
		 * @return String the tile image format
		 */
		public function get format():String {
			return this._format;
		}
		
		/**
		 * setter and getter of the TMS grid origin
		 */
		public function set origin(value:Location):void {
			this._tileOrigin = value;
		}
		public function get origin():Location {
			return this._tileOrigin.clone();
		}
		/**
		 * setter and getter of the TMS layer name
		 */
		public function set layerName(value:String):void {
			this._layerName = value;
		}
		public function get layerName():String {
			return this._layerName;
		}
	}
}
package org.openscales.fx.layer
{
	import org.openscales.core.layer.ArcGISCache;
	import org.openscales.geometry.basetypes.Location;

	public class FxArcGISCache extends FxGrid
	{
		public function FxArcGISCache()
		{
		
			super();
			if(this._layer == null){
				this ._layer= new ArcGISCache("","");
			}
			
			
		}
		
		public function set format(value:String):void{
			if(this.layer!=null) {
			  (this.layer as ArcGISCache).format= value;
			}
		
		}
		
		public function set origin(value :String):void{
		
			if(this.layer!= null){
				
			   (this.layer as ArcGISCache).origin= Location.getLocationFromString(value);
			
			 }
		 }
		
		
		public function set layerName(value:String):void{
		   if(this.layer!= null){
		   (this.layer as ArcGISCache).layerName =value;
		   }
		}
		
	}
}


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
  	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
	
	

 




	
	
		
			
		
		
		
		
		
		
		
		
		
		
		
	
	

你可能感兴趣的:(gis)