[英]Using GEO coordinates in C# to draw map
He, 他,
I want to draw a Countrymap in C# with LAT/LNG coordinates. 我想用CAT和LAT / LNG坐标绘制一个Countrymap。 I have to translate the lat/lng to pixels, what would be the best way?
我必须将lat / lng翻译成像素,最好的方法是什么? I can draw the 'Map' but it's very small and it's not in the center of the window.
我可以绘制'地图'但它非常小而且它不在窗口的中心。
Can someone help? 有人可以帮忙吗? I have this code:
我有这个代码:
void draw(Graphics g, PointF[] points, Pen p)
{
Graphics gfx = g;
gfx.PageUnit = GraphicsUnit.Point;
GraphicsPath gpath = new GraphicsPath();
gpath.StartFigure();
gpath.AddLines(points);
gpath.CloseFigure();
Matrix m = new Matrix();
m.Scale(5, 5);
gfx.Transform = m;
gfx.DrawPath(p, gpath);
gfx.Dispose();
gpath.Dispose();
return;
}
You will need to choose a map projection (eg. Mercator, Cylindrical Equal Area, or Mollweide) and then transform the coordinates from geographic lat,LNG to use this projection. 您需要选择地图投影(例如墨卡托,圆柱等面积或Mollweide),然后转换地理纬度,LNG的坐标以使用此投影。
The standard open source library for this is proj.4. 这个标准的开源库是proj.4。 I understand there are C# wrappers around, ut personally I've used OGR with the ogrsharp wrappers.
我知道有C#包装器,我个人已经使用OGR和ogrsharp包装器。 OGR uses proj.4 internally but also adds a lot of used functions when you want to work with specific coordinate systems (eg defined in a prj file).
OGR在内部使用proj.4,但是当你想使用特定的坐标系(例如在prj文件中定义)时,它还会添加许多使用过的函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.