Hi All,
Can any help me with code in flex which can intersect two feature class?
Regards
Akshay,
The intersect ability that the Flex API has is designed for a array of geometries and a SINGLE geometry. So intersecting two feature classes is a little difficult.
Here is the Flex API docs on the GeometryService: intersect() method:
Robert,
I'm querying on one feature class and getting its geometries and passing that geometry to intersect with other layer.
Can you please share code snippet to pass array of geometries.
Regards
Akshay,
Yes more than one geometry. Yes I'm using GeometryService.
Geometry type is polygon which I'm trying to get it unioned but it is throwing an error.
Intersect feature can be point line or polygon.
Regards,
Akshay Loya
Akshay,
The union of the layers geometries is going to be the critical part then. If you can not get the layers geometries to union using the geometry service then this is issue. Have you tried to check the layer geometry in ArcMap using the "Check Geomtery" tool?
Robert,
That is fine. Mine is SDE Geodatabases, it automatically check the validity of each geometry when they are uploaded.
Error:
Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert com.esri.ags.geometry::Polygon@11bdc129 to com.esri.ags.events.GeometryServiceEvent.
Akshay,
Can I see your code that you are using to do the union?
Robert,
This the code I'm using:
var queryT:QueryTask = new QueryTask(); |
queryT.url = "url";
queryT.useAMF= false;
var queryB:Query = new Query();
queryB.outSpatialReference = map.spatialReference;
queryB.returnGeometry = true;
queryB.outFields = ["*"];
queryB.where= "DCPDistrictCode = 123";
queryT.execute(queryB, new AsyncResponder(onResultT, onFaultT));
function onResultT(featureSetB:FeatureSet, token:Object = null):void
{
var graphicProvider1:ArrayCollection = new ArrayCollection();
if (featureSetB.features.length == 0)
{
Alert.show(resourceManager.getString('ViewerStrings', 'SearchAlert3'));
}
else
for each(var myFirstGraphic:Graphic in featureSetB.features) | |||||||||||||
{
var arrtest:Array= new Array;
arrtest.push(myFirstGraphic.geometry); | ||||||
} |
responder = new mx.rpc.Responder(myGeometryService_unionCompleteHandler,myGeometryService_faultHandler); | |||||
myGeometryService.union(arrtest,responder); |
} |
protected function myGeometryService_unionCompleteHandler(event:GeometryServiceEvent):void
{
doQuery(event.result[0] as Geometry);
}
protected function myGeometryService_faultHandler(event:FaultEvent):void
{
Alert.show("Service temporarily unavailable. Please try again","Information")
}
protected function doQuery(geom:Geometry):void
{
query.geometry = geom;
query.outFields = ["*"];
query.outSpatialReference = map.spatialReference;
query.returnGeometry = true;
query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
QueryTk.url = "url";
QueryTk.useAMF = false;
QueryTk.execute(query,new AsyncResponder(QueryIntersect,QueryIntersectFault));
}
protected function QueryIntersect(featureSetSpa:FeatureSet, token:Object = null):void
{
if (featureSetSpa.features.length = 0)
{
Alert.show("No Records found");
cursorManager.removeBusyCursor();
}
else
{
var arrObjectId:Array=new Array();
var strObjectId:String= new String();
for(var i:int=0;i<featureSetSpa.features.length;i++)
{
arrObjectId.push("'" +FeatureSet+ "'");
}
strObjectId = arrObjectId.toString() ;
}
}
protected function QueryIntersectFault(featureSet:FeatureSet, token:Object = null):void
{
Alert.show("Service temporarily unavailable. Please try again","Information");
}
Akshay,
This portion of your code concerns me:
function onResultT(featureSetB:FeatureSet, token:Object = null):void { var graphicProvider1:ArrayCollection = new ArrayCollection(); if (featureSetB.features.length == 0){ Alert.show(resourceManager.getString('ViewerStrings', 'SearchAlert3')); }else for each(var myFirstGraphic:Graphic in featureSetB.features) { var arrtest:Array= new Array; arrtest.push(myFirstGraphic.geometry); } responder = new mx.rpc.Responder(myGeometryService_unionCompleteHandler,myGeometryService_faultHandler); myGeometryService.union(arrtest,responder); }
Inside you for each loop you are recreating the arrtest array each time?...