hbdong

web service for buffering?

Discussion created by hbdong on Jul 30, 2013
Hi,
   I'm testing out the below web service sample to get a buffer of a giving point but have problem retrieving buffer points.  I'm new to this and not sure whether I'm using the correct APIs for it.   My goal is to pass in a lat/lon point or a line and to get back a buffer around that point or line.   Please let me know what's the correct way for doing this.  Thanks

Henry


import com.esri.arcgisws.EnvelopeN;
import com.esri.arcgisws.GeographicCoordinateSystem;
import com.esri.arcgisws.Geometry;
import com.esri.arcgisws.GeometryServerBindingStub;
import com.esri.arcgisws.LinearUnit;
import com.esri.arcgisws.Point;
import com.esri.arcgisws.PointN;
import com.esri.arcgisws.PolygonN;
import com.esri.arcgisws.ProjectedCoordinateSystem;
import com.esri.arcgisws.Ring;
import com.esri.arcgisws.SpatialReference;

    String serviceURL = "http://localhost:6080/arcgis/services/Utilities/Geometry/GeometryServer?wsdl";
    GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
    SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
    inputSpatialReference.setWKID(4326);        
    //Set buffer spatial reference
    SpatialReference bufferSpatialReference = new ProjectedCoordinateSystem();
    bufferSpatialReference.setWKID(102113);

    //Set output spatial reference
    SpatialReference outputSpatialReference = inputSpatialReference;

    //Input points

    PointN inputPoint1 = new PointN();
    inputPoint1.setX(-117);
    inputPoint1.setY(34);
    Geometry[] inputGeometry = new Geometry[] { inputPoint1};   
    //Distance for buffer for each point

    double[] distances = new double[] { 1000 }; 
    LinearUnit linearUnit = new LinearUnit();
    linearUnit.setWKID(9035);
    boolean bUnionResults = false;
    Geometry[] outputGeometry = geometryService.buffer(inputSpatialReference, bufferSpatialReference, outputSpatialReference,distances, linearUnit, bUnionResults, inputGeometry);
               
    for (Geometry geom : outputGeometry) {
           if (geom instanceof PolygonN){
                 PolygonN polygon = (PolygonN) geom;                
                 EnvelopeN extent = (EnvelopeN) polygon.getExtent();                
                 System.out.println("Extent - XMin,YMin: " + extent.getXMin() + "," + extent.getYMin() + " XMax,YMax: " + extent.getXMax() + "," + extent.getYMax());
                                                  
                 Ring[] ring = polygon.getRingArray();
                 for (int i=0 ;i<ring.length;i++) {
                  Point[] point = ring[i].getPointArray();                   
                  for (int j=0; j< point.length; j++) {
                   System.out.println("point: " + point[j]);
                  }
                 }                
           }

     }   // end of for

Outcomes