当前位置: 代码迷 >> CGI >> openscales1.2 兑现加载arcgis 切片
  详细解决方案

openscales1.2 兑现加载arcgis 切片

热度:558   发布时间:2012-09-27 11:11:17.0
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;
		   }
		}
		
	}
}
<?xml version="1.0"?>
<componentPackage>
	<component id="Map" class="org.openscales.fx.FxMap" />
	<component id="Extent" class="org.openscales.fx.FxExtent" />
	<component id="MaxExtent" class="org.openscales.fx.FxMaxExtent" />
	
	<component id="Style" class="org.openscales.fx.feature.FxStyle" />
	
	<component id="FeatureLayer" class="org.openscales.fx.layer.FxFeatureLayer" />
	<component id="ImageLayer" class="org.openscales.fx.layer.FxImageLayer" />
	<component id="WMS" class="org.openscales.fx.layer.FxWMS" />
	<component id="WMSC" class="org.openscales.fx.layer.FxWMSC" />
	<component id="WFS" class="org.openscales.fx.layer.FxWFS" />
	<component id="KML" class="org.openscales.fx.layer.FxKML" />
	<component id="HTC" class="org.openscales.fx.layer.FxHTC" />
	<component id="TMS" class="org.openscales.fx.layer.FxTMS" />
	<component id="ARC" class="org.openscales.fx.layer.FxArcGISCache" />
	
	<component id="Mapnik" class="org.openscales.fx.layer.osm.FxMapnik" />
	<component id="CycleMap" class="org.openscales.fx.layer.osm.FxCycleMap" />
	<component id="Maplint" class="org.openscales.fx.layer.osm.FxMaplint" />
	<component id="Osmarender" class="org.openscales.fx.layer.osm.FxOsmarender" />
	
	<component id="CorePanZoom" class="org.openscales.fx.control.FxCorePanZoom" />
	<component id="CorePanZoomBar" class="org.openscales.fx.control.FxCorePanZoomBar" />
	
	<component id="BorderPanHandler" class="org.openscales.fx.handler.mouse.FxBorderPanHandler" />
	<component id="ClickHandler" class="org.openscales.fx.handler.mouse.FxClickHandler" />
	<component id="DragHandler" class="org.openscales.fx.handler.mouse.FxDragHandler" />
	<component id="WheelHandler" class="org.openscales.fx.handler.mouse.FxWheelHandler" />
	<component id="WMSGetFeatureInfo" class="org.openscales.fx.handler.mouse.FxWMSGetFeatureInfo" />
	
	<component id="DragFeatureHandler" class="org.openscales.fx.handler.feature.FxDragFeatureHandler" />
	<component id="SelectFeaturesHandler" class="org.openscales.fx.handler.feature.FxSelectFeaturesHandler" />
	
	<component id="LayerManager" class="org.openscales.fx.control.layer.LayerManager" />
  	<component id="MousePosition" class="org.openscales.fx.control.FxMousePosition" />
	<component id="Pan" class="org.openscales.fx.control.Pan" />
	<component id="PanZoom" class="org.openscales.fx.control.PanZoom" />
	<component id="Zoom" class="org.openscales.fx.control.Zoom" />
	<component id="ZoomBox" class="org.openscales.fx.control.ZoomBox" />
	
	<component id="OverviewMap" class="org.openscales.fx.control.FxOverviewMap" />
	<component id="Capabilities" class="org.openscales.fx.control.Capabilities" />
	<component id="FeatureDrawing" class="org.openscales.fx.control.FeatureDrawing"/>
	<component id="FeatureInfo" class="org.openscales.fx.control.FeatureInfo" />
	<component id="YahooSearch" class="org.openscales.fx.control.search.YahooSearch" />
	<component id="TraceInfo" class="org.openscales.fx.control.TraceInfo" />
	<component id="ScaleLine" class="org.openscales.fx.control.FxScaleLine" />
	<component id="Spinner" class="org.openscales.fx.control.FxSpinner" />
	
	<component id="SampleRouting" class="org.openscales.fx.routing.FxSampleRouting" />
	<component id="SampleRoutingControl" class="org.openscales.fx.control.routing.SampleRoutingControl"/>
	
	<component id="ControlPanel" class="org.openscales.fx.ControlPanel"/>
	
	<component id="IGNGeoRMSecurity" class="org.openscales.fx.security.ign.FxIGNGeoRMSecurity"/>
		
	<component id="Control" class="org.openscales.fx.control.Control" />
	<component id="IconButton" class="org.openscales.fx.control.IconButton" />
	
</componentPackage>

?

<?xml version="1.0" encoding="utf-8"?>
<!--- Simple TMS example -->
<s:Group xmlns="http://openscales.org" xmlns:fx="http://ns.adobe.com/mxml/2009" 
		 xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%">
	
	<Map id="fxMap" width="100%" height="100%" zoom="1" center="106,40">
		<ARC name="Arc" url="--------------url ---------"  projection="EPSG:4326"
			 layerName="basic" tileHeight="256" tileWidth="256"  origin="-400,400"
			 resolutions="0.053992133368657984,0.020766205141791533,0.010632297032597264,
			 0.005316148516298632,0.002658074258149316,0.001329037129074658">
			
		</ARC>
		<DragHandler/>
		<WheelHandler/>
		
		<Spinner x="{width / 2}" y="{height / 2}"/>
		<MousePosition x="10" y="{height-20}" displayProjection="EPSG:4326"/>
		
		<TraceInfo x="{width-200}" y="0" />
		
		<PanZoom id="panZoom" x="10" y="10" />
		
	</Map>
	
</s:Group>
  相关解决方案