现在的位置: 首页 > 综合 > 正文

Transforming between image coordinates and world coordinates

2012年12月28日 ⁄ 综合 ⁄ 共 548字 ⁄ 字号 评论关闭
文章目录

Transforming between image coordinates and world coordinates

SharpMap has built-in functions to help you transform between image and world coordinates.

When the user clicks the map at a given pixel (x,y), you can translate this world coordinates using the ImageToWorld method:

 
SharpMap.Geometries.Point p = myMap.ImageToWorld(new System.Drawing.PointF(x, y)); 

Please note that the value is calculated based on the current zoom and center-values of the myMap Map object.

If you want to do the opposite transformation, use WorldToImage:

 
System.Drawing.PointF p = myMap.WorldToImage(new SharpMap.Geometries.Point(34.225, 175.432));  

抱歉!评论已关闭.