Select to view content in your preferred language

Reshaping using geometryservice throws error Error: E0002E: Use a subclass instance

753
3
04-18-2012 05:55 PM
Rodwaski
Emerging Contributor
I have a geometryservice that reshapes a feature.

I select a feature then call the geometryservice.

myGeometryService.reshape(selectedGraphic.geometry,drawnLine)

The first time I call the service it works fine.

If I then select the same feature again then try and reshape it the event returns no geometry and gives 'exception thrown by getter' .. Error: E0002E: Use a subclass instance.

I am not using the edit widget and it is the version 2.5 of the flex API.
Tags (2)
0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
That error means you're using an instance of the Geometry base class rather than a Polygon etc.
0 Kudos
Rodwaski
Emerging Contributor
I have changed it from a graphic.geometry to a polygon and it is still doing the same thing.

It works the first time I reshape then when I select the feature, assign that to my selected graphic object and then try and reshape I get this error. Here is a code snippit.

It returns the error on the reshapecompletehandler.

private function reshapepolygon():void
   {
   
    map.removeEventListener(MapMouseEvent.MAP_CLICK, map_mapClickHandler);
    reshapedrawTool.activate(DrawTool.POLYLINE);

   }
  
   protected function reshape_drawEndHandler(event:DrawEvent):void
   {
     var drawnLine:Polyline = Polyline(event.graphic.geometry);
     myGeometryService.addEventListener(GeometryServiceEvent.RESHAPE_COMPLETE, reshapeCompleteHandler);
     var myPolygon:Polygon = Polygon(selectedGraphic.geometry);
    
    
     myGeometryService.reshape(myPolygon,drawnLine)
    reshapedrawTool.deactivate();
    map.addEventListener(MapMouseEvent.MAP_CLICK, map_mapClickHandler);
   }
  
   private function reshapeCompleteHandler(event:GeometryServiceEvent):void
   {
    Alert.show("reshape Complete")
    
    var newAtttrs:* = ObjectUtil.copy(selectedGraphic.attributes);
    var myPolygon:Polygon = new Polygon;
    myPolygon.rings = event.result.rings;
    var newGraphic:Graphic = new Graphic(myPolygon, null, newAtttrs);
    incidentsPolygonLayer.addEventListener(FeatureLayerEvent.EDITS_COMPLETE,editscomplete)
    incidentsPolygonLayer.applyEdits([ newGraphic ], null,incidentsPolygonLayer.selectedFeatures);
   }

The geometryservice.reshapeLastResult is the same as the event returns.

com.esri.ags.geometry.Geometry (@afd16b9)
defaultSymbol <exception thrown by getter>
extent <exception thrown by getter>
spatialReference null
type <exception thrown by getter>

The mypolygon and drawnline both seem to look OK.
0 Kudos
SarthakDatt
Frequent Contributor
Hey Rod,

I tried GeometryService.reshape() at my end with 2.5 api, it seems to working fine for me. Could you send me the complete test case/application or the full stack trace you have? Will be easier to debug

Meanwhile, here's what i am doing in my resultHandler:

var reshapedPolygon:Polygon = event.result as Polygon;
var newGraphic:Graphic = new Graphic(myPolygon);
0 Kudos