Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to intersect all features of a layer with another's but I'm getting the web ADF application stuck while executing the "ConstructUnion" function

Here's the code I've written so far

// create a geometrybag for layer1
ESRI.ArcGIS.Geometry.IGeometry geometryBag = new ESRI.ArcGIS.Geometry.GeometryBagClass();
geometryBag.SpatialReference = m_firstLayerFirstfeatureIGeometry.SpatialReference;
ESRI.ArcGIS.Geometry.IGeometryCollection geometryCollection = (ESRI.ArcGIS.Geometry.IGeometryCollection)geometryBag;
// Cycle all features of first layer and add them to the collection
foreach (DataRow m_dr in m_firstLayerfeatureGraphics.Rows)
{
    // Takes this feature's geometry
    ESRI.ArcGIS.ADF.Web.Geometry.Geometry adfFeature =
        m_firstLayerfeatureGraphics.GeometryFromRow(m_dr) as ESRI.ArcGIS.ADF.Web.Geometry.Geometry;
    // convert to a igeometry object
    ESRI.ArcGIS.Geometry.IGeometry m_tempfeatureIGeometry =
    ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Local.Converter.ToIGeometry(adfFeature, ctx);
    System.Diagnostics.Debug.WriteLine("m_firstLayerfeatureGraphics +1 ");
    object missing = Type.Missing;
    geometryCollection.AddGeometry(m_tempfeatureIGeometry, ref missing, ref
    missing);
}
ESRI.ArcGIS.Geometry.ITopologicalOperator mtopo1 = new ESRI.ArcGIS.Geometry.PolygonClass();
// FOLLOWING LINE BLOCKS APPLICATION
mtopo1.ConstructUnion((ESRI.ArcGIS.Geometry.IEnumGeometry)geometryBag);

Any idea why?

share|improve this question
    
Is there any COM error message or does it really just sit on that line forever? –  blah238 Aug 7 '11 at 20:27
    
It just sits on that line forever. Occasionally everything crashes with no error (w3smp.exe crash or something like that) –  Marco A. Aug 8 '11 at 16:12
add comment

1 Answer 1

up vote 3 down vote accepted

You need to create the ArcObject instances (GeometryBagClass at the beginning and PolygonClass near the end of your code snippet) on the ArcGIS Server SOC by using IServerContext.CreateObject. Your current code creates these objects on the web server (or wherever your ADF app is running), which requires a lot of marshalling which in many cases seems to never finish.

You already have the reference to the server context in the ctx variable, so you are basically all set. Once all the ArcObjects are created on the ArcGIS Server, your problem is likely to be solved.

share|improve this answer
    
You're right! Thank you so much! –  Marco A. Aug 9 '11 at 12:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.