|
20楼#
发布于:2004-02-17 23:39
好是好,如果写在一个文件用来下载就更好了
|
|
|
21楼#
发布于:2004-01-12 18:07
hao
|
|
|
22楼#
发布于:2004-01-11 00:13
大哥,缘分啊
|
|
|
23楼#
发布于:2004-01-06 09:09
太好了,雪中送炭也
|
|
|
24楼#
发布于:2004-01-04 10:04
////**********图形浏览**********
// /////////////////////////////////////////////////////////////// //函数功能 : 拉框放大 //返 回 值 : void //参数说明 : CMap1& map /////////////////////////////////////////////////////////////// void ZoomIn(CMap1& map) { CMoRectangle r(map.TrackRectangle()); if (LPDISPATCH(r)) map.SetExtent(r); } /////////////////////////////////////////////////////////////// //函数功能 : 点击缩小 //返 回 值 : void //参数说明 : CMap1& map /////////////////////////////////////////////////////////////// void ZoomOut(CMap1& map) { CMoRectangle r(map.GetExtent()); ASSERT(LPDISPATCH(r)); r.ScaleRectangle(1.5); //1.5为每次缩小比例 map.SetExtent(r); } /////////////////////////////////////////////////////////////// //函数功能 : 漫游 //返 回 值 : void //参数说明 : CMap1& map /////////////////////////////////////////////////////////////// void Pan(CMap1& map) { map.Pan(); } /////////////////////////////////////////////////////////////// //函数功能 : 刷新 //返 回 值 : void //参数说明 : CMap1& map /////////////////////////////////////////////////////////////// void Refresh(CMap1& map) { map.Refresh(); } /////////////////////////////////////////////////////////////// //函数功能 : 全图显示 //返 回 值 : void //参数说明 : CMap1& map /////////////////////////////////////////////////////////////// void ZoomFull(CMap1& map) { CMoRectangle r(map.GetFullExtent()); //获得地图全图范围 ASSERT(LPDISPATCH(r)); map.SetExtent(r); } /////////////////////////////////////////////////////////////// //函 数 名 : Identify //函数功能 : 属性查询 //处理过程 : //返 回 值 : void //参数说明 : long X, long Y ;X,Y为鼠标点击地图屏幕时,鼠标的屏幕位置 /////////////////////////////////////////////////////////////// void Identify(long X,long Y) { long ShapeType; CMoRecordset selSet; CMoMapLayer selLayer; if(SelectFeatureOnMap(*m_Map,X,Y,m_SelTolerance/* 咬合范围的大小 */,selSet ,ShapeType,selLayer)) //SelectFeatureOnMap函数参考如下 { CMoFields MoFields = selSet.GetFields(); FlashMoFields(*m_Map,MoFields,ShapeType); //使所选择的要素闪烁 // 根据返回的Recordset对象在无模式对话框中显示属性值,代码略 } } /////////////////////////////////////////////////////////////// //函数功能 : 返回要素属性 //处理过程 : //返 回 值 : BOOL //参数说明 : CMap1& map, long X, long Y, double ptSize, // CMoRecordset& set, 该要素的Recordset (返回参数) // long& ShapeType, 要素所在图层的类型(返回参数) // CMoMapLayer& layer 要素所在图层 (返回参数) /////////////////////////////////////////////////////////////// BOOL SelectFeatureOnMap(CMap1& map,long X,long Y,double ptSize,CMoRecordset & set,long& ShapeType,CMoMapLayer& layer) { double tolerance = map.ToMapDistance((float)ptSize); CMoPointmapPt(map.ToMapPoint((float)X, (float)Y)); CMoLayers layers(map.GetLayers()); for(long i=0;i<layers.GetCount();i++) { CMoMapLayer Itemlayer(layers.Item(COleVariant(i))); if(!Itemlayer.GetVisible()) continue; ShapeType = Itemlayer.GetShapeType(); if(Itemlayer.GetShapeType()==moShapeTypePolygon) { set = Itemlayer.SearchShape(mapPt,moPointInPolygon, TEXT("")); layer = Itemlayer; if(!set.GetEof()) return TRUE; } if(Itemlayer.GetShapeType()==moShapeTypePoint||Itemlayer.GetShapeType()==mo ShapeTypeLine) { set = Itemlayer.SearchByDistance(mapPt,tolerance, TEXT("")); layer = Itemlayer; if(!set.GetEof()) return TRUE; } } return FALSE; } /////////////////////////////////////////////////////////////// //函数功能 : 使Recordset对应的要素闪烁 //返 回 值 : void //参数说明 : CMap1& map, CMoFields MoFields, MoFields为要素的Recordset对应的 Fields // long ShapeType /////////////////////////////////////////////////////////////// void FlashMoFields(CMap1& map,CMoFields MoFields,long ShapeType) { CMoField shapeField(MoFields.Item(COleVariant(TEXT("Shape")))); if(ShapeType==moShapeTypePolygon) { CMoPolygon shape(shapeField.Getvalue().pdispVal); map.FlashShape(shape,2); // 2为闪烁次数 } if(ShapeType==moShapeTypeLine) { CMoLine shape(shapeField.Getvalue().pdispVal); map.FlashShape(shape,2); } if(ShapeType==moShapeTypePoint) { CMoPoint shape(shapeField.Getvalue().pdispVal); map.FlashShape(shape,2); } } /////////////////////////////////////////////////////////////// //函数功能 : 设置地图显示比例尺 //处理过程 : 先得到屏幕上一米包含多少个象素点,地图的宽度(象素点值)除以该值 得到 // 地图的显示实际宽度(米),地图的显示宽度(米)乘地图显示的比例尺 即得到该比例尺 // 下地图宽度(象素点值) //返 回 值 : void //参数说明 : CMap1& map, double scale ;scale为地图显示比例尺 /////////////////////////////////////////////////////////////// void SetMapScale(CMap1& map,double scale) { CDC* pDC = map.GetDC(); double MiterPointNum = (1000.0/25.4)*GetDeviceCaps(pDC->m_hDC,LOGPIXELSX); //MiterPointNum为屏幕上一米有多少个象素点 //GetDeviceCaps(pDC->m_hDC,LOGPIXELSX) 返回屏幕横轴方向上每英寸长度包含的象 素个数 CRect r = GetDeviceRect(pDC); double widthX = r.Width()*scale/MiterPointNum; double widthY = r.Height()*scale/MiterPointNum; CMoRectangle moRect(map.GetExtent()); CMoPoint pt(moRect.GetCenter()); CMoRectangle moRectNew; if(!moRectNew.CreateDispatch(TEXT("MapObjects2.Rectangle"))) return; moRectNew.SetLeft(pt.GetX()-widthX/2.0); moRectNew.SetRight(pt.GetX()+widthX/2.0); moRectNew.SetTop(pt.GetY()+widthY/2.0); moRectNew.SetBottom(pt.GetY()-widthY/2.0); map.SetExtent(moRectNew); map.Refresh(); map.ReleaseDC(pDC); } -- GIS尚未明白,学习还需努力 ※ 来源:.侏罗纪公园 http://bbs.cug.edu.cn[FROM: 10.58.4.194] [回文章] [返回上一页][本讨论区] |
|
上一页
下一页