当前位置: 首页>>代码示例>>C#>>正文


C# Polygon.AddPoint方法代码示例

本文整理汇总了C#中Polygon.AddPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.AddPoint方法的具体用法?C# Polygon.AddPoint怎么用?C# Polygon.AddPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polygon的用法示例。


在下文中一共展示了Polygon.AddPoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GoogleMapsEngineFeatureClassManagement

        // the constructor for the Feature Class Management class
        public GoogleMapsEngineFeatureClassManagement(MapsEngine.API.GoogleMapsEngineAPI api)
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("GoogleMapsEngineFeatureClassManagement initializing.");

            // retrieve a reference to the extension
            log.Debug("Retrieiving a reference to the extension object.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // initiate the Google Maps Enigne API object
            log.Debug("Setting the GME API object.");
            this.api = api;

            // generate a worldwide polygon, for default (spatial geometry undetermined or undefined) assets
            log.Debug("Establishing a default worldwide polygon object.");
            IPoint pUL = new Point();
            pUL.X = -180;
            pUL.Y = 90;
            IPoint pLL = new Point();
            pLL.X = -180;
            pLL.Y = -90;
            IPoint pLR = new Point();
            pLR.X = 180;
            pLR.Y = -90;
            IPoint pUR = new Point();
            pUR.X = 180;
            pUR.Y = 90;

            // add the points to the point collection
            IPointCollection pPtColl = new Polygon();
            pPtColl.AddPoint(pUL, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pUR, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pLR, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pLL, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pUL, Type.Missing, Type.Missing);

            // define the polygon as a list of points, then close the polygon
            worldPolygon = (IPolygon)pPtColl;
            worldPolygon.Close();
        }
开发者ID:domesticmouse,项目名称:mapsengine-arcgis-connector,代码行数:43,代码来源:GoogleMapsEngineFeatureClassManagement.cs

示例2: GetGeometry

        private IGeometry GetGeometry(int row, int column)
        {
            IPointCollection polygon = new Polygon();

            //Clockwise for filled, Counter-clockwise for holes
            polygon.AddPoint(LowerLeftPoint(row, column));
            polygon.AddPoint(UpperLeftPoint(row, column));
            polygon.AddPoint(UpperRightPoint(row, column));
            polygon.AddPoint(LowerRightPoint(row, column));
            polygon.AddPoint(LowerLeftPoint(row, column));

            //coordinates are defined in the map display
            ((IGeometry)polygon).SpatialReference = Map.SpatialReference;

            return (IGeometry)polygon;
        }
开发者ID:regan-sarwas,项目名称:AlaskaPak,代码行数:16,代码来源:Grid.cs

示例3: Render

        public void Render(IGraphics g, OpenGLTextureReference tex)
        {
            g.SetColor (Colors.White);

            var x = tex.X + tex.ShapeOffset.X;
            var y = tex.Y + tex.ShapeOffset.Y;

            switch (ShapeType) {
            case OpenGLShapeType.Line:
                g.DrawLine (x, y, x + A, y + B, C);
                break;
            case OpenGLShapeType.Rect:
                if (Fill) {
                    g.FillRect (x, y, A, B);
                }
                else {
                    g.DrawRect (x, y, A, B, C);
                }
                break;
            case OpenGLShapeType.RoundedRect:
                if (Fill) {
                    g.FillRoundedRect (x, y, A, B, C);
                }
                else {
                    g.DrawRoundedRect (x, y, A, B, C, D);
                }
                break;
            case OpenGLShapeType.Oval:
                if (Fill) {
                    g.FillOval (x, y, A, B);
                }
                else {
                    g.DrawOval (x, y, A, B, C);
                }
                break;
            case OpenGLShapeType.Character:
                g.SetFont (Font);
                g.DrawString (Char.ToString (), x, y);
                break;
            case OpenGLShapeType.Polygon: {
                    var dx = x - Poly.Points[0].X;
                    var dy = y - Poly.Points[0].Y;
                    var dpoly = new Polygon ();
                    for (var i = 0; i < Poly.Points.Count; i++) {
                        dpoly.AddPoint (Poly.Points[i].X + dx, Poly.Points[i].Y + dy);
                    }
                    if (Fill) {
                        g.FillPolygon (dpoly);
                    }
                    else {
                        g.DrawPolygon (dpoly, A);
                    }
                }
                break;
            case OpenGLShapeType.Arc:
                if (Fill) {
                    g.FillArc (x, y, A, B, C);
                }
                else {
                    g.DrawArc (x, y, A, B, C, D);
                }
                break;
            case OpenGLShapeType.Polyline: {
                    var dx = x - PolylinePoints[0].X;
                    var dy = y - PolylinePoints[0].Y;
                    g.BeginLines (true);
                    for (var i = 0; i < PolylineLength - 1; i++) {
                        g.DrawLine (
                            PolylinePoints[i].X + dx,
                            PolylinePoints[i].Y + dy,
                            PolylinePoints[i + 1].X + dx,
                            PolylinePoints[i + 1].Y + dy,
                            A);
                    }
                    g.EndLines ();
                }
                break;
            default:
                throw new NotSupportedException ();
            }
        }
开发者ID:robertgreen,项目名称:CrossGraphics,代码行数:81,代码来源:OpenGLGraphics.cs

示例4: ReadXml

        public static OpenGLShapeInfo ReadXml(System.Xml.XmlReader r)
        {
            var icult = System.Globalization.CultureInfo.InvariantCulture;

            var i = new OpenGLShapeInfo ();

            while (r.Read ()) {
                if (r.IsStartElement ("Info")) {
                    i.ShapeType = (OpenGLShapeType)Enum.Parse (typeof (OpenGLShapeType), r.GetAttribute ("ShapeType"));
                    i.A = float.Parse (r.GetAttribute ("A"), icult);
                    i.B = float.Parse (r.GetAttribute ("B"), icult);
                    i.C = float.Parse (r.GetAttribute ("C"), icult);
                    i.D = float.Parse (r.GetAttribute ("D"), icult);
                    i.Fill = r.GetAttribute ("Fill") == "true";
                    var ch = r.GetAttribute ("Char");
                    i.Char = string.IsNullOrEmpty (ch) ? (char)0 : ch[0];
                    var ff = r.GetAttribute ("FontFamily");
                    if (!string.IsNullOrWhiteSpace (ff)) {
                        var fw = r.GetAttribute ("FontWeight");
                        var fo = fw == "bold" ? FontOptions.Bold : FontOptions.None;
                        var fs = int.Parse (r.GetAttribute ("FontSize"), icult);
                        i.Font = new Font (ff, fo, fs);
                    }
                }
                else if (r.IsStartElement ("Polygon")) {
                    var parts = r.GetAttribute ("Points").Split (WS, StringSplitOptions.RemoveEmptyEntries);
                    var poly = new Polygon ();
                    for (var j = 0; j < parts.Length; j += 2) {
                        var p = new PointF (float.Parse (parts[j], icult), float.Parse (parts[j + 1], icult));
                        poly.AddPoint (p);
                    }
                    i.Poly = poly;
                }
                else if (r.IsStartElement ("Polyline")) {
                    var parts = r.GetAttribute ("Points").Split (WS, StringSplitOptions.RemoveEmptyEntries);
                    var poly = new List<PointF> ();
                    for (var j = 0; j < parts.Length; j += 2) {
                        var p = new PointF (float.Parse (parts[j], icult), float.Parse (parts[j + 1], icult));
                        poly.Add (p);
                    }
                    i.PolylinePoints = poly.ToArray ();
                    i.PolylineLength = i.PolylinePoints.Length;
                }
            }

            return i;
        }
开发者ID:robertgreen,项目名称:CrossGraphics,代码行数:47,代码来源:OpenGLGraphics.cs

示例5: Draw

    // dessine un arc de cercle defini par les parametres de point auquel on applique une transformation de matrix
    // le pas de l'arc de cercle est defini par ANGLE_STEP en degré
    public static void Draw(ArchedPoint2 point, Matrix4x4 matrix,
		float offsetWidth=0, float offsetHeight=0)
    {
        Vector2 center = point.GetCenter ();
        float radius = point.GetMeasuredRadius ();

        Vector2 prevTangentPoint = point.GetPrevTangentPoint ();
        Vector2 nextTangentPoint = point.GetNextTangentPoint ();

        Vector2 firstPoint2Add = prevTangentPoint;
        Vector2 lastPoint2Add = nextTangentPoint;

        Vector2 startVector = (prevTangentPoint - center).normalized;
        Vector2 endVector = (nextTangentPoint - center).normalized;

        Vector2 angleMeasureReference = Vector2.right;

        if (point.GetAngleType () == AngleType.Outside)
        {
            startVector = (nextTangentPoint - center).normalized;
            endVector = (prevTangentPoint - center).normalized;

            firstPoint2Add = nextTangentPoint;
            lastPoint2Add = prevTangentPoint;
        }

        // On cherche les angles de depart et de fin par rapport au vector (1, 0)
        // pour tracer l'arc dans le sens trigonometrique
        float startAngle;
        if (Utils.Approximately (Vector3.Cross (startVector, angleMeasureReference).z, 0))
        {
            startAngle = Vector2.Dot (startVector, angleMeasureReference) < 0 ? 180 : 0;
        }
        else
        {
            Quaternion startRotation = Quaternion.FromToRotation (angleMeasureReference, startVector);
            startAngle = startRotation.eulerAngles.z;
        }

        float endAngle;
        if (Utils.Approximately (Vector3.Cross (endVector, angleMeasureReference).z, 0))
        {
            endAngle = Vector2.Dot (endVector, angleMeasureReference) < 0 ? 180 : 0;
        }
        else
        {
            Quaternion endRotation = Quaternion.FromToRotation (angleMeasureReference, endVector);
            endAngle = endRotation.eulerAngles.z;
        }

        //Debug.Log (startAngle + " " + endAngle);

        if (startAngle > endAngle)
        {
            endAngle += 360;
        }

        startAngle += ANGLE_STEP;
        float currentAngle = startAngle;

        // on cree le polygon ouvert correspondant a l'arc de cercle
        Polygon arc = new Polygon ();
        arc.AddPoint (new Point2 (firstPoint2Add));

        // ajout de chaque point du polygone calcule a partir de l'angle courant
        while (currentAngle < endAngle)
        {
            float radAngle = currentAngle * Mathf.Deg2Rad;
            Vector2 arcPoint = new Vector2 (Mathf.Cos (radAngle), Mathf.Sin (radAngle)) * radius + center;

            arc.AddPoint (new Point2 (arcPoint));

            currentAngle += ANGLE_STEP;
        }

        arc.AddPoint (new Point2 (lastPoint2Add));

        //		arc = new Polygon ();
        //		foreach (Vector2 v in point.GetCurve ())
        //		{
        //			arc.AddPoint (new Point2 (v));
        //		}

        // on dessine l'ensemble des edges correspondant a l'arc de cercle
        foreach (Edge2 edge in arc.GetEdges ())
        {
            EdgeDrawer.Draw (edge, matrix,10, offsetWidth, offsetHeight );
        }

        //		Vector2 anchorPoint = matrix.MultiplyPoint (point.GetAnchorPoint ());
        //		GUI.Box (new Rect (anchorPoint.x - POINT_RADIUS / 2,
        //					       anchorPoint.y - POINT_RADIUS / 2,
        //					       POINT_RADIUS,
        //					       POINT_RADIUS), "", "selected point");

        // dessine les points tangents
        prevTangentPoint.Set(prevTangentPoint.x+offsetWidth,prevTangentPoint.y + offsetHeight);
        prevTangentPoint = matrix.MultiplyPoint (prevTangentPoint);
//.........这里部分代码省略.........
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:101,代码来源:ArcDrawer.cs

示例6: populateFCWithGoogleMapsEngineMap

        /*
         * A function to populate a referenced FeatureClass (fc) with the contents of a Google Maps Engine map
         */
        public void populateFCWithGoogleMapsEngineMap(ref IFeatureClass fc, ref MapsEngine.DataModel.gme.Map map)
        {
            // create a feature object
            log.Debug("Creating a new Feature object to be used later in populating the FC.");
            IFeature feature = fc.CreateFeature();

            log.Debug("Creating feature for map " + map.id);

            // create a projectId value from the MapId
            String projectId = map.id.Split("-".ToCharArray())[0];

            // Update the values for this feature
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name), projectId);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name + ": " + projectId);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name), map.id);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name + ": " + map.id);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name), map.id);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name + ": " + map.id);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name), "map");
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name + ": " + "map");
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name), map.name);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name + ": " + map.name);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name), projectId);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name + ": " + projectId);

            // attempt to set the description
            try
            {
                // attempt to set the feature description (truncating if necessary)
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name)
                    , map.description.Length > 256
                    ? map.description.Substring(0, 252) + "..."
                    : map.description);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name + ": " + map.description);
            }
            catch (System.Exception ex)
            {
                // warn
                log.Warn(ex);
            }

            // check to see if the bbox object is not null
            log.Debug("Adding spatial representation if available.");
            if (map.bbox != null && map.bbox.Count() == 4)
            {
                // deterine the maximum and minimum bounds of all layers within this map
                // 0=West, 1=South, 2=East, 3=North
                double XMAX = map.bbox[2];
                log.Debug("XMAX: " + XMAX);
                double YMAX = map.bbox[3];
                log.Debug("YMAX: " + YMAX);
                double XMIN = map.bbox[0];
                log.Debug("XMIN: " + XMIN);
                double YMIN = map.bbox[1];
                log.Debug("YMIN: " + YMIN);


                // determine the map extent based on the layers maximum extent
                IPoint pExtentNE = new Point();
                pExtentNE.X = XMAX;
                pExtentNE.Y = YMAX;
                IPoint pExtentSW = new Point();
                pExtentSW.X = XMIN;
                pExtentSW.Y = YMIN;
                IPoint pExtentNW = new Point();
                pExtentNW.X = XMIN;
                pExtentNW.Y = YMAX;
                IPoint pExtentSE = new Point();
                pExtentSE.X = XMAX;
                pExtentSE.Y = YMIN;

                // define the polygon bounding box (NE/SW) as a point collection
                log.Debug("Building polygon object.");
                IPointCollection pExtentPointCol = new Polygon();
                pExtentPointCol.AddPoint(pExtentNE, Type.Missing, Type.Missing);
                pExtentPointCol.AddPoint(pExtentSE, Type.Missing, Type.Missing);
                pExtentPointCol.AddPoint(pExtentSW, Type.Missing, Type.Missing);
                pExtentPointCol.AddPoint(pExtentNW, Type.Missing, Type.Missing);

                // create a polygon, p, from the point collection, then close the polygon
                IPolygon pExtent = (IPolygon)pExtentPointCol;
                pExtent.Close();

                // add the polygon, p, as the new feature's geometry
                if (pExtent != null)
                {
                    log.Debug("Setting feature's geometry.");
                    feature.Shape = pExtent;
                }
                else
                {
                    log.Warn("Polygon is not valid, setting feature geometry to default worldwide.");
                    feature.Shape = worldPolygon;
                }
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:domesticmouse,项目名称:mapsengine-arcgis-connector,代码行数:101,代码来源:GoogleMapsEngineFeatureClassManagement.cs

示例7: populateFCWithGoogleMapsEngineLayer

        /*
         * A function to populate a referenced Feature Class (fc) with the contents of a Google Maps Engine map layer
         */
        protected void populateFCWithGoogleMapsEngineLayer(ref IFeatureClass fc, string mapId, string parentId, MapsEngine.DataModel.gme.MapLayer layer)
        {
            // create a new feature
            IFeature feature;

            log.Debug("Creating a feature for layer " + layer.id);

            // attempt to process the assets within a the layer
            try
            {
                // fetch the layer asset object from the API
                log.Debug("Fetching an asset object for the layer.");
                MapsEngine.DataModel.gme.Asset layerAsset = api.getAssetById(ext.getToken(), layer.id);

                // create a new feature
                log.Debug("Creating a new feature.");
                feature = fc.CreateFeature();

                // Update the values for this feature
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name), mapId.Split("-".ToCharArray())[0]);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name + ": " + mapId.Split("-".ToCharArray())[0]);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name), layer.id);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name + ": " + layer.id);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name), mapId);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name + ": " + mapId);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name), layerAsset.type);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name + ": " + layerAsset.type);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name), layerAsset.name);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name + ": " + layerAsset.name);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name), parentId);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name + ": " + parentId);

                // attempt to set the description object
                try
                {
                    // set the layer description value (truncate if necessary)
                    feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name)
                        , layerAsset.description.Length > 256
                        ? layerAsset.description.Substring(0, 252) + "..."
                        : layerAsset.description);
                    log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name + ": " + layerAsset.description);
                }
                catch (System.Exception ex)
                {
                    // log warning
                    log.Warn(ex);
                }

                // verify the layer has a bbox and has two valid points
                if (layerAsset.bbox != null && layerAsset.bbox.Count() == 4)
                {
                    // deterine the maximum and minimum bounds of all layers within this map
                    // 0=West, 1=South, 2=East, 3=North
                    double XMAX = layerAsset.bbox[2];
                    log.Debug("XMAX: " + XMAX);
                    double YMAX = layerAsset.bbox[3];
                    log.Debug("YMAX: " + YMAX);
                    double XMIN = layerAsset.bbox[0];
                    log.Debug("XMIN: " + XMIN);
                    double YMIN = layerAsset.bbox[1];
                    log.Debug("YMIN: " + YMIN);

                    // determine the map extent based on the layers maximum extent
                    IPoint pExtentNE = new Point();
                    pExtentNE.X = XMAX;
                    pExtentNE.Y = YMAX;
                    IPoint pExtentSW = new Point();
                    pExtentSW.X = XMIN;
                    pExtentSW.Y = YMIN;
                    IPoint pExtentNW = new Point();
                    pExtentNW.X = XMIN;
                    pExtentNW.Y = YMAX;
                    IPoint pExtentSE = new Point();
                    pExtentSE.X = XMAX;
                    pExtentSE.Y = YMIN;

                    // define the polygon bounding box (NE/SW) as a point collection
                    IPointCollection pExtentPointCol = new Polygon();
                    pExtentPointCol.AddPoint(pExtentNE, Type.Missing, Type.Missing);
                    pExtentPointCol.AddPoint(pExtentSE, Type.Missing, Type.Missing);
                    pExtentPointCol.AddPoint(pExtentSW, Type.Missing, Type.Missing);
                    pExtentPointCol.AddPoint(pExtentNW, Type.Missing, Type.Missing);

                    // create a polygon, p, from the point collection, then close the polygon
                    IPolygon pExtent = (IPolygon)pExtentPointCol;
                    pExtent.Close();

                    // add the polygon, p, as the new feature's geometry
                    if (pExtent != null)
                    {
                        // set the shape geometry
                        log.Debug("Setting the feature's geometry as the polygon.");
                        feature.Shape = pExtent;
                    }
                    else
                    {
                        // set the feature's goemetry as the default world
//.........这里部分代码省略.........
开发者ID:domesticmouse,项目名称:mapsengine-arcgis-connector,代码行数:101,代码来源:GoogleMapsEngineFeatureClassManagement.cs


注:本文中的Polygon.AddPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。