Ejemplo n.º 1
0
        private void DrawPolygonClip(PaintEventArgs e)
        {
            var aPoint1 = new GeoCoordinate(20.0, 20.0, 0.0);
            var aPoint2 = new GeoCoordinate(30.0, 200.0, 0.0);
            var aPoint3 = new GeoCoordinate(100.0, 300.0, 0.0);
            var aPoint4 = new GeoCoordinate(400.0, 350.0, 0.0);
            var aPoint5 = new GeoCoordinate(350.0, 150.0, 0.0);

            var aPolyline = new GeoPolyline();

            aPolyline.addVertex(aPoint1);
            aPolyline.addVertex(aPoint2);
            aPolyline.addVertex(aPoint3);
            aPolyline.addVertex(aPoint4);
            aPolyline.addVertex(aPoint5);
            aPolyline.close();

            var aPolygon = new GeoPolygon();

            aPolygon.setPolyline(aPolyline);

            DrawPolygon(e, aPolygon, Color.FromArgb(255, 0, 0, 255));

            var aNormal = new GeoNormal(1, 1, 0);

            var aPlane = new GeoPlane(aNormal, 3.0 * trackBar1.Value + 100.0);

            var aClippedPolygon = aPolygon.clip(aPlane);

            DrawPolygon(e, aClippedPolygon, Color.FromArgb(255, 255, 0, 0));
        }
Ejemplo n.º 2
0
        public GeoProject shpRead()
        {
            //IFeatureSet fs = FeatureSet.Open(shppath);
            string         str  = fs.ProjectionString;
            ProjectionInfo info = fs.Projection;

            project = new GeoProject();
            for (int i = 0; i < fs.Features.Count; i++)
            {
                Geometries         geometries = new Geometries();
                IList <Coordinate> vertics    = fs.Features[i].Coordinates;
                GeoPolygon         polygon    = new GeoPolygon();
                int circle = 1;
                foreach (Coordinate vertic in vertics)
                {
                    GeoPoint point = new GeoPoint();
                    point.X = vertic.X;
                    point.Y = vertic.Y;
                    if (polygon.Points.Contains(point))
                    {
                        polygon.Circle = circle;
                        geometries.Polygons.Add(polygon);
                        circle++;
                        polygon = new GeoPolygon();
                    }
                    polygon.Points.Add(point);
                }
                polygon.Circle = circle;
                geometries.Polygons.Add(polygon);
                project.Geometries.Add(geometries);
            }


            return(project);
        }
Ejemplo n.º 3
0
 private GeoPolygonRegion GenerateFullMapPolygon()
 {
     double maxValue = double.MaxValue;
     double minValue = double.MinValue;
     double num3 = double.MaxValue;
     double num4 = double.MinValue;
     double num5 = 0.0;
     foreach (Transceiver transceiver in this.m_otherSubSysInterface.INet.TranceiverList)
     {
         num5 = 0.0;
         foreach (PropModelConfig config in transceiver.Cells[0].PropModels)
         {
             num5 = Math.Max(num5, (double) config.CalcRadius);
         }
         maxValue = Math.Min(maxValue, (transceiver.AntConfiguration[0].DX + transceiver.Parent.X) - num5);
         minValue = Math.Max(minValue, (transceiver.AntConfiguration[0].DX + transceiver.Parent.X) + num5);
         num4 = Math.Max(num4, (transceiver.AntConfiguration[0].DY + transceiver.Parent.Y) + num5);
         num3 = Math.Min(num3, (transceiver.AntConfiguration[0].DY + transceiver.Parent.Y) - num5);
     }
     GeoXYRect geoXYRect = new GeoXYRect(maxValue, minValue, num3, num4);
     GeoPolygon geoPolygon = new GeoPolygon(geoXYRect);
     GeoPolygonRegion region = new GeoPolygonRegion();
     region.AddGeoPolygon(geoPolygon);
     region.Name = GeneralResource.GENERAL_FULL_MAP;
     return region;
 }
Ejemplo n.º 4
0
        public void PolyfillTransmeridianComplex()
        {
            // This polygon is "complex" in that it has > 4 vertices - this
            // tests for a bug that was taking the max and min longitude as
            // the bounds for transmeridian polygons
            var verts = new[]
            {
                new GeoCoord(0.1m, -Constants.H3.M_PI + 0.00001m),
                new GeoCoord(0.1m, Constants.H3.M_PI - 0.00001m),
                new GeoCoord(0.05m, Constants.H3.M_PI - 0.2m),
                new GeoCoord(-0.1m, Constants.H3.M_PI - 0.00001m),
                new GeoCoord(-0.1m, -Constants.H3.M_PI + 0.00001m),
                new GeoCoord(-0.05m, -Constants.H3.M_PI + 0.2m),
            };

            var geofence = new GeoFence {
                NumVerts = 6, Verts = verts
            };
            var polygon = new GeoPolygon {
                GeoFence = geofence, NumHoles = 0
            };

            var hexagons          = polygon.Polyfill(4);
            int actualNumHexagons = Utility.CountActualHexagons(hexagons);

            Assert.AreEqual(1204, actualNumHexagons);
        }
Ejemplo n.º 5
0
        public void GeoPolygon_Serialize()
        {
            GeoPolygon poly;

            poly = new GeoPolygon(
                new GeoCoordinate[] {
                new GeoCoordinate(10, 20)
            });

            poly = (GeoPolygon)GeoRegion.Parse(poly.ToString());
            Assert.AreEqual(1, poly.Vertices.Count);
            Assert.IsTrue(new GeoCoordinate(10, 20) == poly.Vertices[0]);

            poly = new GeoPolygon(
                new GeoCoordinate[] {
                new GeoCoordinate(10, 20),
                new GeoCoordinate(0, 20),
                new GeoCoordinate(0, 0)
            });

            poly = (GeoPolygon)GeoRegion.Parse(poly.ToString());
            Assert.AreEqual(3, poly.Vertices.Count);
            Assert.IsTrue(new GeoCoordinate(10, 20) == poly.Vertices[0]);
            Assert.IsTrue(new GeoCoordinate(0, 20) == poly.Vertices[1]);
            Assert.IsTrue(new GeoCoordinate(0, 0) == poly.Vertices[2]);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// maxPolyfillSize returns the number of hexagons to allocate space for when
        /// performing a polyfill on the given GeoJSON-like data structure.
        ///
        /// The size is the maximum of either the number of points in the geofence or the
        /// number of hexagons in the bounding box of the geofence.
        /// </summary>
        /// <param name="geoPolygon">A GeoJSON-like data structure indicating the poly to fill</param>
        /// <param name="res">Hexagon resolution (0-15)</param>
        /// <returns>number of hexagons to allocate for</returns>
        /// <!--
        /// algos.c
        /// int H3_EXPORT(maxPolyfillSize)
        /// -->
        public static int MaxPolyFillSize(this GeoPolygon geoPolygon, int res)
        {
            // Get the bounding box for the GeoJSON-like struct
            var bbox        = geoPolygon.GeoFence.ToBBox();
            int numHexagons = bbox.HexEstimate(res);
            // This algorithm assumes that the number of vertices is usually less than
            // the number of hexagons, but when it's wrong, this will keep it from
            // failing
            int totalVerts = geoPolygon.GeoFence.NumVerts;

            for (var i = 0; i < geoPolygon.NumHoles; i++)
            {
                totalVerts += geoPolygon.Holes[i].NumVerts;
            }

            if (numHexagons < totalVerts)
            {
                numHexagons = totalVerts;
            }
            // When the polygon is very small, near an icosahedron edge and is an odd
            // resolution, the line tracing needs an extra buffer than the estimator
            // function provides (but beefing that up to cover causes most situations to
            // over allocate memory)
            numHexagons += Constants.Algos.PolyfillBuffer;
            return(numHexagons);
        }
Ejemplo n.º 7
0
        public void polyfillExact()
        {
            GeoCoord    somewhere = new GeoCoord(1, 2);
            H3Index     origin    = H3Index.geoToH3(ref somewhere, 9);
            GeoBoundary boundary  = new GeoBoundary();

            H3Index.h3ToGeoBoundary(origin, ref boundary);

            List <GeoCoord> verts = new GeoCoord [boundary.numVerts + 1].ToList();

            for (int i = 0; i < boundary.numVerts; i++)
            {
                verts[i] = boundary.verts[i];
            }
            verts[boundary.numVerts] = boundary.verts[0];

            Geofence someGeofence = new Geofence();

            someGeofence.numVerts = boundary.numVerts + 1;
            someGeofence.verts    = verts.ToArray();
            GeoPolygon someHexagon = new GeoPolygon();

            someHexagon.Geofence = someGeofence;
            someHexagon.numHoles = 0;

            int numHexagons = Algos.maxPolyfillSize(ref someHexagon, 9);
            var hexagons    = new ulong[numHexagons].Select(cell => new H3Index(cell)).ToList();

            Algos.polyfill(someHexagon, 9, hexagons);
            int actualNumHexagons = countActualHexagons(hexagons, numHexagons);

            Assert.True(actualNumHexagons == 1, "got expected polyfill size (1)");
        }
Ejemplo n.º 8
0
 public static List<GeoXYPoint> CoverageDistributePoint(GeoPolygon polygonPeak, double r)
 {
     List<GeoXYPoint> list = new List<GeoXYPoint>();
     GeoXYPoint centerPoint = new GeoXYPoint((polygonPeak.Right + polygonPeak.Left) / 2.0, (polygonPeak.Top + polygonPeak.Bottom) / 2.0);
     GeoXYPoint southwest = GetSouthWestPoint(polygonPeak.Left, polygonPeak.Right, polygonPeak.Top, polygonPeak.Bottom, centerPoint, r);
     GeoXYPoint northeast = GetNorthEastClutterPoint(polygonPeak.Left, polygonPeak.Right, polygonPeak.Top, polygonPeak.Bottom, centerPoint, r);
     list = InitialDistribute(southwest, northeast, r);
     int index = 0;
     while (index < list.Count)
     {
         if (!polygonPeak.IsPointInPolygon(list[index]))
         {
             list.RemoveAt(index);
             index--;
         }
         index++;
     }
     for (int i = 0; list.Count == 0; i++)
     {
         if (i >= polygonPeak.Points.Count)
         {
             return list;
         }
         list = InitialDistribute(polygonPeak.Points[i], northeast, r);
         for (index = 0; index < list.Count; index++)
         {
             if (!polygonPeak.IsPointInPolygon(list[index]))
             {
                 list.RemoveAt(index);
                 index--;
             }
         }
     }
     return list;
 }
        public void Polygons()
        {
            GeoLine line = new GeoLine(
                new[]
                {
                    new GeoPosition(0, 0),
                    new GeoPosition(0, 1),
                    new GeoPosition(1, 1),
                    new GeoPosition(0, 0),
                });
            Assert.AreEqual(
                "geo.intersects(Foo, geography'POLYGON((0 0,0 1,1 1,0 0))')",
                SearchFilter.Create($"geo.intersects(Foo, {line})"));

            GeoPolygon polygon = new GeoPolygon(new[] { line });
            Assert.AreEqual(
                "geo.intersects(Foo, geography'POLYGON((0 0,0 1,1 1,0 0))')",
                SearchFilter.Create($"geo.intersects(Foo, {polygon})"));

            Assert.Throws<ArgumentException>(() => SearchFilter.Create(
                $"{new GeoLine(new[] { new GeoPosition(0, 0) })}"));
            Assert.Throws<ArgumentException>(() => SearchFilter.Create(
                $"{new GeoLine(new[] { new GeoPosition(0, 0), new GeoPosition(0, 0), new GeoPosition(0, 0), new GeoPosition(1, 1) })}"));
            Assert.Throws<ArgumentException>(() => SearchFilter.Create(
                $"{new GeoPolygon(new[] { line, line })}"));
        }
Ejemplo n.º 10
0
        public void PolyfillExact()
        {
            var somewhere = new GeoCoord(1, 2);
            var origin    = somewhere.ToH3Index(9);
            var boundary  = origin.ToGeoBoundary();

            var verts = new List <GeoCoord>();

            verts.AddRange(boundary.Verts.Take(boundary.NumVerts));
            verts.Add(boundary.Verts[0]);

            var someGeofence = new GeoFence {
                NumVerts = boundary.NumVerts + 1, Verts = verts.ToArray()
            };

            var someHexagon = new GeoPolygon {
                GeoFence = someGeofence, NumHoles = 0
            };

            var hexagons = someHexagon.Polyfill(9);

            var actualNumHexagons = Utility.CountActualHexagons(hexagons);

            Assert.AreEqual(1, actualNumHexagons);
        }
Ejemplo n.º 11
0
        public void h3js_67()
        {
            decimal east  = (-56.25m).DegreesToRadians();
            decimal north = (-33.13755119234615m).DegreesToRadians();
            decimal south = (-34.30714385628804m).DegreesToRadians();
            decimal west  = (-57.65625m).DegreesToRadians();

            var testVerts = new[]
            {
                new GeoCoord(north, east),
                new GeoCoord(south, east),
                new GeoCoord(south, west),
                new GeoCoord(north, west),
            };

            var testGeoFence = new GeoFence {
                NumVerts = 4, Verts = testVerts
            };
            var testPolygon = new GeoPolygon {
                GeoFence = testGeoFence, NumHoles = 0
            };

            const int res               = 7;
            var       hexagons          = testPolygon.Polyfill(res);
            int       actualNumHexagons = Utility.CountActualHexagons(hexagons);

            Assert.AreEqual(4499, actualNumHexagons);
        }
Ejemplo n.º 12
0
        public void bboxesFromGeoPolygon()
        {
            List <GeoCoord> verts =
                new List <GeoCoord>
            {
                new GeoCoord(0.8, 0.3),
                new GeoCoord(0.7, 0.6),
                new GeoCoord(1.1, 0.7),
                new GeoCoord(1.0, 0.2)
            };
            Geofence geofence = new Geofence {
                numVerts = 4, verts = verts.ToArray()
            };
            GeoPolygon polygon = new GeoPolygon {
                Geofence = geofence, numHoles = 0
            };

            BBox expected = new BBox {
                north = 1.1, south = 0.7, east = 0.7, west = 0.2
            };

            List <BBox> result = new List <BBox>();

            result.Add(new BBox());
            Polygon.bboxesFromGeoPolygon(polygon, ref result);
            Assert.True(BBox.bboxEquals(result[0], expected), "Got expected bbox");
        }
Ejemplo n.º 13
0
        public GeoProject shpRead()
        {
            //IFeatureSet fs = FeatureSet.Open(shppath);
            string str = fs.ProjectionString;
            ProjectionInfo info = fs.Projection;
            project = new GeoProject();
            for (int i = 0; i < fs.Features.Count; i++) {
                Geometries geometries = new Geometries();
                IList<Coordinate> vertics = fs.Features[i].Coordinates;
                GeoPolygon polygon = new GeoPolygon();
                int circle = 1;
                foreach (Coordinate vertic in vertics) {
                    GeoPoint point = new GeoPoint();
                    point.X = vertic.X;
                    point.Y = vertic.Y;
                    if (polygon.Points.Contains(point)) {
                        polygon.Circle = circle;
                        geometries.Polygons.Add(polygon);
                        circle++;
                        polygon = new GeoPolygon();
                    }
                    polygon.Points.Add(point);
                }
                polygon.Circle = circle;
                geometries.Polygons.Add(polygon);
                project.Geometries.Add(geometries);
            }

            return project;
        }
Ejemplo n.º 14
0
        private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region)
        {
            Pen       pen        = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), mapPen.Width);
            Brush     brush      = GetBrush(mapBrush);
            GeoBounds bounds     = new GeoBounds(118.808451, 31.907395, 0.003907, 0.0035);
            ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints());

            GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts);

            if (screenPts.Length > 2)
            {
                {
                    int[] xpoints = new int[screenPts.Length];
                    int[] ypoints = new int[screenPts.Length];
                    for (int i = 0; i < screenPts.Length; i++)
                    {
                        xpoints[i] = (int)screenPts[i].X;
                        ypoints[i] = (int)screenPts[i].Y;
                    }

                    Point[] points = new Point[xpoints.Length];
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] = new Point(xpoints[i], ypoints[i]);
                    }
                    SharedGraphics2D.Graphics.DrawPolygon(pen, points);
                    SharedGraphics2D.Graphics.FillPolygon(brush, points);
                }
            }
        }
Ejemplo n.º 15
0
 [Test] public void CreatePolygonWithHoles()
 {
     #region Snippet:CreatePolygonWithHoles
     var polygon = new GeoPolygon(new[]
     {
         // Outer ring
         new GeoLinearRing(new[]
         {
             new GeoPosition(-122.108727, 47.649383),
             new GeoPosition(-122.081538, 47.640846),
             new GeoPosition(-122.078634, 47.576066),
             new GeoPosition(-122.112686, 47.578559),
             // Last position same as first
             new GeoPosition(-122.108727, 47.649383),
         }),
         // Inner ring
         new GeoLinearRing(new[]
         {
             new GeoPosition(-122.102370, 47.607370),
             new GeoPosition(-122.083488, 47.608007),
             new GeoPosition(-122.085419, 47.597879),
             new GeoPosition(-122.107005, 47.596895),
             // Last position same as first
             new GeoPosition(-122.102370, 47.607370),
         })
     });
     #endregion
 }
Ejemplo n.º 16
0
        //  https://github.com/uber/h3-js/issues/76#issuecomment-561204505
        public void entireWorld()
        {
            // TODO: Fails for a single worldwide polygon
            var worldVerts = new List <GeoCoord>
            {
                new GeoCoord(-Constants.H3.M_PI_2, -Constants.H3.M_PI),
                new GeoCoord(Constants.H3.M_PI_2, -Constants.H3.M_PI),
                new GeoCoord(Constants.H3.M_PI_2, 0),
                new GeoCoord(-Constants.H3.M_PI_2, 0),
            };

            var worldGeofence = new GeoFence {
                NumVerts = 4, Verts = worldVerts.ToArray()
            };
            var worldGeoPolygon = new GeoPolygon {
                GeoFence = worldGeofence, NumHoles = 0
            };

            var worldVerts2 = new List <GeoCoord>
            {
                new GeoCoord(-Constants.H3.M_PI_2, 0),
                new GeoCoord(Constants.H3.M_PI_2, 0),
                new GeoCoord(Constants.H3.M_PI_2, -Constants.H3.M_PI),
                new GeoCoord(-Constants.H3.M_PI_2, -Constants.H3.M_PI),
            };

            var worldGeofence2 = new GeoFence {
                NumVerts = 4, Verts = worldVerts2.ToArray()
            };
            var worldGeoPolygon2 = new GeoPolygon {
                GeoFence = worldGeofence2, NumHoles = 0
            };

            for (int res = 0; res < 3; res++)
            {
                var polyfillOut       = worldGeoPolygon.Polyfill(res);
                var actualNumHexagons = Utility.CountActualHexagons(polyfillOut);

                var polyfillOut2       = worldGeoPolygon2.Polyfill(res);
                var actualNumHexagons2 = Utility.CountActualHexagons(polyfillOut2);

                Assert.AreEqual(res.NumHexagons(), actualNumHexagons + actualNumHexagons2);


                // Sets should be disjoint
                foreach (var fill1 in polyfillOut)
                {
                    if (fill1 == 0)
                    {
                        continue;
                    }
                    bool found = polyfillOut2.Any(fill2 => fill1 == fill2);
                    Assert.IsFalse(found);
                }

                polyfillOut.Clear();
                polyfillOut2.Clear();
            }
        }
Ejemplo n.º 17
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * default constructor.
         */
        public MapRegion()
        {
            SetMapObjectType(REGION);
            PenStyle   = new MapPen();
            BrushStyle = new MapBrush();
            CenterPt   = new GeoLatLng();
            Region     = null;
        }
Ejemplo n.º 18
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param region     map object copy from.
         */
        public MapRegion(MapRegion region)
            : base(region)
        {
            SetMapObjectType(REGION);
            PenStyle   = new MapPen(region.PenStyle);
            BrushStyle = new MapBrush(region.BrushStyle);
            Region     = new GeoPolygon(region.Region);
            CenterPt   = new GeoLatLng(region.CenterPt);
        }
Ejemplo n.º 19
0
        public void GeoPolygon_Empty()
        {
            // Verify that a polygon created from an empty set of vertices is initalized to (0,0).

            var poly = new GeoPolygon(new GeoCoordinate[0]);

            Assert.IsTrue(poly.IsPoint);
            Assert.AreEqual(1, poly.Vertices.Count);
            Assert.AreEqual(GeoCoordinate.Origin, poly.Vertices[0]);
        }
Ejemplo n.º 20
0
        public void GeoPolygon_Point()
        {
            // Verifies that point polygons are allowed.

            var pt   = new GeoCoordinate(10, 20);
            var poly = new GeoPolygon(new GeoCoordinate[] { pt });

            Assert.IsTrue(poly.IsPoint);
            Assert.AreEqual(1, poly.Vertices.Count);
            Assert.AreEqual(pt, poly.Vertices[0]);
        }
Ejemplo n.º 21
0
        private void DrawPolygon(PaintEventArgs e, GeoPolygon aPolygon, Color aColor)
        {
            var aPolyline = aPolygon.polyline();

            for (int i = 0; i < aPolyline.nbLines(); i++)
            {
                var aLine = aPolyline.line(i);

                DrawLine(e, aLine, aColor);
            }
        }
Ejemplo n.º 22
0
        private static void fillIndex_assertions(H3Index h)
        {
            if (IsTransmeridianCell(h))
            {
                // TODO: these do not work correctly
                return;
            }

            int currentRes = h.Resolution;

            // TODO: Not testing more than one depth because the assertions fail.
            for (int nextRes = currentRes; nextRes <= currentRes + 1; nextRes++)
            {
                var boundary = h.ToGeoBoundary();

                var polygon = new GeoPolygon()
                {
                    GeoFence =
                        new GeoFence
                    {
                        NumVerts = boundary.NumVerts,
                        Verts    = boundary.Verts.ToArray()
                    },
                    NumHoles = 0,
                    Holes    = new List <GeoFence>()
                };

                var polyfillOut   = polygon.Polyfill(nextRes);
                int polyfillCount = Utility.CountActualHexagons(polyfillOut);

                var children          = h.ToChildren(nextRes);
                int h3ToChildrenCount = Utility.CountActualHexagons(children);

                polyfillOut = polyfillOut.Where(p => p != Constants.H3Index.H3_NULL).ToList();
                polyfillOut.Sort();

                children = children.Where(p => p != Constants.H3Index.H3_NULL).ToList();
                children.Sort();

                Assert.AreEqual(h3ToChildrenCount, polyfillCount, $"h: {h}\nnextRes: {nextRes}\ncurrentRes: {currentRes}");

                bool match = true;
                for (int i = 0; i < children.Count; i++)
                {
                    if (children[i] != polyfillOut[i])
                    {
                        match = false;
                    }
                }

                Assert.IsTrue(match);
            }
        }
Ejemplo n.º 23
0
 public ZoomInRegionOperator(IApplicationContext appContext, GeoEventManager eventMgr, GeoMapMgr geoMapMgr)
 {
     this.m_Helper = ServiceHelper.Lookup<IGeoSelectionHelper>(appContext);
     this.m_Cursor = new Cursor(Huawei.UNet.Common.GlobalResource.GlobalResource.ZoomIn.GetHicon());
     this.m_EventMgr = eventMgr;
     this.m_GeoMapMgr = geoMapMgr;
     this.InitDrawingStyle();
     this.m_StartPlanePoint = new GeoXYPoint();
     this.m_SelectionPolygon = new GeoPolygon();
     this.m_SelectionRegion = new GeoPolygonRegion();
     this.m_SelectionRegion.AddGeoPolygon(this.m_SelectionPolygon);
 }
Ejemplo n.º 24
0
        private GeoPolygon CreatePolygon()
        {
            GeoPoint center       = Map1.CurrentCenter;
            int      segmentCount = 5;
            double   radius       = Math.Min(Map1.CurrentBound.Width, Map1.CurrentBound.Height) * .4;

            GeoPolygon polygon = new GeoPolygon();

            polygon.OuterRing = CreateRing(center, radius, segmentCount);

            return(polygon);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Create a set of bounding boxes from a GeoPolygon
        /// </summary>
        /// <param name="polygon">Input GeoPolygon</param>
        /// <returns>
        /// Output bboxes, one for the outer loop and one for each hole
        /// </returns>
        /// <!--
        /// polygon.c
        /// void bboxesFromGeoPolygon
        /// -->
        public static List <BBox> ToBBoxes(this GeoPolygon polygon)
        {
            var results = new List <BBox> {
                polygon.GeoFence.ToBBox()
            };

            for (var i = 0; i < polygon.NumHoles; i++)
            {
                results.Add(polygon.Holes[i].ToBBox());
            }

            return(results);
        }
Ejemplo n.º 26
0
 public void CreatePolygon()
 {
     #region Snippet:CreatePolygon
     var polygon = new GeoPolygon(new[]
     {
         new GeoPosition(-122.108727, 47.649383),
         new GeoPosition(-122.081538, 47.640846),
         new GeoPosition(-122.078634, 47.576066),
         new GeoPosition(-122.112686, 47.578559),
         new GeoPosition(-122.108727, 47.649383),
     });
     #endregion
 }
Ejemplo n.º 27
0
        private IMapZoneModel CreateMapZone(int id, string zoneName, GeoPolygon polygon)
        {
            var holes = new List <List <Vector2> >();

            var bounds = GetWorldPoints2d(polygon.OuterBounds);

            foreach (var hole in polygon.Holes)
            {
                holes.Add(GetWorldPoints2d(hole));
            }

            return(new MapZoneModel(zoneName, id, bounds, holes));
        }
Ejemplo n.º 28
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param multiRegion     map object copy from.
         */
        public MapMultiRegion(MapMultiRegion multiRegion)
            : base(multiRegion)
        {
            SetMapObjectType(MULTIREGION);
            PenStyle   = new MapPen(multiRegion.PenStyle);
            BrushStyle = new MapBrush(multiRegion.BrushStyle);
            Regions    = new GeoPolygon[multiRegion.Regions.Length];
            for (int i = 0; i < Regions.Length; i++)
            {
                Regions[i] = new GeoPolygon(multiRegion.Regions[i]);
            }
            CenterPt = new GeoLatLng(multiRegion.CenterPt);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Encodes a polygon for use in OData filters.
        /// <seealso cref="EncodePolygon(GeoLine)"/>
        /// </summary>
        /// <param name="polygon">The <see cref="GeoPolygon"/> to encode.</param>
        /// <returns>The OData filter-encoded POLYGON string.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="polygon"/> or <see cref="GeoPolygon.Rings"/> is null.</exception>
        public static string EncodePolygon(GeoPolygon polygon)
        {
            Argument.AssertNotNull(polygon, nameof(polygon));
            Argument.AssertNotNull(polygon.Rings, $"{nameof(polygon)}.{nameof(polygon.Rings)}");

            if (polygon.Rings.Count != 1)
            {
                throw new ArgumentException(
                          $"A {nameof(GeoPolygon)} must have exactly one {nameof(GeoPolygon.Rings)} to form a searchable polygon.",
                          $"{nameof(polygon)}.{nameof(polygon.Rings)}");
            }

            return(EncodePolygon(polygon.Rings[0]));
        }
Ejemplo n.º 30
0
        public void bboxesFromGeoPolygonHole()
        {
            List <GeoCoord> verts =
                new List <GeoCoord>
            {
                new GeoCoord(0.8, 0.3),
                new GeoCoord(0.7, 0.6),
                new GeoCoord(1.1, 0.7),
                new GeoCoord(1.0, 0.2)
            };
            Geofence geofence = new Geofence {
                numVerts = 4, verts = verts.ToArray()
            };

            // not a real hole, but doesn't matter for the test
            List <GeoCoord> holeVerts =
                new List <GeoCoord>
            {
                new GeoCoord(0.9, 0.3),
                new GeoCoord(0.9, 0.5),
                new GeoCoord(1.0, 0.7),
                new GeoCoord(0.9, 0.3)
            };
            List <Geofence> holeGeofence =
                new List <Geofence>
            {
                new Geofence {
                    numVerts = 4, verts = holeVerts.ToArray()
                }
            };

            GeoPolygon polygon = new GeoPolygon {
                Geofence = geofence, numHoles = 1, holes = holeGeofence
            };

            BBox expected = new BBox {
                north = 1.1, south = 0.7, east = 0.7, west = 0.2
            };
            BBox expectedHole = new BBox {
                north = 1.0, south = 0.9, east = 0.7, west = 0.3
            };

            List <BBox> result = new List <BBox> {
                new BBox(), new BBox()
            };

            Polygon.bboxesFromGeoPolygon(polygon, ref result);
            Assert.True(BBox.bboxEquals(result[0], expected), "Got expected bbox");
            Assert.True(BBox.bboxEquals(result[1], expectedHole), "Got expected hole bbox");
        }
Ejemplo n.º 31
0
        /// <summary>
        /// polyfill takes a given GeoJSON-like data structure and preallocated,
        /// zeroed memory, and fills it with the hexagons that are contained by
        /// the GeoJSON-like data structure.
        ///
        /// This implementation traces the GeoJSON geofence(s) in cartesian space with
        /// hexagons, tests them and their neighbors to be contained by the geofence(s),
        /// and then any newly found hexagons are used to test again until no new
        /// hexagons are found.
        /// </summary>
        /// <param name="polygon">The geofence and holes defining the relevant area</param>
        /// <param name="res">The Hexagon resolution (0-15)</param>
        /// <returns>List of H3Index that compose the polyfill</returns>
        /// <!--
        /// algos.c
        /// void H3_EXPORT(polyfill)
        /// -->
        public static List <H3Index> Polyfill(this GeoPolygon polygon, int res)
        {
            // TODO: Eliminate this wrapper with the H3 4.0.0 release
            (int failure, var result) = polygon.PolyFillInternal(res);
            if (failure == 0)
            {
                return(result.Where(r => r != 0).ToList());
            }
            // The polyfill algorithm can theoretically fail if the allocated memory is
            // not large enough for the polygon, but this should be impossible given the
            // conservative overestimation of the number of hexagons possible.
            int numHexagons = polygon.MaxPolyFillSize(res);

            return(new H3Index[numHexagons].ToList());
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Encodes a polygon for use in OData filters.
        /// <seealso cref="EncodePolygon(GeoLinearRing)"/>
        /// </summary>
        /// <param name="polygon">The <see cref="GeoPolygon"/> to encode.</param>
        /// <returns>The OData filter-encoded POLYGON string.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="polygon"/> or <see cref="GeoPolygon.Rings"/> is null.</exception>
        public static string EncodePolygon(GeoPolygon polygon)
        {
            Argument.AssertNotNull(polygon, nameof(polygon));
            Argument.AssertNotNull(polygon.Rings, $"{nameof(polygon)}.{nameof(polygon.Rings)}");

            if (polygon.Rings.Count != 1)
            {
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
                throw new ArgumentException(
                          $"A {nameof(GeoPolygon)} must have exactly one {nameof(GeoPolygon.Rings)} to form a searchable polygon.",
                          $"{nameof(polygon)}.{nameof(polygon.Rings)}");
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
            }

            return(EncodePolygon(polygon.Rings[0]));
        }
Ejemplo n.º 33
0
        private GeoMultiPolygon CreateMultiPolygon()
        {
            GeoPoint center1      = new GeoPoint(Map1.CurrentBound.MinX + Map1.CurrentBound.Width * .25, Map1.CurrentCenter.Y);
            GeoPoint center2      = new GeoPoint(Map1.CurrentBound.MinX + Map1.CurrentBound.Width * .75, Map1.CurrentCenter.Y);
            double   radius       = Map1.CurrentBound.Width * .25;
            int      segmentCount = 5;

            GeoPolygon polygon1 = new GeoPolygon(CreateRing(center1, radius, segmentCount));
            GeoPolygon polygon2 = new GeoPolygon(CreateRing(center2, radius, segmentCount));

            GeoMultiPolygon multiPolygon = new GeoMultiPolygon();

            multiPolygon.Polygons.Add(polygon1);
            multiPolygon.Polygons.Add(polygon2);
            return(multiPolygon);
        }
Ejemplo n.º 34
0
        private static Polygon projectPolygon(GeoPolygon polygon, GnomonicProjection projection)
        {
            Polygon p = polygon.ToPlanarPolygon(false);

            foreach (Contour contour in p.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    double x, y;
                    projection.Project(contour.Vertices[i].Y, contour.Vertices[i].X, out x, out y);
                    contour.Vertices[i] = PlanimetryEnvironment.NewCoordinate(x, y);
                }
            }

            return(p);
        }
Ejemplo n.º 35
0
 private void CalcInsideSituation(int index)
 {
     int indexRef = 0;
     int num2 = 0;
     GeoPolygon item = new GeoPolygon();
     double slope = this.GetSlopeFromLinePair(index - 1, true, ref indexRef).PositiveLine.Slope;
     double d = this.GetSlopeFromLinePair(index, false, ref num2).PositiveLine.Slope;
     double num5 = Math.Tan((Math.Atan(slope) + Math.Atan(d)) / 2.0);
     if (this.IsSlopeNeedTransform(this.m_SourceLine.Points[indexRef + 1], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[num2 + 1]))
     {
         num5 = -1.0 / num5;
     }
     if (!(this.IsSlopeNeedTransform(this.m_SourceLine.Points[indexRef + 1], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[num2 + 1]) || (Math.Abs((double) (Math.Atan(slope) - Math.Atan(d))) >= 0.8)))
     {
         num5 = -1.0 / num5;
     }
     if (num5 == double.NegativeInfinity)
     {
         num5 = 1000.0;
     }
     GisLine line = this.GetPositionLine(this.m_SourceLine.Points[index], this.m_SourceLine.Points[index + 1], d, this.m_WidthOfStrip / 2.0);
     this.m_PositivePt = line.GetJointPt(this.GetSlopeFromLinePair(index, false, ref indexRef).PositiveLine);
     this.m_OppositePt = line.GetJointPt(this.GetSlopeFromLinePair(index, false, ref indexRef).OppositeLine);
     item.Points.Add(this.m_PositivePt);
     item.Points.Add(this.m_OppositePt);
     slope = this.GetSlopeFromLinePair(index, true, ref indexRef).PositiveLine.Slope;
     d = this.GetSlopeFromLinePair(index + 1, true, ref num2).PositiveLine.Slope;
     num5 = Math.Tan((Math.Atan(slope) + Math.Atan(d)) / 2.0);
     if (this.IsSlopeNeedTransform(this.m_SourceLine.Points[indexRef + 1], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[num2 + 1]))
     {
         num5 = -1.0 / num5;
     }
     if (!(this.IsSlopeNeedTransform(this.m_SourceLine.Points[indexRef + 1], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[num2 + 1]) || (Math.Abs((double) (Math.Atan(slope) - Math.Atan(d))) >= 0.8)))
     {
         num5 = -1.0 / num5;
     }
     if (num5 == double.NegativeInfinity)
     {
         num5 = 1000.0;
     }
     line = this.GetPositionLine(this.m_SourceLine.Points[index + 1], this.m_SourceLine.Points[index], slope, this.m_WidthOfStrip / 2.0);
     this.m_PositivePt = line.GetJointPt(this.GetSlopeFromLinePair(index, true, ref indexRef).PositiveLine);
     this.m_OppositePt = line.GetJointPt(this.GetSlopeFromLinePair(index, true, ref indexRef).OppositeLine);
     item.Points.Add(this.m_OppositePt);
     item.Points.Add(this.m_PositivePt);
     this.m_PolyList.Add(item);
 }
Ejemplo n.º 36
0
 private GeoPolygonRegion CreatRegion()
 {
     GeoPolygonRegion region=new GeoPolygonRegion();
     GeoPolygon polygon=new GeoPolygon();
     List<GeoXYPoint> point_list=new List<GeoXYPoint>();
     GeoXYPoint fpoint=new GeoXYPoint(1000,2500);
     point_list.Add(fpoint);
     GeoXYPoint spoint=new GeoXYPoint(3000,1000);
     point_list.Add(spoint);
     GeoXYPoint tpoint=new GeoXYPoint(3800,4000);
     point_list.Add(tpoint);
     GeoXYPoint lpoint=new GeoXYPoint(2200,4500);
     point_list.Add(lpoint);
     polygon.Points=point_list;
     region.AddGeoPolygon(polygon);
     return region;
 }
Ejemplo n.º 37
0
 private GeoPolygonRegion CreatRegion()
 {
     GeoPolygonRegion region = new GeoPolygonRegion();
     GeoPolygon polygon = new GeoPolygon();
     List<GeoXYPoint> point_list = new List<GeoXYPoint>();
     GeoXYPoint fpoint = new GeoXYPoint(0, 0);
     point_list.Add(fpoint);
     GeoXYPoint spoint = new GeoXYPoint(0, 50);
     point_list.Add(spoint);
     GeoXYPoint tpoint = new GeoXYPoint(50, 0);
     point_list.Add(tpoint);
     GeoXYPoint lpoint = new GeoXYPoint(50, 50);
     point_list.Add(lpoint);
     polygon.Points = point_list;
     region.AddGeoPolygon(polygon);
     return region;
 }
Ejemplo n.º 38
0
 public bool Remove(GeoPolygon geoPolygon)
 {
     return this.m_Region.Remove(geoPolygon);
 }
Ejemplo n.º 39
0
 public bool CalcPolyRegionResult()
 {
     GeoPolygon polygon;
     GeoPolygonRegion region;
     for (int i = 0; i < (this.m_SourceLine.Points.Count - 1); i++)
     {
         this.CalcPairParallel(this.m_SourceLine.Points[i], this.m_SourceLine.Points[i + 1]);
     }
     if (this.m_ValidPairParallel == 0)
     {
         GeoXYRect geoXYRect = new GeoXYRect(this.m_SourceLine.Points[0].X - (this.m_WidthOfStrip / 2.0), this.m_SourceLine.Points[0].X + (this.m_WidthOfStrip / 2.0), this.m_SourceLine.Points[0].Y - (this.m_WidthOfStrip / 2.0), this.m_SourceLine.Points[0].Y + (this.m_WidthOfStrip / 2.0));
         polygon = new GeoPolygon(geoXYRect);
         region = new GeoPolygonRegion(true, PolygonCreationType.Union);
         region.AddGeoPolygon(polygon);
         this.m_BaseData.AddPolygonRegion(region);
         this.m_BaseData.RaiseDataChangedEvent(this, null);
         return true;
     }
     if (this.m_ValidPairParallel == 1)
     {
         this.m_GisLinePairList.Clear();
         polygon = new GeoPolygon();
         GisLine line = this.CreateGisLine(this.m_SourceLine.Points[0], this.m_SourceLine.Points[1]);
         GisLine line2 = this.GetPositionLine(this.m_SourceLine.Points[0], this.m_SourceLine.Points[1], line.Slope, this.m_WidthOfStrip / 2.0);
         this.CalcPairParallel(this.m_SourceLine.Points[0], this.m_SourceLine.Points[1]);
         this.m_PositivePt = line2.GetJointPt(this.m_GisLinePairList[0].PositiveLine);
         this.m_OppositePt = line2.GetJointPt(this.m_GisLinePairList[0].OppositeLine);
         polygon.Points.Add(this.m_PositivePt);
         polygon.Points.Add(this.m_OppositePt);
         line2 = this.GetPositionLine(this.m_SourceLine.Points[1], this.m_SourceLine.Points[0], line.Slope, this.m_WidthOfStrip / 2.0);
         this.m_PositivePt = line2.GetJointPt(this.m_GisLinePairList[0].PositiveLine);
         this.m_OppositePt = line2.GetJointPt(this.m_GisLinePairList[0].OppositeLine);
         polygon.Points.Add(this.m_OppositePt);
         polygon.Points.Add(this.m_PositivePt);
         region = new GeoPolygonRegion(true, PolygonCreationType.Union);
         region.AddGeoPolygon(polygon);
         this.m_BaseData.AddPolygonRegion(region);
         this.m_BaseData.RaiseDataChangedEvent(this, null);
         return true;
     }
     this.CreateHeadPolygon();
     this.CreateInsidePolygonList();
     this.CreateTailPolygon();
     this.CreatePolyRegion(this.m_PolyList);
     return true;
 }
Ejemplo n.º 40
0
 private void ReadRectangle(string[] contents)
 {
     double x = double.Parse(contents[1]);
     double y = double.Parse(contents[2]);
     double num3 = double.Parse(contents[3]);
     double num4 = double.Parse(contents[4]);
     GeoPolygon geoPolygon = new GeoPolygon();
     geoPolygon.Points.Add(new GeoXYPoint(x, y));
     geoPolygon.Points.Add(new GeoXYPoint(num3, y));
     geoPolygon.Points.Add(new GeoXYPoint(num3, num4));
     geoPolygon.Points.Add(new GeoXYPoint(x, num4));
     GeoPolygonRegion region = new GeoPolygonRegion();
     region.AddGeoPolygon(geoPolygon);
     try
     {
         BrushStyle brushStyle = null;
         PenStyle penStyle = null;
         this.BuildStyle(ref penStyle, ref brushStyle);
         GeoPolygonStyle style = this.BuildPolygonStyle(brushStyle, penStyle);
         GeoDisplayPolygonRegion item = new GeoDisplayPolygonRegion(region, style);
         this.m_RegionList.Add(item);
     }
     catch
     {
     }
 }
Ejemplo n.º 41
0
 private void ReadPolygon(int numParts, int numPoints)
 {
     int[] numArray = new int[numParts];
     for (int i = 0; i < numParts; i++)
     {
         numArray[i] = this.ReadInteger(ByteOrder.LittleEndian);
     }
     int index = 1;
     GeoPolygon geoPolygon = new GeoPolygon();
     for (int j = 0; j < numPoints; j++)
     {
         double x = this.ReadDouble(ByteOrder.LittleEndian);
         double y = this.ReadDouble(ByteOrder.LittleEndian);
         GeoXYPoint point = new GeoXYPoint(x, y);
         if (index < numParts)
         {
             if (j < numArray[index])
             {
                 geoPolygon.Points.Add(point);
             }
             else
             {
                 GeoPolygonRegion region = new GeoPolygonRegion();
                 region.AddGeoPolygon(geoPolygon);
                 GeoDisplayPolygonRegion region2 = new GeoDisplayPolygonRegion(region, this.m_DefaultPolygonStyle);
                 index++;
             }
         }
         else
         {
             geoPolygon.Points.Add(point);
         }
     }
     GeoPolygonRegion region3 = new GeoPolygonRegion();
     region3.AddGeoPolygon(geoPolygon);
     GeoDisplayPolygonRegion item = new GeoDisplayPolygonRegion(region3, this.m_DefaultPolygonStyle);
     item.AddFeature("ID", this.CreateMapUnitId());
     this.m_RegionList.Add(item);
 }
Ejemplo n.º 42
0
            /// <summary>
            /// 读取地块
            /// </summary>
            /// <param name="line"></param>
            private void GeometriesRead(String line)
            {
                int count = Methods.getCharCout(line, ',');
                //判断是否为地块信息行
                if(count == 8) {
                    if(geometries.Polygons.Count != 0) {//地块信息是否为空
                        geometries.Polygons.Add(polygon);
                        project.Geometries.Add(geometries);//不为空则将该地块添加入批次中
                    }
                    //初始化地块
                    geometries = new Geometries();
                    //初始化多边形
                    polygon = new GeoPolygon();
                    String[] geo = line.Split(',');
                    geometries.Area = Double.Parse(geo[1]);//地块面积
                    geometries.Name = geo[3].ToString();//地块名称

                }
                //判断是否为坐标点行
                else if(count == 3) {
                    GeoPoint point = new GeoPoint();
                    String[] geo = line.Split(',');
                    point.X = Double.Parse(geo[3]);
                    point.Y = Double.Parse(geo[2]);
                    int circle = Int32.Parse(geo[1]);
                    if(polygon.Circle != circle) {//判断当前圈号是否一致
                        if(polygon.Points.Count != 0) {//多边形信息是否为空
                            geometries.Polygons.Add(polygon);//不为空则将该地块加入地块中
                        }
                        polygon = new GeoPolygon(); //不一致则初始化多边形
                        polygon.Circle = circle;    //多边形圈号赋值
                        polygon.Points.Add(point);
                    } else {
                        polygon.Points.Add(point);
                    }
                }
            }
Ejemplo n.º 43
0
 private void GetBlockCellInfoColl(int blockCount, GeoPolygonRegion region)
 {
     this.m_BlockCellInfoArr = new List<PredictionBlockCellInfoColl>();
     double maxValue = double.MaxValue;
     double minValue = double.MinValue;
     double bottom = double.MaxValue;
     double top = double.MinValue;
     ICellFilter cellFilter = this.m_Interfaces.CellFilterBuilder.GetCellFilter();
     GeoPolygonRegion regionRectangle = cellFilter.GetRegionRectangle(region, this.m_Group.Resolution);
     List<Transceiver> list = new List<Transceiver>();
     foreach (LTECellCalcInfo info in this.m_CalcLTECells)
     {
         list.Add(info.Tanceiver);
     }
     int num5 = (int)((regionRectangle.Top - regionRectangle.Bottom) / ((double)this.m_Group.Resolution));
     int num6 = num5 % blockCount;
     int num7 = num5 / blockCount;
     for (int i = 0; i < blockCount; i++)
     {
         maxValue = regionRectangle.Left;
         minValue = regionRectangle.Right;
         top = regionRectangle.Top - ((i * num7) * this.m_Group.Resolution);
         if (i == (blockCount - 1))
         {
             bottom = regionRectangle.Top - ((((i * num7) + num7) + num6) * this.m_Group.Resolution);
         }
         else
         {
             bottom = regionRectangle.Top - (((i * num7) + num7) * this.m_Group.Resolution);
         }
         GeoXYRect geoXYRect = new GeoXYRect(maxValue, minValue, bottom, top);
         GeoPolygon geoPolygon = new GeoPolygon(geoXYRect);
         GeoPolygonRegion region3 = new GeoPolygonRegion();
         region3.AddGeoPolygon(geoPolygon);
         PredictionBlockCellInfoColl item = new PredictionBlockCellInfoColl();
         item.BlockIndex = i;
         LTECalcCellsInfoCollection infos = new LTECalcCellsInfoCollection();
         infos = cellFilter.GetCalculateCellsInfo(list, region3, this.m_Group.Resolution);
         item.CalCellColl = infos;
         this.m_BlockCellInfoArr.Add(item);
     }
 }
Ejemplo n.º 44
0
        private static Polygon getBoundsBuffer(GeoPolygon polygon, GnomonicProjection projection, double distance, int pointsPerCircle, bool allowParallels)
        {
            Polygon temp = new Polygon();

            List<Polygon> partialBuffers = new List<Polygon>();
            GeographyCollection geographyCollection = new GeographyCollection();
            ICollection<IGeometry> unionResult = null;

            int c = 0;
            foreach (GeoContour contour in polygon.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    GeoPoint p = contour.Vertices[i];

                    GeoPolygon tempPolygon = getPointBuffer(p, Math.Abs(distance), pointsPerCircle);
                    geographyCollection.Clear();
                    geographyCollection.Add(tempPolygon);

                    GeometryCollection gc = GeometrySpreader.GetGeometries(geographyCollection, projection);
                    if(gc[0] is Polygon)
                        unionResult = temp.Union((Polygon)gc[0]);
                    if (unionResult.Count > 0)
                        temp = (Polygon)((GeometryCollection)unionResult)[0];

                    c++;
                    if (c == 3)
                    {
                        partialBuffers.Add(temp);
                        temp = new Polygon();
                        c = 0;
                    }
                }
            }

            if (temp.CoordinateCount > 0)
                partialBuffers.Add(temp);

            return mergePartialBuffers(partialBuffers, allowParallels);
        }
Ejemplo n.º 45
0
 public GeoPolygonRegion GetRegionRectangle(GeoPolygonRegion polygon, float resolution)
 {
     this.GetPolygonRectangle(polygon, resolution);
     GeoXYRect geoXYRect = new GeoXYRect(this.m_polygonLeftTop.X, this.m_polygonRightBottom.X, this.m_polygonRightBottom.Y, this.m_polygonLeftTop.Y);
     GeoPolygon geoPolygon = new GeoPolygon(geoXYRect);
     GeoPolygonRegion region = new GeoPolygonRegion();
     region.AddGeoPolygon(geoPolygon);
     return region;
 }
Ejemplo n.º 46
0
 private void CreateTailPolygon()
 {
     int indexRef = 0;
     int num2 = 0;
     GeoPolygon item = new GeoPolygon();
     int count = this.m_SourceLine.Points.Count;
     this.GetSlopeFromLinePair(count - 2, true, ref indexRef);
     double slope = this.CreateGisLine(this.m_SourceLine.Points[count - 1], this.m_SourceLine.Points[indexRef]).Slope;
     double num5 = (slope == 0.0) ? 1000.0 : (-1.0 / slope);
     GisLine line2 = this.GetPositionLine(this.m_SourceLine.Points[count - 1], this.m_SourceLine.Points[indexRef], slope, this.m_WidthOfStrip / 2.0);
     GeoXYPoint jointPt = line2.GetJointPt(this.GetSlopeFromLinePair(count - 2, true, ref indexRef).PositiveLine);
     GeoXYPoint point2 = line2.GetJointPt(this.GetSlopeFromLinePair(count - 2, true, ref indexRef).OppositeLine);
     item.Points.Add(jointPt);
     item.Points.Add(point2);
     double d = this.GetSlopeFromLinePair(count - 2, true, ref indexRef).PositiveLine.Slope;
     double num7 = this.GetSlopeFromLinePair(count - 3, true, ref num2).PositiveLine.Slope;
     double num8 = Math.Tan((Math.Atan(d) + Math.Atan(num7)) / 2.0);
     if (this.IsSlopeNeedTransform(this.m_SourceLine.Points[num2 + 1], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[indexRef + 1]))
     {
         num8 = -1.0 / num8;
     }
     if (!(this.IsSlopeNeedTransform(this.m_SourceLine.Points[num2 + 1], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[indexRef + 1]) || (Math.Abs((double) (Math.Atan(d) - Math.Atan(num7))) >= 0.8)))
     {
         num8 = -1.0 / num8;
     }
     if (num8 == double.NegativeInfinity)
     {
         num8 = 1000.0;
     }
     line2 = new GisLine(this.m_SourceLine.Points[indexRef], num8);
     this.m_PositivePt = line2.GetJointPt(this.GetSlopeFromLinePair(count - 2, true, ref indexRef).PositiveLine);
     this.m_OppositePt = line2.GetJointPt(this.GetSlopeFromLinePair(count - 2, true, ref indexRef).OppositeLine);
     item.Points.Add(this.m_OppositePt);
     item.Points.Add(this.m_PositivePt);
     this.m_PolyList.Add(item);
 }
Ejemplo n.º 47
0
 private GeoPolygon[] GetPolygons(List<int> PolygonOrders, List<int> PointOrders, int type, List<double> xPositions, List<double> yPositions)
 {
     int num;
     List<int> list = new List<int>();
     for (num = 0; num < PolygonOrders.Count; num++)
     {
         if (!list.Contains(PolygonOrders[num]))
         {
             list.Add(PolygonOrders[num]);
         }
     }
     GeoPolygon[] polygonArray = new GeoPolygon[list.Count];
     for (num = 0; num < list.Count; num++)
     {
         polygonArray[num] = new GeoPolygon();
     }
     Predicate<int> match = null;
     for (int i = 0; i < xPositions.Count; i++)
     {
         GeoXYPoint item = null;
         if (type == 1)
         {
             item = new GeoXYPoint(xPositions[i], yPositions[i]);
         }
         else if (type == 2)
         {
             item = this.m_Helper.LatToPlane(new GeoBLPoint(xPositions[i], yPositions[i]));
         }
         if (match == null)
         {
             match = delegate (int a) {
                 return a.Equals(PolygonOrders[i]);
             };
         }
         polygonArray[list.FindIndex(match)].Points.Add(item);
     }
     return polygonArray;
 }
Ejemplo n.º 48
0
 public bool AddGeoPolygon(GeoPolygon geoPolygon)
 {
     return this.m_Region.AddGeoPolygon(geoPolygon);
 }
Ejemplo n.º 49
0
 public bool AutoDistributeSiteMsg(GeoPolygon geoPolygon, out List<GeoSite> sites, out List<GeoCell> cells)
 {
     AutoDistributeSiteEventArgs args = new AutoDistributeSiteEventArgs(geoPolygon);
     return this.OnAutoDistributeSiteMsgChange(args, out sites, out cells);
 }
Ejemplo n.º 50
0
 private void ReadRegion(string[] contents)
 {
     int num = int.Parse(contents[1]);
     int num2 = 0;
     GeoPolygonRegion region = new GeoPolygonRegion();
     while (num2 < num)
     {
         GeoPolygon geoPolygon = new GeoPolygon();
         int num3 = int.Parse(this.ReadValidLine());
         int num4 = 0;
         string[] strArray = null;
         string[] separator = new string[] { " ", "\t" };
         while (num4 < num3)
         {
             num4++;
             strArray = this.ReadValidLine().Split(separator, StringSplitOptions.RemoveEmptyEntries);
             double x = double.Parse(strArray[0]);
             double y = double.Parse(strArray[1]);
             geoPolygon.Points.Add(new GeoXYPoint(x, y));
         }
         num2++;
         num2++;
         region.AddGeoPolygon(geoPolygon);
     }
     BrushStyle brushStyle = null;
     PenStyle penStyle = null;
     this.BuildStyle(ref penStyle, ref brushStyle);
     GeoPolygonStyle style = this.BuildPolygonStyle(brushStyle, penStyle);
     GeoDisplayPolygonRegion item = new GeoDisplayPolygonRegion(region, style);
     this.m_RegionList.Add(item);
 }
Ejemplo n.º 51
0
        private static Polygon projectPolygon(GeoPolygon polygon, GnomonicProjection projection)
        {
            Polygon p = polygon.ToPlanarPolygon(false);
            foreach (Contour contour in p.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    double x, y;
                    projection.Project(contour.Vertices[i].Y, contour.Vertices[i].X, out x, out y);
                    contour.Vertices[i] = PlanimetryEnvironment.NewCoordinate(x, y);
                }
            }

            return p;
        }
Ejemplo n.º 52
0
 private GeoPolygon[] GetPolygonsFromForm()
 {
     int num2;
     List<int> list = new List<int>();
     int num = 0;
     for (num2 = 0; num2 < this.m_PolygonDataTable.Rows.Count; num2++)
     {
         int id = (int) this.m_PolygonDataTable.Rows[num2][0];
         if (!list.Exists(delegate (int a) {
             return a.Equals(id);
         }))
         {
             list.Add(id);
             num++;
         }
     }
     GeoPolygon[] polygonArray = new GeoPolygon[num];
     for (num2 = 0; num2 < num; num2++)
     {
         polygonArray[num2] = new GeoPolygon();
     }
     Predicate<int> match = null;
     for (int i = 0; i < this.m_PolygonDataTable.Rows.Count; i++)
     {
         GeoXYPoint point;
         if ((this.m_PolygonDataTable.Rows[i][2] != DBNull.Value) && (this.m_PolygonDataTable.Rows[i][3] != DBNull.Value))
         {
             point = new GeoXYPoint((double) this.m_PolygonDataTable.Rows[i][2], (double) this.m_PolygonDataTable.Rows[i][3]);
         }
         else
         {
             point = this.m_Helper.LatToPlane(new GeoBLPoint((double) this.m_PolygonDataTable.Rows[i][4], (double) this.m_PolygonDataTable.Rows[i][5]));
         }
         if (match == null)
         {
             match = delegate (int a) {
                 return a.Equals((int) this.m_PolygonDataTable.Rows[i][0]);
             };
         }
         polygonArray[list.FindIndex(match)].Points.Add(point);
     }
     return polygonArray;
 }
Ejemplo n.º 53
0
 private void CreateHeadPolygon()
 {
     int indexRef = 0;
     int num2 = 0;
     GeoPolygon item = new GeoPolygon();
     GisLine line = this.CreateGisLine(this.m_SourceLine.Points[0], this.m_SourceLine.Points[1]);
     GisLine line2 = this.GetPositionLine(this.m_SourceLine.Points[0], this.m_SourceLine.Points[1], line.Slope, this.m_WidthOfStrip / 2.0);
     GeoXYPoint jointPt = line2.GetJointPt(this.GetSlopeFromLinePair(0, false, ref indexRef).PositiveLine);
     GeoXYPoint point2 = line2.GetJointPt(this.GetSlopeFromLinePair(0, false, ref indexRef).OppositeLine);
     item.Points.Add(jointPt);
     item.Points.Add(point2);
     double slope = this.GetSlopeFromLinePair(0, false, ref indexRef).PositiveLine.Slope;
     double d = this.GetSlopeFromLinePair(1, false, ref num2).PositiveLine.Slope;
     double num5 = Math.Tan((Math.Atan(slope) + Math.Atan(d)) / 2.0);
     if (this.IsSlopeNeedTransform(this.m_SourceLine.Points[indexRef + 1], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[num2 + 1]))
     {
         num5 = -1.0 / num5;
     }
     if (!(this.IsSlopeNeedTransform(this.m_SourceLine.Points[indexRef + 1], this.m_SourceLine.Points[indexRef], this.m_SourceLine.Points[num2], this.m_SourceLine.Points[num2 + 1]) || (Math.Abs((double) (Math.Atan(slope) - Math.Atan(d))) >= 0.8)))
     {
         num5 = -1.0 / num5;
     }
     if (num5 == double.NegativeInfinity)
     {
         num5 = 1000.0;
     }
     line2 = this.GetPositionLine(this.m_SourceLine.Points[1], this.m_SourceLine.Points[0], slope, this.m_WidthOfStrip / 2.0);
     this.m_PositivePt = line2.GetJointPt(this.GetSlopeFromLinePair(0, false, ref indexRef).PositiveLine);
     this.m_OppositePt = line2.GetJointPt(this.GetSlopeFromLinePair(0, false, ref indexRef).OppositeLine);
     item.Points.Add(this.m_OppositePt);
     item.Points.Add(this.m_PositivePt);
     this.m_PolyList.Add(item);
 }
Ejemplo n.º 54
0
 private void GetBlockCellInfoColl(int blockCount, GeoPolygonRegion region)
 {
     BlockLTETransceiverColl coll;
     this.m_BlockTransceiverExCollArr = new List<BlockLTETransceiverColl>();
     if (blockCount > 1)
     {
         double maxValue = double.MaxValue;
         double minValue = double.MinValue;
         double bottom = double.MaxValue;
         double top = double.MinValue;
         GeoPolygonRegion regionRectangle = this.m_ICellFilterBuilder.GetCellFilter().GetRegionRectangle(region, this.m_Group.Resolution);
         List<Transceiver> allTran = new List<Transceiver>();
         foreach (LTETransceiverEX rex in this.m_CalTansceiverExColl.LTETransceiverEXList)
         {
             //modify 20110228
             if (rex.LteCellExList.Count > 0)
             {
                 allTran.Add(rex.Transceiver);
             }
         }
         int numOfPoint = (int)((regionRectangle.Top - regionRectangle.Bottom) / ((double)this.m_Group.Resolution));
         int numOfblockPoint = numOfPoint % blockCount;
         int leftNumOfblockPoint = numOfPoint / blockCount;
         for (int i = 0; i < blockCount; i++)
         {
             maxValue = regionRectangle.Left;
             minValue = regionRectangle.Right;
             top = regionRectangle.Top - ((i * leftNumOfblockPoint) * this.m_Group.Resolution);
             if (i == (blockCount - 1))
             {
                 bottom = regionRectangle.Top - ((((i * leftNumOfblockPoint) + leftNumOfblockPoint) + numOfblockPoint) * this.m_Group.Resolution);
             }
             else
             {
                 bottom = regionRectangle.Top - (((i * leftNumOfblockPoint) + leftNumOfblockPoint) * this.m_Group.Resolution);
             }
             GeoXYRect geoXYRect = new GeoXYRect(maxValue, minValue, bottom, top);
             GeoPolygon geoPolygon = new GeoPolygon(geoXYRect);
             GeoPolygonRegion polygon = new GeoPolygonRegion(PolygonCreationType.Other);
             polygon.AddGeoPolygon(geoPolygon);
             coll = new BlockLTETransceiverColl();
             coll.BlockIndex = i;
             coll.TransceiverExColl = this.m_LteCellFilter.GetCalculateTransceiverInfo(ref allTran, polygon, this.m_Group.Resolution);
             this.FilterTranByFrequencyBand(coll.TransceiverExColl);
             this.InitialCalCarriers(coll.TransceiverExColl);
             this.m_BlockTransceiverExCollArr.Add(coll);
         }
     }
     else
     {
         coll = new BlockLTETransceiverColl();
         coll.BlockIndex = 0;
         coll.TransceiverExColl = this.m_CalTansceiverExColl;
         this.m_BlockTransceiverExCollArr.Add(coll);
     }
 }
Ejemplo n.º 55
0
        private static GeoPolygon getPolygonBuffer(GeoPolygon geoPolygon, double angleDistance, int pointsPerCircle, bool allowParallels)
        {
            geoPolygon = (GeoPolygon)geoPolygon.Clone();
            double minAngle = Math.Sin(Math.Abs(angleDistance)) * Math.Sin(Math.PI / pointsPerCircle);
            geoPolygon.ReduceSegments(minAngle);
            geoPolygon.Densify(minAngle);

            GnomonicProjection projection;
            IGeometry geometry;
            projectGeography(geoPolygon, out projection, out geometry);
            Polygon planePolygon = (Polygon)geometry;

            Polygon boundaryBuffer = getBoundsBuffer(geoPolygon, projection, angleDistance, pointsPerCircle, allowParallels);

            ICollection<IGeometry> result;
            if (angleDistance > 0)
                result = planePolygon.Union(boundaryBuffer);
            else
                result = planePolygon.Difference(boundaryBuffer);

            GeographyCollection geographyCollection = GeometrySpreader.GetGeographies(result, projection);

            foreach (IGeography g in geographyCollection)
                if (g is GeoPolygon)
                    return (GeoPolygon)g;

            return new GeoPolygon();
        }
Ejemplo n.º 56
0
 private GeoPolygonRegion CreateRegion(GisLine line)
 {
     GeoPolygonRegion region = new GeoPolygonRegion(true, PolygonCreationType.Union);
     GeoPolygon geoPolygon = new GeoPolygon();
     double num = Math.Atan(line.Slope);
     double num2 = ((1.5707963267948966 + num) * 3.1415926535897931) / 180.0;
     for (int i = 0; i < 8; i++)
     {
         double a = num2 + (i * 0.39269908169872414);
         double num5 = (Math.Sin(a) * this.m_WidthOfStrip) / 2.0;
         double num6 = (Math.Cos(a) * this.m_WidthOfStrip) / 2.0;
         double x = line.StandardPt.X - num5;
         double y = line.StandardPt.Y - num6;
         geoPolygon.Points.Add(new GeoXYPoint(x, y));
     }
     region.AddGeoPolygon(geoPolygon);
     return region;
 }
Ejemplo n.º 57
0
 public void ResetStatus()
 {
     this.m_StartPlanePoint = new GeoXYPoint();
     this.m_OuterBoundPolygon = new GeoPolygon();
     this.m_OuterBoundPolygon.IsHollow = false;
     this.m_CapturePolygon = new GeoPolygon();
     this.m_CapturePolygon.IsHollow = true;
     this.m_CaptureRegion = new GeoPolygonRegion();
     this.m_CaptureRegion.AddGeoPolygon(this.m_OuterBoundPolygon);
     this.m_CaptureRegion.AddGeoPolygon(this.m_CapturePolygon);
     if (this.m_GlassPanel != null)
     {
         this.m_GlassPanel.RemoveVectors(this.m_VectorIdCollection);
         this.m_VectorIdCollection.Clear();
         this.m_GlassPanel.AddPolygonRegion(this.m_CaptureRegion, this.m_RectangleStyle);
         this.m_VectorIdCollection.Add(this.m_CaptureRegion.ID);
     }
     this.m_EventMgr.SendSelectedAreaMsg(null);
 }
Ejemplo n.º 58
0
        private static GeoPolygon unprojectPolygon(Polygon polygon, GnomonicProjection projection)
        {
            GeoPolygon geoPolygon = new GeoPolygon();
            foreach (Contour contour in polygon.Contours)
            {
                GeoContour geoContour = new GeoContour();
                geoContour.Layout = contour.Layout;
                foreach (ICoordinate p in contour.Vertices)
                    geoContour.Vertices.Add(unprojectPoint(new PointD(p), projection));

                geoPolygon.Contours.Add(geoContour);
            }

            return geoPolygon;
        }