コード例 #1
0
        protected override InteractiveResult MouseUpCore(InteractionArguments interactionArguments)
        {
            if (IsShiftKeyDown == true)
            {
                PolygonShape newPolygonShape = (PolygonShape)EditShapesLayer.InternalFeatures[0].GetShape();
                RingShape    ringShape       = new RingShape();

                foreach (Feature feature in controlPoints)
                {
                    PointShape controlPointShape = (PointShape)feature.GetShape();
                    if (feature.ColumnValues["nodetype"] == "special")
                    {
                        BaseShape  baseShape  = snappingFeature.GetShape();
                        PointShape pointShape = baseShape.GetClosestPointTo(controlPointShape, GeographyUnit.DecimalDegree);
                        ringShape.Vertices.Add(new Vertex(pointShape.X, pointShape.Y));
                    }
                    else
                    {
                        ringShape.Vertices.Add(new Vertex(controlPointShape.X, controlPointShape.Y));
                    }
                }

                newPolygonShape.OuterRing = ringShape;

                Feature newFeature = new Feature(newPolygonShape, EditShapesLayer.InternalFeatures[0].ColumnValues);

                EditShapesLayer.Open();
                EditShapesLayer.EditTools.BeginTransaction();
                EditShapesLayer.InternalFeatures.Clear();
                EditShapesLayer.InternalFeatures.Add(newFeature);
                EditShapesLayer.EditTools.CommitTransaction();
                EditShapesLayer.Close();
            }
            return(base.MouseUpCore(interactionArguments));
        }
コード例 #2
0
 private static IEnumerable <PointShape> CollectPoints(RingShape ring)
 {
     foreach (var vertex in ring.Vertices)
     {
         yield return(new PointShape(vertex));
     }
 }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Map1.MapBackground = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                Map1.CurrentExtent = new RectangleShape(-10779959, 3909739, -10777699, 3908399);
                Map1.MapUnit       = GeographyUnit.Meter;

                Map1.MapTools.OverlaySwitcher.Enabled = true;
                Map1.MapTools.MouseCoordinate.Enabled = true;

                //Adds the Google Map as an overlay
                GoogleOverlay google = new GoogleOverlay("Google Map");
                google.GoogleMapType = GoogleMapType.Normal;
                Map1.CustomOverlays.Add(google);

                //Creates polygon feature to be added to the EditOverlay
                PolygonShape polygonShape = new PolygonShape();
                RingShape    ringShape    = new RingShape();
                ringShape.Vertices.Add(new Vertex(-10778968, 3909448));
                ringShape.Vertices.Add(new Vertex(-10778686, 3909443));
                ringShape.Vertices.Add(new Vertex(-10778691, 3909180));
                ringShape.Vertices.Add(new Vertex(-10778982, 3909175));
                ringShape.Vertices.Add(new Vertex(-10778968, 3909448));
                polygonShape.OuterRing = ringShape;

                Feature editFeature = new Feature(polygonShape);
                Map1.EditOverlay.Features.Add(editFeature);

                //Sets the properties so that the features can be only draggable.
                //Notice that we don't set the style here. We set the style in javascript in TestForm.aspx under the script tag.
                Map1.EditOverlay.TrackMode = TrackMode.Edit;
                Map1.EditOverlay.EditSettings.IsDraggable  = true;
                Map1.EditOverlay.EditSettings.IsReshapable = false;
                Map1.EditOverlay.EditSettings.IsResizable  = false;
                Map1.EditOverlay.EditSettings.IsRotatable  = false;
            }
        }
コード例 #4
0
ファイル: MBTilesGenerator.cs プロジェクト: bymin/EasyGIS.NET
        private static void ProcessRingShape(int zoom, int tileSize, RectangleInt tileScreenBoundingBox, TileFeature tileFeature, RingShape ringShape, int simplificationFactor, RectangleShape tileBoundingBox)
        {
            PointInt[] tilePoints = new PointInt[ringShape.Vertices.Count];
            for (int n = 0; n < ringShape.Vertices.Count; ++n)
            {
                tilePoints[n] = WorldPointToTilePoint(ringShape.Vertices[n].X, ringShape.Vertices[n].Y, zoom, tileSize, tileBoundingBox);
            }
            PointInt[] simplifiedTilePoints = SimplifyPointData(tilePoints, simplificationFactor);

            //output count may be zero for short records at low zoom levels as
            //the pixel coordinates wil be a single point after simplification
            if (simplifiedTilePoints.Length > 3)
            {
                if (simplifiedTilePoints[0] != simplifiedTilePoints[simplifiedTilePoints.Length - 1])
                {
                    Console.WriteLine("Not Closed");
                }
                List <PointInt> clippedRing = ClipRingShape(simplifiedTilePoints, tileScreenBoundingBox);
                if (clippedRing.Count > 3)
                {
                    tileFeature.Geometry.Add(clippedRing);
                }
            }
        }
コード例 #5
0
 private static void CloseSplittedRing(Vertex vertex, RectangleShape closeArea, RingShape ring)
 {
     for (int i = 0; i < ring.Vertices.Count; i++)
     {
         var currentVertex = ring.Vertices[i];
         if (closeArea.Contains(new PointShape(currentVertex)))
         {
             ring.Vertices[i] = new Vertex(vertex.X, vertex.Y);
         }
     }
 }