Select to view content in your preferred language

Geometry Service in FV (2 Beta)

1142
6
08-05-2010 09:42 AM
ZahidChaudhry
Deactivated User
I am trying to project an array of points from UTM to 102100 but no luck.
[HTML]

var wellGraphics:Array = [];
                for each (var item:Object in wellResults){
                    var attrib:Object = {
                        Permit_id:item.pid,
                        Resp_party:item.resParty,
                        County:item.county
                    }
                        if(item.Datum == 27){
                            var datum:Number = 26717;
                        }else{
                            datum = 26917;
                        }
                        var wPoint:MapPoint = new MapPoint(item.UTME,item.UTMN,new SpatialReference(datum));
                            var wgraphics:Graphic = new Graphic(wPoint,null,attrib);
                           
                            wellGraphics.push(wgraphics);
                           
                }
                var outSR:SpatialReference = new SpatialReference(102100);
               
                geometryService.project(wellGraphics,outSR);
               
            }
            protected function projectCompleteHandler(event:GeometryServiceEvent):void
            {
               
                trace(event.result);
               
                
            }


<esri:GeometryService id="geometryService"
                              concurrency="multiple"
                                                          projectComplete="projectCompleteHandler(event)"
                              url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
[/HTML]
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
Zahid,

   The GeometryService in the 2.0 API does not take graphics anymore it takes an array of geometries now.
0 Kudos
ZahidChaudhry
Deactivated User
Zahid,

   The GeometryService in the 2.0 API does not take graphics anymore it takes an array of geometries now.


Thanks Robert,
Yelp. You are right. I have found a work around but i am not happy with it. I want to re project bunch of points at once, not one by one...

Thanks

Zahid
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Zahid,

   You should have to re-project then one at a time if you send an array of the geometries than it can do all of them at once...
0 Kudos
ZahidChaudhry
Deactivated User
Zahid,

   The GeometryService in the 2.0 API does not take graphics anymore it takes an array of geometries now.

  The other work arround  to do a batch type process is as under but now i am loosing all the attributes..
[HTML]
var wPoint:MapPoint = new MapPoint(item.UTME,item.UTMN,new SpatialReference(datum));
                            var wgraphics:Graphic = new Graphic(wPoint,null,attrib);
                           
                            wellGraphics.push(wPoint);
                           
                }
                geometryService.project(wellGraphics,new SpatialReference(102100));
               
            }
            protected function projectCompleteHandler(event:GeometryServiceEvent):void
            {
                var pntArray:Array = event.result as Array;
                var sp:SpatialReference = new SpatialReference(102100);
                for each(var item:Object in pntArray){
                    var pt:MapPoint = new MapPoint(item.x,item.y, sp);
                    var g:Graphic = new Graphic (pt);
                    graphicsLayer.add(g);
                }
               
[/HTML]

Either way it is not very good coding...there has to be a better way
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Zahid,

  If I remember correctly the results of the project method return the geometry array in the exact same order so you can just loop back through your attributes and attach them to the results.
0 Kudos
ZahidChaudhry
Deactivated User
Thanks Robert,
that's what i thought and i tried and it work...

Thanks one more time

Zahid
0 Kudos