【美高梅游戏官网娱乐】如果是用百度地图或者

作者:求生之路2地图

【美高梅游戏官网娱乐】如果是用百度地图或者其他网上的地图可能不适用。【美高梅游戏官网娱乐】如果是用百度地图或者其他网上的地图可能不适用。【美高梅游戏官网娱乐】如果是用百度地图或者其他网上的地图可能不适用。【美高梅游戏官网娱乐】如果是用百度地图或者其他网上的地图可能不适用。【美高梅游戏官网娱乐】如果是用百度地图或者其他网上的地图可能不适用。  当我们要把一个地块导出为txt的时候,应该怎么写,这是比较有用的这样可以帮助我们存档之类的,这里是基于某个地方的独立坐标系,是基于自己发布地图,如果是用百度地图或者其他网上的地图可能不适用。

  1 package com.szpl.extension.util
  2 {
  3     import com.esri.ags.geometry.MapPoint;
  4     import com.esri.ags.geometry.Polygon;
  5     import com.esri.ags.layers.GraphicsLayer;
  6     import com.esri.ags.symbols.SimpleFillSymbol;
  7     import com.esri.ags.symbols.SimpleLineSymbol;
  8     import com.szpl.extension.util.shp.shp.ShpPolygon;
  9     
 10     import flash.geom.Point;
 11 
 12     public class PointPolygonExchange
 13     {
 14         public function PointPolygonExchange()
 15         {
 16         }
 17         
 18         
 19         private var _pointstr:String="";
 20         
 21         public function get pointstr():String
 22         {
 23             return _pointstr;
 24         }
 25 
 26         public function set pointstr(value:String):void
 27         {
 28             _pointstr = value;
 29         }
 30        
 31       //  "x,y x,y x,y*x,y x,y..."
 32       public function coordText_to_polygon(coordText:String):Polygon
 33       {
 34           var ringsText:Array = coordText.split("*");
 35           
 36           var polygon:Polygon = new Polygon();
 37           for each(var ringText:String in ringsText)
 38           {
 39               var ring:Array = coordText_to_Ring(ringText);
 40               if(ring==null)
 41                 continue;
 42               polygon.addRing(ring);
 43           }
 44           return polygon;
 45       }
 46       
 47       public var xyChange:String = "x";
 48      
 49       
 50       public function polygon_to_CoordText(polygon:*):String
 51       {
 52           var _polygon:Polygon = new Polygon();
 53           if (polygon is ShpPolygon)
 54           {
 55               _polygon = (polygon as ShpPolygon).toPolygon();
 56           }
 57           else
 58           {
 59               _polygon = polygon as Polygon
 60           }
 61           xyChange = "x";
 62           var polygonText:String="";
 63           for each(var ring:Array in _polygon.rings)
 64           {
 65               var ringText:String = ring_to_CoordText(ring);
 66               polygonText += ringText;
 67               polygonText += "*";
 68           }
 69           
 70           return polygonText.substr(0,polygonText.length -1);          
 71       }
 72       
 73       
 74       public function polygon_to_CoordTextXY(polygon:*):String
 75       {
 76           xyChange = "y";
 77           var polygonText:String="";
 78           for each(var ring:Array in polygon.rings)
 79           {
 80               var ringText:String = ring_to_CoordText(ring);
 81               polygonText += ringText;
 82               polygonText += "*";
 83           }
 84           
 85           return polygonText.substr(0,polygonText.length -1);         
 86       }
 87       
 88       private function ring_to_CoordText(points:Array):String
 89       {
 90           var ringText:String="";
 91           for each(var point:MapPoint in points)
 92           {
 93               var pointText:String = point_to_CoordText(point);
 94               ringText += pointText;
 95               ringText += " ";
 96           }
 97           return ringText.substr(0,ringText.length-1);
 98       }
 99       
100       private function coordText_to_Ring(coordText:String):Array
101       {
102           if(coordText=="")
103               return null;
104           var pointsText:Array = coordText.split(" ");          
105           var ring:Array = new Array();
106           for each(var pointText:String in pointsText)
107           {
108               if(pointText!="")
109               {
110                   var point:MapPoint = coordText_to_Point(pointText);
111                   if (point != null)
112                       ring.push(point);
113               }
114             
115           }
116           if (ring.length < 3)
117               return null;
118           ring.push(new MapPoint((ring[0] as MapPoint).x,(ring[0] as MapPoint).y));
119           return ring;
120       }
121       
122       
123      
124       private function point_to_CoordText(point:MapPoint):String
125       {
126          var x:String = point.x.toString();
127          var y:String = point.y.toString();
128          if(xyChange == "x")
129              return x + "," + y;
130          else 
131              return y + "," + x;
132       }
133       
134       ///  "343.234,23423.534"
135       private function coordText_to_Point(coordText:String):MapPoint{
136           
137           var coord:Array = coordText.split(",");
138           if (coord.length != 2)
139               return null;
140           var x:Number = coord[1];
141           var y:Number = coord[0];
142           var point:MapPoint;
143           if (x > y) 
144                point = new MapPoint(x, y, null);
145           else
146                point = new MapPoint(y, x, null);
147           return point;
148       }
149           
150       // "rn"  ====> " "
151       public function txtFile_to_CoordText(txtFile:String):String
152       {
153           var regE:RegExp = new RegExp("rn", "g");    
154           var str:String = txtFile.replace(regE," ");
155           return str;
156       }
157       
158         
159         
160 
161         
162 
163         
164         
165     }
166 }

 

本文由美高梅游戏官网娱乐发布,转载请注明来源

关键词: