I have X layers on a map and I need to intersect chosen layers (two per time) and color resulting features.
I'm trying to get this code working
// get first feature (index 0)
ESRI.ArcGIS.ADF.Web.Geometry.Geometry adfFeature =
m_firstLayer.GeometryFromRow(m_firstLayer.Rows[0])
as ESRI.ArcGIS.ADF.Web.Geometry.Geometry;
// THE FOLLOWING LINE RETURNS NULL
ESRI.ArcGIS.Geometry.IGeometry featureInterface =
adfFeature as ESRI.ArcGIS.Geometry.IGeometry;
ESRI.ArcGIS.Geometry.ITopologicalOperator topoOp =
adfFeature as ESRI.ArcGIS.Geom开发者_如何学运维etry.ITopologicalOperator;
How to use the IGeometry interface with an ADF Geometry object?
I can't really find samples to intersect features between two layers, and it's a pity that Spatial Joins are just a arcgis desktop function, I surely could use them!
I do not think you use the IGeometry directly. However if you know the specialized type (Point, Polyline, Polygon) you can convert (see the "Web ADF to ArcGIS Server ArcObjects" bullets) to ArcObjects.
You could test what subtype your ESRI.ArcGIS.ADF.Web.Geometry.Geometry adfFeature
is and do conversion accordingly.
By the way I suggest that you never use the "as" cast since it can fail silently (just returning null
). Instead I suggest:
ESRI.ArcGIS.Geometry.IGeometry featureInterface =
(ESRI.ArcGIS.Geometry.IGeometry)adfFeature;
Then you will see the problem as soon as it occurs.
精彩评论