ThinkGeo.com    |     Documentation    |     Premium Support

VirtualEarth Coordinates

Hello,


 


I have some trouble to get the correct coordinates when I use the virtual earth layer.


I use this code to do it :


private void winformsMap1_MouseMove(object sender, MouseEventArgs e) {                         
PointShape currentWorldCoordonate = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height); 

......
......
}


When I use it on the sample shapefile "Countries02.shp", it works great. I've got values between 80N/80S & 180E/180W.

But when I use the VE layer, the values aren't correct.


How can I get the right coordinates ?


Thanks.


 



Pierre, 



Thanks for your post. 



I am afraid that maybe you use the wrong MapUnit, the default value is DecimalDegree, can you try to set the value to Meter?


The VE layer uses different projection from countries02 layer, so I think maybe problem is caused by this if it's not MapUnit.


I will do more research on this later.




Please let me know if you have more questions. 



Thanks 

James



Hi,


The MapUnit is set to Meters. I already try to change the projection but the result is still not correct.

I use the SRID 4326 and 3395. I try to use them in External and Internal and conversely but it still doesn't work.

I'll keep trying to found a solution.


Thanks again for your answer.



Hi,


 


I found what is the problem !


When I try to use a projection, I was projected the current extend instead of the result (the pointshape).


Now it's work perfectly !


 


proj4proj.InternalProjectionParametersString = "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";//Mercator
proj4proj.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); //Geodetic (Longitude/Latitude)

PointShape currentWorldCoordonate = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height);

double X, Y;

X = currentWorldCoordonate.X;
Y = currentWorldCoordonate.Y;
            
//Converts the point to Geodetic from the Mercator projection.
proj4proj.Open();
Vertex geoVertex = proj4proj.ConvertToExternalProjection(X, Y);
proj4proj.Close();

//Displays world coordinates in Decimal Degrees.
X = Math.Round(geoVertex.X, 4);
Y = Math.Round(geoVertex.Y, 4);


I am glad this is working for you.  
 I also want to let you know that if you want you can also show your decimal degrees values in the Decimal Minutes Seconds format using this: 
  
  string DMS = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegreePoint(new PointShape(X, Y),2);