AE implements GPS User tracking (VB. NET source code)

Source: Internet
Author: User
Tags ipoint
GPS User tracking is divided into two modes:
1. Real-time tracking: When GPS receives new data from the tracked point, the current view is updated to the extent with the tracking point as the center. This method is updated frequently, efficiency may not be high, but if the time interval between GPS data reception is appropriate, the tracking effect will be great;
2. Non-real-time tracking. When the tracked point is out of the current view range, the view range is updated to the extent with the tracking point as the central point. Obviously, this method is more efficient than the previous one, but the Tracing Effect is slightly inferior.
The implementation of these two methods is attached below. You only need to call the updateextentbytype function in the response event of the GPS receives the data, and the current view can be updated as required. As for the tracking point, you can use the element method to draw and map.

# Region "GPS tracking"
''' <Summary>
'''Gps tracking function, which updates the current map range based on tracking points and tracking methods
''' </Summary>
''' <Param name = "Ppoint"> tracing point </param>
''' <Param name = "pactiveview"> current view </param>
''' <Param name = "ptypecheck"> tracking method, whether to update in real time </param>
''' <Remarks> real-time update means that the new GPS data is updated once upon receipt. Non-real-time update means that the data is updated only when the tracking point exceeds the current range. </remarks>
Public sub updateextentbytype (byval Ppoint as ipoint, byval pactiveview as iactiveview, optional byval ptypecheck as Boolean = false)
If ptypecheck then
Updateextent (Ppoint, pactiveview)
Else
'': Determines if it exceeds the current range.
If not geoiscontainsanothergeo (pactiveview. Extent, Ppoint) then
Updateextent (Ppoint, pactiveview)
End if
End if
End sub
''' <Summary>
''' Update the current view range to the Ppoint-centered range.
''' </Summary>
''' <Param name = "Ppoint"> input point </param>
''' <Param name = "pactiveview"> current view </param>
''' <Remarks> </remarks>
Private sub updateextent (byval Ppoint as ipoint, byval pactiveview as iactiveview)
Dim penv as ienvelope = new envelope
Penv = getenvelopefrompointandenvelope (Ppoint, pactiveview. extent)
Pactiveview. extent = penv
Pactiveview. partialrefresh (esriviewdrawphase. esriviewbackground, nothing, nothing)
End sub
''' <Summary>
''' Obtain a new range based on the original view range and the new center point.
''' </Summary>
''' <Param name = "pnewcenter"> new center </param>
''' <Param name = "penv"> original view range </param>
''' <Returns> new range </returns>
''' <Remarks> </remarks>
Public Function getenvelopefrompointandenvelope (byval pnewcenter as ipoint, byval penv as ienvelope) as ienvelope
Dim parea as iarea = penv
Dim poldcenter as ipoint = parea. Centroid
Dim ptrans as itransform2d = penv
Ptrans. Move (pnewcenter. X-poldcenter. X, pnewcenter. Y-poldcenter. Y)
Return ptrans
End Function
''' <Summary>
''' Determines whether a ry contains another ry.
''' </Summary>
''' <Param name = "pgeo1"> contains ry </param>
''' <Param name = "pgeo2"> contained ry </param>
''' <Returns> </returns>
''' <Remarks> </remarks>
Function geoiscontainsanothergeo (byval pgeo1 as igeometry, byval pgo2 as igeometry) as Boolean
Dim prelationaloperator as irelationaloperator = new envelope
Prelationaloperator = pgeo1
Return (prelationaloperator. Contains (pgo2 ))
End Function
# End Region

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.