How to create one donut in adf in arcserver9.3 (c# win2003)

673
0
07-17-2013 02:46 AM
lihong1
New Contributor
My environment is win2003 ,arcsever9.3(c#) ,vs2008, sde(sqlserver2005)
My data is
string strpoint1 = "110.487339726558,31.3602083855353,0 110.491448987015,31.3577775549622,0 110.487571233632,31.3549994637781,0 110.484619511243,31.3555782323626,0 110.487339726558,31.3602083855353,0";
        string strpoint2 = "110.48728184889,31.358356324446,0 110.486934587379,31.3569094016358,0 110.488323633421,31.3572566631463,0 110.48728184889,31.358356324446,0";
       
I want to create one donut featureclass in sde polygon layer in ao (adf) by above data(2 strings)?
(I expains about 2 strings , and  strpoint1  contains strpoint2. Now I want get one donut(strpoint1 -strpoint2))
Who can help me ?

(I find codes are wrong below


http://forums.esri.com/Thread.asp?c=93&f=993&t=295756

if (((IRelationalOperator)(polygonA)).Within(polygonB))
{
        // Polygon maintenance
        ((ITopologicalOperator2)polygonA).IsKnownSimple_2 = false;
        ((ITopologicalOperator2)polygonA).Simplify();
        ((ITopologicalOperator2)polygonB).IsKnownSimple_2 = false;
        ((ITopologicalOperator2)polygonB).Simplify();

        // Add donut hole PolygonA to PolygonB (IPolygon)
        AddHole(polygonB, polygonA); // PolygonA is wholly contained by PolygonB

        // Outer poly graphic
        ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement ge = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement();
        ge.Symbol = sfSymOutside;// A simple fill symbol defined elsewhere

        // Add donut graphic to the map
        ESRI.ArcGIS.ADF.Web.Geometry.Polygon pTemp = ConvertIPolygonToWebPolygon((IPolygon)polygonB); // Must be converted in the ArcGIS Server world
        ge.Geometry = (ESRI.ArcGIS.ADF.Web.Geometry.Geometry)pTemp;
        ((ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)GResource.Graphics.Tables["myLayer"]).Add(ge);
}

// Kirk's method
private void AddHole(IPolygon Donut, IPolygon DonutHole)
{
    IGeometryCollection extRrings = ((IPolygon4)DonutHole).ExteriorRingBag as IGeometryCollection;
    IRing holeRing = extRrings.get_Geometry(0) as IRing;
    if (holeRing.IsExterior)
        holeRing.ReverseOrientation();
    object missing = Type.Missing;
    ((IGeometryCollection)Donut).AddGeometry(holeRing, ref missing, ref missing);
}

// Converter compliment of ESRI samples
private ESRI.ArcGIS.ADF.Web.Geometry.Polygon ConvertIPolygonToWebPolygon(ESRI.ArcGIS.Geometry.IPolygon com_polygon)
{
    ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)com_polygon;
    ESRI.ArcGIS.ADF.Web.Geometry.Point[] new_adf_points = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPointCollection(com_pointcollection);
    ESRI.ArcGIS.ADF.Web.Geometry.PointCollection new_adf_pointcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();

    for (int i = 0; i < new_adf_points.Length - 1; i++)
    {
        new_adf_pointcollection.Add(new_adf_points);
    }
    ESRI.ArcGIS.ADF.Web.Geometry.Ring new_adf_ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();

    new_adf_ring.Points = new_adf_pointcollection;

    ESRI.ArcGIS.ADF.Web.Geometry.RingCollection new_adf_ringcollection = new ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();
    new_adf_ringcollection.Add(new_adf_ring);

    ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
    new_adf_polygon.Rings = new_adf_ringcollection;

    return new_adf_polygon;
}
codes above don't run wrong but it can't get ideal results
Error points are
1 if (((IRelationalOperator)(polygonA)).Within(polygonB))
useless�?
2polygonB aren't donut and it is one common polygon
)
0 Kudos
0 Replies