Map Latitude and Longitude

Topics: CompactFramework, SharpMap v2.0, WinForms Controls
Apr 15, 2014 at 6:32 AM
Hello There;

I'm new to geocoding and need some help.

Step1 : Google geocoding and gets latitude and longitude from address.
Step 2 : Read shape file that which have a electorate information.
Step 3 : Get the electorate from file opened in step2 corresponding to the result from step1.

I was able to partly do the things. I done with step 1 and was able to pen the shape file but had no luck in mapping the coordinates to the map and get the electoral information. I'm using c#.net and VS 2012 for development. Any body have any idea please help.
Editor
Apr 15, 2014 at 12:31 PM
You will have to query the information in the shapefile using the result from the geocode service.

to do this you just need to call the ExecuteIntersectionQuery method on your shapefileprovider and give the envelope of the geocode geometry and a featureDataset to populate.

you can then iterate the featureDataset , do a true intersection test on the returned values and see if they intersect.
Apr 24, 2014 at 8:41 AM
I had no luck with it . I was able to place my coordinates on the map , but no luck in returning the electorate names . Anybody have a code snippet . Please help
Coordinator
Apr 24, 2014 at 12:37 PM
Edited Apr 24, 2014 at 12:38 PM
If you are use google geocoding, you get lat/long in WGS84. Are the shapes in your shapefile of same coordinate system? if not you need to set up a coordinate transformation.
// Beware, code has not seen a compiler
var ctFac = new ProjNet.CoordinateSystems.Transformation.CoordinateTransformationFactory();
var cs = shapeFile.CoordinateSystem;
var ct = ctFac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, cs);

var pt = ct.MathTransform(new Coordinate(geoCodePt.Long, geoCodePt.Lat)
var fds = new SharpMap.Data.FeatureDataSet();
shapeFile.ExecuteIntersectionQuery(shapeFile.Factory.CreatePoint(pt), fds);
Apr 28, 2014 at 3:24 AM
I found a way out

SharpMap.Layers.VectorLayer vlayer = new SharpMap.Layers.VectorLayer("vlayer");
SharpMap.Data.Providers.ShapeFile oshape=new SharpMap.Data.Providers.ShapeFile("C:\Geo\electorate.shp");
vlayer.DataSource = oshape;
NetTopologySuite.Geometries.Point gPoint = new NetTopologySuite.Geometries.Point(Longiyude,Latitude);
var fds = new SharpMap.Data.FeatureDataSet();
vlayer.DataSource.Open();
vlayer.DataSource.ExecuteIntersectionQuery(gPoint, fds);

foreach (SharpMap.Data.FeatureDataTable fdt in fds.Tables)
{
foreach (SharpMap.Data.FeatureDataRow fdr in fdt.Rows)
{
String sElectorate = fdr[1].ToString();
}
}

thank you for all your help