Discussion on buffer analysis using ArcGIS Flex API

Source: Internet
Author: User

In the ArcGIS Flex API, you can use the GeometryService service for buffer analysis. Next we will discuss the implementation of buffer analysis. <Esri: GeometryService/> is used to process the Geometry service. To perform buffer analysis, you must first create a Geometry service in the ArcCatalog, after the establishment, we can write code in Flex. I imagine adding a map file first in the map. We can add the local shapfile file to GraphicLayer using the LibertyGIS we mentioned earlier, or we can draw a polygon on GraphicLayer using our own code, click this polygon to perform buffering analysis and add the analysis result to GraphicLayer. The operation is complete. However, it is worth noting that the processing methods of the Points and Points in the buffer analysis are different from those of the line and polygon. Find the following sentence on the Internet: Point (Points) and multipoint (Multipoints ): if the unit is long, such as meters and feet, the geodesic buffering analysis will be performed as is saved med. polylines and Polygons: the unit must be an angle, for example, in decimal format. First, let's take a look at the buffer analysis. The Code is as follows: [java] private function mouseClickHandler (e: MouseEvent): void {var myMapCenterPoint: MapPoint = MapPoint (map. extent. center); var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [50]; // The unit of length is bufferParm. geometries = [myMapCenterPoint]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm);} function bufferCompleteHandler (event: GeometryServiceEvent): void {var sfs: SimpleFillSymbol = new SimpleFillSymbol ("solid", 0xff0000, 1, sls); myGeometryService. removeEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); for each (var geometry: Polygon in event. result) {var graphic: Graphic = new Graphic (); graphic. geometry = geometry; graphic. symbol = sfs; graphicsLayer. add (graphic) ;}} private function mouseClickHandler (e: MouseEvent): void {var myMapCenterPoint: MapPoint = MapPoint (map. extent. center); var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [50]; // The unit of length is bufferParm. geometries = [myMapCenterPoint]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm);} function bufferCompleteHandler (event: GeometryServiceEvent): void {var sfs: SimpleFillSymbol = new SimpleFillSymbol ("solid", 0xff0000, 1, sls); myGeometryService. removeEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); for each (var geometry: Polygon in event. result) {www.2cto. comvar graphic: Graphic = new Graphic (); graphic. geometry = geometry; graphic. symbol = sfs; graphicsLayer. add (graphic) ;}}result: The reference coordinate system needs to be set for the line or polygon for buffering analysis on the line and polygon, and The radian is used as the distance unit. The following uses the polygon as an example, the Code is as follows: [java] private function mouseClickHandler (e: MouseEvent): void {var gra: Graphic = e. currentTarget as Graphic; var polygon: Polygon = gra. geometry as Polygon; polygon. spatialReference = map. spatialReference; // set reference coordinate system var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [1, 50/6378137. 0*180.0/Math. PI]; // unit conversion to radian unit bufferParm. geometries = [polygon]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm);} private function mouseClickHandler (e: MouseEvent): void {var gra: Graphic = e. currentTarget as Graphic; var polygon: Polygon = gra. geometry as Polygon; polygon. spatialReference = map. spatialReference; // set reference coordinate system var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [1, 50/6378137. 0*180.0/Math. PI]; // unit conversion to radian unit bufferParm. geometries = [polygon]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm );}
The result is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.