Select to view content in your preferred language

Geometry Server Question

1054
12
10-19-2010 03:47 PM
FrankRoberts
Occasional Contributor III


In a different post I figured out how to use the Geometry Server to project a point, see:

http://forums.arcgis.com/threads/14793-UTM-or-State-Plane-to-Decimal-Degrees

However, I'm still left with a question. My question is there anyway to avoid adding the Declarations section at the end (i.e. just define the geometryService info in the body of the ActionScript function)??

This is what I'm currently adding:





<fx:Declarations>
<esri:GeometryService id="geometryService"
concurrency="last"
fault="onFault(event)"
projectComplete="projectCompleteHandler(event)"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
</fx:Declarations>



Thanks




Frank


Tags (2)
0 Kudos
12 Replies
JamesFaron
Occasional Contributor
Robert,

I input the Spatial Reference, and that will definitely fix the error when I input the url send to the geometry server: it will reproject there as expected. But the action script never sends to the geometry server, i.e. when I debug it will skip through the function pResult. In other words I can't seem to get the action script to complete the request, thus not even a fault will return (i.e when I previously forgot the input spatial reference).

Here is the code:
public function convertToPoint(x:Number, y:Number, bool:Boolean):Point
  {   
   var _pointObject:MapPoint = new MapPoint();
   _pointObject.spatialReference = new SpatialReference(4326);
   _pointObject.x = x;
   _pointObject.y = y;
   
   if((bool) && (!isNaN(x)) && (!isNaN(y)))
   {
    //_pointObject = WebMercatorUtil.geographicToWebMercator(_pointObject) as MapPoint;
    var geomServ:GeometryService = new GeometryService("https://my-imap.austinisd.org/arcgis/rest/services/Utilities/Geometry/GeometryServer");
    //geomServ.addEventListener(GeometryServiceEvent.PROJECT_COMPLETE,pResult);
    const projParams:ProjectParameters = new ProjectParameters();
    projParams.geometries = [_pointObject ];
    var outSR:SpatialReference = new SpatialReference(2277);
    projParams.outSpatialReference = outSR;
    geomServ.project(projParams, 
     new AsyncResponder(
      function pResult(item:Object, token:Object = null):void{
       var pt:MapPoint = (item as Array)[0] as MapPoint;
       _pointObject.x = pt.x;
       _pointObject.y = pt.y;
      },
      function pFault(fault:Fault, token:Object = null):void{
       Alert.show("Error: " + fault.faultString, "Error code: " + fault.faultCode);
      }
     )
    );
    
   }

Here is the url that would be sent:
https://my-imap.austinisd.org/arcgis/rest/services/Utilities/Geometry/GeometryServer/project?outSR=2277&f=json&geometries={%22geometryType%22%3A%22esriGeometryPoint%22%2C%22geometries%22%3A[{%22x%22%3A-97.75055769%2C%22y%22%3A30.22752472}]}&inSR=4326


The return from the geometry server: {"geometries":[{"x":3112207.5068722428,"y":10055955.767591864}]}

So I wonder if this is an action script issue, since all of this would work easily in mxml.

Thanks,

Jim Faron
Austin Independent School District
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jim,

   You have to have something wrong else where then. Here is a simple app that demos all this working:
0 Kudos
JamesFaron
Occasional Contributor
Robert,

Yes there must be something else at play, and it may be that this can only work within the mxml component. I am trying to do this in an action script class, and it never sends to the geometry service. So I guess I may create a new post to see if it is possible to use a geometry service in an action script class, i.e. not in mxml.

Thanks again for the help.

Jim Faron
Austin Independent School District
0 Kudos