CSDN博客

img yesgis

MapX之VC设置非地球坐标系

发表于2004/4/23 13:25:00  1063人阅读

【功能】:MapX之VC设置非地球坐标系
【环境】:vc6+mapx4.5+win2k+sp3
【提示】:CoordSys.set设置非地球坐标系时,必须定义坐标范围
【出处】:www.51gis.com


int CMyGIsView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;

// create map with default size
// resize message will cause it to be
// size to the client area of the view
m_ctrlMapX.Create(NULL, WS_VISIBLE, CRect(0,0,100,100), this, IDC_MAP);
m_ctrlMapX.SetGeoSet("Mygst.gst");

//-------以下代码设置nonearth(meters)坐标系-------------
CMapXRectangle Rect;
CMapXCoordSys CurrentCoordsys;
COptionalVariant vEmpty;
VARIANT MapUnit,MapBounds;
if(!Rect.CreateDispatch(Rect.GetClsid()))
{
TRACE0("Could not Create object");
}
if(!CurrentCoordsys.CreateDispatch(CurrentCoordsys.GetClsid())) {
TRACE0("Could not Create object");
}
try {
MapUnit.vt=VT_I4;
MapUnit.lVal=miUnitMeter;
//设置坐标范围(MBR).为求一致,这里取当GeosetManager中设置为non-earth(meters)时,
//gst文件中的参数"/GEOSET/MBR/LOWERLEFT" ,"/GEOSET/MBR/UPPERRIGHT"。
Rect.Set(-2165.540090678837, 9841.99939777,46782.41871417205,41026.85331473999);

MapBounds.vt=VT_DISPATCH;
MapBounds.pdispVal=Rect.m_lpDispatch;
MapBounds.pdispVal->AddRef();
CurrentCoordsys.Set(0, vEmpty,MapUnit, vEmpty, vEmpty, vEmpty,vEmpty, vEmpty, vEmpty, vEmpty, vEmpty, vEmpty,MapBounds, vEmpty);
m_ctrlMapX.SetNumericCoordSys(CurrentCoordsys.m_lpDispatch);
m_ctrlMapX.SetDisplayCoordSys(m_ctrlMapX.GetNumericCoordSys().m_lpDispatch);

} catch (COleDispatchException *e) {
e->ReportError();
e->Delete();
} catch (COleException *e) {
e->ReportError();
e->Delete();
}
//------------------------------------------------

return 0;
}

 

==================MapX专家论坛(www.51gis.com)===================

0 0

相关博文

我的热门文章

img
取 消
img