CoordinateTransformation does not work with PuntalVectorLayer?

Topics: SharpMap Project, SharpMap v0.9 / v1.x, WinForms Controls
Jul 31, 2014 at 9:32 PM
Here is the code, but it is not shown at the right place with a webmecator back layer:
                                    SharpMap.Layers.Symbolizer.PuntalVectorLayer searL =new SharpMap.Layers.Symbolizer.PuntalVectorLayer("ReservedSearchVectorLayer",
                new SharpMap.Data.Providers.GeometryProvider(mapBox1.Map.f.Factory.CreatePoint(new Coordinate(loc.Lng, loc.Lat))),
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateCircle(Pens.Aquamarine, Brushes.BurlyWood, 24));

                ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
                searL.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
                searL.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);

                mapBox1.Map.Layers.Add(searL);
                //mapBox1.Map.ZoomToBox(searL.Envelope);
                mapBox1.Refresh();
Jul 31, 2014 at 9:34 PM
There is typo, here is the right code:
                SharpMap.Layers.Symbolizer.PuntalVectorLayer searL =new SharpMap.Layers.Symbolizer.PuntalVectorLayer("ReservedSearchVectorLayer",
                new SharpMap.Data.Providers.GeometryProvider(mapBox1.Map.Factory.CreatePoint(new Coordinate(loc.Lng, loc.Lat))),
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateCircle(Pens.Aquamarine, Brushes.BurlyWood, 24));

                ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
                searL.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
                searL.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);

                mapBox1.Map.Layers.Add(searL);
                //mapBox1.Map.ZoomToBox(searL.Envelope);
                mapBox1.Refresh();
Coordinator
Aug 1, 2014 at 8:04 AM
Is it off by a margin or completly wrong? Maybe you have mixed lat/long?
Aug 1, 2014 at 3:32 PM
I tried VectorLayer, and it works perfectly. So looks like PuntalVectorLayer does not implement CoordinateTransformation.
                VectorLayer vectorLayer = new VectorLayer("ReservedSearchVectorLayer");
                Collection<GeoAPI.Geometries.IGeometry> geomColl = new Collection<GeoAPI.Geometries.IGeometry>();
                //Get the default geometry factory
                GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();
                GeoAPI.Geometries.IGeometryFactory gf = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory();
                geomColl.Add(gf.CreatePoint(new GeoAPI.Geometries.Coordinate(loc.Lng, loc.Lat)));

                ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
                vectorLayer.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
                vectorLayer.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);

                var MyStyle = new SharpMap.Styles.VectorStyle();
                MyStyle.Symbol = new Bitmap(imgLstTreeView.Images[5]);
                vectorLayer.Style = MyStyle;
                vectorLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomColl);
                mapBox1.Map.Layers.Add(vectorLayer);
Coordinator
Aug 4, 2014 at 7:49 AM
I cannot confirm that. The version in Branches/1.0 properly reprojects.
Which version are you using?
Aug 4, 2014 at 4:37 PM
The latest one in nuget. I think it is 1.1. Thanks