【功能】: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文件中的參數"GEOSETMBRLOWERLEFT" ,"GEOSETMBRUPPERRIGHT"。
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;
}