hyg6ji
路人甲
路人甲
  • 注册日期2004-09-08
  • 发帖数22
  • QQ
  • 铜币167枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1218回复:1

[求助]如何运用MO实现缓冲区查询的功能?

楼主#
更多 发布于:2006-08-13 15:31
怎样实现缓冲区查询啊?对用与缓冲区查询的数据又有什么要求?是不是要有坐标系统?
喜欢0 评分0
gisgeoboy
路人甲
路人甲
  • 注册日期2003-11-11
  • 发帖数73
  • QQ
  • 铜币377枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-08-14 18:10
<P>MO帮助里面的例子,参考一下,看明白了改成自己需要的代码。</P>
<P>'This example uses the Buffer method to allow the user to buffer points, lines, 'rectangles, polygons and ellipses. The user point and the new shape generated by 'the buffer operation are added to the tracking layer as GeoEvents. To try this 'example, paste the code into the Declarations section of a form containing a Map 'named Map1 that has at least one MapLayer, and 5 OptionButtons named Option1 to 'Option5. Also add a Textbox named Text1. Press F5, and choose an option, then 'click on the map to create a point, or track a line, rectangle, ellipse or 'polygon. Try changing the value in the textbox.  </P>
<P>Option Explicit</P>
<P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)<BR>  'Point buffering<BR>  If Option1.Value Then<BR>    Dim pt As New MapObjects2.Point<BR>    Dim eventPt As New MapObjects2.GeoEvent<BR>    Dim buffPt As New MapObjects2.Polygon<BR>    Dim buffEventPt As New MapObjects2.GeoEvent<BR>    <BR>    Set pt = Map1.ToMapPoint(x, y)<BR>    Set eventPt = Map1.TrackingLayer.AddEvent(pt, 0)<BR>    Set buffPt = pt.Buffer(Text1.Text, Map1.FullExtent)</P>
<P>    Set buffEventPt = Map1.TrackingLayer.AddEvent(buffPt, 3)<BR>    <BR>  'Line buffering<BR>  ElseIf Option2.Value Then<BR>    Dim line As New MapObjects2.line<BR>    Dim eventLine As New MapObjects2.GeoEvent<BR>    Dim buffLine As New MapObjects2.Polygon<BR>    Dim buffEventLine As New MapObjects2.GeoEvent<BR>    <BR>    Set line = Map1.TrackLine<BR>    Set eventLine = Map1.TrackingLayer.AddEvent(line, 1)<BR>    Set buffLine = line.Buffer(Text1.Text, Map1.FullExtent)<BR>    Set buffEventLine = Map1.TrackingLayer.AddEvent(buffLine, 3)</P>
<P>    <BR>  'Rectangle buffering<BR>  ElseIf Option3.Value Then<BR>    Dim rect As New MapObjects2.Rectangle<BR>    Dim eventRect As New MapObjects2.GeoEvent<BR>    Dim buffRect As New MapObjects2.Polygon<BR>    Dim buffEventRect As New MapObjects2.GeoEvent<BR>    <BR>    Set rect = Map1.TrackRectangle<BR>    Set eventRect = Map1.TrackingLayer.AddEvent(rect, 2)<BR>    Set buffRect = rect.Buffer(Text1.Text, Map1.FullExtent)<BR>    Set buffEventRect = Map1.TrackingLayer.AddEvent(buffRect, 3)<BR>    </P>
<P>  'Polygon buffering<BR>  ElseIf Option4.Value Then<BR>    Dim poly As New MapObjects2.Polygon<BR>    Dim eventPoly As New MapObjects2.GeoEvent<BR>    Dim buffPoly As New MapObjects2.Polygon<BR>    Dim buffEventPoly As New MapObjects2.GeoEvent<BR>    <BR>    Set poly = Map1.TrackPolygon<BR>    Set eventPoly = Map1.TrackingLayer.AddEvent(poly, 2)<BR>    Set buffPoly = poly.Buffer(Text1.Text, Map1.FullExtent)<BR>    Set buffEventPoly = Map1.TrackingLayer.AddEvent(buffPoly, 3)<BR>  <BR>  'Ellipse buffering</P>
<P>  ElseIf Option5.Value Then<BR>    Dim arect As New MapObjects2.Rectangle<BR>    Dim elli As New MapObjects2.Ellipse<BR>    Dim eventElli As New MapObjects2.GeoEvent<BR>    Dim buffElli As New MapObjects2.Polygon<BR>    Dim buffEventElli As New MapObjects2.GeoEvent<BR>    <BR>    Set arect = Map1.TrackRectangle<BR>    elli.Top = arect.Top<BR>    elli.Bottom = arect.Bottom<BR>    elli.Left = arect.Left<BR>    elli.Right = arect.Right<BR>    <BR>    Set eventElli = Map1.TrackingLayer.AddEvent(elli, 2)</P>
<P>    Set buffElli = elli.Buffer(Text1.Text, Map1.FullExtent)<BR>    Set buffEventElli = Map1.TrackingLayer.AddEvent(buffElli, 3)<BR>    <BR>  End If<BR>  <BR>End Sub<BR>Private Sub Form_Load()<BR>  Option1.Caption = "Point"<BR>  Option2.Caption = "Line"<BR>  Option3.Caption = "Rectangle"<BR>  Option4.Caption = "Polygon"<BR>  Option5.Caption = "Ellipse"<BR>  Text1.Text = "100"<BR>  Map1.TrackingLayer.SymbolCount = 4<BR>  With Map1.TrackingLayer.Symbol(0)<BR>    .SymbolType = moPointSymbol<BR>    .Style = moTriangleMarker</P>
<P>    .Color = moRed<BR>    .Size = 3<BR>  End With<BR>  With Map1.TrackingLayer.Symbol(1)<BR>    .SymbolType = moLineSymbol<BR>    .Color = moRed<BR>    .Size = 3<BR>  End With<BR>  With Map1.TrackingLayer.Symbol(2)<BR>    .SymbolType = moFillSymbol<BR>    .Style = moGrayFill<BR>    .Color = moRed<BR>    .OutlineColor = moRed<BR>  End With<BR>  With Map1.TrackingLayer.Symbol(3)<BR>    .SymbolType = moFillSymbol<BR>    .Style = moGrayFill<BR>    .Color = moBlue<BR>    .OutlineColor = moBlue<BR>  End With<BR>End Sub</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部