阅读:1695回复:2
像素与地图空间单位转换问题
<PRE><CODE><FONT color=#0000ff>Private Function</FONT></CODE> <FONT style="BACKGROUND-COLOR: #316ac5" color=#ffffff>ConvertPixelsToMapUnits</FONT>(pixelUnits <CODE><FONT color=#0000ff>As Double</FONT></CODE>) <CODE><FONT color=#0000ff>As Double
Dim</FONT></CODE> realWorldDisplayExtent <CODE><FONT color=#0000ff>As Double Dim</FONT></CODE> pixelExtent <CODE><FONT color=#0000ff>As Long Dim</FONT></CODE> sizeOfOnePixel <CODE><FONT color=#0000ff>As Double Dim</FONT></CODE> pDT <CODE><FONT color=#0000ff>As</FONT></CODE> IDisplayTransformation <CODE><FONT color=#0000ff>Dim</FONT></CODE> deviceRECT <CODE><FONT color=#0000ff>As</FONT></CODE> tagRECT <CODE><FONT color=#0000ff>Dim</FONT></CODE> pEnv <CODE><FONT color=#0000ff>As</FONT></CODE> IEnvelope <CODE><FONT color=#0000ff>Dim</FONT></CODE> pActiveView <CODE><FONT color=#0000ff>As</FONT></CODE> IActiveView <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMxDocument <CODE><FONT color=#0000ff>As</FONT></CODE> IMxDocument <CODE><FONT color=#008000>' Get the width of the display extents in Pixels</FONT></CODE> <CODE><FONT color=#008000>' and get the extent of the displayed data</FONT></CODE> <CODE><FONT color=#008000>' work out the size of one pixel and then return</FONT></CODE> <CODE><FONT color=#008000>' the pixels units passed in mulitplied by that value</FONT></CODE> <CODE><FONT color=#008000>' QI for the IMxDocument interface from ThisDocument</FONT></CODE> <CODE><FONT color=#0000ff>Set</FONT></CODE> pMxDocument = ThisDocument <CODE><FONT color=#008000>' QI for the IActiveView interface from the currently selected Map</FONT></CODE> <CODE><FONT color=#0000ff>Set</FONT></CODE> pActiveView = pMxDocument.FocusMap <CODE><FONT color=#008000>' Get IDisplayTransformation</FONT></CODE> <CODE><FONT color=#0000ff>Set</FONT></CODE> pDT = pActiveView.ScreenDisplay.DisplayTransformation <CODE><FONT color=#008000>' Get the device frame which will give us the number of pixels in the X direction</FONT></CODE> deviceRECT = pDT.DeviceFrame pixelExtent = deviceRECT.Right - deviceRECT.Left <CODE><FONT color=#008000>' Now get the map extent of the currently visible area</FONT></CODE> <CODE><FONT color=#0000ff>Set</FONT></CODE> pEnv = pDT.VisibleBounds <CODE><FONT color=#008000>' Calculate the size of one pixel</FONT></CODE> realWorldDisplayExtent = pEnv.Width sizeOfOnePixel = realWorldDisplayExtent / pixelExtent <CODE><FONT color=#008000>'Multiply this by the input argument to get the result</FONT></CODE> <FONT style="BACKGROUND-COLOR: #316ac5" color=#ffffff>ConvertPixelsToMapUnits</FONT> = pixelUnits * sizeOfOnePixel <CODE><FONT color=#0000ff>End Function</FONT></CODE> 这是Map中像素转为地图单位的程序,可是在Scene中如何实现呢?</PRE> |
|
1楼#
发布于:2006-02-27 13:52
没弄过
|
|
2楼#
发布于:2006-02-27 10:37
高手们帮忙看看啊,急
|
|