Select to view content in your preferred language

Multipolgons

3448
12
04-19-2010 05:55 AM
AmyRamsdell
Occasional Contributor
Looking for suggestions on working with Multipolygons and their extents and projecting their coordinates.

I have a graphics layer that I build from a service JSON return.  Right now the only way that I know how to use the
WebMercatorUtil to convert from WGS to webmercator is point by point because it doesn't work with polys with multiple rings. Does this sound correct or is there another approach?

Also once all the polys are returned I want to zoom to that extent of the graphics layer however the GraphicUtil.getGraphicsExtent doesn't work on this type of poly as well.

By the way, I miss the old Search in the forums. For that matter, the whole thing is getting more difficult to navigate through.  Gotta use the new icons though.
Tags (2)
0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
aramsdell,

   I have been able to verify that the WebMercatorUtil is indeed having issues with multi ring polygons. The GraphicUtil on the other hand does not have any issue that I can find. It looks like the AGS Flex API team will have to resolve the WebMercatorUtil issue.
0 Kudos
AmyRamsdell
Occasional Contributor
Yes you are right on both. We are stuck with that in the merc util but I messed up, I originally thought the second error was happening in the graphic util extent. But it is not the extent, the problem comes in when you add the poly to the graphics layer and try to draw it.  It can't convert an array to mappoint was the error.  I have since deconstructed the polys to draw them.
0 Kudos
AmyRamsdell
Occasional Contributor
Robert, How do I give you points in this crazy thing???
0 Kudos
MehulChoksey
Esri Contributor
Could you provide geometry of MultiPolygon thats passed in to WebMercatorUtil ?

Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Mehul,

   Sure attached is a simple Personal GDB with some multi-ring polygons in WGS1984
0 Kudos
AmyRamsdell
Occasional Contributor
I am still struggling with adding teh multipolygons to a gaphics layer.   Has anyone been successful at adding a multipolygon to a graphics layer? Not sure if it is the way I am building the multipoly.

This is the error I am getting:

TypeError: Error #1034: Type Coercion failed: cannot convert []@f046431 to com.esri.ags.geometry.MapPoint.
at com.esri.ags.geometry::Polygon/get extent()
at com.esri.ags.utils::GraphicUtil$/getGraphicsExtent()
at com.indus.widgets::WatersServicesWidget/loadCatchmentResults()
at com.indus.widgets::WatersServicesWidget/__catchmentService_result()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at DirectHTTPMessageResponder/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
0 Kudos
MehulChoksey
Esri Contributor
Robert,

I tried with one of the polygon that you provided and it worked.
aramsdell,
from the error it seems like you are passing argument of different type than the one expected by getGraphicsExtent method.
Could you paste code from line 491 of your code WatersServicesWidget. mxml?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:esri="http://www.esri.com/2008/ags">
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.SpatialReference;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.geometry.Polygon;
   import com.esri.ags.layers.GraphicsLayer;
   import com.esri.ags.utils.WebMercatorUtil;
   
   import mx.events.FlexEvent;
   
   
   protected function myGraphicsLayer_creationCompleteHandler(event:FlexEvent):void
   {
    var polygon:Polygon = new Polygon([[
     new MapPoint(-85.75041310899991,33.72542224500006 ),
     new MapPoint(-85.73190945499994,33.657326939000086),
     new MapPoint(-85.82494958099994,33.68269326400008),
     new MapPoint(-85.75041310899991,33.72542224500006)]],new SpatialReference(4326))
    
    polygon.addRing([
     new MapPoint(-85.75630669999993,33.71122135300004),
     new MapPoint(-85.80296428299994,33.68655667500008),
     new MapPoint(-85.74392047999993,33.668993786000044),
     new MapPoint(-85.75630669999993,33.71122135300004)
    ]);
    
    var mercPoly:Polygon = WebMercatorUtil.geographicToWebMercator(polygon) as Polygon;
    myMap.extent = mercPoly.extent.expand(2);
    myGraphicsLayer.add(new  Graphic(mercPoly));
   }
   
  ]]>
 </fx:Script>
 
 <esri:Map id="myMap">
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
  <esri:GraphicsLayer id="myGraphicsLayer"  creationComplete="myGraphicsLayer_creationCompleteHandler(event)"/>
 </esri:Map>
 
</mx:Application>
0 Kudos
AmyRamsdell
Occasional Contributor
OK I must be doing something wrong if you are able to convert the multipoly and draw it on the graphic layer.

This is the line

map.extent = (GraphicUtil.getGraphicsExtent(graphicsArray)).expand(2.0);


The graphics array has one poly and one multipoly.  If I don't add the multipoly it works fine so there is something about the way I am constructing it. 

I appreciate your help!!
0 Kudos
MehulChoksey
Esri Contributor
aramsdell,
Could you share the code snippet used for constructing graphicsArray?
0 Kudos