コード例 #1
0
ファイル: MultiShape.cs プロジェクト: ExRam/DotSpatial-PCL
 public void Multils()
 {
     Random rnd = new Random();
     LineString[] ls = new LineString[40];
     GeoAPI.Geometries.ILineString[] lscheck = new GeoAPI.Geometries.ILineString[40];
     GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
     for (int ii = 0; ii < 40; ii++)
     {
         Coordinate[] coord = new Coordinate[36];
         GeoAPI.Geometries.ICoordinate[] coordcheck = new GeoAPI.Geometries.ICoordinate[36];
         for (int i = 0; i < 36; i++)
         {
             coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
             double x = coord[i].X;
             double y = coord[i].Y;
             GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
             coordcheck[i] = c;
         }
         ls[ii] = new LineString(coord);
         lscheck[ii] = gf.CreateLineString(coordcheck);
     }
     MultiLineString mls = new MultiLineString(ls);
     GeoAPI.Geometries.IMultiLineString mlscheck = gf.CreateMultiLineString(lscheck);
     for (int ii = 0; ii < mls.Coordinates.Count; ii++)
     {
         Assert.AreEqual(mls.Coordinates[ii].X, mlscheck.Coordinates[ii].X);
         Assert.AreEqual(mls.Coordinates[ii].Y, mlscheck.Coordinates[ii].Y);
     }
     Assert.AreEqual(mls.NumGeometries, mlscheck.NumGeometries);
 }
コード例 #2
0
        public void Multils()
        {
            var rnd     = new Random();
            var ls      = new LineString[40];
            var lscheck = new GeoAPI.Geometries.ILineString[40];
            var gf      = new NetTopologySuite.Geometries.GeometryFactory();

            for (var ii = 0; ii < 40; ii++)
            {
                var coord      = new Coordinate[36];
                var coordcheck = new GeoAPI.Geometries.Coordinate[36];
                for (var i = 0; i < 36; i++)
                {
                    coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                    var x = coord[i].X;
                    var y = coord[i].Y;
                    var c = new GeoAPI.Geometries.Coordinate(x, y);
                    coordcheck[i] = c;
                }
                ls[ii]      = new LineString(coord);
                lscheck[ii] = gf.CreateLineString(coordcheck);
            }
            var mls      = new MultiLineString(ls);
            var mlscheck = gf.CreateMultiLineString(lscheck);

            for (var ii = 0; ii < mls.Coordinates.Count; ii++)
            {
                Assert.AreEqual(mls.Coordinates[ii].X, mlscheck.Coordinates[ii].X);
                Assert.AreEqual(mls.Coordinates[ii].Y, mlscheck.Coordinates[ii].Y);
            }
            Assert.AreEqual(mls.NumGeometries, mlscheck.NumGeometries);
        }
コード例 #3
0
        /// <summary>
        /// Method to place the street direction symbols
        /// </summary>
        /// <param name="map"></param>
        /// <param name="lineString"></param>
        /// <param name="graphics"></param>
        private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineString lineString,
                                      System.Drawing.Graphics graphics)
        {
            var length = lineString.Length;
            var lil    = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString);

            if (length < RepeatInterval + ArrowLength)
            {
                var start = System.Math.Max(0, (length - ArrowLength) / 2);
                var end   = System.Math.Min(length, (length + ArrowLength) / 2);
                var arrow = (GeoAPI.Geometries.ILineString)lil.ExtractLine(start, end);

                RenderArrow(map, graphics, arrow);

                return;
            }

            var numArrows = (int)((lineString.Length - ArrowLength) / RepeatInterval);
            var offset    = (lineString.Length - numArrows * RepeatInterval - ArrowLength) * 0.5;

            while (offset + ArrowLength < lineString.Length)
            {
                var arrow = (GeoAPI.Geometries.ILineString)lil.ExtractLine(offset, offset + ArrowLength);
                RenderArrow(map, graphics, arrow);
                offset += RepeatInterval;
            }
        }
コード例 #4
0
        public GeoAPI.Geometries.IMultiLineString SplitLineString(
            GeoAPI.Geometries.ILineString lineString,
            System.Double length)
        {
            if (lineString == null || lineString.IsEmpty)
            {
                throw new System.ArgumentException("Linestring is null or Empty", "lineString");
            }

            //var gf = new NetTopologySuite.Geometries.GeometryFactory();
            //var ntsLine = (NetTopologySuite.Geometries.LineString)
            //                SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf);

            var ret = new System.Collections.Generic.List <GeoAPI.Geometries.ILineString>();
            var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString);

            double currentLength = 0d;

            while (currentLength < lineString.Length)
            {
                var tmpLine = (GeoAPI.Geometries.ILineString)
                              lil.ExtractLine(currentLength, currentLength + length);
                ret.Add(tmpLine);
                currentLength += length;
            }
            return(lineString.Factory.CreateMultiLineString(ret.ToArray()));
        }
コード例 #5
0
ファイル: MultiShape.cs プロジェクト: yangkf1985/DotSpatial
        public void MlsLength()
        {
            Random rnd = new Random();

            LineString[] ls = new LineString[40];
            GeoAPI.Geometries.ILineString[] lscheck = new GeoAPI.Geometries.ILineString[40];
            GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
            for (int ii = 0; ii < 40; ii++)
            {
                Coordinate[] coord = new Coordinate[36];
                GeoAPI.Geometries.ICoordinate[] coordcheck = new GeoAPI.Geometries.ICoordinate[36];
                for (int i = 0; i < 36; i++)
                {
                    coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                    double x = coord[i].X;
                    double y = coord[i].Y;
                    GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
                    coordcheck[i] = c;
                }
                ls[ii]      = new LineString(coord);
                lscheck[ii] = gf.CreateLineString(coordcheck);
            }
            MultiLineString mls = new MultiLineString(ls);

            GeoAPI.Geometries.IMultiLineString mlscheck = gf.CreateMultiLineString(lscheck);
            Assert.AreEqual(mls.Length, mlscheck.Length);
        }
コード例 #6
0
        public void EnveloptMls()
        {
            var rnd     = new Random();
            var ls      = new LineString[40];
            var lscheck = new GeoAPI.Geometries.ILineString[40];
            var gf      = new NetTopologySuite.Geometries.GeometryFactory();

            for (var ii = 0; ii < 40; ii++)
            {
                var coord      = new Coordinate[36];
                var coordcheck = new GeoAPI.Geometries.Coordinate[36];
                for (var i = 0; i < 36; i++)
                {
                    coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                    var x = coord[i].X;
                    var y = coord[i].Y;
                    var c = new GeoAPI.Geometries.Coordinate(x, y);
                    coordcheck[i] = c;
                }
                ls[ii]      = new LineString(coord);
                lscheck[ii] = gf.CreateLineString(coordcheck);
            }
            var mls      = new MultiLineString(ls);
            var mlscheck = gf.CreateMultiLineString(lscheck);

            Assert.AreEqual(mls.Envelope.Width, mlscheck.EnvelopeInternal.Width);
            Assert.AreEqual(mls.Envelope.Height, mlscheck.EnvelopeInternal.Height);
        }
コード例 #7
0
ファイル: MultiShape.cs プロジェクト: hanchao/DotSpatial
 public void Multils()
 {
     var rnd = new Random();
     var ls = new LineString[40];
     var lscheck = new GeoAPI.Geometries.ILineString[40];
     var gf = new NetTopologySuite.Geometries.GeometryFactory();
     for (var ii = 0; ii < 40; ii++)
     {
         var coord = new Coordinate[36];
         var coordcheck = new GeoAPI.Geometries.Coordinate[36];
         for (var i = 0; i < 36; i++)
         {
             coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
             var x = coord[i].X;
             var y = coord[i].Y;
             var c = new GeoAPI.Geometries.Coordinate(x, y);
             coordcheck[i] = c;
         }
         ls[ii] = new LineString(coord);
         lscheck[ii] = gf.CreateLineString(coordcheck);
     }
     var mls = new MultiLineString(ls);
     var mlscheck = gf.CreateMultiLineString(lscheck);
     for (var ii = 0; ii < mls.Coordinates.Count; ii++)
     {
         Assert.AreEqual(mls.Coordinates[ii].X, mlscheck.Coordinates[ii].X);
         Assert.AreEqual(mls.Coordinates[ii].Y, mlscheck.Coordinates[ii].Y);
     }
     Assert.AreEqual(mls.NumGeometries, mlscheck.NumGeometries);
 }
コード例 #8
0
ファイル: LineSymbolizerTest.cs プロジェクト: cugkgq/Project
        /// <summary>
        /// Method to render the arrow
        /// </summary>
        /// <param name="map">The map</param>
        /// <param name="graphics">The graphics object</param>
        /// <param name="arrow">The arrow</param>
        private void RenderArrow(SharpMap.Map map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow)
        {
            var pts = new System.Drawing.PointF[arrow.Coordinates.Length];

            for (var i = 0; i < pts.Length; i++)
            {
                pts[i] = map.WorldToImage(arrow.GetCoordinateN(i));
            }
            graphics.DrawLines(ArrowPen, pts);
        }
コード例 #9
0
        public void LineStringCoordiantesCount()
        {
            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);

            Assert.AreEqual(ls.Coordinates.Count, lscheck.Coordinates.Count());
        }
コード例 #10
0
        public void LineStringEnvelopeHeightWidth()
        {
            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);
            AssertExt.AreEqual15(ls.Envelope.Width, lscheck.EnvelopeInternal.Width);
            AssertExt.AreEqual15(ls.Envelope.Height, lscheck.EnvelopeInternal.Height);

        }
コード例 #11
0
ファイル: EnvelopeUnitTests.cs プロジェクト: qingqibing/aa
        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);
        }
コード例 #12
0
ファイル: MultiShape.cs プロジェクト: hanchao/DotSpatial
 public void EnveloptMls()
 {
     var rnd = new Random();
     var ls = new LineString[40];
     var lscheck = new GeoAPI.Geometries.ILineString[40];
     var gf = new NetTopologySuite.Geometries.GeometryFactory();
     for (var ii = 0; ii < 40; ii++)
     {
         var coord = new Coordinate[36];
         var coordcheck = new GeoAPI.Geometries.Coordinate[36];
         for (var i = 0; i < 36; i++)
         {
             coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
             var x = coord[i].X;
             var y = coord[i].Y;
             var c = new GeoAPI.Geometries.Coordinate(x, y);
             coordcheck[i] = c;
         }
         ls[ii] = new LineString(coord);
         lscheck[ii] = gf.CreateLineString(coordcheck);
     }
     var mls = new MultiLineString(ls);
     var mlscheck = gf.CreateMultiLineString(lscheck);
     Assert.AreEqual(mls.Envelope.Width, mlscheck.EnvelopeInternal.Width);
     Assert.AreEqual(mls.Envelope.Height, mlscheck.EnvelopeInternal.Height);
 }