Select/delete tracks
This commit is contained in:
360
PBMap.pb
360
PBMap.pb
@@ -52,7 +52,10 @@ DeclareModule PBMap
|
|||||||
Declare SetCallBackLocation(*CallBackLocation)
|
Declare SetCallBackLocation(*CallBackLocation)
|
||||||
Declare SetCallBackMainPointer(CallBackMainPointer.i)
|
Declare SetCallBackMainPointer(CallBackMainPointer.i)
|
||||||
Declare SetMapScaleUnit(ScaleUnit=PBMAP::#SCALE_KM)
|
Declare SetMapScaleUnit(ScaleUnit=PBMAP::#SCALE_KM)
|
||||||
Declare LoadGpxFile(file.s);
|
Declare.i LoadGpxFile(file.s);
|
||||||
|
Declare ClearTracks()
|
||||||
|
Declare DeleteTrack(*Ptr)
|
||||||
|
Declare DeleteSelectedTracks()
|
||||||
Declare.i AddMarker(Latitude.d, Longitude.d, Legend.s = "", color.l=-1, CallBackPointer.i = -1)
|
Declare.i AddMarker(Latitude.d, Longitude.d, Legend.s = "", color.l=-1, CallBackPointer.i = -1)
|
||||||
Declare ClearMarkers()
|
Declare ClearMarkers()
|
||||||
Declare DeleteMarker(*Ptr)
|
Declare DeleteMarker(*Ptr)
|
||||||
@@ -167,8 +170,12 @@ Module PBMap
|
|||||||
MaxMemCache.i ; in MiB
|
MaxMemCache.i ; in MiB
|
||||||
ShowMarkersNb.i
|
ShowMarkersNb.i
|
||||||
ShowMarkersLegend.i
|
ShowMarkersLegend.i
|
||||||
|
;Drawing stuff
|
||||||
|
StrokeWidthTrackDefault.i
|
||||||
;Colours
|
;Colours
|
||||||
ColourFocus.i
|
ColourFocus.i
|
||||||
|
ColourSelected.i
|
||||||
|
ColourTrackDefault.i
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
Structure Layer
|
Structure Layer
|
||||||
@@ -187,6 +194,11 @@ Module PBMap
|
|||||||
Structure Tracks
|
Structure Tracks
|
||||||
List Track.GeographicCoordinates() ; To display a GPX track
|
List Track.GeographicCoordinates() ; To display a GPX track
|
||||||
BoundingBox.Box
|
BoundingBox.Box
|
||||||
|
Visible.i
|
||||||
|
Focus.i
|
||||||
|
Selected.i
|
||||||
|
Colour.i
|
||||||
|
StrokeWidth.i
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
;-PBMap Structure
|
;-PBMap Structure
|
||||||
@@ -418,8 +430,14 @@ Module PBMap
|
|||||||
SelBool(ShowMarkersLegend)
|
SelBool(ShowMarkersLegend)
|
||||||
Case "showtrackkms"
|
Case "showtrackkms"
|
||||||
SelBool(ShowTrackKms)
|
SelBool(ShowTrackKms)
|
||||||
|
Case "strokewidthtrackdefault"
|
||||||
|
SelBool(StrokeWidthTrackDefault)
|
||||||
Case "colourfocus"
|
Case "colourfocus"
|
||||||
PBMap\Options\ColourFocus = ColourString2Value(Value)
|
PBMap\Options\ColourFocus = ColourString2Value(Value)
|
||||||
|
Case "colourselected"
|
||||||
|
PBMap\Options\ColourSelected = ColourString2Value(Value)
|
||||||
|
Case "colourtrackdefault"
|
||||||
|
PBMap\Options\ColourTrackDefault = ColourString2Value(Value)
|
||||||
EndSelect
|
EndSelect
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
@@ -452,8 +470,12 @@ Module PBMap
|
|||||||
WritePreferenceInteger("ShowTrackKms", \ShowTrackKms)
|
WritePreferenceInteger("ShowTrackKms", \ShowTrackKms)
|
||||||
WritePreferenceInteger("ShowMarkersNb", \ShowMarkersNb)
|
WritePreferenceInteger("ShowMarkersNb", \ShowMarkersNb)
|
||||||
WritePreferenceInteger("ShowMarkersLegend", \ShowMarkersLegend)
|
WritePreferenceInteger("ShowMarkersLegend", \ShowMarkersLegend)
|
||||||
|
PreferenceGroup("DRAWING")
|
||||||
|
WritePreferenceInteger("StrokeWidthTrackDefault", \StrokeWidthTrackDefault)
|
||||||
;Colours;
|
;Colours;
|
||||||
WritePreferenceInteger("ColourFocus", \ColourFocus)
|
WritePreferenceInteger("ColourFocus", \ColourFocus)
|
||||||
|
WritePreferenceInteger("ColourSelected", \ColourSelected)
|
||||||
|
WritePreferenceInteger("ColourTrackDefault", \ColourTrackDefault)
|
||||||
ClosePreferences()
|
ClosePreferences()
|
||||||
EndWith
|
EndWith
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -503,9 +525,13 @@ Module PBMap
|
|||||||
\ShowTrackKms = ReadPreferenceInteger("ShowTrackKms", #False)
|
\ShowTrackKms = ReadPreferenceInteger("ShowTrackKms", #False)
|
||||||
\ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True)
|
\ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True)
|
||||||
\ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False)
|
\ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False)
|
||||||
\TimerInterval = 20
|
PreferenceGroup("DRAWING")
|
||||||
|
\StrokeWidthTrackDefault = ReadPreferenceInteger("StrokeWidthTrackDefault", 10)
|
||||||
PreferenceGroup("COLOURS")
|
PreferenceGroup("COLOURS")
|
||||||
\ColourFocus = ReadPreferenceInteger("ColourFocus", RGBA(255, 255, 0, 255))
|
\ColourFocus = ReadPreferenceInteger("ColourFocus", RGBA(255, 255, 0, 255))
|
||||||
|
\ColourSelected = ReadPreferenceInteger("ColourSelected", RGBA(225, 225, 0, 255))
|
||||||
|
\ColourTrackDefault = ReadPreferenceInteger("ColourTrackDefault", RGBA(0, 255, 0, 150))
|
||||||
|
\TimerInterval = 20
|
||||||
ClosePreferences()
|
ClosePreferences()
|
||||||
EndWith
|
EndWith
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -633,11 +659,7 @@ Module PBMap
|
|||||||
Procedure.d ClipLongitude(Longitude.d)
|
Procedure.d ClipLongitude(Longitude.d)
|
||||||
ProcedureReturn Mod(Mod(Longitude + 180, 360.0) + 360.0, 360.0) - 180
|
ProcedureReturn Mod(Mod(Longitude + 180, 360.0) + 360.0, 360.0) - 180
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
; Procedure.d Positivise(Value.d)
|
|
||||||
; ProcedureReturn Mod(Mod(Value, 360) + 360.0, 360)
|
|
||||||
; EndProcedure
|
|
||||||
|
|
||||||
;Lat Lon coordinates 2 pixel absolute [0 to 2^Zoom * TileSize [
|
;Lat Lon coordinates 2 pixel absolute [0 to 2^Zoom * TileSize [
|
||||||
Procedure LatLon2Pixel(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom)
|
Procedure LatLon2Pixel(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom)
|
||||||
Protected tilemax = Pow(2.0, Zoom) * PBMap\TileSize
|
Protected tilemax = Pow(2.0, Zoom) * PBMap\TileSize
|
||||||
@@ -708,37 +730,37 @@ Module PBMap
|
|||||||
*Pixel\y=GadgetHeight(PBMap\Gadget)/2 - (y2-y1)
|
*Pixel\y=GadgetHeight(PBMap\Gadget)/2 - (y2-y1)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure LoadGpxFile(file.s)
|
Procedure IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates)
|
||||||
If LoadXML(0, file.s)
|
Protected Lat.d = *Position\Latitude, Lon.d = *Position\Longitude
|
||||||
Protected Message.s
|
Protected LatNW.d = *Drawing\Bounds\NorthWest\Latitude, LonNW.d = *Drawing\Bounds\NorthWest\Longitude
|
||||||
If XMLStatus(0) <> #PB_XML_Success
|
Protected LatSE.d = *Drawing\Bounds\SouthEast\Latitude, LonSE.d = *Drawing\Bounds\SouthEast\Longitude
|
||||||
Message = "Error in the XML file:" + Chr(13)
|
If LatSE > LatNW
|
||||||
Message + "Message: " + XMLError(0) + Chr(13)
|
Debug "WTF"
|
||||||
Message + "Line: " + Str(XMLErrorLine(0)) + " Character: " + Str(XMLErrorPosition(0))
|
CallDebugger
|
||||||
MessageRequester("Error", Message)
|
|
||||||
EndIf
|
|
||||||
Protected *MainNode,*subNode,*child,child.l
|
|
||||||
*MainNode=MainXMLNode(0)
|
|
||||||
*MainNode=XMLNodeFromPath(*MainNode,"/gpx/trk/trkseg")
|
|
||||||
Protected *NewTrack.Tracks = AddElement(PBMap\TracksList())
|
|
||||||
For child = 1 To XMLChildCount(*MainNode)
|
|
||||||
*child = ChildXMLNode(*MainNode, child)
|
|
||||||
AddElement(*NewTrack\Track())
|
|
||||||
If ExamineXMLAttributes(*child)
|
|
||||||
While NextXMLAttribute(*child)
|
|
||||||
Select XMLAttributeName(*child)
|
|
||||||
Case "lat"
|
|
||||||
*NewTrack\Track()\Latitude=ValD(XMLAttributeValue(*child))
|
|
||||||
Case "lon"
|
|
||||||
*NewTrack\Track()\Longitude=ValD(XMLAttributeValue(*child))
|
|
||||||
EndSelect
|
|
||||||
Wend
|
|
||||||
EndIf
|
|
||||||
Next
|
|
||||||
ZoomToTracks(LastElement(PBMap\TracksList())) ; <-To center the view, and zoom on the tracks
|
|
||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
If Lat >= LatSE And Lat <= LatNW
|
||||||
|
If *Drawing\Width >= 360
|
||||||
|
ProcedureReturn #True
|
||||||
|
Else
|
||||||
|
If LonNW < LonSE
|
||||||
|
If Lon >= LonNW And Lon <= LonSE
|
||||||
|
ProcedureReturn #True
|
||||||
|
Else
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndIf
|
||||||
|
Else
|
||||||
|
If (Lon >= -180 And Lon <= LonSE) Or (Lon >= LonNW And Lon <= 180)
|
||||||
|
ProcedureReturn #True
|
||||||
|
Else
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Else
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
;-*** These are threaded
|
;-*** These are threaded
|
||||||
Procedure.i GetTileFromHDD(CacheFile.s)
|
Procedure.i GetTileFromHDD(CacheFile.s)
|
||||||
Protected nImage.i
|
Protected nImage.i
|
||||||
@@ -1068,65 +1090,137 @@ Module PBMap
|
|||||||
DrawVectorText(Str(dist))
|
DrawVectorText(Str(dist))
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure DeleteTrack(*Ptr)
|
||||||
|
If *Ptr
|
||||||
|
ChangeCurrentElement(PBMap\TracksList(), *Ptr)
|
||||||
|
DeleteElement(PBMap\TracksList())
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure DeleteSelectedTracks()
|
||||||
|
ForEach PBMap\TracksList()
|
||||||
|
If PBMap\TracksList()\Selected
|
||||||
|
DeleteElement(PBMap\TracksList())
|
||||||
|
PBMap\Redraw = #True
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure ClearTracks()
|
||||||
|
ClearList(PBMap\TracksList())
|
||||||
|
PBMap\Redraw = #True
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure DrawTracks(*Drawing.DrawingParameters)
|
Procedure DrawTracks(*Drawing.DrawingParameters)
|
||||||
Protected Pixel.PixelCoordinates
|
Protected Pixel.PixelCoordinates
|
||||||
Protected Location.GeographicCoordinates
|
Protected Location.GeographicCoordinates
|
||||||
Protected km.f, memKm.i
|
Protected km.f, memKm.i
|
||||||
With PBMap\TracksList()
|
With PBMap\TracksList()
|
||||||
;Trace Track
|
;Trace Track
|
||||||
If ListSize(PBMap\TracksList()) > 0
|
If ListSize(PBMap\TracksList()) > 0
|
||||||
BeginVectorLayer()
|
BeginVectorLayer()
|
||||||
ForEach PBMap\TracksList()
|
ForEach PBMap\TracksList()
|
||||||
If ListSize(\Track()) > 0
|
If ListSize(\Track()) > 0
|
||||||
ForEach \Track()
|
;Check visibility
|
||||||
;If *Drawing\GeographicCoordinates\Latitude<>0 And *Drawing\GeographicCoordinates\Longitude<>0
|
\Visible = #False
|
||||||
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
ForEach \Track()
|
||||||
If ListIndex(\Track()) = 0
|
If IsInDrawingBoundaries(*Drawing, @PBMap\TracksList()\Track())
|
||||||
MovePathCursor(Pixel\X, Pixel\Y)
|
\Visible = #True
|
||||||
Else
|
Break
|
||||||
AddPathLine(Pixel\X, Pixel\Y)
|
EndIf
|
||||||
EndIf
|
Next
|
||||||
;EndIf
|
If \Visible
|
||||||
Next
|
;Draw tracks
|
||||||
; \BoundingBox\x = PathBoundsX()
|
ForEach \Track()
|
||||||
; \BoundingBox\y = PathBoundsY()
|
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
||||||
; \BoundingBox\w = PathBoundsWidth()
|
If ListIndex(\Track()) = 0
|
||||||
; \BoundingBox\h = PathBoundsHeight()
|
MovePathCursor(Pixel\X, Pixel\Y)
|
||||||
VectorSourceColor(RGBA(0, 255, 0, 150))
|
Else
|
||||||
StrokePath(10, #PB_Path_RoundEnd|#PB_Path_RoundCorner)
|
AddPathLine(Pixel\X, Pixel\Y)
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
EndVectorLayer()
|
; \BoundingBox\x = PathBoundsX()
|
||||||
EndIf
|
; \BoundingBox\y = PathBoundsY()
|
||||||
;Draw Distance
|
; \BoundingBox\w = PathBoundsWidth()
|
||||||
If PBMap\Options\ShowTrackKms And ListSize(PBMap\TracksList()) > 0
|
; \BoundingBox\h = PathBoundsHeight()
|
||||||
BeginVectorLayer()
|
If \Focus
|
||||||
ForEach PBMap\TracksList()
|
VectorSourceColor(PBMap\Options\ColourFocus)
|
||||||
km = 0 : memKm = -1
|
ElseIf \Selected
|
||||||
ForEach PBMap\TracksList()\Track()
|
VectorSourceColor(PBMap\Options\ColourSelected)
|
||||||
;Test Distance
|
Else
|
||||||
If ListIndex(\Track()) = 0
|
VectorSourceColor(\Colour)
|
||||||
Location\Latitude = \Track()\Latitude
|
EndIf
|
||||||
Location\Longitude = \Track()\Longitude
|
StrokePath(\StrokeWidth, #PB_Path_RoundEnd|#PB_Path_RoundCorner)
|
||||||
Else
|
EndIf
|
||||||
km = km + HaversineInKM(@Location, @PBMap\TracksList()\Track())
|
|
||||||
Location\Latitude = \Track()\Latitude
|
|
||||||
Location\Longitude = \Track()\Longitude
|
|
||||||
EndIf
|
|
||||||
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
|
||||||
If Int(km) <> memKm
|
|
||||||
memKm = Int(km)
|
|
||||||
If PBMap\Zoom > 10
|
|
||||||
TrackPointer(Pixel\X , Pixel\Y, Int(km))
|
|
||||||
EndIf
|
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
Next
|
EndVectorLayer()
|
||||||
EndVectorLayer()
|
;Draw distances
|
||||||
EndIf
|
If PBMap\Options\ShowTrackKms
|
||||||
|
BeginVectorLayer()
|
||||||
|
ForEach PBMap\TracksList()
|
||||||
|
If \Visible
|
||||||
|
km = 0 : memKm = -1
|
||||||
|
ForEach PBMap\TracksList()\Track()
|
||||||
|
;Test Distance
|
||||||
|
If ListIndex(\Track()) = 0
|
||||||
|
Location\Latitude = \Track()\Latitude
|
||||||
|
Location\Longitude = \Track()\Longitude
|
||||||
|
Else
|
||||||
|
km = km + HaversineInKM(@Location, @PBMap\TracksList()\Track())
|
||||||
|
Location\Latitude = \Track()\Latitude
|
||||||
|
Location\Longitude = \Track()\Longitude
|
||||||
|
EndIf
|
||||||
|
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
||||||
|
If Int(km) <> memKm
|
||||||
|
memKm = Int(km)
|
||||||
|
If PBMap\Zoom > 10
|
||||||
|
TrackPointer(Pixel\X , Pixel\Y, Int(km))
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
EndVectorLayer()
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
EndWith
|
EndWith
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure.i LoadGpxFile(file.s)
|
||||||
|
If LoadXML(0, file.s)
|
||||||
|
Protected Message.s
|
||||||
|
If XMLStatus(0) <> #PB_XML_Success
|
||||||
|
Message = "Error in the XML file:" + Chr(13)
|
||||||
|
Message + "Message: " + XMLError(0) + Chr(13)
|
||||||
|
Message + "Line: " + Str(XMLErrorLine(0)) + " Character: " + Str(XMLErrorPosition(0))
|
||||||
|
MessageRequester("Error", Message)
|
||||||
|
EndIf
|
||||||
|
Protected *MainNode,*subNode,*child,child.l
|
||||||
|
*MainNode=MainXMLNode(0)
|
||||||
|
*MainNode=XMLNodeFromPath(*MainNode,"/gpx/trk/trkseg")
|
||||||
|
Protected *NewTrack.Tracks = AddElement(PBMap\TracksList())
|
||||||
|
PBMap\TracksList()\StrokeWidth = PBMap\Options\StrokeWidthTrackDefault
|
||||||
|
PBMap\TracksList()\Colour = PBMap\Options\ColourTrackDefault
|
||||||
|
For child = 1 To XMLChildCount(*MainNode)
|
||||||
|
*child = ChildXMLNode(*MainNode, child)
|
||||||
|
AddElement(*NewTrack\Track())
|
||||||
|
If ExamineXMLAttributes(*child)
|
||||||
|
While NextXMLAttribute(*child)
|
||||||
|
Select XMLAttributeName(*child)
|
||||||
|
Case "lat"
|
||||||
|
*NewTrack\Track()\Latitude=ValD(XMLAttributeValue(*child))
|
||||||
|
Case "lon"
|
||||||
|
*NewTrack\Track()\Longitude=ValD(XMLAttributeValue(*child))
|
||||||
|
EndSelect
|
||||||
|
Wend
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
ZoomToTracks(LastElement(PBMap\TracksList())) ; <-To center the view, and zoom on the tracks
|
||||||
|
ProcedureReturn *NewTrack
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure DrawMarker(x.i, y.i, Nb, Color.l, Legend.s, Focus.i, Selected.i)
|
Procedure DrawMarker(x.i, y.i, Nb, Color.l, Legend.s, Focus.i, Selected.i)
|
||||||
;Nice marker by yves86
|
;Nice marker by yves86
|
||||||
VectorSourceColor(color)
|
VectorSourceColor(color)
|
||||||
@@ -1143,7 +1237,7 @@ Module PBMap
|
|||||||
VectorSourceColor(PBMap\Options\ColourFocus)
|
VectorSourceColor(PBMap\Options\ColourFocus)
|
||||||
StrokePath(3)
|
StrokePath(3)
|
||||||
ElseIf Selected
|
ElseIf Selected
|
||||||
VectorSourceColor(PBMap\Options\ColourFocus)
|
VectorSourceColor(PBMap\Options\ColourSelected)
|
||||||
StrokePath(4)
|
StrokePath(4)
|
||||||
Else
|
Else
|
||||||
VectorSourceColor(Color)
|
VectorSourceColor(Color)
|
||||||
@@ -1181,11 +1275,15 @@ Module PBMap
|
|||||||
|
|
||||||
Procedure ClearMarkers()
|
Procedure ClearMarkers()
|
||||||
ClearList(PBMap\Markers())
|
ClearList(PBMap\Markers())
|
||||||
|
PBMap\Redraw = #True
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure DeleteMarker(*Ptr)
|
Procedure DeleteMarker(*Ptr)
|
||||||
ChangeCurrentElement(PBMap\Markers(), *Ptr)
|
If *Ptr
|
||||||
DeleteElement(PBMap\Markers())
|
ChangeCurrentElement(PBMap\Markers(), *Ptr)
|
||||||
|
DeleteElement(PBMap\Markers())
|
||||||
|
PBMap\Redraw = #True
|
||||||
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure DeleteSelectedMarkers()
|
Procedure DeleteSelectedMarkers()
|
||||||
@@ -1209,38 +1307,7 @@ Module PBMap
|
|||||||
ProcedureReturn *Ptr
|
ProcedureReturn *Ptr
|
||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates)
|
|
||||||
Protected Lat.d = *Position\Latitude, Lon.d = *Position\Longitude
|
|
||||||
Protected LatNW.d = *Drawing\Bounds\NorthWest\Latitude, LonNW.d = *Drawing\Bounds\NorthWest\Longitude
|
|
||||||
Protected LatSE.d = *Drawing\Bounds\SouthEast\Latitude, LonSE.d = *Drawing\Bounds\SouthEast\Longitude
|
|
||||||
If LatSE > LatNW
|
|
||||||
Debug "WTF"
|
|
||||||
CallDebugger
|
|
||||||
EndIf
|
|
||||||
If Lat >= LatSE And Lat <= LatNW
|
|
||||||
If *Drawing\Width >= 360
|
|
||||||
ProcedureReturn #True
|
|
||||||
Else
|
|
||||||
If LonNW < LonSE
|
|
||||||
If Lon >= LonNW And Lon <= LonSE
|
|
||||||
ProcedureReturn #True
|
|
||||||
Else
|
|
||||||
ProcedureReturn #False
|
|
||||||
EndIf
|
|
||||||
Else
|
|
||||||
If (Lon >= -180 And Lon <= LonSE) Or (Lon >= LonNW And Lon <= 180)
|
|
||||||
ProcedureReturn #True
|
|
||||||
Else
|
|
||||||
ProcedureReturn #False
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
Else
|
|
||||||
ProcedureReturn #False
|
|
||||||
EndIf
|
|
||||||
EndProcedure
|
|
||||||
|
|
||||||
; Draw all markers
|
; Draw all markers
|
||||||
Procedure DrawMarkers(*Drawing.DrawingParameters)
|
Procedure DrawMarkers(*Drawing.DrawingParameters)
|
||||||
Protected Pixel.PixelCoordinates
|
Protected Pixel.PixelCoordinates
|
||||||
@@ -1256,7 +1323,7 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure DrawDebugInfos(*Drawing.DrawingParameters)
|
Procedure DrawDebugInfos(*Drawing.DrawingParameters)
|
||||||
; Display how many images in cache
|
; Display how many images in cache
|
||||||
@@ -1558,6 +1625,7 @@ Module PBMap
|
|||||||
Protected MouseX.i, MouseY.i
|
Protected MouseX.i, MouseY.i
|
||||||
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
||||||
Protected key.s, Touch.i
|
Protected key.s, Touch.i
|
||||||
|
Protected Pixel.PixelCoordinates
|
||||||
Static CtrlKey
|
Static CtrlKey
|
||||||
PBMap\Moving = #False
|
PBMap\Moving = #False
|
||||||
Select EventType()
|
Select EventType()
|
||||||
@@ -1565,6 +1633,7 @@ Module PBMap
|
|||||||
Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key)
|
Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key)
|
||||||
Case #PB_Shortcut_Delete
|
Case #PB_Shortcut_Delete
|
||||||
DeleteSelectedMarkers()
|
DeleteSelectedMarkers()
|
||||||
|
DeleteSelectedTracks()
|
||||||
EndSelect
|
EndSelect
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control = 0
|
If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control = 0
|
||||||
@@ -1651,6 +1720,16 @@ Module PBMap
|
|||||||
PBMap\Markers()\Focus = #False
|
PBMap\Markers()\Focus = #False
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
|
;Check if we select track(s)
|
||||||
|
ForEach PBMap\TracksList()
|
||||||
|
If CtrlKey = #False
|
||||||
|
PBMap\TracksList()\Selected = #False ;If no CTRL key, deselect everything and select only the focused track
|
||||||
|
EndIf
|
||||||
|
If PBMap\TracksList()\Focus
|
||||||
|
PBMap\TracksList()\Selected = #True
|
||||||
|
PBMap\TracksList()\Focus = #False
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
EndIf
|
EndIf
|
||||||
;Mem cursor Coord
|
;Mem cursor Coord
|
||||||
PBMap\MoveStartingPoint\x = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
PBMap\MoveStartingPoint\x = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
||||||
@@ -1692,8 +1771,8 @@ Module PBMap
|
|||||||
MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
||||||
;Clip MouseX to the map range (in X, the map is infinite)
|
;Clip MouseX to the map range (in X, the map is infinite)
|
||||||
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
||||||
;Check if mouse touch markers
|
|
||||||
If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT
|
If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT
|
||||||
|
;Check if mouse touch markers
|
||||||
ForEach PBMap\Markers()
|
ForEach PBMap\Markers()
|
||||||
LatLon2Pixel(@PBMap\Markers()\GeographicCoordinates, @MarkerCoords, PBMap\Zoom)
|
LatLon2Pixel(@PBMap\Markers()\GeographicCoordinates, @MarkerCoords, PBMap\Zoom)
|
||||||
If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8
|
If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8
|
||||||
@@ -1704,6 +1783,35 @@ Module PBMap
|
|||||||
;EndIf
|
;EndIf
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
|
;Check if mouse touch tracks
|
||||||
|
With PBMap\TracksList()
|
||||||
|
;Trace Track
|
||||||
|
If ListSize(PBMap\TracksList()) > 0
|
||||||
|
ForEach PBMap\TracksList()
|
||||||
|
If ListSize(\Track()) > 0
|
||||||
|
If \Visible
|
||||||
|
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||||
|
;Draw tracks
|
||||||
|
ForEach \Track()
|
||||||
|
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
||||||
|
If ListIndex(\Track()) = 0
|
||||||
|
MovePathCursor(Pixel\X, Pixel\Y)
|
||||||
|
Else
|
||||||
|
AddPathLine(Pixel\X, Pixel\Y)
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
If IsInsideStroke(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY), \StrokeWidth)
|
||||||
|
\Focus = #True
|
||||||
|
Else
|
||||||
|
\Focus = #False
|
||||||
|
EndIf
|
||||||
|
StopVectorDrawing()
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
EndIf
|
||||||
|
EndWith
|
||||||
|
|
||||||
EndIf
|
EndIf
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
EndIf
|
EndIf
|
||||||
@@ -1931,8 +2039,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
CompilerEndIf
|
CompilerEndIf
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.50 (Windows - x64)
|
; IDE Options = PureBasic 5.50 (Windows - x64)
|
||||||
; CursorPosition = 638
|
; CursorPosition = 55
|
||||||
; FirstLine = 636
|
; FirstLine = 34
|
||||||
; Folding = -------------
|
; Folding = --------------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
Reference in New Issue
Block a user