View Single Post
Old 05-25-2005   #42 (permalink)
ragmanii
Registered Member
 
Join Date: Sep 2004
Posts: 3
A few minor changes to script...

I have made a few minor mods to the script I thought I would share. I do not like the fact that the script updates the map with every GPS move. I like to see my car moving on the map and only refresh when it is X pixels (Yes pixels) from the center. I have changed (Snippet ends with "-End Change "):

In ns04settings.vbs (note first line for reference):

'True to centre map on vehicle - Laidback 20040706
'Removed CONST so we can change this variable if you want to only center on certain conditions -RagmanII
'Made variable so we can only center the map if your location is X pixels away from the center -RagmanII
CentreVehicle = 150

-End Change Note that the CenterVehicle can be set to 1 or 0 and it would emulate the true/false condition that was originally in the script.

Then change ns04mappoint.vbs (First line for reference):

Dim BSSID_Signal

'need to know what pixel is the center on the map -RagmanII
Dim CenterPixelX
Dim CenterPixelY

-End Change Then change ns04mappoint.vbs (First line for reference):

Set LastLocation = ActiveMap.GetLocation(Lat, Lon, Alt)

'We need the screen coordinates for map centering calculations -RagmanII
If NOT HadGPSData Then
CenterPixelX = MapPointApp.ActiveMap.LocationToX(LastLocation)
CenterPixelY = MapPointApp.ActiveMap.LocationToY(LastLocation)
End If

-End Change Further down in ns04mappoint.vbs (First line for reference):

If TrackVehicle Then
' Move the visual indicator to the new location.
Set Vehicle.Location = LastLocation
'use CenterVehicle as a number instead of ON/OFF to calculate distance from center of map -RagmanII
If CentreVehicle > 0 Then
' If scanning or first position, center the map on the new location
If ((IsScanning AND ((MapPointApp.ActiveMap.LocationToX(LastLocation)-CenterPixelX) < CentreVehicle OR (MapPointApp.ActiveMap.LocationToX(LastLocation)-CenterPixelX) > (CentreVehicle * -1) OR (MapPointApp.ActiveMap.LocationToY(LastLocation)-CenterPixelY) < CentreVehicle OR (MapPointApp.ActiveMap.LocationToY(LastLocation)-CenterPixelY) > (CentreVehicle * -1))) Or Not HadGPSData) Then
UpdateCurrentLocation Lat, Lon ' by Laidback 030504
'Just in case the user changed resolutions/changed windows size/location.
CenterPixelX = MapPointApp.ActiveMap.LocationToX(LastLocation)
CenterPixelY = MapPointApp.ActiveMap.LocationToY(LastLocation)
End If
End If
End If
HadGPSData = True
End Sub

-End Change Replace all the way through the End Sub.

You can use any number for the center. It is a box, not a circle, so 150 is 300 pixels wide. If you change that to 300 then the box would be 600 pixels wide and 600 tall. If you put in too big of a number then the screen will only refresh when your car is no longer seen on the map.

I started all this because I wanted to be able to calculate a route and if I went off track then it would recalculate the route. With all the screen redraws it was difficult to see what route I should be on. I have that part done with one error. When you get on a highway it recalculates the route wrong. (I guess MS decided that you cant start a route from a highway, so I am redoing that part so that the route will not recalculate until you actually go off track.

I know... you say use AGPS to do that. Yeah.. one problem. Speed. With the screen redraws and APGS my laptop is so slow it starts falling behind. It gets even worse with voice turned on. I could have also done some optimization but I want to complete it first with the route script. I have all the calculations in my head for completing this but I just need to find the few hours it will take to code. I also want to add voice so that when you approach a turn it will automagicaly say where to turn. Well that’s enough for now, I need to get back to my real job. BTW, I did import those changes into "20041124 - master script.zip" and they seemed to work, but I didn’t test it with my laptop so YMMV.

If anyone knows of this already being done let me know. I have not found a script that will recalculate routes like what I am trying to do. Thanks!

-RagManII
ragmanii is offline   Reply With Quote