This project has moved and is read-only. For the latest updates, please go here.

Shape-file in WPF

Topics: Data Access, SharpMap Project, SharpMap v2.0
May 5, 2011 at 5:22 AM

Hello, everybody.

I'm trying to output my shape-file into WPF-control (SharpMap v2), but I have only white form.
There are no mistakes when compiling solution, shape-file was parsed well too. I use "initialgdalintegration" branch.

Here is my code:

        public MainWindow()
            SridMap.DefaultInstance = new SridMap(new[] { new SridProj4Strategy(0, new GeometryServices().CoordinateSystemFactory) });
            _coordinateFactory = new BufferedCoordinateFactory();
            _coordinateSequenceFactory = new BufferedCoordinateSequenceFactory(CoordinateFactory);
            _geometryFactory = new GeometryFactory<BufferedCoordinate>(_coordinateSequenceFactory);
            _coordinateSystemFactory = new CoordinateSystemFactory<BufferedCoordinate>(_coordinateFactory, _geometryFactory);
            Map = new Map(GeometryServices.DefaultGeometryFactory, GeometryServices.CoordinateTransformationFactory);
            MapControl.Map = Map;

        private Map _map;
        private readonly BindingList<KeyValuePair<string, GeometryStyle>> _loadedStyles = new BindingList<KeyValuePair<string, GeometryStyle>>();
        private readonly IGeometryServices GeometryServices = new GeometryServices();
        private static BufferedCoordinateFactory _coordinateFactory;
        private static BufferedCoordinateSequenceFactory _coordinateSequenceFactory;
        private static GeometryFactory<BufferedCoordinate> _geometryFactory;
        private static CoordinateSystemFactory<BufferedCoordinate> _coordinateSystemFactory;
        public static readonly DependencyProperty ActiveProperty = DependencyProperty.Register("Map", typeof(Map), typeof(MainWindow), null);
        public static BufferedCoordinateFactory CoordinateFactory
        { get { return _coordinateFactory; } }
        public static BufferedCoordinateSequenceFactory CoordinateSequenceFactory
        { get { return _coordinateSequenceFactory; } }
        public static GeometryFactory<BufferedCoordinate> GeometryFactory
        { get { return _geometryFactory; } }
        public static CoordinateSystemFactory<BufferedCoordinate> CoordinateSystemFactory
        { get { return _coordinateSystemFactory; } }
        public Map Map
            get { return _map; }
            set { _map = value; }

        private void AddLayer()
            var s = new[]
                { new GeometryStyle { Fill = new SolidStyleBrush(StyleColor.DarkGreen), Outline = new StylePen() },
                  new GeometryStyle { Line = new StylePen(new SolidStyleBrush(StyleColor.DarkSeaGreen), 2d), Outline = new StylePen(new SolidStyleBrush(StyleColor.Blue), 4d)},
                  new GeometryStyle()};
            int i = 0;
            string layer_path = "cities.shp";
            var prov = new SharpMap.Data.Providers.ShapeFile.ShapeFileProvider(layer_path, GeometryFactory, CoordinateSystemFactory);
            var fl = new GeometryLayer(layer_path, s[i++], prov);
You can download my project here [3,5 Mb].
Where have I mistaken? Can you give your variant?
I need your help. Thank you

May 5, 2011 at 1:55 PM

Hello ego2, I will look at it asap.