Exemplo n.º 1
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            var          build = new GeomBuild();
            MgLinearRing geom1 = build.CreateLinearRing(1.0);
            MgLinearRing geom2 = build.CreateLinearRing(5.0);
            MgLinearRing geom3 = build.CreateLinearRing(1.0);

            MgLinearRingCollection coll = new MgLinearRingCollection();

            coll.Add(geom1);
            coll.Add(geom2);
            coll.Add(geom3);

            Assert.AreEqual(3, coll.Count);
            Assert.IsTrue(geom1.Envelope().Contains(coll[0].Envelope()));
            Assert.IsTrue(coll[0].Envelope().Contains(coll[2].Envelope()));
            Assert.IsFalse(coll[0].Envelope().Contains(coll[1].Envelope()));
            coll[0] = coll[1];
            Assert.IsTrue(coll[0].Envelope().Contains(coll[1].Envelope()));

            double width = 0.0;

            foreach (MgLinearRing geom in coll)
            {
                width += geom.Envelope().GetWidth();
            }
            Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
        }
Exemplo n.º 2
0
        public MgPolygon CreatePolygon(double offset)
        {
            // OuterRing
            MgCoordinate oCoord1 = factory.CreateCoordinateXY(offset + 0.0, 0.0);
            MgCoordinate oCoord2 = factory.CreateCoordinateXY(offset + 5.0, 0.0);
            MgCoordinate oCoord3 = factory.CreateCoordinateXY(offset + 5.0, 5.0);
            MgCoordinate oCoord4 = factory.CreateCoordinateXY(offset + 0.0, 5.0);
            MgCoordinate oCoord5 = factory.CreateCoordinateXY(offset + 0.0, 0.0);

            MgCoordinateCollection outerRingCoord = new MgCoordinateCollection();

            outerRingCoord.Add(oCoord1);
            outerRingCoord.Add(oCoord2);
            outerRingCoord.Add(oCoord3);
            outerRingCoord.Add(oCoord4);
            outerRingCoord.Add(oCoord5);

            // Inner Ring1
            MgCoordinate i1Coord1 = factory.CreateCoordinateXY(offset + 1.0, 1.0);
            MgCoordinate i1Coord2 = factory.CreateCoordinateXY(offset + 2.0, 1.0);
            MgCoordinate i1Coord3 = factory.CreateCoordinateXY(offset + 2.0, 2.0);
            MgCoordinate i1Coord4 = factory.CreateCoordinateXY(offset + 1.0, 1.0);

            MgCoordinateCollection inner1RingCoord = new MgCoordinateCollection();

            inner1RingCoord.Add(i1Coord1);
            inner1RingCoord.Add(i1Coord2);
            inner1RingCoord.Add(i1Coord3);
            inner1RingCoord.Add(i1Coord4);

            // Inner Ring2
            MgCoordinate i2Coord1 = factory.CreateCoordinateXY(offset + 3.0, 3.0);
            MgCoordinate i2Coord2 = factory.CreateCoordinateXY(offset + 4.0, 3.0);
            MgCoordinate i2Coord3 = factory.CreateCoordinateXY(offset + 4.0, 4.0);
            MgCoordinate i2Coord4 = factory.CreateCoordinateXY(offset + 3.0, 3.0);

            MgCoordinateCollection inner2RingCoord = new MgCoordinateCollection();

            inner2RingCoord.Add(i2Coord1);
            inner2RingCoord.Add(i2Coord2);
            inner2RingCoord.Add(i2Coord3);
            inner2RingCoord.Add(i2Coord4);

            MgLinearRing extRing  = factory.CreateLinearRing(outerRingCoord);
            MgLinearRing intRing1 = factory.CreateLinearRing(inner1RingCoord);
            MgLinearRing intRing2 = factory.CreateLinearRing(inner2RingCoord);

            MgLinearRingCollection intRings = new MgLinearRingCollection();

            intRings.Add(intRing1);
            intRings.Add(intRing2);

            return(factory.CreatePolygon(extRing, intRings));
        }
Exemplo n.º 3
0
 private void btnSelectPolygon_Click(object sender, EventArgs e)
 {
     mgMapViewer1.DigitizePolygon((coordinates) =>
     {
         MgCoordinateCollection coords = new MgCoordinateCollection();
         for (int i = 0; i < coordinates.GetLength(0); i++)
         {
             coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], coordinates[i, 1]));
         }
         coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], coordinates[0, 1]));
         MgLinearRing ring = _geomFact.CreateLinearRing(coords);
         MgGeometry poly   = _geomFact.CreatePolygon(ring, null);
         mgMapViewer1.SelectByGeometry(poly);
     });
 }
Exemplo n.º 4
0
        private void OnPolygonDigitized(double[,] coordinates)
        {
            CheckRedlineLayer();
            MgCoordinateCollection coords = new MgCoordinateCollection();

            for (int i = 0; i < coordinates.GetLength(0); i++)
            {
                coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], coordinates[i, 1]));
            }
            coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], coordinates[0, 1]));
            MgLinearRing ring = _geomFact.CreateLinearRing(coords);
            MgGeometry   poly = _geomFact.CreatePolygon(ring, null);

            InsertRedlineGeometry(poly);
        }
Exemplo n.º 5
0
 private void btnPolygon_Click(object sender, EventArgs e)
 {
     _viewer.DigitizePolygon((coordinates) =>
     {
         ClearFilterGeometry();
         MgCoordinateCollection coords = new MgCoordinateCollection();
         for (int i = 0; i < coordinates.GetLength(0); i++)
         {
             coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], coordinates[i, 1]));
         }
         coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], coordinates[0, 1]));
         MgLinearRing ring = _geomFact.CreateLinearRing(coords);
         _filterGeometry   = _geomFact.CreatePolygon(ring, null);
         lblSpatialFilterGeomSet.Visible = true;
     });
 }
Exemplo n.º 6
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            MgGeometryFactory      gf          = new MgGeometryFactory();
            MgCoordinate           pt1         = gf.CreateCoordinateXY(0, 0);
            MgCoordinate           pt2         = gf.CreateCoordinateXY(0, 10);
            MgCoordinate           pt3         = gf.CreateCoordinateXY(10, 10);
            MgCoordinate           pt4         = gf.CreateCoordinateXY(10, 0);
            MgCoordinateCollection coordinates = new MgCoordinateCollection();

            coordinates.Add(pt1);
            coordinates.Add(pt2);
            coordinates.Add(pt3);
            coordinates.Add(pt4);
            MgLinearRing linearRing = gf.CreateLinearRing(coordinates);

            Assert.AreEqual(MgGeometryComponentType.LinearRing, linearRing.ComponentType);
            Assert.AreEqual(2, linearRing.Dimension);
        }
Exemplo n.º 7
0
        void OnSelectPolygon(object sender, EventArgs e)
        {
            if (_viewer == null)
            {
                return;
            }

            _viewer.DigitizePolygon((coordinates) => {
                MgCoordinateCollection coords = new MgCoordinateCollection();
                for (int i = 0; i < coordinates.GetLength(0); i++)
                {
                    coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], coordinates[i, 1]));
                }
                coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], coordinates[0, 1]));
                MgLinearRing ring = _geomFact.CreateLinearRing(coords);
                MgGeometry poly   = _geomFact.CreatePolygon(ring, null);
                _viewer.SelectByGeometry(poly);
            });
        }
Exemplo n.º 8
0
    private void EmitLinearRing(MgLinearRing linearRing, double ht)
    {
        if (linearRing != null)
        {
            outString.Append("<LinearRing>");
            outString.Append("<coordinates>");

            MgCoordinateIterator coordIter = linearRing.GetCoordinates();
            while (coordIter.MoveNext())
            {
                MgCoordinate coord = coordIter.GetCurrent();
                if (coord != null)
                {
                    outString.Append(coord.GetX() + ", " + coord.GetY() + ", " + ht + " ");
                }
            }
            outString.Append("</coordinates>");
            outString.Append("</LinearRing>");
        }
    }
Exemplo n.º 9
0
 private void AddPolygon(RedlineTextFunction retrieveTextMethod, RedlineAction onRedlineAdded)
 {
     _viewer.DigitizePolygon((coordinates) =>
     {
         string text = string.Empty;
         if (retrieveTextMethod != null)
         {
             text = retrieveTextMethod();
         }
         MgCoordinateCollection coords = new MgCoordinateCollection();
         for (int i = 0; i < coordinates.GetLength(0); i++)
         {
             coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], coordinates[i, 1]));
         }
         coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], coordinates[0, 1]));
         MgLinearRing ring = _geomFact.CreateLinearRing(coords);
         MgGeometry poly   = _geomFact.CreatePolygon(ring, null);
         InsertRedlineGeometry(text, poly, onRedlineAdded);
     });
 }
Exemplo n.º 10
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            MgGeometryFactory      gf          = new MgGeometryFactory();
            MgCoordinate           pt1         = gf.CreateCoordinateXY(0, 0);
            MgCoordinate           pt2         = gf.CreateCoordinateXY(0, 10);
            MgCoordinate           pt3         = gf.CreateCoordinateXY(10, 10);
            MgCoordinate           pt4         = gf.CreateCoordinateXY(10, 0);
            MgCoordinateCollection coordinates = new MgCoordinateCollection();

            coordinates.Add(pt1);
            coordinates.Add(pt2);
            coordinates.Add(pt3);
            coordinates.Add(pt4);
            MgLinearRing linearRing = gf.CreateLinearRing(coordinates);
            MgPolygon    polygon    = gf.CreatePolygon(linearRing, null);

            Assert.AreEqual(linearRing.ToString(), polygon.ExteriorRing.ToString());
            Assert.AreEqual(0, polygon.InteriorRingCount);
            Assert.AreEqual(MgGeometryType.Polygon, polygon.GeometryType);
            Assert.AreEqual(2, polygon.Dimension);
        }
Exemplo n.º 11
0
        public override void Invoke()
        {
            var viewer = this.Viewer;

            viewer.DigitizePolygon((coordinates) =>
            {
                if (_geomFact == null)
                {
                    _geomFact = new MgGeometryFactory();
                }

                MgCoordinateCollection coords = new MgCoordinateCollection();
                for (int i = 0; i < coordinates.GetLength(0); i++)
                {
                    coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], coordinates[i, 1]));
                }
                coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], coordinates[0, 1]));
                MgLinearRing ring = _geomFact.CreateLinearRing(coords);
                MgGeometry poly   = _geomFact.CreatePolygon(ring, null);
                viewer.SelectByGeometry(poly);
            });
        }