Exemplo n.º 1
0
        public void PolygonEnvelopeArea()
        {
            var coords      = new Coordinate[20];
            var rnd         = new Random();
            var center      = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var coordscheck = new GeoAPI.Geometries.Coordinate[20];

            for (var i = 0; i < 19; i++)
            {
                coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10);
                var x = coords[i].X;
                var y = coords[i].Y;
                var c = new GeoAPI.Geometries.Coordinate(x, y);
                coordscheck[i] = c;
            }
            coordscheck[19] = new GeoAPI.Geometries.Coordinate(coords[0].X, coords[0].Y);
            coords[19]      = new Coordinate(coords[0].X, coords[0].Y);
            var gf = new NetTopologySuite.Geometries.GeometryFactory();

            GeoAPI.Geometries.ILinearRing ring    = gf.CreateLinearRing(coordscheck);
            GeoAPI.Geometries.IPolygon    pgcheck = gf.CreatePolygon(ring, null);
            var pg   = new Polygon(coords);
            var area = pg.Envelope.Area();

            AssertExt.AreEqual15(area, pgcheck.Envelope.Area);
        }
Exemplo n.º 2
0
        public void PolygonShellEndPoint()
        {
            Coordinate[] coords = new Coordinate[20];
            Random       rnd    = new Random();
            Coordinate   center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);

            GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[20];
            for (int i = 0; i < 19; i++)
            {
                coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10);
                double x = coords[i].X;
                double y = coords[i].Y;
                GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
                coordscheck[i] = c;
            }
            coordscheck[19] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coords[0].X, coords[0].Y);
            coords[19]      = new Coordinate(coords[0].X, coords[0].Y);
            GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
            GeoAPI.Geometries.ILinearRing ring         = gf.CreateLinearRing(coordscheck);
            GeoAPI.Geometries.IPolygon    polygonCheck = gf.CreatePolygon(ring, null);
            Polygon pg = new Polygon(coords);

            AssertExt.AreEqual15(pg.Shell.EndPoint.X, polygonCheck.Shell.EndPoint.X);
            AssertExt.AreEqual15(pg.Shell.EndPoint.Y, polygonCheck.Shell.EndPoint.Y);
        }
Exemplo n.º 3
0
        public void PolygonCentroid()
        {
            var coords      = new Coordinate[20];
            var rnd         = new Random();
            var center      = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var coordscheck = new GeoAPI.Geometries.Coordinate[20];

            for (var i = 0; i < 19; i++)
            {
                coords[i] = new Coordinate(center.X + Math.Cos((i * 10) * Math.PI / 10), center.Y + (i * 10) * Math.PI / 10);
                var x = coords[i].X;
                var y = coords[i].Y;
                var c = new GeoAPI.Geometries.Coordinate(x, y);
                coordscheck[i] = c;
            }
            coordscheck[19] = new GeoAPI.Geometries.Coordinate(coords[0].X, coords[0].Y);
            coords[19]      = new Coordinate(coords[0].X, coords[0].Y);
            var gf           = new NetTopologySuite.Geometries.GeometryFactory();
            var ring         = gf.CreateLinearRing(coordscheck);
            var polygonCheck = gf.CreatePolygon(ring, null);
            var pg           = new Polygon(coords);
            var x1           = pg.Centroid.X;
            var x2           = polygonCheck.Centroid.X;

            AssertExt.AreEqual15(x1, x2);
            var y1 = pg.Centroid.Y;
            var y2 = polygonCheck.Centroid.Y;

            AssertExt.AreEqual15(y1, y2);
        }
Exemplo n.º 4
0
 public void HeightWidth()
 {
     Random rnd = new Random();
     double x1 = ((rnd.NextDouble() * 360) - 180);
     double x2 = ((rnd.NextDouble() * 360) - 180);
     double y1 = ((rnd.NextDouble() * 360) - 180);
     double y2 = ((rnd.NextDouble() * 360) - 180);
     Envelope ev = new Envelope(x1, x2, y1, y2);
     GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(x1, x2, y1, y2);
     AssertExt.AreEqual15(ev.Height, evcheck.Height);
     AssertExt.AreEqual15(ev.Width, evcheck.Width);
 }
Exemplo n.º 5
0
        public void HeightWidth()
        {
            var rnd     = new Random();
            var x1      = ((rnd.NextDouble() * 360) - 180);
            var x2      = ((rnd.NextDouble() * 360) - 180);
            var y1      = ((rnd.NextDouble() * 360) - 180);
            var y2      = ((rnd.NextDouble() * 360) - 180);
            var ev      = new Envelope(x1, x2, y1, y2);
            var evcheck = new GeoAPI.Geometries.Envelope(x1, x2, y1, y2);

            AssertExt.AreEqual15(ev.Height, evcheck.Height);
            AssertExt.AreEqual15(ev.Width, evcheck.Width);
        }
Exemplo n.º 6
0
 public void EnvelopeCoordinate()
 {
     Random rnd = new Random();
     Coordinate c = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
     Envelope ev = new Envelope(c);
     double x = c.X;
     double y = c.Y;
     GisSharpBlog.NetTopologySuite.Geometries.Coordinate ccheck = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
     GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(ccheck);
     AssertExt.AreEqual15(ev.Maximum.Y, evcheck.MaxY);
     AssertExt.AreEqual15(ev.Maximum.X, evcheck.MaxX);
     AssertExt.AreEqual15(ev.Minimum.Y, evcheck.MinY);
     AssertExt.AreEqual15(ev.Minimum.X, evcheck.MinX);
 }
Exemplo n.º 7
0
        public void EnvelopeCoordinate()
        {
            var rnd     = new Random();
            var c       = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var ev      = new Envelope(c);
            var x       = c.X;
            var y       = c.Y;
            var ccheck  = new GeoAPI.Geometries.Coordinate(x, y);
            var evcheck = new GeoAPI.Geometries.Envelope(ccheck);

            AssertExt.AreEqual15(ev.Maximum.Y, evcheck.MaxY);
            AssertExt.AreEqual15(ev.Maximum.X, evcheck.MaxX);
            AssertExt.AreEqual15(ev.Minimum.Y, evcheck.MinY);
            AssertExt.AreEqual15(ev.Minimum.X, evcheck.MinX);
        }
Exemplo n.º 8
0
        public void BufferLength()
        {
            var rnd    = new Random();
            var coords = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var x      = coords.X;
            var y      = coords.Y;
            var c      = new GeoAPI.Geometries.Coordinate(x, y);
            //coordscheck[i] = c;
            var p             = new Point(coords);
            var gf            = new NetTopologySuite.Geometries.GeometryFactory();
            var ps            = gf.CreatePoint(c);
            var boundary      = p.Buffer(500).Length;
            var boundarycheck = ps.Buffer(500).Length;

            AssertExt.AreEqual15(boundary, boundarycheck);
        }
Exemplo n.º 9
0
        public void BufferLength()
        {
            Random     rnd    = new Random();
            Coordinate coords = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            double     x      = coords.X;
            double     y      = coords.Y;

            GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
            //coordscheck[i] = c;
            Point p = new Point(coords);

            GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
            GeoAPI.Geometries.IPoint ps = gf.CreatePoint(c);
            double boundary             = p.Buffer(500).Length;
            double boundarycheck        = ps.Buffer(500).Length;

            AssertExt.AreEqual15(boundary, boundarycheck);
        }
Exemplo n.º 10
0
 public void Center()
 {
     Random rnd = new Random();
     Coordinate c1 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
     Coordinate c2 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
     Envelope ev = new Envelope(c1, c2);
     double x1 = c1.X;
     double y1 = c1.Y;
     double x2 = c2.X;
     double y2 = c2.Y;
     GisSharpBlog.NetTopologySuite.Geometries.Coordinate c1Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x1, y1);
     GisSharpBlog.NetTopologySuite.Geometries.Coordinate c2Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x2, y2);
     GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(c1Check, c2Check);
     Coordinate center = new Coordinate(ev.Center());
     GisSharpBlog.NetTopologySuite.Geometries.Coordinate centercheck = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(evcheck.Centre);
     AssertExt.AreEqual15(center.X, centercheck.X);
     AssertExt.AreEqual15(center.Y, centercheck.Y);
 }
Exemplo n.º 11
0
        public void Center()
        {
            var rnd         = new Random();
            var c1          = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var c2          = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var ev          = new Envelope(c1, c2);
            var x1          = c1.X;
            var y1          = c1.Y;
            var x2          = c2.X;
            var y2          = c2.Y;
            var c1Check     = new GeoAPI.Geometries.Coordinate(x1, y1);
            var c2Check     = new GeoAPI.Geometries.Coordinate(x2, y2);
            var evcheck     = new GeoAPI.Geometries.Envelope(c1Check, c2Check);
            var center      = new Coordinate(ev.Center());
            var centercheck = new GeoAPI.Geometries.Coordinate(evcheck.Centre);

            AssertExt.AreEqual15(center.X, centercheck.X);
            AssertExt.AreEqual15(center.Y, centercheck.Y);
        }
Exemplo n.º 12
0
        public void TwoCoordinates()
        {
            var rnd     = new Random();
            var c1      = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var c2      = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            var ev      = new Envelope(c1, c2);
            var x1      = c1.X;
            var y1      = c1.Y;
            var x2      = c2.X;
            var y2      = c2.Y;
            var c1Check = new GeoAPI.Geometries.Coordinate(x1, y1);
            var c2Check = new GeoAPI.Geometries.Coordinate(x2, y2);
            var evcheck = new GeoAPI.Geometries.Envelope(c1Check, c2Check);

            AssertExt.AreEqual15(ev.Maximum.Y, evcheck.MaxY);
            AssertExt.AreEqual15(ev.Maximum.X, evcheck.MaxX);
            AssertExt.AreEqual15(ev.Minimum.Y, evcheck.MinY);
            AssertExt.AreEqual15(ev.Minimum.X, evcheck.MinX);
        }
Exemplo n.º 13
0
        public void TwoCoordinates()
        {
            Random rnd = new Random();
            Coordinate c1 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            Coordinate c2 = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            Envelope ev = new Envelope(c1, c2);
            double x1 = c1.X;
            double y1 = c1.Y;
            double x2 = c2.X;
            double y2 = c2.Y;
            GisSharpBlog.NetTopologySuite.Geometries.Coordinate c1Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x1, y1);
            GisSharpBlog.NetTopologySuite.Geometries.Coordinate c2Check = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x2, y2);
            GisSharpBlog.NetTopologySuite.Geometries.Envelope evcheck = new GisSharpBlog.NetTopologySuite.Geometries.Envelope(c1Check, c2Check);
            AssertExt.AreEqual15(ev.Maximum.Y, evcheck.MaxY);
            AssertExt.AreEqual15(ev.Maximum.X, evcheck.MaxX);
            AssertExt.AreEqual15(ev.Minimum.Y, evcheck.MinY);
            AssertExt.AreEqual15(ev.Minimum.X, evcheck.MinX);

        }
Exemplo n.º 14
0
 public void LineStringEnvelopeArea()
 {
     Coordinate[] coords = new Coordinate[36];
     Random rnd = new Random();
     GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36];
     for (int i = 0; i < 36; i++)
     {
         coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
         double x = coords[i].X;
         double y = coords[i].Y;
         GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
         coordscheck[i] = c;
     }
     GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
     GeoAPI.Geometries.ILineString lscheck = gf.CreateLineString(coordscheck);
     LineString ls = new LineString(coords);
     double area = ls.Envelope.Area();
     double areacheck = lscheck.Envelope.Area;
     AssertExt.AreEqual15(area, areacheck);
 }
Exemplo n.º 15
0
        public void LineStringCentroid()
        {
            var coords      = new Coordinate[36];
            var rnd         = new Random();
            var coordscheck = new GeoAPI.Geometries.Coordinate[36];

            for (var i = 0; i < 36; i++)
            {
                coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                var x = coords[i].X;
                var y = coords[i].Y;
                var c = new GeoAPI.Geometries.Coordinate(x, y);
                coordscheck[i] = c;
            }
            var gf      = new NetTopologySuite.Geometries.GeometryFactory();
            var lscheck = gf.CreateLineString(coordscheck);
            var ls      = new LineString(coords);

            AssertExt.AreEqual15(ls.Centroid.X, lscheck.Centroid.X);
            AssertExt.AreEqual15(ls.Centroid.Y, lscheck.Centroid.Y);
        }
Exemplo n.º 16
0
        public void LineStringEnvelopeHeightWidth()
        {
            var coords      = new Coordinate[36];
            var rnd         = new Random();
            var coordscheck = new GeoAPI.Geometries.Coordinate[36];

            for (var i = 0; i < 36; i++)
            {
                coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                var x = coords[i].X;
                var y = coords[i].Y;
                var c = new GeoAPI.Geometries.Coordinate(x, y);
                coordscheck[i] = c;
            }
            var gf = new NetTopologySuite.Geometries.GeometryFactory();

            GeoAPI.Geometries.ILineString lscheck = gf.CreateLineString(coordscheck);
            var ls = new LineString(coords);

            AssertExt.AreEqual15(ls.Envelope.Width, lscheck.EnvelopeInternal.Width);
            AssertExt.AreEqual15(ls.Envelope.Height, lscheck.EnvelopeInternal.Height);
        }