예제 #1
0
        public void TestLayer()
        {
            var map = new SharpMap.Map(new System.Drawing.Size(500, 500));
            var gp  = new SharpMap.Data.Providers.FeatureProvider(
                new[]
            {
                Factory.CreatePolygon(
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(0, 0),
                                               new System.Drawing.SizeF(40, 30)),
                    new[]
                {
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(90, 55),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(77, 24),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-80, 41),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-45, -36),
                                               new System.Drawing.SizeF(40, 30)),
                })
            });
            var gl = new SharpMap.Layers.VectorLayer("GeometryLayer", gp);

            map.Layers.Add(gl);
            map.ZoomToExtents();
            var mapimage = map.GetMap();

            mapimage.Save("ellipse.png", System.Drawing.Imaging.ImageFormat.Png);
        }
예제 #2
0
        private static GeoAPI.Geometries.IPolygon ReadPolygon(byte[] geom, ref int idx, bool isLittleEndian, GeoAPI.Geometries.IGeometryFactory factory)
        {
            var nRings = ReadUInt32(geom, ref idx, isLittleEndian);

            if (nRings < 1 || nRings > Int32.MaxValue / (2 * 8))
            {
                throw new ApplicationException("Currupt SpatialLite geom");
            }

            List <GeoAPI.Geometries.ILineString> lineStrings = new List <GeoAPI.Geometries.ILineString>();

            for (int i = 0; i < nRings; i++)
            {
                lineStrings.Add(ReadLineString(geom, ref idx, isLittleEndian, factory));
            }

            List <GeoAPI.Geometries.ILinearRing> holes = null;
            var shell = factory.CreateLinearRing(lineStrings[0].Coordinates);

            if (lineStrings.Count > 1)
            {
                holes = new List <GeoAPI.Geometries.ILinearRing>();
                for (int i = 1; i < lineStrings.Count; i++)
                {
                    holes.Add(factory.CreateLinearRing(lineStrings[i].Coordinates));
                }
            }
            return(factory.CreatePolygon(shell, holes == null ? null : holes.ToArray()));
        }