This project has moved. For the latest updates, please go here.

Cordinate Transformation for Geometry Provider

Topics: SharpMap Project, WinForms Controls
Sep 13, 2014 at 11:05 AM
My Map's Background Google/Bing Layer Coordinate system is WebMercator and then I convert my Vector Layer Coordinate system to the same as Background Layer.
var ctf = new CoordinateTransformationFactory();
vlay.CoordinateTransformation = tf.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
I need to use Drawing tool on my map. when i am using event map_GeometryDefined then i need to get all the points under the drawn polygon ? The Geometry object in the arguments of event gives me Coordinates but i need to know these coordinates in which coordinator system and how to convert into WebMercator?
Sep 13, 2014 at 6:22 PM
The coordinates of the defined geometry are in the coordinate system of your map, WebMercator.
Sep 14, 2014 at 11:22 AM
Hi FObermaier,
Its cool having coordinates in the same coordinate system in which the map has shown.
My next question is this when i had drawn the polygon on map i need to get all the point inside that polygon but i get nothing .
I used the ExecuteIntersectionQuery.
Please help me to get out of this..
Sep 15, 2014 at 6:11 AM
If you use ExecuteIntersectionQuery of the VectorLayer, coordinate transformation should be handled automatically.
Sep 15, 2014 at 9:07 AM
Hi FObermaier,
One more question ..
My Function to get points inside the Polygon is:-
SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet();
 var layer = mapBox1.Map.Layers[0] as SharpMap.Layers.VectorLayer;
layer.ExecuteIntersectionQuery(geometry.Envelope, ds);
In above particular code i am taking layer as a vector layer which gave me no points inside the polygon.
But when i replace vector layer to ICanQueryLayer Like below:-
SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet();
var layer = mapBox1.Map.Layers[0] as SharpMap.Layers.ICanQueryLayer;
layer.ExecuteIntersectionQuery(geometry.Envelope, ds);
In this case i have got some right values.
I need to know :-
1. What is the difference between taking as a Vector Layer and ICanQueryLayer?
2. According to you which we have to use to get the exact results?
Sep 15, 2014 at 11:56 AM
It should not make any difference. If it does, setup example unit test.