diff --git a/Forms/MarkerEdit.pbf b/Forms/MarkerEdit.pbf new file mode 100644 index 0000000..4d94df9 --- /dev/null +++ b/Forms/MarkerEdit.pbf @@ -0,0 +1,40 @@ +; +; This code is automatically generated by the FormDesigner. +; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled. +; Event procedures needs to be put in another source file. +; + +Global WindowMarkerEdit + +Global TextIdentifier, TextLegend, StringIdentifier, EditorLegend + + +Procedure OpenWindowMarkerEdit(x = 0, y = 0, width = 300, height = 100) + WindowMarkerEdit = OpenWindow(#PB_Any, x, y, width, height, Marker Edit, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_WindowCentered | #PB_Window_NoGadgets) + TextIdentifier = TextGadget(#PB_Any, 2, 2, 80, 25, Identifier) + TextLegend = TextGadget(#PB_Any, 2, 27, 80, 25, Legend) + StringIdentifier = StringGadget(#PB_Any, 84, 2, 120, 25, "") + EditorLegend = EditorGadget(#PB_Any, 84, 27, 210, 70) +EndProcedure + +Procedure WindowMarkerEdit_Events(event) + Select event + Case #PB_Event_CloseWindow + ProcedureReturn #False + + Case #PB_Event_Menu + Select EventMenu() + EndSelect + + Case #PB_Event_Gadget + Select EventGadget() + EndSelect + EndSelect + ProcedureReturn #True +EndProcedure + + +; IDE Options = PureBasic 5.50 (Windows - x64) +; CursorPosition = 11 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/PBMap.pb b/PBMap.pb index 2f9aaa1..91c0c67 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -1,18 +1,15 @@ -;************************************************************** +;******************************************************************** ; Program: PBMap ; Description: Permits the use of tiled maps like ; OpenStreetMap in a handy PureBASIC module -; Author: Thyphoon, Djes And Idle -; Date: Mai 17, 2016 -; License: Free, unrestricted, credit appreciated -; but not required. +; Author: Thyphoon, djes And Idle +; Date: March, 2017 +; License: PBMap : Free, unrestricted, credit +; appreciated but not required. +; OSM : see http://www.openstreetmap.org/copyright ; Note: Please share improvement ! -; Thanks: Progi1984 -; Usage: Change the Proxy global variables if needed -; (see also Proxy Details) -;************************************************************** - -;#Red = 255 +; Thanks: Progi1984, yves86 +;******************************************************************** CompilerIf #PB_Compiler_Thread = #False MessageRequester("Warning !!","You must enable ThreadSafe support in compiler options",#PB_MessageRequester_Ok ) @@ -25,12 +22,22 @@ InitNetwork() UsePNGImageDecoder() UsePNGImageEncoder() -DeclareModule PBMap - #Red = 255 +DeclareModule PBMap + ;-Show debug infos + Global MyDebugLevel = 0 - ;-Show debug infos - Global Verbose = 0 - Global MyDebugLevel = 5 + CompilerIf #PB_Compiler_OS = #PB_OS_Linux + #Red = 255 + CompilerEndIf + + Global slash.s + + CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Windows + slash = "\" + CompilerDefault + slash = "/" + CompilerEndSelect #SCALE_NAUTICAL = 1 #SCALE_KM = 0 @@ -40,6 +47,8 @@ DeclareModule PBMap #MODE_SELECT = 2 #MODE_EDIT = 3 + #MARKER_EDIT_EVENT = #PB_Event_FirstCustomValue + ;-Declarations Declare InitPBMap(window) Declare SetOption(Option.s, Value.s) @@ -47,17 +56,23 @@ DeclareModule PBMap Declare SaveOptions(PreferencesFile.s = "PBMap.prefs") Declare.i AddMapServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/", TileSize = 256, ZoomMin = 0, ZoomMax = 18) Declare DeleteLayer(Nb.i) + Declare BindMapGadget(Gadget.i) Declare MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i) Declare SetLocation(latitude.d, longitude.d, Zoom = -1, mode.i = #PB_Absolute) Declare Drawing() + Declare SetAngle(Angle.d, Mode = #PB_Absolute) Declare SetZoom(Zoom.i, mode.i = #PB_Relative) Declare ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d) Declare ZoomToTracks(*Tracks) Declare SetCallBackLocation(*CallBackLocation) Declare SetCallBackMainPointer(CallBackMainPointer.i) Declare SetMapScaleUnit(ScaleUnit=PBMAP::#SCALE_KM) - Declare LoadGpxFile(file.s); - Declare.i AddMarker(Latitude.d, Longitude.d, Legend.s = "", color.l=-1, CallBackPointer.i = -1) + Declare.i LoadGpxFile(file.s); + Declare ClearTracks() + Declare DeleteTrack(*Ptr) + Declare DeleteSelectedTracks() + Declare SetTrackColour(*Ptr, Colour.i) + Declare.i AddMarker(Latitude.d, Longitude.d, Identifier.s = "", Legend.s = "", color.l=-1, CallBackPointer.i = -1) Declare ClearMarkers() Declare DeleteMarker(*Ptr) Declare DeleteSelectedMarkers() @@ -68,7 +83,12 @@ DeclareModule PBMap Declare.d GetLongitude() Declare.d MouseLatitude() Declare.d MouseLongitude() + Declare.d GetAngle() Declare.i GetZoom() + Declare.i GetMode() + Declare SetMode(Mode.i = #MODE_DEFAULT) + Declare NominatimGeoLocationQuery(Address.s, *ReturnPosition= 0) ;Send back the position *ptr.GeographicCoordinates + Declare.i ClearDiskCache() EndDeclareModule Module PBMap @@ -81,8 +101,8 @@ Module PBMap EndStructure Structure PixelCoordinates - x.i - y.i + x.d + y.d EndStructure Structure Coordinates @@ -92,32 +112,32 @@ Module PBMap ;- Tile Structure Structure Tile - Position.Coordinates - PBMapTileX.i - PBMapTileY.i - PBMapZoom.i nImage.i key.s + URL.s CacheFile.s GetImageThread.i RetryNb.i - ServerURL.s EndStructure - Structure TileBounds - NorthWest.Coordinates - SouthEast.Coordinates + Structure BoundingBox + NorthWest.GeographicCoordinates + SouthEast.GeographicCoordinates + BottomRight.PixelCoordinates + TopLeft.PixelCoordinates EndStructure Structure DrawingParameters - TileCoordinates.Coordinates - Bounds.TileBounds Canvas.i + RadiusX.d ; Canvas radius, or center in pixels + RadiusY.d + GeographicCoordinates.GeographicCoordinates ; Real center in lat/lon + TileCoordinates.Coordinates ; Center coordinates in tile.decimal + Bounds.BoundingBox ; Drawing boundaries in lat/lon + Width.d ; Drawing width in degrees + Height.d ; Drawing height in degrees PBMapZoom.i - GeographicCoordinates.GeographicCoordinates - CenterX.i - CenterY.i - DeltaX.i + DeltaX.i ; Screen relative pixels tile shift DeltaY.i Dirty.i End.i @@ -127,6 +147,7 @@ Module PBMap nImage.i *Tile.Tile TimeStackPosition.i + Alpha.i EndStructure Structure ImgMemCachKey @@ -140,13 +161,16 @@ Module PBMap Structure Marker GeographicCoordinates.GeographicCoordinates ; Marker latitude and longitude + Identifier.s Legend.s Color.l ; Marker color Focus.i Selected.i ; Is the marker selected ? CallBackPointer.i ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib) + EditWindow.i EndStructure + ;-Options Structure Option HDDCachePath.s ; Path where to load and save tiles downloaded from server DefaultOSMServer.s ; Base layer OSM server @@ -161,13 +185,21 @@ Module PBMap ShowDebugInfos.i ShowScale.i ShowTrack.i + ShowTrackKms.i ShowMarkers.i ShowPointer.i TimerInterval.i MaxMemCache.i ; in MiB - TrackShowKms.i + Verbose.i ; Maximum debug informations + Warning.i ; Warning requesters ShowMarkersNb.i ShowMarkersLegend.i + ;Drawing stuff + StrokeWidthTrackDefault.i + ;Colours + ColourFocus.i + ColourSelected.i + ColourTrackDefault.i EndStructure Structure Layer @@ -176,9 +208,23 @@ Module PBMap ServerURL.s ; Web URL ex: http://tile.openstreetmap.org/ EndStructure + Structure Box + x1.i + y1.i + x2.i + y2.i + EndStructure + Structure Tracks - List Track.GeographicCoordinates() + List Track.GeographicCoordinates() ; To display a GPX track + BoundingBox.Box + Visible.i + Focus.i + Selected.i + Colour.i + StrokeWidth.i EndStructure + ;-PBMap Structure Structure PBMap Window.i ; Parent Window @@ -197,6 +243,7 @@ Module PBMap List Layers.Layer() ; + Angle.d ZoomMin.i ; Min Zoom supported by server ZoomMax.i ; Max Zoom supported by server Zoom.i ; Current zoom @@ -235,71 +282,15 @@ Module PBMap ;Send debug infos to stdout (allowing mixed debug infos with curl or other libs) Procedure MyDebug(msg.s, DbgLevel = 0) - If Verbose And MyDebugLevel >= DbgLevel + If PBMap\Options\Verbose And DbgLevel >= MyDebugLevel PrintN(msg) ;Debug msg EndIf EndProcedure - ;- *** CURL specific - ; (program has To be compiled in console format for curl debug infos) - - IncludeFile "libcurl.pbi" ; https://github.com/deseven/pbsamples/tree/master/crossplatform/libcurl - - ;Curl write callback (needed for win32 dll) - ProcedureC ReceiveHTTPWriteToFileFunction(*ptr, Size.i, NMemB.i, FileHandle.i) - ProcedureReturn WriteData(FileHandle, *ptr, Size * NMemB) - EndProcedure - - Procedure.i CurlReceiveHTTPToFile(URL$, DestFileName$, ProxyURL$="", ProxyPort$="", ProxyUser$="", ProxyPassword$="") - Protected *Buffer, curl.i, Timeout.i, res.i - Protected FileHandle.i - MyDebug("CurlReceiveHTTPToFile from " + URL$ + " " + ProxyURL$ + " " + ProxyPort$ + " " + ProxyUser$, 4) - MyDebug(" to file : " + DestFileName$, 4) - FileHandle = CreateFile(#PB_Any, DestFileName$) - If FileHandle And Len(URL$) - curl = curl_easy_init() - If curl - Timeout = 120 - curl_easy_setopt(curl, #CURLOPT_URL, str2curl(URL$)) - curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0) - curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0) - curl_easy_setopt(curl, #CURLOPT_HEADER, 0) - curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1) - curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout) - curl_easy_setopt(curl, #CURLOPT_VERBOSE, 1) - ;curl_easy_setopt(curl, #CURLOPT_CONNECTTIMEOUT, 60) - If Len(ProxyURL$) - ;curl_easy_setopt(curl, #CURLOPT_HTTPPROXYTUNNEL, #True) - If Len(ProxyPort$) - ProxyURL$ + ":" + ProxyPort$ - EndIf - MyDebug( ProxyURL$) - curl_easy_setopt(curl, #CURLOPT_PROXY, str2curl(ProxyURL$)) - If Len(ProxyUser$) - If Len(ProxyPassword$) - ProxyUser$ + ":" + ProxyPassword$ - EndIf - MyDebug( ProxyUser$) - curl_easy_setopt(curl, #CURLOPT_PROXYUSERPWD, str2curl(ProxyUser$)) - EndIf - EndIf - curl_easy_setopt(curl, #CURLOPT_WRITEDATA, FileHandle) - curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @ReceiveHTTPWriteToFileFunction()) - res = curl_easy_perform(curl) - If res <> #CURLE_OK - MyDebug("CURL problem", 4) - EndIf - curl_easy_cleanup(curl) - Else - MyDebug("Can't init CURL", 4) - EndIf - CloseFile(FileHandle) - ProcedureReturn FileSize(DestFileName$) - EndIf - ProcedureReturn #False - EndProcedure - ;- *** + ;- *** GetText - Translation purpose + ;TODO use this for all text + IncludeFile "gettext.pbi" Procedure TechnicalImagesCreation() ;"Loading" image @@ -352,6 +343,27 @@ Module PBMap EndSelect EndMacro + Procedure.i ColourString2Value(Value.s) + ;TODO : better string check + Protected Col.s = RemoveString(Value, " ") + If Left(Col, 1) = "$" + Protected r.i, g.i, b.i, a.i = 255 + Select Len(Col) + Case 4 ;RGB (eg : "$9BC" + r = Val("$"+Mid(Col, 2, 1)) : g = Val("$"+Mid(Col, 3, 1)) : b = Val("$"+Mid(Col, 4, 1)) + Case 5 ;RGBA (eg : "$9BC5") + r = Val("$"+Mid(Col, 2, 1)) : g = Val("$"+Mid(Col, 3, 1)) : b = Val("$"+Mid(Col, 4, 1)) : a = Val("$"+Mid(Col, 5, 1)) + Case 7 ;RRGGBB (eg : "$95B4C2") + r = Val("$"+Mid(Col, 2, 2)) : g = Val("$"+Mid(Col, 4, 2)) : b = Val("$"+Mid(Col, 6, 2)) + Case 9 ;RRGGBBAA (eg : "$95B4C249") + r = Val("$"+Mid(Col, 2, 2)) : g = Val("$"+Mid(Col, 4, 2)) : b = Val("$"+Mid(Col, 6, 2)) : a = Val("$"+Mid(Col, 8, 2)) + EndSelect + ProcedureReturn RGBA(r, g, b, a) + Else + ProcedureReturn Val(Value) + EndIf + EndProcedure + Procedure SetOption(Option.s, Value.s) Option = StringCheck(Option) Select LCase(Option) @@ -367,6 +379,10 @@ Module PBMap PBMap\Options\HDDCachePath = Value Case "maxmemcache" PBMap\Options\MaxMemCache = Val(Value) + Case "verbose" + SelBool(Verbose) + Case "warning" + SelBool(Warning) Case "wheelmouserelative" SelBool(WheelMouseRelative) Case "showdegrees" @@ -385,8 +401,16 @@ Module PBMap SelBool(ShowMarkersNb) Case "showmarkerslegend" SelBool(ShowMarkersLegend) - Case "trackshowkms" - SelBool(TrackShowKms) + Case "showtrackkms" + SelBool(ShowTrackKms) + Case "strokewidthtrackdefault" + SelBool(StrokeWidthTrackDefault) + Case "colourfocus" + PBMap\Options\ColourFocus = ColourString2Value(Value) + Case "colourselected" + PBMap\Options\ColourSelected = ColourString2Value(Value) + Case "colourtrackdefault" + PBMap\Options\ColourTrackDefault = ColourString2Value(Value) EndSelect EndProcedure @@ -397,28 +421,38 @@ Module PBMap Else CreatePreferences(PreferencesFile) EndIf - PreferenceGroup("PROXY") - WritePreferenceInteger("Proxy", PBMap\Options\Proxy) - WritePreferenceString("ProxyURL", PBMap\Options\ProxyURL) - WritePreferenceString("ProxyPort", PBMap\Options\ProxyPort) - WritePreferenceString("ProxyUser", PBMap\Options\ProxyUser) - PreferenceGroup("URL") - WritePreferenceString("DefaultOSMServer", PBMap\Options\DefaultOSMServer) - PreferenceGroup("PATHS") - WritePreferenceString("TilesCachePath", PBMap\Options\HDDCachePath) - PreferenceGroup("OPTIONS") - WritePreferenceInteger("WheelMouseRelative", PBMap\Options\WheelMouseRelative) - WritePreferenceInteger("MaxMemCache", PBMap\Options\MaxMemCache) - WritePreferenceInteger("ShowDegrees", PBMap\Options\ShowDegrees) - WritePreferenceInteger("ShowDebugInfos", PBMap\Options\ShowDebugInfos) - WritePreferenceInteger("ShowScale", PBMap\Options\ShowScale) - WritePreferenceInteger("ShowMarkers", PBMap\Options\ShowMarkers) - WritePreferenceInteger("ShowPointer", PBMap\Options\ShowPointer) - WritePreferenceInteger("ShowTrack", PBMap\Options\ShowTrack) - WritePreferenceInteger("ShowMarkersNb", PBMap\Options\ShowMarkersNb) - WritePreferenceInteger("ShowMarkersLegend", PBMap\Options\ShowMarkersLegend) - WritePreferenceInteger("TrackShowKms", PBMap\Options\TrackShowKms) - ClosePreferences() + With PBMap\Options + PreferenceGroup("PROXY") + WritePreferenceInteger("Proxy", \Proxy) + WritePreferenceString("ProxyURL", \ProxyURL) + WritePreferenceString("ProxyPort", \ProxyPort) + WritePreferenceString("ProxyUser", \ProxyUser) + PreferenceGroup("URL") + WritePreferenceString("DefaultOSMServer", \DefaultOSMServer) + PreferenceGroup("PATHS") + WritePreferenceString("TilesCachePath", \HDDCachePath) + PreferenceGroup("OPTIONS") + WritePreferenceInteger("WheelMouseRelative", \WheelMouseRelative) + WritePreferenceInteger("MaxMemCache", \MaxMemCache) + WritePreferenceInteger("Verbose", \Verbose) + WritePreferenceInteger("Warning", \Warning) + WritePreferenceInteger("ShowDegrees", \ShowDegrees) + WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos) + WritePreferenceInteger("ShowScale", \ShowScale) + WritePreferenceInteger("ShowMarkers", \ShowMarkers) + WritePreferenceInteger("ShowPointer", \ShowPointer) + WritePreferenceInteger("ShowTrack", \ShowTrack) + WritePreferenceInteger("ShowTrackKms", \ShowTrackKms) + WritePreferenceInteger("ShowMarkersNb", \ShowMarkersNb) + WritePreferenceInteger("ShowMarkersLegend", \ShowMarkersLegend) + PreferenceGroup("DRAWING") + WritePreferenceInteger("StrokeWidthTrackDefault", \StrokeWidthTrackDefault) + ;Colours; + WritePreferenceInteger("ColourFocus", \ColourFocus) + WritePreferenceInteger("ColourSelected", \ColourSelected) + WritePreferenceInteger("ColourTrackDefault", \ColourTrackDefault) + ClosePreferences() + EndWith EndProcedure Procedure LoadOptions(PreferencesFile.s = "PBMap.prefs") @@ -440,69 +474,47 @@ Module PBMap ; WritePreferenceString("ProxyUser", "myproxyname") ; WritePreferenceString("ProxyPass", "myproxypass") ;TODO !Warning! !not encoded! ; ClosePreferences() - PreferenceGroup("PROXY") - PBMap\Options\Proxy = ReadPreferenceInteger("Proxy", #False) - If PBMap\Options\Proxy - PBMap\Options\ProxyURL = ReadPreferenceString("ProxyURL", "") ;InputRequester("ProxyServer", "Do you use a Proxy Server? Then enter the full url:", "") - PBMap\Options\ProxyPort = ReadPreferenceString("ProxyPort", "") ;InputRequester("ProxyPort" , "Do you use a specific port? Then enter it", "") - PBMap\Options\ProxyUser = ReadPreferenceString("ProxyUser", "") ;InputRequester("ProxyUser" , "Do you use a user name? Then enter it", "") - PBMap\Options\ProxyPassword = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO - EndIf - PreferenceGroup("URL") - PBMap\Options\DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") - - PreferenceGroup("PATHS") - PBMap\Options\HDDCachePath = ReadPreferenceString("TilesCachePath", GetTemporaryDirectory()) - PreferenceGroup("OPTIONS") - PBMap\Options\WheelMouseRelative = ReadPreferenceInteger("WheelMouseRelative", #True) - PBMap\Options\MaxMemCache = ReadPreferenceInteger("MaxMemCache", 20480) ;20 MiB, about 80 tiles in memory - PBMap\Options\ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False) - PBMap\Options\ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False) - PBMap\Options\ShowScale = ReadPreferenceInteger("ShowScale", #False) - PBMap\Options\ShowMarkers = ReadPreferenceInteger("ShowMarkers", #True) - PBMap\Options\ShowPointer = ReadPreferenceInteger("ShowPointer", #True) - PBMap\Options\ShowTrack = ReadPreferenceInteger("ShowTrack", #True) - PBMap\Options\ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True) - PBMap\Options\ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False) - PBMap\Options\TrackShowKms = ReadPreferenceInteger("TrackShowKms", #False) - PBMap\Options\TimerInterval = 20 - ClosePreferences() - EndProcedure - - Procedure InitPBMap(Window) - Protected Result.i - If Verbose - OpenConsole() - EndIf - PBMap\ZoomMin = 0 - PBMap\ZoomMax = 18 - PBMap\MoveStartingPoint\x = - 1 - PBMap\TileSize = 256 - PBMap\Dirty = #False - PBMap\EditMarker = #False - PBMap\Font = LoadFont(#PB_Any, "Arial", 20, #PB_Font_Bold) - PBMap\Window = Window - PBMap\Timer = 1 - PBMap\Mode = #MODE_DEFAULT - LoadOptions() - If PBMap\Options\DefaultOSMServer <> "" - AddMapServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) - EndIf - curl_global_init(#CURL_GLOBAL_WIN32) - TechnicalImagesCreation() - SetLocation(0, 0) + With PBMap\Options + PreferenceGroup("PROXY") + \Proxy = ReadPreferenceInteger("Proxy", #False) + If \Proxy + \ProxyURL = ReadPreferenceString("ProxyURL", "") ;InputRequester("ProxyServer", "Do you use a Proxy Server? Then enter the full url:", "") + \ProxyPort = ReadPreferenceString("ProxyPort", "") ;InputRequester("ProxyPort" , "Do you use a specific port? Then enter it", "") + \ProxyUser = ReadPreferenceString("ProxyUser", "") ;InputRequester("ProxyUser" , "Do you use a user name? Then enter it", "") + \ProxyPassword = InputRequester("ProxyPass", "Do you use a password ? Then enter it", "") ;TODO + EndIf + PreferenceGroup("URL") + \DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/") + + PreferenceGroup("PATHS") + \HDDCachePath = ReadPreferenceString("TilesCachePath", GetTemporaryDirectory() + "PBMap" + slash) + PreferenceGroup("OPTIONS") + \WheelMouseRelative = ReadPreferenceInteger("WheelMouseRelative", #True) + \MaxMemCache = ReadPreferenceInteger("MaxMemCache", 20480) ;20 MiB, about 80 tiles in memory + \Verbose = ReadPreferenceInteger("Verbose", #True) + \Warning = ReadPreferenceInteger("Warning", #False) + \ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False) + \ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False) + \ShowScale = ReadPreferenceInteger("ShowScale", #False) + \ShowMarkers = ReadPreferenceInteger("ShowMarkers", #True) + \ShowPointer = ReadPreferenceInteger("ShowPointer", #True) + \ShowTrack = ReadPreferenceInteger("ShowTrack", #True) + \ShowTrackKms = ReadPreferenceInteger("ShowTrackKms", #False) + \ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True) + \ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False) + PreferenceGroup("DRAWING") + \StrokeWidthTrackDefault = ReadPreferenceInteger("StrokeWidthTrackDefault", 10) + PreferenceGroup("COLOURS") + \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() + EndWith EndProcedure Procedure.i AddMapServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/", TileSize = 256, ZoomMin = 0, ZoomMax = 18) Protected *Ptr = AddElement(PBMap\Layers()) - Protected DirName.s = PBMap\Options\HDDCachePath + LayerName + "\" - If FileSize(DirName) <> -2 - If CreateDirectory(DirName) = #False ; Creates a directory based on the layer name - Error("Can't create the following cache directory : " + DirName) - Else - MyDebug(DirName + " successfully created", 4) - EndIf - EndIf If *Ptr PBMap\Layers()\Name = LayerName PBMap\Layers()\Order = Order @@ -543,8 +555,7 @@ Module PBMap EndIf Next Delay(10) - Until MapSize(PBMap\MemCache\Images()) = 0 - curl_global_cleanup() + Until MapSize(PBMap\MemCache\Images()) = 0 EndProcedure Macro Min(a,b) @@ -579,6 +590,12 @@ Module PBMap ;Ensures the longitude to be in the range [-180;180[ *Location\Longitude = Mod(Mod(*Coords\x / n * 360.0, 360.0) + 360.0, 360.0) - 180 *Location\Latitude = Degree(ATan(SinH(#PI * (1.0 - 2.0 * *Coords\y / n)))) + If *Location\Latitude <= -89 + *Location\Latitude = -89 + EndIf + If *Location\Latitude >= 89 + *Location\Latitude = 89 + EndIf EndProcedure Procedure Pixel2LatLon(*Coords.PixelCoordinates, *Location.GeographicCoordinates, Zoom) @@ -586,6 +603,12 @@ Module PBMap ;Ensures the longitude to be in the range [-180;180[ *Location\Longitude = Mod(Mod(*Coords\x / n * 360.0, 360.0) + 360.0, 360.0) - 180 *Location\Latitude = Degree(ATan(SinH(#PI * (1.0 - 2.0 * *Coords\y / n)))) + If *Location\Latitude <= -89 + *Location\Latitude = -89 + EndIf + If *Location\Latitude >= 89 + *Location\Latitude = 89 + EndIf EndProcedure ;Ensures the longitude to be in the range [-180;180[ @@ -604,11 +627,11 @@ Module PBMap ;Lat Lon coordinates 2 pixel relative to the center of view Procedure LatLon2PixelRel(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom) Protected tilemax = Pow(2.0, Zoom) * PBMap\TileSize - Protected cx.d = PBMap\Drawing\CenterX + Protected cx.d = PBMap\Drawing\RadiusX Protected dpx.d = PBMap\PixelCoordinates\x Protected LatRad.d = Radian(*Location\Latitude) - Protected px = tilemax * (Mod( *Location\Longitude + 180.0, 360) / 360.0 ) - Protected py = tilemax * ( 1.0 - Log(Tan(LatRad) + (1.0/Cos(LatRad))) / #PI ) / 2.0 + Protected px.d = tilemax * (Mod( *Location\Longitude + 180.0, 360) / 360.0 ) + Protected py.d = tilemax * ( 1.0 - Log(Tan(LatRad) + (1.0/Cos(LatRad))) / #PI ) / 2.0 ;check the x boundaries of the map to adjust the position (coz of the longitude wrapping) If dpx - px >= tilemax / 2 ;Debug "c1" @@ -623,7 +646,7 @@ Module PBMap ;Debug "c0" *Pixel\x = cx + (px - dpx) EndIf - *Pixel\y = PBMap\Drawing\CenterY + (py - PBMap\PixelCoordinates\y) + *Pixel\y = PBMap\Drawing\RadiusY + (py - PBMap\PixelCoordinates\y) EndProcedure ; HaversineAlgorithm @@ -644,6 +667,7 @@ Module PBMap ProcedureReturn (1000 * HaversineInKM(@*posA,@*posB)); EndProcedure + ; No more used, see LatLon2PixelRel Procedure GetPixelCoordFromLocation(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom) ; TODO to Optimize Protected mapWidth.l = Pow(2, Zoom + 8) Protected mapHeight.l = Pow(2, Zoom + 8) @@ -659,41 +683,47 @@ Module PBMap latRad = PBMap\GeographicCoordinates\Latitude*#PI/180; mercN = Log(Tan((#PI/4)+(latRad/2))) y2 = (mapHeight/2)-(mapWidth*mercN/(2*#PI)); - *Pixel\x=GadgetWidth(PBMap\Gadget)/2 - (x2-x1) - *Pixel\y=GadgetHeight(PBMap\Gadget)/2 - (y2-y1) + *Pixel\x=PBMap\Drawing\RadiusX - (x2-x1) + *Pixel\y=PBMap\Drawing\RadiusY - (y2-y1) EndProcedure - Procedure 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()) - 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 + Procedure IsInDrawingPixelBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates) + Protected Pixel.PixelCoordinates + LatLon2PixelRel(*Position, @Pixel, PBMap\Zoom) + If Pixel\x >= 0 And Pixel\y >= 0 And Pixel\x < *Drawing\RadiusX * 2 And Pixel\y < *Drawing\RadiusY * 2 + ProcedureReturn #True + Else + ProcedureReturn #False EndIf 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 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 Procedure.i GetTileFromHDD(CacheFile.s) Protected nImage.i @@ -714,16 +744,17 @@ Module PBMap Procedure.i GetTileFromWeb(TileURL.s, CacheFile.s) Protected *Buffer Protected nImage.i = -1 - Protected FileSize.i, timg - FileSize = CurlReceiveHTTPToFile(TileURL, CacheFile, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + Protected FileSize.i, timg + HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + FileSize = ReceiveHTTPFile(TileURL, CacheFile) If FileSize > 0 MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3) nImage = GetTileFromHDD(CacheFile) Else MyDebug("Problem loading from web " + TileURL, 3) EndIf - ; **** IMPORTANT NOTICE - ; I'm (djes) now using Curl only, as this original catchimage/saveimage method is a double operation (uncompress/recompress PNG) + ; **** IMPORTANT NOTICE (please not remove) + ; I'm (djes) now using Curl (actually, just normal pb) only, as this original catchimage/saveimage method is a double operation (uncompress/recompress PNG) ; and is modifying the original PNG image which could lead to PNG error (Idle has spent hours debunking the 1 bit PNG bug) ; More than that, the original Purebasic Receive library is still not Proxy enabled. ; *Buffer = ReceiveHTTPMemory(TileURL) ;TODO to thread by using #PB_HTTP_Asynchronous @@ -749,15 +780,14 @@ Module PBMap Procedure GetImageThread(*Tile.Tile) Protected nImage.i = -1 - Protected TileURL.s = *Tile\ServerURL + Str(*Tile\PBMapZoom) + "/" + Str(*Tile\PBMapTileX) + "/" + Str(*Tile\PBMapTileY) + ".png" Repeat - nImage = GetTileFromWeb(TileURL, *Tile\CacheFile) + nImage = GetTileFromWeb(*Tile\URL, *Tile\CacheFile) If nImage <> -1 MyDebug("Image key : " + *Tile\key + " web image loaded", 3) *Tile\RetryNb = 0 Else MyDebug("Image key : " + *Tile\key + " web image not correctly loaded", 3) - Delay(1000) + Delay(2000) *Tile\RetryNb - 1 EndIf Until *Tile\RetryNb <= 0 @@ -767,27 +797,27 @@ Module PBMap EndProcedure ;-*** - Procedure.i GetTile(key.s, CacheFile.s, px.i, py.i, tilex.i, tiley.i, ServerURL.s) + Procedure.i GetTile(key.s, URL.s, CacheFile.s) ; Try to find the tile in memory cache. If not found, add it, try To load it from the ; HDD, or launch a loading thread, and try again on the next drawing loop. - Protected timg = -1 - If FindMapElement(PBMap\MemCache\Images(), key) + Protected img.i = -1 + Protected *timg.ImgMemCach = FindMapElement(PBMap\MemCache\Images(), key) + If *timg MyDebug("Key : " + key + " found in memory cache!", 3) - timg = PBMap\MemCache\Images()\nImage - If timg <> -1 - MyDebug("Image : " + timg + " found in memory cache!", 3) + img = *timg\nImage + If img <> -1 + MyDebug("Image : " + img + " found in memory cache!", 3) ;*** Cache management ; Move the newly used element to the last position of the time stack - SelectElement(PBMap\MemCache\ImagesTimeStack(), PBMap\MemCache\Images()\TimeStackPosition) + SelectElement(PBMap\MemCache\ImagesTimeStack(), *timg\TimeStackPosition) MoveElement(PBMap\MemCache\ImagesTimeStack(), #PB_List_Last) ;*** - ProcedureReturn timg + ProcedureReturn *timg EndIf Else - AddMapElement(PBMap\MemCache\Images(), key) - PushMapPosition(PBMap\MemCache\Images()) + ;PushMapPosition(PBMap\MemCache\Images()) ;*** Cache management - ; if cache size exceeds limit, try to delete the oldest tile used + ; if cache size exceeds limit, try to delete the oldest tile used (first in the list) Protected CacheSize = MapSize(PBMap\MemCache\Images()) * Pow(PBMap\TileSize, 2) * 4 ; Size of a tile = TileSize * TileSize * 4 bytes (RGBA) Protected CacheLimit = PBMap\Options\MaxMemCache * 1024 MyDebug("Cache size : " + Str(CacheSize/1024) + " / CacheLimit : " + Str(CacheLimit/1024), 4) @@ -803,36 +833,38 @@ Module PBMap CacheSize = MapSize(PBMap\MemCache\Images()) * Pow(PBMap\TileSize, 2) * 4 ; Size of a tile = TileSize * TileSize * 4 bytes (RGBA) EndIf Wend - PopMapPosition(PBMap\MemCache\Images()) + LastElement(PBMap\MemCache\ImagesTimeStack()) + ;PopMapPosition(PBMap\MemCache\Images()) + AddMapElement(PBMap\MemCache\Images(), key) AddElement(PBMap\MemCache\ImagesTimeStack()) + ;MoveElement(PBMap\MemCache\ImagesTimeStack(), #PB_List_Last) PBMap\MemCache\ImagesTimeStack()\MapKey = MapKey(PBMap\MemCache\Images()) ;*** MyDebug("Key : " + key + " added in memory cache!", 3) - PBMap\MemCache\Images()\nImage = -1 + *timg = PBMap\MemCache\Images() + *timg\nImage = -1 EndIf - If PBMap\MemCache\Images()\Tile = 0 ; Check if a loading thread is not running + If *timg\Tile = 0 ; Check if a loading thread is not running MyDebug("Trying to load from HDD " + CacheFile, 3) - timg = GetTileFromHDD(CacheFile.s) - If timg <> -1 + img = GetTileFromHDD(CacheFile.s) + If img <> -1 MyDebug("Key : " + key + " found on HDD", 3) - PBMap\MemCache\Images()\nImage = timg - ProcedureReturn timg + *timg\nImage = img + *timg\Alpha = 256 + ProcedureReturn *timg EndIf MyDebug("Key : " + key + " not found on HDD", 3) ;Launch a new thread Protected *NewTile.Tile = AllocateMemory(SizeOf(Tile)) If *NewTile With *NewTile - PBMap\MemCache\Images()\Tile = *NewTile + *timg\Tile = *NewTile + *timg\Alpha = 0 + ;*timg\nImage = -1 ;New tile parameters - \Position\x = px - \Position\y = py - \PBMapTileX = tilex - \PBMapTileY = tiley - \PBMapZoom = PBMap\Zoom \key = key + \URL = URL \CacheFile = CacheFile - \ServerURL = ServerURL \RetryNb = 5 \nImage = -1 MyDebug(" Creating get image thread nb " + Str(\GetImageThread) + " to get " + CacheFile, 3) @@ -842,23 +874,24 @@ Module PBMap MyDebug(" Error, can't create a new tile loading thread", 3) EndIf EndIf - ProcedureReturn timg + ProcedureReturn *timg EndProcedure - Procedure DrawTiles(*Drawing.DrawingParameters, Layer, alpha.i=255) + Procedure DrawTiles(*Drawing.DrawingParameters, Layer) Protected x.i, y.i,kq.q Protected tx = Int(*Drawing\TileCoordinates\x) ;Don't forget the Int() ! Protected ty = Int(*Drawing\TileCoordinates\y) - Protected nx = *Drawing\CenterX / PBMap\TileSize ;How many tiles around the point - Protected ny = *Drawing\CenterY / PBMap\TileSize - Protected px, py, img, tilex,tiley, key.s, CacheFile.s + Protected nx = *Drawing\RadiusX / PBMap\TileSize ;How many tiles around the point + Protected ny = *Drawing\RadiusY / PBMap\TileSize + Protected px, py, *timg.ImgMemCach, tilex, tiley, key.s + Protected URL.s, CacheFile.s Protected tilemax = 1< -2 + If CreateDirectory(DirName) = #False ; Creates a directory based on the layer name + Error("Can't create the following layer directory : " + DirName) + Else + MyDebug(DirName + " successfully created", 4) + EndIf + EndIf ; Creates the sub-directory based on the zoom - Protected DirName.s = PBMap\Options\HDDCachePath + PBMap\Layers()\Name + "\" + Str(PBMap\Zoom) + DirName + slash + Str(PBMap\Zoom) If FileSize(DirName) <> -2 If CreateDirectory(DirName) = #False - Error("Can't create the following cache directory : " + DirName) + Error("Can't create the following zoom directory : " + DirName) + Else + MyDebug(DirName + " successfully created", 4) EndIf EndIf ; Creates the sub-directory based on x - DirName.s + "\" + Str(tilex) + DirName.s + slash + Str(tilex) If FileSize(DirName) <> -2 If CreateDirectory(DirName) = #False - Error("Can't create the following cache directory : " + DirName) + Error("Can't create the following x directory : " + DirName) + Else + MyDebug(DirName + " successfully created", 4) EndIf EndIf ; Tile cache name based on y - CacheFile = DirName + "\" + Str(tiley) + ".png" - img = GetTile(key, CacheFile, px, py, tilex, tiley, PBMap\Layers()\ServerURL) - If img <> -1 + URL = PBMap\Layers()\ServerURL + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + ".png" + CacheFile = DirName + slash + Str(tiley) + ".png" + *timg = GetTile(key, URL, CacheFile) + If *timg\nImage <> -1 MovePathCursor(px, py) - DrawVectorImage(ImageID(img), alpha) + If *timg\Alpha <= 224 + DrawVectorImage(ImageID(*timg\nImage), *timg\Alpha) + *timg\Alpha + 32 + PBMap\Redraw = #True + Else + DrawVectorImage(ImageID(*timg\nImage), 255) + *timg\Alpha = 256 + EndIf Else MovePathCursor(px, py) - DrawVectorImage(ImageID(PBMap\ImgLoading), alpha) + DrawVectorImage(ImageID(PBMap\ImgLoading), 255) EndIf Else ;If PBMap\Layers()\Name = "" MovePathCursor(px, py) - DrawVectorImage(ImageID(PBMap\ImgNothing)) + DrawVectorImage(ImageID(PBMap\ImgNothing), 255) ;EndIf EndIf If PBMap\Options\ShowDebugInfos @@ -913,10 +966,10 @@ Module PBMap Procedure DrawPointer(*Drawing.DrawingParameters) If PBMap\CallBackMainPointer > 0 ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib) - CallFunctionFast(PBMap\CallBackMainPointer, *Drawing\CenterX, *Drawing\CenterY) + CallFunctionFast(PBMap\CallBackMainPointer, *Drawing\RadiusX, *Drawing\RadiusY) Else VectorSourceColor(RGBA($FF, 0, 0, $FF)) - MovePathCursor(*Drawing\CenterX, *Drawing\CenterY) + MovePathCursor(*Drawing\RadiusX, *Drawing\RadiusY) AddPathLine(-8, -16, #PB_Path_Relative) AddPathCircle(8, 0, 8, 180, 0, #PB_Path_Relative) AddPathLine(-8, 16, #PB_Path_Relative) @@ -938,7 +991,7 @@ Module PBMap sunit = " Km" EndSelect VectorFont(FontID(PBMap\Font), 10) - VectorSourceColor(RGBA(0, 0, 0,alpha)) + VectorSourceColor(RGBA(0, 0, 0, alpha)) MovePathCursor(x,y) DrawVectorText(StrD(Scale,3)+sunit) MovePathCursor(x,y+12) @@ -950,17 +1003,27 @@ Module PBMap Protected tx, ty, nx,ny,nx1,ny1,x,y,n,cx,dperpixel.d Protected pos1.PixelCoordinates,pos2.PixelCoordinates,Degrees1.GeographicCoordinates,degrees2.GeographicCoordinates Protected realx - tx = Int(*Drawing\TileCoordinates\x) - ty = Int(*Drawing\TileCoordinates\y) - nx = *Drawing\CenterX / PBMap\TileSize ;How many tiles around the point - ny = *Drawing\CenterY / PBMap\TileSize - *Drawing\Bounds\NorthWest\x = tx-nx-1 - *Drawing\Bounds\NorthWest\y = ty-ny-1 - *Drawing\Bounds\SouthEast\x = tx+nx+2 - *Drawing\Bounds\SouthEast\y = ty+ny+2 - ; Debug "------------------" - TileXY2LatLon(*Drawing\Bounds\NorthWest, @Degrees1, PBMap\Zoom) - TileXY2LatLon(*Drawing\Bounds\SouthEast, @Degrees2, PBMap\Zoom) + + ;TODO to find why it doesn't work + CopyStructure(*Drawing\Bounds\NorthWest, @Degrees1, GeographicCoordinates) + Debug "----" + Debug Degrees1\Longitude-1 + CopyStructure(*Drawing\Bounds\SouthEast, @Degrees2, GeographicCoordinates) + ;tx = Int(*Drawing\TileCoordinates\x) + ;ty = Int(*Drawing\TileCoordinates\y) + tx = *Drawing\TileCoordinates\x + ty = *Drawing\TileCoordinates\y + nx = *Drawing\RadiusX / PBMap\TileSize ;How many tiles around the point + ny = *Drawing\RadiusY / PBMap\TileSize + *Drawing\Bounds\TopLeft\x = tx-nx-1 + *Drawing\Bounds\TopLeft\y = ty-ny-1 + *Drawing\Bounds\BottomRight\x = tx+nx+2 + *Drawing\Bounds\BottomRight\y = ty+ny+2 + TileXY2LatLon(*Drawing\Bounds\TopLeft, @Degrees1, PBMap\Zoom) + TileXY2LatLon(*Drawing\Bounds\BottomRight, @Degrees2, PBMap\Zoom) + Debug Degrees1\Longitude + ;*** + ;ensure we stay positive for the drawing nx = Mod(Mod(Round(Degrees1\Longitude, #PB_Round_Down)-1, 360) + 360, 360) ny = Round(Degrees1\Latitude, #PB_Round_Up) +1 @@ -1000,7 +1063,7 @@ Module PBMap StrokePath(1) EndProcedure - Procedure TrackPointer(x.i, y.i, dist.l) + Procedure DrawTrackPointer(x.d, y.d, dist.l) Protected color.l color=RGBA(0, 0, 0, 255) MovePathCursor(x,y) @@ -1019,103 +1082,178 @@ Module PBMap DrawVectorText(Str(dist)) EndProcedure + Procedure DrawTrackPointerFirst(x.d, y.d, dist.l) + Protected color.l + color=RGBA(0, 0, 0, 255) + MovePathCursor(x,y) + AddPathLine(-9,-17,#PB_Path_Relative) + AddPathLine(17,0,#PB_Path_Relative) + AddPathLine(-9,17,#PB_Path_Relative) + VectorSourceColor(color) + AddPathCircle(x,y-24,16) + FillPath() + VectorSourceColor(RGBA(255, 0, 0, 255)) + AddPathCircle(x,y-24,14) + FillPath() + VectorFont(FontID(PBMap\Font), 14) + MovePathCursor(x-VectorTextWidth(Str(dist))/2, y-24-VectorTextHeight(Str(dist))/2) + VectorSourceColor(RGBA(0, 0, 0, 255)) + DrawVectorText(Str(dist)) + 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 SetTrackColour(*Ptr, Colour.i) + If *Ptr + ChangeCurrentElement(PBMap\TracksList(), *Ptr) + PBMap\TracksList()\Colour = Colour + PBMap\Redraw = #True + EndIf + EndProcedure + Procedure DrawTracks(*Drawing.DrawingParameters) Protected Pixel.PixelCoordinates Protected Location.GeographicCoordinates Protected km.f, memKm.i - ;Trace Track - If ListSize(PBMap\TracksList()) > 0 - BeginVectorLayer() - ForEach PBMap\TracksList() - If ListSize(PBMap\TracksList()\Track()) > 0 - ForEach PBMap\TracksList()\Track() - ;If *Drawing\GeographicCoordinates\Latitude<>0 And *Drawing\GeographicCoordinates\Longitude<>0 - LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom) - If ListIndex(PBMap\TracksList()\Track()) = 0 - MovePathCursor(Pixel\X, Pixel\Y) - Else - AddPathLine(Pixel\X, Pixel\Y) - EndIf - ;EndIf - Next - VectorSourceColor(RGBA(0, 255, 0, 150)) - StrokePath(10, #PB_Path_RoundEnd|#PB_Path_RoundCorner) - EndIf - Next - EndVectorLayer() - EndIf - ;Draw Distance - If PBMap\Options\TrackShowKms And ListSize(PBMap\TracksList()) > 0 - BeginVectorLayer() - ForEach PBMap\TracksList() - km = 0 : memKm = -1 - ForEach PBMap\TracksList()\Track() - ;Test Distance - If ListIndex(PBMap\TracksList()\Track()) = 0 - Location\Latitude = PBMap\TracksList()\Track()\Latitude - Location\Longitude = PBMap\TracksList()\Track()\Longitude - Else - km = km + HaversineInKM(@Location, @PBMap\TracksList()\Track()) - Location\Latitude = PBMap\TracksList()\Track()\Latitude - Location\Longitude = PBMap\TracksList()\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 + With PBMap\TracksList() + ;Trace Track + If ListSize(PBMap\TracksList()) > 0 + BeginVectorLayer() + ForEach PBMap\TracksList() + If ListSize(\Track()) > 0 + ;Check visibility + \Visible = #False + ForEach \Track() + If IsInDrawingPixelBoundaries(*Drawing, @PBMap\TracksList()\Track()) + \Visible = #True + Break + EndIf + Next + If \Visible + ;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 + ; \BoundingBox\x = PathBoundsX() + ; \BoundingBox\y = PathBoundsY() + ; \BoundingBox\w = PathBoundsWidth() + ; \BoundingBox\h = PathBoundsHeight() + If \Focus + VectorSourceColor(PBMap\Options\ColourFocus) + ElseIf \Selected + VectorSourceColor(PBMap\Options\ColourSelected) + Else + VectorSourceColor(\Colour) + EndIf + StrokePath(\StrokeWidth, #PB_Path_RoundEnd|#PB_Path_RoundCorner) + EndIf EndIf Next - Next - EndVectorLayer() + EndVectorLayer() + ;Draw distances + If PBMap\Options\ShowTrackKms And PBMap\Zoom > 10 + 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 Int(km) = 0 + DrawTrackPointerFirst(Pixel\x , Pixel\y, Int(km)) + Else + DrawTrackPointer(Pixel\x , Pixel\y, Int(km)) + EndIf + EndIf + Next + EndIf + Next + EndVectorLayer() + EndIf + EndIf + EndWith + 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) - VectorSourceColor(color) - MovePathCursor(x, y) - AddPathLine(-8, -16, #PB_Path_Relative) - AddPathCircle(8, 0, 8, 180, 0, #PB_Path_Relative) - AddPathLine(-8, 16, #PB_Path_Relative) - ;FillPath(#PB_Path_Preserve) - ;ClipPath(#PB_Path_Preserve) - AddPathCircle(0, -16, 5, 0, 360, #PB_Path_Relative) - VectorSourceColor(Color) - FillPath(#PB_Path_Preserve) - If Focus - VectorSourceColor(RGBA(255, 255, 0, 255)) - StrokePath(3) - ElseIf Selected - VectorSourceColor(RGBA(255, 255, 0, 255)) - StrokePath(4) - Else - VectorSourceColor(Color) - StrokePath(1) - EndIf - If PBMap\Options\ShowMarkersNb - Protected Text.s = Str(Nb) - VectorFont(FontID(PBMap\Font), 13) - MovePathCursor(x - 10, y) - VectorSourceColor(RGBA(0, 0, 0, 255)) - DrawVectorParagraph(Text, 20, 20, #PB_VectorParagraph_Center) - EndIf - If PBMap\Options\ShowMarkersLegend - VectorFont(FontID(PBMap\Font), 13) - Protected Height = VectorParagraphHeight(Legend, 100, 13) - MovePathCursor(x - 50, y - 30 - Height) - VectorSourceColor(RGBA(0, 0, 0, 255)) - DrawVectorParagraph(Legend, 100, Height, #PB_VectorParagraph_Center) - EndIf - EndProcedure Procedure ClearMarkers() ClearList(PBMap\Markers()) + PBMap\Redraw = #True EndProcedure Procedure DeleteMarker(*Ptr) - ChangeCurrentElement(PBMap\Markers(), *Ptr) - DeleteElement(PBMap\Markers()) + If *Ptr + ChangeCurrentElement(PBMap\Markers(), *Ptr) + DeleteElement(PBMap\Markers()) + PBMap\Redraw = #True + EndIf EndProcedure Procedure DeleteSelectedMarkers() @@ -1127,11 +1265,12 @@ Module PBMap Next EndProcedure - Procedure.i AddMarker(Latitude.d, Longitude.d, Legend.s = "", Color.l=-1, CallBackPointer.i = -1) + Procedure.i AddMarker(Latitude.d, Longitude.d, Identifier.s = "", Legend.s = "", Color.l=-1, CallBackPointer.i = -1) Protected *Ptr = AddElement(PBMap\Markers()) If *Ptr PBMap\Markers()\GeographicCoordinates\Latitude = Latitude - PBMap\Markers()\GeographicCoordinates\Longitude = Mod(Mod(Longitude, 360) + 360, 360) + PBMap\Markers()\GeographicCoordinates\Longitude = ClipLongitude(Longitude) + PBMap\Markers()\Identifier = Identifier PBMap\Markers()\Legend = Legend PBMap\Markers()\Color = Color PBMap\Markers()\CallBackPointer = CallBackPointer @@ -1140,31 +1279,122 @@ Module PBMap EndIf EndProcedure - ; Draw all markers - Procedure DrawMarkers() - Protected Pixel.PixelCoordinates + ;-*** Marker Edit + Procedure MarkerIdentifierChange() + Protected *Marker.Marker = GetGadgetData(EventGadget()) + If GetGadgetText(EventGadget()) <> *Marker\Identifier + *Marker\Identifier = GetGadgetText(EventGadget()) + EndIf + EndProcedure + Procedure MarkerLegendChange() + Protected *Marker.Marker = GetGadgetData(EventGadget()) + If GetGadgetText(EventGadget()) <> *Marker\Legend + *Marker\Legend = GetGadgetText(EventGadget()) + EndIf + EndProcedure + Procedure MarkerEditCloseWindow() ForEach PBMap\Markers() - If PBMap\Markers()\GeographicCoordinates\Latitude <> 0 And PBMap\Markers()\GeographicCoordinates\Longitude <> 0 - ;GetPixelCoordFromLocation(PBMap\Markers()\GeographicCoordinates, @Pixel) - LatLon2PixelRel(PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom) - If Pixel\X >= 0 And Pixel\Y >= 0 And Pixel\X < GadgetWidth(PBMap\Gadget) And Pixel\Y < GadgetHeight(PBMap\Gadget) ; Only if visible ^_^ - If PBMap\Markers()\CallBackPointer > 0 - CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\X, Pixel\Y, PBMap\Markers()\Focus, PBMap\Markers()\Selected) - Else - DrawMarker(Pixel\X, Pixel\Y, ListIndex(PBMap\Markers()), PBMap\Markers()\Color, PBMap\Markers()\Legend, PBMap\Markers()\Focus, PBMap\Markers()\Selected) - EndIf - EndIf - EndIf + If PBMap\Markers()\EditWindow = EventWindow() + PBMap\Markers()\EditWindow = 0 + EndIf Next + CloseWindow(EventWindow()) + EndProcedure + Procedure MarkerEdit(*Marker.Marker) + If *Marker\EditWindow = 0 ;Check that this marker has no already opened window + Protected WindowMarkerEdit = OpenWindow(#PB_Any, WindowX(PBMap\Window) + WindowWidth(PBMap\Window) / 2 - 150, WindowY(PBMap\Window)+ WindowHeight(PBMap\Window) / 2 + 50, 300, 100, "Marker Edit", #PB_Window_SystemMenu | #PB_Window_TitleBar) + StickyWindow(WindowMarkerEdit, #True) + TextGadget(#PB_Any, 2, 2, 80, 25, gettext("Identifier")) + TextGadget(#PB_Any, 2, 27, 80, 25, gettext("Legend")) + Protected StringIdentifier = StringGadget(#PB_Any, 84, 2, 120, 25, *Marker\Identifier) : SetGadgetData(StringIdentifier, *Marker) + Protected EditorLegend = EditorGadget(#PB_Any, 84, 27, 210, 70) : SetGadgetText(EditorLegend, *Marker\Legend) : SetGadgetData(EditorLegend, *Marker) + *Marker\EditWindow = WindowMarkerEdit + BindGadgetEvent(StringIdentifier, @MarkerIdentifierChange(), #PB_EventType_Change) + BindGadgetEvent(EditorLegend, @MarkerLegendChange(), #PB_EventType_Change) + BindEvent(#PB_Event_CloseWindow, @MarkerEditCloseWindow(), WindowMarkerEdit) + Else + SetActiveWindow(*Marker\EditWindow) + EndIf + EndProcedure + ;-*** + + Procedure DrawMarker(x.i, y.i, Nb.i, *Marker.Marker) + Protected Text.s + VectorSourceColor(*Marker\Color) + MovePathCursor(x, y) + AddPathLine(-8, -16, #PB_Path_Relative) + AddPathCircle(8, 0, 8, 180, 0, #PB_Path_Relative) + AddPathLine(-8, 16, #PB_Path_Relative) + ;FillPath(#PB_Path_Preserve) + ;ClipPath(#PB_Path_Preserve) + AddPathCircle(0, -16, 5, 0, 360, #PB_Path_Relative) + VectorSourceColor(*Marker\Color) + FillPath(#PB_Path_Preserve) + If *Marker\Focus + VectorSourceColor(PBMap\Options\ColourFocus) + StrokePath(3) + ElseIf *Marker\Selected + VectorSourceColor(PBMap\Options\ColourSelected) + StrokePath(4) + Else + VectorSourceColor(*Marker\Color) + StrokePath(1) + EndIf + If PBMap\Options\ShowMarkersNb + If *Marker\Identifier = "" + Text.s = Str(Nb) + Else + Text.s = *Marker\Identifier + EndIf + VectorFont(FontID(PBMap\Font), 13) + MovePathCursor(x - VectorTextWidth(Text) / 2, y) + VectorSourceColor(RGBA(0, 0, 0, 255)) + DrawVectorText(Text) + EndIf + If PBMap\Options\ShowMarkersLegend And *Marker\Legend <> "" + VectorFont(FontID(PBMap\Font), 13) + ;dessin d'un cadre avec fond transparent + Protected Height = VectorParagraphHeight(*Marker\Legend, 100, 100) + Protected Width.l + If Height < 20 ; une ligne + Width = VectorTextWidth(*Marker\Legend) + Else + Width = 100 + EndIf + AddPathBox(x - (Width / 2), y - 30 - Height, Width, Height) + VectorSourceColor(RGBA(168, 255, 255, 100)) + FillPath() + AddPathBox(x - (Width / 2), y - 30 - Height, Width, Height) + VectorSourceColor(RGBA(36, 36, 255, 100)) + StrokePath(2) + MovePathCursor(x - 50, y - 30 - Height) + VectorSourceColor(RGBA(0, 0, 0, 255)) + DrawVectorParagraph(*Marker\Legend, 100, Height, #PB_VectorParagraph_Center) + EndIf EndProcedure - Procedure DrawDebugInfos() + ; Draw all markers + Procedure DrawMarkers(*Drawing.DrawingParameters) + Protected Pixel.PixelCoordinates + ForEach PBMap\Markers() + If IsInDrawingPixelBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates) + LatLon2PixelRel(@PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom) + If PBMap\Markers()\CallBackPointer > 0 + CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\x, Pixel\y, PBMap\Markers()\Focus, PBMap\Markers()\Selected) + Else + DrawMarker(Pixel\x, Pixel\y, ListIndex(PBMap\Markers()), @PBMap\Markers()) + EndIf + EndIf + Next + EndProcedure + + Procedure DrawDebugInfos(*Drawing.DrawingParameters) ; Display how many images in cache - VectorFont(FontID(PBMap\Font), 30) + VectorFont(FontID(PBMap\Font), 16) VectorSourceColor(RGBA(0, 0, 0, 80)) - MovePathCursor(50,50) + MovePathCursor(50, 50) DrawVectorText(Str(MapSize(PBMap\MemCache\Images()))) - MovePathCursor(50,80) + MovePathCursor(50, 70) Protected ThreadCounter = 0 ForEach PBMap\MemCache\Images() If PBMap\MemCache\Images()\Tile <> 0 @@ -1173,29 +1403,60 @@ Module PBMap EndIf EndIf Next - DrawVectorText(Str(ThreadCounter)) - MovePathCursor(50,110) + DrawVectorText(Str(ThreadCounter)) + MovePathCursor(50, 90) DrawVectorText(Str(PBMap\Zoom)) + MovePathCursor(50, 110) + DrawVectorText(StrD(*Drawing\Bounds\NorthWest\Latitude) + "," + StrD(*Drawing\Bounds\NorthWest\Longitude)) + MovePathCursor(50, 130) + DrawVectorText(StrD(*Drawing\Bounds\SouthEast\Latitude) + "," + StrD(*Drawing\Bounds\SouthEast\Longitude)) + EndProcedure + + Procedure DrawOSMCopyright(*Drawing.DrawingParameters) + Protected Text.s = "© OpenStreetMap contributors" + VectorFont(FontID(PBMap\Font), 12) + VectorSourceColor(RGBA(0, 0, 0, 80)) + MovePathCursor(GadgetWidth(PBMAP\Gadget) - VectorTextWidth(Text), GadgetHeight(PBMAP\Gadget) - 20) + DrawVectorText(Text) EndProcedure ;-*** Main drawing Procedure Drawing() Protected *Drawing.DrawingParameters = @PBMap\Drawing - Protected Px.d, Py.d,a, ts = PBMap\TileSize + Protected PixelCenter.PixelCoordinates + Protected Px.d, Py.d,a, ts = PBMap\TileSize, nx, ny + Protected NW.Coordinates, SE.Coordinates PBMap\Dirty = #False PBMap\Redraw = #False - ; Precalc some values - *Drawing\CenterX = GadgetWidth(PBMap\Gadget) / 2 - *Drawing\CenterY = GadgetHeight(PBMap\Gadget) / 2 + ;*** Precalc some values + *Drawing\RadiusX = GadgetWidth(PBMap\Gadget) / 2 + *Drawing\RadiusY = GadgetHeight(PBMap\Gadget) / 2 *Drawing\GeographicCoordinates\Latitude = PBMap\GeographicCoordinates\Latitude *Drawing\GeographicCoordinates\Longitude = PBMap\GeographicCoordinates\Longitude LatLon2TileXY(*Drawing\GeographicCoordinates, *Drawing\TileCoordinates, PBMap\Zoom) + LatLon2Pixel(*Drawing\GeographicCoordinates, @PixelCenter, PBMap\Zoom) ; Pixel shift, aka position in the tile - Px = *Drawing\TileCoordinates\x : Py = *Drawing\TileCoordinates\y + Px = *Drawing\TileCoordinates\x + Py = *Drawing\TileCoordinates\y *Drawing\DeltaX = Px * ts - (Int(Px) * ts) ;Don't forget the Int() ! *Drawing\DeltaY = Py * ts - (Int(Py) * ts) + ;Drawing boundaries + nx = *Drawing\RadiusX / ts ;How many tiles around the point + ny = *Drawing\RadiusY / ts + NW\x = Px - nx - 1 + NW\y = Py - ny - 1 + SE\x = Px + nx + 2 + SE\y = Py + ny + 2 + TileXY2LatLon(@NW, *Drawing\Bounds\NorthWest, PBMap\Zoom) + TileXY2LatLon(@SE, *Drawing\Bounds\SouthEast, PBMap\Zoom) + ;*Drawing\Width = (SE\x / Pow(2, PBMap\Zoom) * 360.0) - (NW\x / Pow(2, PBMap\Zoom) * 360.0) ;Calculus without clipping + ;*Drawing\Height = *Drawing\Bounds\NorthWest\Latitude - *Drawing\Bounds\SouthEast\Latitude + ;*** ; Main drawing stuff StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget)) + ;Clearscreen + VectorSourceColor(RGBA(150, 150, 150, 255)) + FillVectorOutput() ;TODO add in layers of tiles ;this way we can cache them as 0 base 1.n layers ; such as for openseamap tiles which are overlaid. not that efficent from here though. ForEach PBMap\Layers() @@ -1205,20 +1466,21 @@ Module PBMap DrawTracks(*Drawing) EndIf If PBMap\Options\ShowMarkers - DrawMarkers() + DrawMarkers(*Drawing) EndIf + If PBMap\Options\ShowDegrees And PBMap\Zoom > 2 + DrawDegrees(*Drawing, 192) + EndIf If PBMap\Options\ShowPointer DrawPointer(*Drawing) EndIf If PBMap\Options\ShowDebugInfos - DrawDebugInfos() - EndIf - If PBMap\Options\ShowDegrees - DrawDegrees(*Drawing, 192) + DrawDebugInfos(*Drawing) EndIf If PBMap\Options\ShowScale DrawScale(*Drawing, 10, GadgetHeight(PBMAP\Gadget) - 20, 192) - EndIf + EndIf + DrawOSMCopyright(*Drawing) StopVectorDrawing() EndProcedure @@ -1228,27 +1490,27 @@ Module PBMap EndProcedure Procedure.d Pixel2Lon(x) - Protected NewX.d = (PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + x) / PBMap\TileSize + Protected NewX.d = (PBMap\PixelCoordinates\x - PBMap\Drawing\RadiusX + x) / PBMap\TileSize Protected n.d = Pow(2.0, PBMap\Zoom) ; double mod is to ensure the longitude to be in the range [-180;180[ ProcedureReturn Mod(Mod(NewX / n * 360.0, 360.0) + 360.0, 360.0) - 180 EndProcedure Procedure.d Pixel2Lat(y) - Protected NewY.d = (PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + y) / PBMap\TileSize + Protected NewY.d = (PBMap\PixelCoordinates\y - PBMap\Drawing\RadiusY + y) / PBMap\TileSize Protected n.d = Pow(2.0, PBMap\Zoom) ProcedureReturn Degree(ATan(SinH(#PI * (1.0 - 2.0 * NewY / n)))) EndProcedure Procedure.d MouseLongitude() - Protected MouseX.d = (PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)) / PBMap\TileSize + Protected MouseX.d = (PBMap\PixelCoordinates\x - PBMap\Drawing\RadiusX + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)) / PBMap\TileSize Protected n.d = Pow(2.0, PBMap\Zoom) ; double mod is to ensure the longitude to be in the range [-180;180[ ProcedureReturn Mod(Mod(MouseX / n * 360.0, 360.0) + 360.0, 360.0) - 180 EndProcedure Procedure.d MouseLatitude() - Protected MouseY.d = (PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)) / PBMap\TileSize + Protected MouseY.d = (PBMap\PixelCoordinates\y - PBMap\Drawing\RadiusY + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)) / PBMap\TileSize Protected n.d = Pow(2.0, PBMap\Zoom) ProcedureReturn Degree(ATan(SinH(#PI * (1.0 - 2.0 * MouseY / n)))) EndProcedure @@ -1268,6 +1530,13 @@ Module PBMap PBMap\Zoom + Zoom EndIf EndSelect + PBMap\GeographicCoordinates\Longitude = ClipLongitude(PBMap\GeographicCoordinates\Longitude) + If PBMap\GeographicCoordinates\Latitude < -89 + PBMap\GeographicCoordinates\Latitude = -89 + EndIf + If PBMap\GeographicCoordinates\Latitude > 89 + PBMap\GeographicCoordinates\Latitude = 89 + EndIf If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf LatLon2TileXY(@PBMap\GeographicCoordinates, @PBMap\Drawing\TileCoordinates, PBMap\Zoom) @@ -1283,17 +1552,17 @@ Module PBMap Procedure ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d) ;Source => http://gis.stackexchange.com/questions/19632/how-to-calculate-the-optimal-zoom-level-to-display-two-or-more-points-on-a-map ;bounding box in long/lat coords (x=long, y=lat) - Protected DeltaX.d=MaxX-MinX ;assumption ! In original code DeltaX have no source - Protected centerX.d=MinX+DeltaX/2 ; assumption ! In original code CenterX have no source - Protected paddingFactor.f= 1.2 ;paddingFactor: this can be used to get the "120%" effect ThomM refers to. Value of 1.2 would get you the 120%. + Protected DeltaX.d = MaxX - MinX ;assumption ! In original code DeltaX have no source + Protected centerX.d = MinX + DeltaX / 2 ; assumption ! In original code CenterX have no source + Protected paddingFactor.f= 1.2 ;paddingFactor: this can be used to get the "120%" effect ThomM refers to. Value of 1.2 would get you the 120%. Protected ry1.d = Log((Sin(Radian(MinY)) + 1) / Cos(Radian(MinY))) Protected ry2.d = Log((Sin(Radian(MaxY)) + 1) / Cos(Radian(MaxY))) Protected ryc.d = (ry1 + ry2) / 2 Protected centerY.d = Degree(ATan(SinH(ryc))) - Protected resolutionHorizontal.d = DeltaX / GadgetWidth(PBMap\Gadget) + Protected resolutionHorizontal.d = DeltaX / (PBMap\Drawing\RadiusX * 2) Protected vy0.d = Log(Tan(#PI*(0.25 + centerY/360))); Protected vy1.d = Log(Tan(#PI*(0.25 + MaxY/360))) ; - Protected viewHeightHalf.d = GadgetHeight(PBMap\Gadget)/2; + Protected viewHeightHalf.d = PBMap\Drawing\RadiusY ; Protected zoomFactorPowered.d = viewHeightHalf / (40.7436654315252*(vy1 - vy0)) Protected resolutionVertical.d = 360.0 / (zoomFactorPowered * PBMap\TileSize) If resolutionHorizontal<>0 And resolutionVertical<>0 @@ -1331,6 +1600,7 @@ Module PBMap EndWith EndIf EndProcedure + Procedure SetZoom(Zoom.i, mode.i = #PB_Relative) Select mode Case #PB_Relative @@ -1351,6 +1621,16 @@ Module PBMap EndIf EndProcedure + Procedure SetAngle(Angle.d, Mode = #PB_Absolute) + If Mode = #PB_Absolute + PBmap\Angle = Angle + Else + PBMap\Angle + Angle + PBMap\Angle = Mod(PBMap\Angle,360) + EndIf + PBMap\Redraw = #True + EndProcedure + Procedure SetCallBackLocation(CallBackLocation.i) PBMap\CallBackLocation = CallBackLocation EndProcedure @@ -1370,18 +1650,16 @@ Module PBMap ; #MODE_HAND = 1 -> Hand only ; #MODE_SELECT = 2 -> Move objects only ; #MODE_EDIT = 3 -> Create objects - Procedure SetMode(Mode = #MODE_DEFAULT) - PBMap\Mode = Mode - EndProcedure + Procedure SetMode(Mode.i = #MODE_DEFAULT) + PBMap\Mode = Mode + EndProcedure - ;Zoom on x, y position relative to the canvas gadget - Procedure SetZoomOnPosition(x, y, zoom) - Protected MouseX.d, MouseY.d - Protected OldPx.d, OldPy.d, OldMx.d, OldMy.d, Px.d, Py.d - Protected CenterX = GadgetWidth(PBMap\Gadget) / 2 - Protected CenterY = GadgetHeight(PBMap\Gadget) / 2 - x - CenterX - y - CenterY + Procedure.i GetMode() + ProcedureReturn PBMap\Mode + EndProcedure + + ;Zoom on x, y pixel position from the center + Procedure ZoomOnPixel(x, y, zoom) ;*** First : Zoom PBMap\Zoom + zoom If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : ProcedureReturn : EndIf @@ -1403,15 +1681,29 @@ Module PBMap EndIf EndProcedure - ;Go to x, y position relative to the canvas gadget + ;Zoom on x, y position relative to the canvas gadget + Procedure ZoomOnPixelRel(x, y, zoom) + ZoomOnPixel(x - PBMap\Drawing\RadiusX, y - PBMap\Drawing\RadiusY, zoom) + EndProcedure + + ;Go to x, y position relative to the canvas gadget left up Procedure GotoPixelRel(x, y) - Protected CenterX = GadgetWidth(PBMap\Gadget) / 2 - Protected CenterY = GadgetHeight(PBMap\Gadget) / 2 - x - CenterX - y - CenterY LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom) - PBMap\PixelCoordinates\x + x - PBMap\PixelCoordinates\y + y + PBMap\PixelCoordinates\x + x - PBMap\Drawing\RadiusX + PBMap\PixelCoordinates\y + y - PBMap\Drawing\RadiusY + Pixel2LatLon(@PBMap\PixelCoordinates, @PBMap\GeographicCoordinates, PBMap\Zoom) + ; Start drawing + PBMap\Redraw = #True + ; If CallBackLocation send Location to function + If PBMap\CallBackLocation > 0 + CallFunctionFast(PBMap\CallBackLocation, @PBMap\GeographicCoordinates) + EndIf + EndProcedure + + ;Go to x, y position relative to the canvas gadget + Procedure GotoPixel(x, y) + PBMap\PixelCoordinates\x = x + PBMap\PixelCoordinates\y = y Pixel2LatLon(@PBMap\PixelCoordinates, @PBMap\GeographicCoordinates, PBMap\Zoom) ; Start drawing PBMap\Redraw = #True @@ -1430,22 +1722,136 @@ Module PBMap EndProcedure Procedure.i GetZoom() - Protected Value.d - Value = PBMap\Zoom - ProcedureReturn Value + ProcedureReturn PBMap\Zoom + EndProcedure + + Procedure.d GetAngle() + ProcedureReturn PBMap\Angle + EndProcedure + + Procedure NominatimGeoLocationQuery(Address.s, *ReturnPosition.GeographicCoordinates = 0) + Protected Size.i + Protected Query.s = "http://nominatim.openstreetmap.org/search/" + + URLEncoder(Address) + + "?format=json&addressdetails=0&polygon=0&limit=1" + Protected JSONFileName.s = PBMap\Options\HDDCachePath + "nominatimresponse.json" + ; Protected *Buffer = CurlReceiveHTTPToMemory("http://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1", PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + ; Debug *Buffer + ; Debug MemorySize(*Buffer) + ; Protected JSon.s = PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8) + HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) + Size = ReceiveHTTPFile(Query, JSONFileName) + If LoadJSON(0, JSONFileName) = 0 + ;Demivec's code + MyDebug( JSONErrorMessage() + " at position " + + JSONErrorPosition() + " in line " + + JSONErrorLine() + " of JSON web Data", 1) + ElseIf JSONArraySize(JSONValue(0)) > 0 + Protected object_val = GetJSONElement(JSONValue(0), 0) + Protected object_box = GetJSONMember(object_val, "boundingbox") + Protected bbox.BoundingBox + bbox\SouthEast\Latitude = ValD(GetJSONString(GetJSONElement(object_box, 0))) + bbox\NorthWest\Latitude = ValD(GetJSONString(GetJSONElement(object_box, 1))) + bbox\NorthWest\Longitude = ValD(GetJSONString(GetJSONElement(object_box, 2))) + bbox\SouthEast\Longitude = ValD(GetJSONString(GetJSONElement(object_box, 3))) + Protected lat.s = GetJSONString(GetJSONMember(object_val, "lat")) + Protected lon.s = GetJSONString(GetJSONMember(object_val, "lon")) + If *ReturnPosition <> 0 + *ReturnPosition\Latitude = ValD(lat) + *ReturnPosition\Longitude = ValD(lon) + EndIf + If lat<> "" And lon <> "" + ZoomToArea(bbox\SouthEast\Latitude, bbox\NorthWest\Latitude, bbox\NorthWest\Longitude, bbox\SouthEast\Longitude) + ;SetLocation(Position\Latitude, Position\Longitude) + EndIf + EndIf + EndProcedure + + ;(c) ts-soft http://www.purebasic.fr/english/viewtopic.php?f=12&t=58657&hilit=createdirectory&view=unread#unread + CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Windows + #FILE_ATTRIBUTE_DEVICE = 64 ;(0x40) + #FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768 ;(0x8000) + #FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192;(0x2000) + #FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072;(0x20000) + #FILE_ATTRIBUTE_VIRTUAL = 65536;(0x10000) + #FILE_ATTRIBUTE_DONTSETFLAGS = ~(#FILE_ATTRIBUTE_DIRECTORY| + #FILE_ATTRIBUTE_SPARSE_FILE| + #FILE_ATTRIBUTE_OFFLINE| + #FILE_ATTRIBUTE_NOT_CONTENT_INDEXED| + #FILE_ATTRIBUTE_VIRTUAL| + 0) + Macro SetFileAttributesEx(Name, Attribs) + SetFileAttributes(Name, Attribs & #FILE_ATTRIBUTE_DONTSETFLAGS) + EndMacro + CompilerDefault + Macro SetFileAttributesEx(Name, Attribs) + SetFileAttributes(Name, Attribs) + EndMacro + CompilerEndSelect + + Procedure CreateDirectoryEx(DirectoryName.s, FileAttribute = #PB_Default) + Protected i, c, tmp.s + If Right(DirectoryName, 1) = slash + DirectoryName = Left(DirectoryName, Len(DirectoryName) -1) + EndIf + c = CountString(DirectoryName, slash) + 1 + For i = 1 To c + tmp + StringField(DirectoryName, i, slash) + If FileSize(tmp) <> -2 + CreateDirectory(tmp) + EndIf + tmp + slash + Next + If FileAttribute <> #PB_Default + SetFileAttributesEx(DirectoryName, FileAttribute) + EndIf + If FileSize(DirectoryName) = -2 + ProcedureReturn #True + EndIf + EndProcedure + + Procedure.i ClearDiskCache() + If PBMap\Options\Warning + Protected Result.i = MessageRequester("Warning", "You will clear all cache content in " + PBMap\Options\HDDCachePath + ". Are you sure ?",#PB_MessageRequester_YesNo) + If Result = #PB_MessageRequester_No ; Quit if "no" selected + ProcedureReturn #False + EndIf + EndIf + If DeleteDirectory(PBMap\Options\HDDCachePath, "", #PB_FileSystem_Recursive) + MyDebug("Cache in : " + PBMap\Options\HDDCachePath + " cleared") + CreateDirectoryEx(PBMap\Options\HDDCachePath) + ProcedureReturn #True + Else + MyDebug("Can't clear cache in " + PBMap\Options\HDDCachePath) + ProcedureReturn #False + EndIf EndProcedure Procedure CanvasEvents() - Protected MouseX.i, MouseY.i + Protected CanvasMouseX.d, CanvasMouseY.d, MouseX.d, MouseY.d Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize Protected key.s, Touch.i + Protected Pixel.PixelCoordinates Static CtrlKey PBMap\Moving = #False + CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX + CanvasMouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\Drawing\RadiusY + ; rotation wip + ; StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget)) + ; RotateCoordinates(0, 0, PBMap\Angle) + ; CanvasMouseX = ConvertCoordinateX(MouseX, MouseY, #PB_Coordinate_Device, #PB_Coordinate_User) + ; CanvasMouseY = ConvertCoordinateY(MouseX, MouseY, #PB_Coordinate_Device, #PB_Coordinate_User) + ; StopVectorDrawing() Select EventType() + Case #PB_EventType_Focus + PBMap\Drawing\RadiusX = GadgetWidth(PBMap\Gadget) / 2 + PBMap\Drawing\RadiusY = GadgetHeight(PBMap\Gadget) / 2 Case #PB_EventType_KeyUp Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key) Case #PB_Shortcut_Delete DeleteSelectedMarkers() + DeleteSelectedTracks() EndSelect PBMap\Redraw = #True If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control = 0 @@ -1453,72 +1859,77 @@ Module PBMap EndIf Case #PB_EventType_KeyDown With PBMap\Markers() - Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key) - Case #PB_Shortcut_Left - ForEach PBMap\Markers() - If \Selected - \GeographicCoordinates\Longitude = ClipLongitude( \GeographicCoordinates\Longitude - 10* 360 / Pow(2, PBMap\Zoom + 8)) - EndIf - Next - Case #PB_Shortcut_Up - ForEach PBMap\Markers() - If \Selected - \GeographicCoordinates\Latitude + 10* 360 / Pow(2, PBMap\Zoom + 8) - EndIf - Next - Case #PB_Shortcut_Right - ForEach PBMap\Markers() - If \Selected - \GeographicCoordinates\Longitude = ClipLongitude( \GeographicCoordinates\Longitude + 10* 360 / Pow(2, PBMap\Zoom + 8)) - EndIf - Next - Case #PB_Shortcut_Down - ForEach PBMap\Markers() - If \Selected - \GeographicCoordinates\Latitude - 10* 360 / Pow(2, PBMap\Zoom + 8) - EndIf - Next - EndSelect + Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key) + Case #PB_Shortcut_Left + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Longitude = ClipLongitude( \GeographicCoordinates\Longitude - 10* 360 / Pow(2, PBMap\Zoom + 8)) + EndIf + Next + Case #PB_Shortcut_Up + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Latitude + 10* 360 / Pow(2, PBMap\Zoom + 8) + EndIf + Next + Case #PB_Shortcut_Right + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Longitude = ClipLongitude( \GeographicCoordinates\Longitude + 10* 360 / Pow(2, PBMap\Zoom + 8)) + EndIf + Next + Case #PB_Shortcut_Down + ForEach PBMap\Markers() + If \Selected + \GeographicCoordinates\Latitude - 10* 360 / Pow(2, PBMap\Zoom + 8) + EndIf + Next + EndSelect EndWith PBMap\Redraw = #True If GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Modifiers)&#PB_Canvas_Control <> 0 CtrlKey = #True EndIf Case #PB_EventType_LeftDoubleClick - If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT - ;Check if the mouse touch a marker, if so, jump to it - LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom) - MouseX = PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - 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) - MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth) - Touch = #False - ForEach PBMap\Markers() - LatLon2Pixel(@PBMap\Markers()\GeographicCoordinates, @MarkerCoords, PBMap\Zoom) - If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8 + LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom) + MouseX = PBMap\PixelCoordinates\x + CanvasMouseX + MouseY = PBMap\PixelCoordinates\y + CanvasMouseY + ;Clip MouseX to the map range (in X, the map is infinite) + MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth) + Touch = #False + ;Check if the mouse touch a marker + ForEach PBMap\Markers() + LatLon2Pixel(@PBMap\Markers()\GeographicCoordinates, @MarkerCoords, PBMap\Zoom) + If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8 + If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT + ;Jump to the marker Touch = #True SetLocation(PBMap\Markers()\GeographicCoordinates\Latitude, PBMap\Markers()\GeographicCoordinates\Longitude) - Break + ElseIf PBMap\Mode = #MODE_EDIT + ;Edit the legend + MarkerEdit(@PBMap\Markers()) EndIf - Next - EndIf + Break + EndIf + Next If Not Touch - GotoPixelRel(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)) + GotoPixel(MouseX, MouseY) EndIf Case #PB_EventType_MouseWheel If PBMap\Options\WheelMouseRelative ;Relative zoom (centered on the mouse) - SetZoomOnPosition(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta)) + ZoomOnPixel(CanvasMouseX, CanvasMouseY, GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta)) Else ;Absolute zoom (centered on the center of the map) SetZoom(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta), #PB_Relative) EndIf Case #PB_EventType_LeftButtonDown - LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom) - MouseX = PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) + ;LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom) + ;Mem cursor Coord + PBMap\MoveStartingPoint\x = CanvasMouseX + PBMap\MoveStartingPoint\y = CanvasMouseY ;Clip MouseX to the map range (in X, the map is infinite) - MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth) + PBMap\MoveStartingPoint\x = Mod(Mod(PBMap\MoveStartingPoint\x, MapWidth) + MapWidth, MapWidth) If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT PBMap\EditMarker = #False ;Check if we select marker(s) @@ -1532,15 +1943,25 @@ Module PBMap PBMap\Markers()\Focus = #False EndIf 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 - ;Mem cursor Coord - PBMap\MoveStartingPoint\x = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\MoveStartingPoint\y = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) Case #PB_EventType_MouseMove PBMap\Moving = #True + ; Drag If PBMap\MoveStartingPoint\x <> - 1 - MouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\MoveStartingPoint\x - MouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\MoveStartingPoint\y + MouseX = CanvasMouseX - PBMap\MoveStartingPoint\x + MouseY = CanvasMouseY - PBMap\MoveStartingPoint\y + PBMap\MoveStartingPoint\x = CanvasMouseX + PBMap\MoveStartingPoint\y = CanvasMouseY ;Move selected markers If PBMap\EditMarker And (PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT) ForEach PBMap\Markers() @@ -1565,28 +1986,57 @@ Module PBMap EndIf EndIf PBMap\Redraw = #True - PBMap\MoveStartingPoint\x = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\MoveStartingPoint\y = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) Else + ; Touch test LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom) - MouseX = PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) + MouseX = PBMap\PixelCoordinates\x + CanvasMouseX + MouseY = PBMap\PixelCoordinates\y + CanvasMouseY ;Clip MouseX to the map range (in X, the map is infinite) 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 Or PBMap\Mode = #MODE_EDIT + ;Check if mouse touch markers ForEach PBMap\Markers() LatLon2Pixel(@PBMap\Markers()\GeographicCoordinates, @MarkerCoords, PBMap\Zoom) If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8 PBMap\Markers()\Focus = #True - Else + PBMap\Redraw = #True + ElseIf PBMap\Markers()\Focus ;If CtrlKey = #False PBMap\Markers()\Focus = #False - ;EndIf + PBMap\Redraw = #True EndIf 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)) + ;Simulate tracks drawing + ForEach \Track() + LatLon2Pixel(@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(MouseX, MouseY, \StrokeWidth) + \Focus = #True + PBMap\Redraw = #True + ElseIf \Focus + \Focus = #False + PBMap\Redraw = #True + EndIf + StopVectorDrawing() + EndIf + EndIf + Next + EndIf + EndWith EndIf - PBMap\Redraw = #True EndIf Case #PB_EventType_LeftButtonUp PBMap\MoveStartingPoint\x = - 1 @@ -1610,29 +2060,66 @@ Module PBMap EndSelect EndProcedure + ; Redraws at regular intervals Procedure TimerEvents() - ;Redraw at regular intervals If EventTimer() = PBMap\Timer And (PBMap\Redraw Or PBMap\Dirty) Drawing() EndIf EndProcedure + ; Could be called directly to attach our map to an existing canvas + Procedure BindMapGadget(Gadget.i) + PBMap\Gadget = Gadget + BindGadgetEvent(PBMap\Gadget, @CanvasEvents()) + AddWindowTimer(PBMap\Window, PBMap\Timer, PBMap\Options\TimerInterval) + BindEvent(#PB_Event_Timer, @TimerEvents()) + PBMap\Drawing\RadiusX = GadgetWidth(PBMap\Gadget) / 2 + PBMap\Drawing\RadiusY = GadgetHeight(PBMap\Gadget) / 2 + EndProcedure + + ; Creates a canvas and attach our map Procedure MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i) If Gadget = #PB_Any PBMap\Gadget = CanvasGadget(PBMap\Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard) ;#PB_Canvas_Keyboard has to be set for mousewheel to work on windows Else PBMap\Gadget = Gadget CanvasGadget(PBMap\Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard) - EndIf - BindGadgetEvent(PBMap\Gadget, @CanvasEvents()) - AddWindowTimer(PBMap\Window, PBMap\Timer, PBMap\Options\TimerInterval) - BindEvent(#PB_Event_Timer, @TimerEvents()) - ;AddKeyboardShortcut(#PB_Shortcut_Delete + EndIf + BindMapGadget(PBMap\Gadget) + EndProcedure + + Procedure InitPBMap(Window) + Protected Result.i + PBMap\ZoomMin = 0 + PBMap\ZoomMax = 18 + PBMap\MoveStartingPoint\x = - 1 + PBMap\TileSize = 256 + PBMap\Dirty = #False + PBMap\EditMarker = #False + PBMap\Font = LoadFont(#PB_Any, "Arial", 20, #PB_Font_Bold) + PBMap\Window = Window + PBMap\Timer = 1 + PBMap\Mode = #MODE_DEFAULT + LoadOptions() + If PBMap\Options\Verbose + OpenConsole() + EndIf + CreateDirectoryEx(PBMap\Options\HDDCachePath) + If PBMap\Options\DefaultOSMServer <> "" + AddMapServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer) + EndIf + TechnicalImagesCreation() + SetLocation(0, 0) EndProcedure EndModule -;-**** Example of application **** +;**************************************************************** +; +;- Example of application +; +;**************************************************************** + CompilerIf #PB_Compiler_IsMainFile InitNetwork() @@ -1643,6 +2130,8 @@ CompilerIf #PB_Compiler_IsMainFile #Gdt_Right #Gdt_Up #Gdt_Down + ;#Gdt_RotateLeft + ;#Gdt_RotateRight #Button_4 #Button_5 #Combo_0 @@ -1657,6 +2146,16 @@ CompilerIf #PB_Compiler_IsMainFile #Gdt_AddMarker #Gdt_AddOpenseaMap #Gdt_Degrees + #Gdt_EditMode + #Gdt_ClearDiskCache + #TextGeoLocationQuery + #StringGeoLocationQuery + EndEnumeration + + ;Menu events + Enumeration + #MenuEventLonLatStringEnter + #MenuEventGeoLocationStringEnter EndEnumeration Structure Location @@ -1701,19 +2200,25 @@ CompilerIf #PB_Compiler_IsMainFile ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_Left, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_Right,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ;ResizeGadget(#Gdt_RotateLeft, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ;ResizeGadget(#Gdt_RotateRight,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_Up, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_Down, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Text_2,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Button_4,WindowWidth(#Window_0)-150,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Button_5,WindowWidth(#Window_0)-100,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Text_3,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) - ResizeGadget(#StringLatitude,WindowWidth(#Window_0)-100,#PB_Ignore,#PB_Ignore,#PB_Ignore) - ResizeGadget(#StringLongitude,WindowWidth(#Window_0)-100,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#StringLatitude,WindowWidth(#Window_0)-120,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#StringLongitude,WindowWidth(#Window_0)-120,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Text_4,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_AddMarker,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_LoadGpx,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_AddOpenseaMap,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Gdt_Degrees,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#Gdt_EditMode,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#Gdt_ClearDiskCache,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#TextGeoLocationQuery,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) + ResizeGadget(#StringGeoLocationQuery,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore) PBMap::Refresh() EndProcedure @@ -1722,8 +2227,11 @@ CompilerIf #PB_Compiler_IsMainFile LoadFont(0, "Arial", 12) LoadFont(1, "Arial", 12, #PB_Font_Bold) + LoadFont(2, "Arial", 8) TextGadget(#Text_1, 530, 50, 60, 15, "Movements") + ;ButtonGadget(#Gdt_RotateLeft, 550, 070, 30, 30, "LRot") : SetGadgetFont(#Gdt_RotateLeft, FontID(2)) + ;ButtonGadget(#Gdt_RotateRight, 610, 070, 30, 30, "RRot") : SetGadgetFont(#Gdt_RotateRight, FontID(2)) ButtonGadget(#Gdt_Left, 550, 100, 30, 30, Chr($25C4)) : SetGadgetFont(#Gdt_Left, FontID(0)) ButtonGadget(#Gdt_Right, 610, 100, 30, 30, Chr($25BA)) : SetGadgetFont(#Gdt_Right, FontID(0)) ButtonGadget(#Gdt_Up, 580, 070, 30, 30, Chr($25B2)) : SetGadgetFont(#Gdt_Up, FontID(0)) @@ -1731,32 +2239,48 @@ CompilerIf #PB_Compiler_IsMainFile TextGadget(#Text_2, 530, 160, 60, 15, "Zoom") ButtonGadget(#Button_4, 550, 180, 50, 30, " + ") : SetGadgetFont(#Button_4, FontID(1)) ButtonGadget(#Button_5, 600, 180, 50, 30, " - ") : SetGadgetFont(#Button_5, FontID(1)) - TextGadget(#Text_3, 530, 230, 60, 15, "Latitude : ") - StringGadget(#StringLatitude, 600, 230, 90, 20, "") - TextGadget(#Text_4, 530, 250, 60, 15, "Longitude : ") - StringGadget(#StringLongitude, 600, 250, 90, 20, "") + TextGadget(#Text_3, 530, 230, 50, 15, "Latitude ") + StringGadget(#StringLatitude, 580, 230, 90, 20, "") + TextGadget(#Text_4, 530, 250, 50, 15, "Longitude ") + StringGadget(#StringLongitude, 580, 250, 90, 20, "") ButtonGadget(#Gdt_AddMarker, 530, 280, 150, 30, "Add Marker") ButtonGadget(#Gdt_LoadGpx, 530, 310, 150, 30, "Load GPX") - ButtonGadget(#Gdt_AddOpenseaMap, 530, 340, 150, 30, "OpenSeaMap") - ButtonGadget(#Gdt_Degrees, 530, 370, 150, 30, "Show/Hide Degrees") - + ButtonGadget(#Gdt_AddOpenseaMap, 530, 340, 150, 30, "Show/Hide OpenSeaMap", #PB_Button_Toggle) + ButtonGadget(#Gdt_Degrees, 530, 370, 150, 30, "Show/Hide Degrees", #PB_Button_Toggle) + ButtonGadget(#Gdt_EditMode, 530, 400, 150, 30, "Edit mode ON/OFF", #PB_Button_Toggle) + ButtonGadget(#Gdt_ClearDiskCache, 530, 430, 150, 30, "Clear disk cache", #PB_Button_Toggle) + TextGadget(#TextGeoLocationQuery, 530, 465, 150, 15, "Enter an address") + StringGadget(#StringGeoLocationQuery, 530, 480, 150, 20, "") + SetActiveGadget(#StringGeoLocationQuery) + AddKeyboardShortcut(#Window_0, #PB_Shortcut_Return, #MenuEventGeoLocationStringEnter) + ;*** TODO : code to remove when the SetActiveGadget(-1) will be fixed + CompilerIf #PB_Compiler_OS = #PB_OS_Linux + Define Dummy = ButtonGadget(#PB_Any, 0, 0, 1, 1, "Dummy") + HideGadget(Dummy, 1) + CompilerElse + Define Dummy = -1 + CompilerEndIf + ;*** Define Event.i, Gadget.i, Quit.b = #False Define pfValue.d Define OpenSeaMap = 0, Degrees = 1 + Define *Track ;Our main gadget PBMap::InitPBMap(#Window_0) - PBMap::SetOption("ShowDegrees", "1") + PBMap::SetOption("ShowDegrees", "0") : Degrees = 0 PBMap::SetOption("ShowDebugInfos", "0") - PBMap::SetOption("ShowScale", "1") + PBMap::SetOption("ShowScale", "1") + PBMap::SetOption("Warning", "1") PBMap::SetOption("ShowMarkersLegend", "1") - PBMap::SetOption("TrackShowKms", "1") + PBMap::SetOption("ShowTrackKms", "1") + PBMap::SetOption("ColourFocus", "$FFFF00AA") PBMap::MapGadget(#Map, 10, 10, 512, 512) PBMap::SetCallBackMainPointer(@MainPointer()) ; To change the main pointer (center of the view) PBMap::SetCallBackLocation(@UpdateLocation()) ; To obtain realtime coordinates PBMap::SetLocation(-36.81148, 175.08634,12) ; Change the PBMap coordinates PBMAP::SetMapScaleUnit(PBMAP::#SCALE_KM) ; To change the scale unit - PBMap::AddMarker(49.0446828398, 2.0349812508, "", -1, @MyMarker()) ; To add a marker with a customised GFX + PBMap::AddMarker(49.0446828398, 2.0349812508, "", "", -1, @MyMarker()) ; To add a marker with a customised GFX Repeat Event = WaitWindowEvent() @@ -1773,35 +2297,78 @@ CompilerIf #PB_Compiler_IsMainFile PBMap::SetLocation(0, 10* -360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative) Case #Gdt_Right PBMap::SetLocation(0, 10* 360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative) + ;Case #Gdt_RotateLeft + ; PBMAP::SetAngle(-5,#PB_Relative) + ; PBMap::Refresh() + ;Case #Gdt_RotateRight + ; PBMAP::SetAngle(5,#PB_Relative) + ; PBMap::Refresh() Case #Button_4 PBMap::SetZoom(1) Case #Button_5 PBMap::SetZoom( - 1) Case #Gdt_LoadGpx - PBMap::LoadGpxFile(OpenFileRequester("Choose a file to load", "", "Gpx|*.gpx", 0)) + *Track = PBMap::LoadGpxFile(OpenFileRequester("Choose a file to load", "", "Gpx|*.gpx", 0)) + PBMap::SetTrackColour(*Track, RGBA(Random(255), Random(255), Random(255), 128)) Case #StringLatitude, #StringLongitude Select EventType() + Case #PB_EventType_Focus + AddKeyboardShortcut(#Window_0, #PB_Shortcut_Return, #MenuEventLonLatStringEnter) Case #PB_EventType_LostFocus - PBMap::SetLocation(ValD(GetGadgetText(#StringLatitude)), ValD(GetGadgetText(#StringLongitude))) ; Change the PBMap coordinates - PBMAP::Refresh() + RemoveKeyboardShortcut(#Window_0, #PB_Shortcut_Return) EndSelect Case #Gdt_AddMarker - PBMap::AddMarker(ValD(GetGadgetText(#StringLatitude)), ValD(GetGadgetText(#StringLongitude)), "Test", RGBA(Random(255), Random(255), Random(255), 255)) + PBMap::AddMarker(ValD(GetGadgetText(#StringLatitude)), ValD(GetGadgetText(#StringLongitude)), "", "Test", RGBA(Random(255), Random(255), Random(255), 255)) Case #Gdt_AddOpenseaMap If OpenSeaMap = 0 OpenSeaMap = PBMap::AddMapServerLayer("OpenSeaMap", 2, "http://t1.openseamap.org/seamark/") ; Add a special osm overlay map on layer nb 2 + SetGadgetState(#Gdt_AddOpenseaMap, 1) Else PBMap::DeleteLayer(OpenSeaMap) OpenSeaMap = 0 + SetGadgetState(#Gdt_AddOpenseaMap, 0) EndIf PBMAP::Refresh() Case #Gdt_Degrees Degrees = 1 - Degrees PBMap::SetOption("ShowDegrees", Str(Degrees)) PBMap::Refresh() + SetGadgetState(#Gdt_Degrees, Degrees) + Case #Gdt_EditMode + If PBMap::GetMode() <> PBMap::#MODE_EDIT + PBMap::SetMode(PBMap::#MODE_EDIT) + SetGadgetState(#Gdt_EditMode, 1) + Else + PBMap::SetMode(PBMap::#MODE_DEFAULT) + SetGadgetState(#Gdt_EditMode, 0) + EndIf + Case #Gdt_ClearDiskCache + PBMap::ClearDiskCache() + Case #StringGeoLocationQuery + Select EventType() + Case #PB_EventType_Focus + AddKeyboardShortcut(#Window_0, #PB_Shortcut_Return, #MenuEventGeoLocationStringEnter) + Case #PB_EventType_LostFocus + RemoveKeyboardShortcut(#Window_0, #PB_Shortcut_Return) + EndSelect EndSelect Case #PB_Event_SizeWindow ResizeAll() + Case #PB_Event_Menu + ;Receive "enter" key events + Select EventMenu() + Case #MenuEventGeoLocationStringEnter + If GetGadgetText(#StringGeoLocationQuery) <> "" + PBMap::NominatimGeoLocationQuery(GetGadgetText(#StringGeoLocationQuery)) + PBMap::Refresh() + EndIf + ;*** TODO : code to change when the SetActiveGadget(-1) will be fixed + SetActiveGadget(Dummy) + ;*** + Case #MenuEventLonLatStringEnter + PBMap::SetLocation(ValD(GetGadgetText(#StringLatitude)), ValD(GetGadgetText(#StringLongitude))) ; Change the PBMap coordinates + PBMap::Refresh() + EndSelect EndSelect Until Quit = #True @@ -1809,10 +2376,12 @@ CompilerIf #PB_Compiler_IsMainFile EndIf CompilerEndIf -; IDE Options = PureBasic 5.50 (Windows - x64) -; CursorPosition = 11 -; Folding = ------------- + + +; IDE Options = PureBasic 5.60 beta 7 (Windows - x64) +; CursorPosition = 2250 +; FirstLine = 2260 +; Folding = ----------------- ; EnableThread ; EnableXP -; DisableDebugger ; EnableUnicode \ No newline at end of file diff --git a/gettext.pbi b/gettext.pbi new file mode 100644 index 0000000..c5f5b7e --- /dev/null +++ b/gettext.pbi @@ -0,0 +1,29 @@ +Procedure.s gettext(String.s = "") + Protected Language.s = "EN_en" + + Select Language + + Case "EN_en" + ProcedureReturn String + + Case "FR_fr" + + Select String + + Case "Identifier" + ProcedureReturn("Identificateur") + + Default + ProcedureReturn String + + EndSelect + + Default + ProcedureReturn String + + EndSelect +EndProcedure +; IDE Options = PureBasic 5.50 (Windows - x64) +; CursorPosition = 21 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/libcurl.pbi b/libcurl.pbi deleted file mode 100644 index 0902a9d..0000000 --- a/libcurl.pbi +++ /dev/null @@ -1,1070 +0,0 @@ -Enumeration 0 - #CURLE_OK - #CURLE_UNSUPPORTED_PROTOCOL ; 1 - #CURLE_FAILED_INIT ; 2 - #CURLE_URL_MALFORMAT ; 3 - #CURLE_URL_MALFORMAT_USER ; 4 (Not USED) - #CURLE_COULDNT_RESOLVE_PROXY ; 5 - #CURLE_COULDNT_RESOLVE_HOST ; 6 - #CURLE_COULDNT_CONNECT ; 7 - #CURLE_FTP_WEIRD_SERVER_REPLY ; 8 - #CURLE_FTP_ACCESS_DENIED ; 9 a service was denied by the FTP server due To lack of access - when login fails this is Not returned. - #CURLE_FTP_USER_PASSWORD_INCORRECT ; 10 - #CURLE_FTP_WEIRD_PASS_REPLY ; 11 - #CURLE_FTP_WEIRD_USER_REPLY ; 12 - #CURLE_FTP_WEIRD_PASV_REPLY ; 13 - #CURLE_FTP_WEIRD_227_FORMAT ; 14 - #CURLE_FTP_CANT_GET_HOST ; 15 - #CURLE_FTP_CANT_RECONNECT ; 16 - #CURLE_FTP_COULDNT_SET_BINARY ; 17 - #CURLE_PARTIAL_FILE ; 18 - #CURLE_FTP_COULDNT_RETR_FILE ; 19 - #CURLE_FTP_WRITE_ERROR ; 20 - #CURLE_FTP_QUOTE_ERROR ; 21 - #CURLE_HTTP_RETURNED_ERROR ; 22 - #CURLE_WRITE_ERROR ; 23 - #CURLE_MALFORMAT_USER ; 24 - Not USED - #CURLE_FTP_COULDNT_STOR_FILE ; 25 - failed FTP upload - #CURLE_READ_ERROR ; 26 - could open/Read from file - #CURLE_OUT_OF_MEMORY ; 27 - #CURLE_OPERATION_TIMEOUTED ; 28 - the timeout time was reached - #CURLE_FTP_COULDNT_SET_ASCII ; 29 - TYPE A failed - #CURLE_FTP_PORT_FAILED ; 30 - FTP PORT operation failed - #CURLE_FTP_COULDNT_USE_REST ; 31 - the REST command failed - #CURLE_FTP_COULDNT_GET_SIZE ; 32 - the SIZE command failed - #CURLE_HTTP_RANGE_ERROR ; 33 - RANGE "command" didn't work - #CURLE_HTTP_POST_ERROR ; 34 - #CURLE_SSL_CONNECT_ERROR ; 35 - wrong when connecting With SSL - #CURLE_BAD_DOWNLOAD_RESUME ; 36 - couldn't resume download - #CURLE_FILE_COULDNT_READ_FILE ; 37 - #CURLE_LDAP_CANNOT_BIND ; 38 - #CURLE_LDAP_SEARCH_FAILED ; 39 - #CURLE_LIBRARY_NOT_FOUND ; 40 - #CURLE_FUNCTION_NOT_FOUND ; 41 - #CURLE_ABORTED_BY_CALLBACK ; 42 - #CURLE_BAD_FUNCTION_ARGUMENT ; 43 - #CURLE_BAD_CALLING_ORDER ; 44 - Not USED - #CURLE_INTERFACE_FAILED ; 45 - CURLOPT_INTERFACE failed - #CURLE_BAD_PASSWORD_ENTERED ; 46 - Not USED - #CURLE_TOO_MANY_REDIRECTS ; 47 - catch endless re-direct loops - #CURLE_UNKNOWN_TELNET_OPTION ; 48 - User specified an unknown option - #CURLE_TELNET_OPTION_SYNTAX ; 49 - Malformed telnet option - #CURLE_OBSOLETE ; 50 - Not USED - #CURLE_SSL_PEER_CERTIFICATE ; 51 - peer's certificate wasn't ok - #CURLE_GOT_NOTHING ; 52 - when this is a specific error - #CURLE_SSL_ENGINE_NOTFOUND ; 53 - SSL crypto engine Not found - #CURLE_SSL_ENGINE_SETFAILED ; 54 - can Not set SSL crypto engine As Default - #CURLE_SEND_ERROR ; 55 - failed sending network Data - #CURLE_RECV_ERROR ; 56 - failure in receiving network Data - #CURLE_SHARE_IN_USE ; 57 - share is in use - #CURLE_SSL_CERTPROBLEM ; 58 - problem With the local certificate - #CURLE_SSL_CIPHER ; 59 - couldn't use specified cipher - #CURLE_SSL_CACERT ; 60 - problem With the CA cert (path?) - #CURLE_BAD_CONTENT_ENCODING ; 61 - Unrecognized transfer encoding - #CURLE_LDAP_INVALID_URL ; 62 - Invalid LDAP URL - #CURLE_FILESIZE_EXCEEDED ; 63 - Maximum file size exceeded - #CURLE_FTP_SSL_FAILED ; 64 - Requested FTP SSL level failed - #CURLE_SEND_FAIL_REWIND ; 65 - Sending the Data requires a rewind that failed - #CURLE_SSL_ENGINE_INITFAILED ; 66 - failed To initialise ENGINE - #CURLE_LOGIN_DENIED ; 67 - user password Or similar was Not accepted And we failed To login - #CURLE_TFTP_NOTFOUND ; 68 - file Not found on server - #CURLE_TFTP_PERM ; 69 - permission problem on server - #CURLE_TFTP_DISKFULL ; 70 - out of disk space on server - #CURLE_TFTP_ILLEGAL ; 71 - Illegal TFTP operation - #CURLE_TFTP_UNKNOWNID ; 72 - Unknown transfer ID - #CURLE_TFTP_EXISTS ; 73 - File already exists - #CURLE_TFTP_NOSUCHUSER ; 74 - No such user - #CURL_LAST ; never use! -EndEnumeration -Enumeration 0 ; curlsocktype - #CURLSOCKTYPE_IPCXN ; socket created For a specific IP connection - #CURLSOCKTYPE_LAST ; never use -EndEnumeration -Enumeration ; curlioerr - #CURLIOE_OK ; I/O operation successful - #CURLIOE_UNKNOWNCMD ; command was unknown To callback - #CURLIOE_FAILRESTART ; failed To restart the Read - #CURLIOE_LAST ; never use -EndEnumeration -Enumeration ; curliocmd - #CURLIOCMD_NOP ; no operation - #CURLIOCMD_RESTARTREAD ; restart the Read stream from start - #CURLIOCMD_LAST ; never use -EndEnumeration -Enumeration 0 ; curl_infotype - ; the kind of Data that is passed To information_callback - #CURLINFO_TEXT - #CURLINFO_HEADER_IN ; 1 - #CURLINFO_HEADER_OUT ; 2 - #CURLINFO_DATA_IN ; 3 - #CURLINFO_DATA_OUT ; 4 - #CURLINFO_SSL_DATA_IN ; 5 - #CURLINFO_SSL_DATA_OUT ; 6 - #CURLINFO_END -EndEnumeration -Enumeration ; curl_proxytype - #CURLPROXY_HTTP = 0 - #CURLPROXY_SOCKS4 = 4 - #CURLPROXY_SOCKS5 = 5 -EndEnumeration -Enumeration ; curl_usessl - ; parameter For the CURLOPT_USE_SSL option - #CURLUSESSL_NONE ; do Not attempt To use SSL - #CURLUSESSL_TRY ; try using SSL proceed anyway otherwise - #CURLUSESSL_CONTROL ; SSL For the control connection Or fail - #CURLUSESSL_ALL ; SSL For all communication Or fail - #CURLUSESSL_LAST ; Not an option never use -EndEnumeration ; -Enumeration ; curl_ftpccc - ; parameter For the CURLOPT_FTP_SSL_CCC option - #CURLFTPSSL_CCC_NONE ; do Not send CCC - #CURLFTPSSL_CCC_PASSIVE ; Let the server initiate the shutdown - #CURLFTPSSL_CCC_ACTIVE ; Initiate the shutdown - #CURLFTPSSL_CCC_LAST ; Not an option never use -EndEnumeration -Enumeration ; curl_ftpauth - ; parameter For the CURLOPT_FTPSSLAUTH option - #CURLFTPAUTH_DEFAULT ; let libcurl decide - #CURLFTPAUTH_SSL ; use "AUTH SSL" - #CURLFTPAUTH_TLS ; use "AUTH TLS" - #CURLFTPAUTH_LAST ; Not an option never use -EndEnumeration -Enumeration ; curl_ftpmethod - ; parameter For the CURLOPT_FTP_FILEMETHOD option - #CURLFTPMETHOD_DEFAULT ; let libcurl pick - #CURLFTPMETHOD_MULTICWD ; single CWD operation For each path part - #CURLFTPMETHOD_NOCWD ; no CWD at all - #CURLFTPMETHOD_SINGLECWD ; one CWD To full dir then work on file - #CURLFTPMETHOD_LAST ; Not an option never use -EndEnumeration -Enumeration ; curl_http - ; These enums are For use With the CURLOPT_HTTP_VERSION option. - #CURL_HTTP_VERSION_NONE ; setting this means we don't care and that we'd - ; like the library To choose the best possible - ; For us! - #CURL_HTTP_VERSION_1_0 ; please use HTTP 1.0 in the request - #CURL_HTTP_VERSION_1_1 ; please use HTTP 1.1 in the request - #CURL_HTTP_VERSION_LAST ; *ILLEGAL* http version -EndEnumeration -Enumeration ; curl_NETRC_OPTION - ; These enums are For use With the CURLOPT_NETRC option. - #CURL_NETRC_IGNORED ; The .netrc will never be Read. - ; This is the Default. - #CURL_NETRC_OPTIONAL ; A user:password in the URL will be preferred - ; To one in the .netrc. - #CURL_NETRC_REQUIRED ; A user:password in the URL will be ignored. - ; Unless one is set programmatically the .netrc - ; will be queried. - #CURL_NETRC_LAST -EndEnumeration -Enumeration ; curl_sslversion - #CURL_SSLVERSION_DEFAULT - #CURL_SSLVERSION_TLSv1 - #CURL_SSLVERSION_SSLv2 - #CURL_SSLVERSION_SSLv3 - #CURL_SSLVERSION_LAST ; never use keep last -EndEnumeration -Enumeration ; curl_TimeCond - #CURL_TIMECOND_NONE - #CURL_TIMECOND_IFMODSINCE - #CURL_TIMECOND_IFUNMODSINCE - #CURL_TIMECOND_LASTMOD - #CURL_TIMECOND_LAST -EndEnumeration ; -Enumeration ; curlformoption - #CURLFORM_NOTHING ; the first one is unused - #CURLFORM_COPYNAME - #CURLFORM_PTRNAME - #CURLFORM_NAMELENGTH - #CURLFORM_COPYCONTENTS - #CURLFORM_PTRCONTENTS - #CURLFORM_CONTENTSLENGTH - #CURLFORM_FILECONTENT - #CURLFORM_ARRAY - #CURLFORM_OBSOLETE - #CURLFORM_FILE - #CURLFORM_BUFFER - #CURLFORM_BUFFERPTR - #CURLFORM_BUFFERLENGTH - #CURLFORM_CONTENTTYPE - #CURLFORM_CONTENTHEADER - #CURLFORM_FILENAME - #CURLFORM_End - #CURLFORM_OBSOLETE2 - #CURLFORM_LASTENTRY ; the last unusued -EndEnumeration -; use this For multipart formpost building -; Returns code For #CURL_formadd() -; Returns: -; #CURL_FORMADD_OK on success -; #CURL_FORMADD_MEMORY If the FormInfo allocation fails -; #CURL_FORMADD_OPTION_TWICE If one option is given twice For one Form -; #CURL_FORMADD_NULL If a null pointer was given For a char -; #CURL_FORMADD_MEMORY If the allocation of a FormInfo struct failed -; #CURL_FORMADD_UNKNOWN_OPTION If an unknown option was used -; #CURL_FORMADD_INCOMPLETE If the some FormInfo is Not complete (Or error) -; #CURL_FORMADD_MEMORY If a HttpPost struct cannot be allocated -; #CURL_FORMADD_MEMORY If some allocation For string copying failed. -; #CURL_FORMADD_ILLEGAL_ARRAY If an illegal option is used in an array -Enumeration ; CURLFORMcode - #CURL_FORMADD_OK ; first no error - #CURL_FORMADD_MEMORY - #CURL_FORMADD_OPTION_TWICE - #CURL_FORMADD_NULL - #CURL_FORMADD_UNKNOWN_OPTION - #CURL_FORMADD_INCOMPLETE - #CURL_FORMADD_ILLEGAL_ARRAY - #CURL_FORMADD_DISABLED ; libcurl was built With this disabled - #CURL_FORMADD_LAST ; last -EndEnumeration -Enumeration ; CURL_closepolicy - #CURLCLOSEPOLICY_NONE ; first never use this - #CURLCLOSEPOLICY_OLDEST - #CURLCLOSEPOLICY_LEAST_RECENTLY_USED - #CURLCLOSEPOLICY_LEAST_TRAFFIC - #CURLCLOSEPOLICY_SLOWEST - #CURLCLOSEPOLICY_CALLBACK - #CURLCLOSEPOLICY_LAST ; last never use this -EndEnumeration -; Different Data locks For a single share -Enumeration 0 ; CURL_lock_data - #CURL_LOCK_DATA_NONE - ; #CURL_LOCK_DATA_SHARE is used internaly To say that - ; the locking is just made To change the internal state of the share - ; itself. - #CURL_LOCK_DATA_SHARE - #CURL_LOCK_DATA_COOKIE - #CURL_LOCK_DATA_DNS - #CURL_LOCK_DATA_SSL_SESSION - #CURL_LOCK_DATA_CONNECT - #CURL_LOCK_DATA_LAST -EndEnumeration ; - ; Different lock access types -Enumeration ; CURL_lock_access - #CURL_LOCK_ACCESS_NONE = 0 ; unspecified action - #CURL_LOCK_ACCESS_SHARED = 1 ; For Read perhaps - #CURL_LOCK_ACCESS_SINGLE = 2 ; For write perhaps - #CURL_LOCK_ACCESS_LAST ; never use -EndEnumeration ; -Enumeration ; CURLSHcode - #CURLSHE_OK ; all is fine - #CURLSHE_BAD_OPTION ; 1 - #CURLSHE_IN_USE ; 2 - #CURLSHE_INVALID ; 3 - #CURLSHE_NOMEM ; out of memory - #CURLSHE_LAST ; never use -EndEnumeration -Enumeration ; CURLSHoption - #CURLSHOPT_NONE ; don't use - #CURLSHOPT_SHARE ; specify a Data type To share - #CURLSHOPT_UNSHARE ; specify shich Data type To stop sharing - #CURLSHOPT_LOCKFUNC ; pass in a '#CURL_lock_function' pointer - #CURLSHOPT_UNLOCKFUNC ; pass in a '#CURL_unlock_function' pointer - #CURLSHOPT_USERDATA ; pass in a user Data pointer used in the lock/unlock - ; callback functions - #CURLSHOPT_LAST ; never use -EndEnumeration -Enumeration ; CURLversion - #CURLVERSION_FIRST - #CURLVERSION_SECOND - #CURLVERSION_THIRD - #CURLVERSION_FOURTH - #CURLVERSION_LAST ; never actually use this -EndEnumeration -;} - -;{ Constantes -#CURL_IPRESOLVE_WHATEVER = 0 ; Default resolves addresses To all IP versions that your system allows -#CURL_IPRESOLVE_V4 = 1 ; resolve To ipv4 addresses -#CURL_IPRESOLVE_V6 = 2 ; resolve To ipv6 addresses - -#CURLOPT_HTTPREQUEST = -1 -; #CURLOPT_FTPASCII = #CURLOPT_TRANSFERTEXT -#CURLOPT_MUTE = -2 -#CURLOPT_PASSWDFUNCTION = -3 -#CURLOPT_PASSWDDATA = -4 -#CURLOPT_CLOSEFUNCTION = -5 -#CURLOPT_SOURCE_HOST = -6 -#CURLOPT_SOURCE_PATH = -7 -#CURLOPT_SOURCE_PORT = -8 -#CURLOPT_PASV_HOST = -9 - -#CURLOPT_INFILESIZE = 00014 -#CURLOPT_VERBOSE = 00041 -#CURLOPT_HEADER = 00042 -#CURLOPT_UPLOAD = 00046 -#CURLOPT_FOLLOWLOCATION = 00052 -#CURLOPT_SSL_VERIFYPEER = 00064 -#CURLOPT_SSL_VERIFYHOST = 00081 -#CURLOPT_IGNORE_CONTENT_LENGTH= 00136 -#CURLOPT_FILE = 10001 -#CURLOPT_URL = 10002 -#CURLOPT_USERPWD = 10005 -#CURLOPT_INFILE = 10009 -#CURLOPT_WRITEHEADER = 10029 -#CURLOPT_POSTQUOTE = 10039 - -#CURLOPT_INFILESIZE_LARGE = 30115 - -#CURLOPTTYPE_OBJECTPOINT = 10000 -#CURLOPT_POSTFIELDS = #CURLOPTTYPE_OBJECTPOINT + 15 - -#CURLOPTTYPE_FUNCTIONPOINT = 20000 -#CURLOPT_WRITEFUNCTION = #CURLOPTTYPE_FUNCTIONPOINT + 11 -#CURLOPT_HEADERFUNCTION = #CURLOPTTYPE_FUNCTIONPOINT + 79 - -; Three convenient "aliases" that follow the name scheme better -#CURLOPT_WRITEDATA = #CURLOPT_FILE -#CURLOPT_READDATA = #CURLOPT_INFILE -#CURLOPT_HEADERDATA = #CURLOPT_WRITEHEADER - -#CURL_GLOBAL_ALL = $00000003 -#CURL_GLOBAL_DEFAULT = $00000003 - -#CURL_MAX_WRITE_SIZE = 16384 -#CURL_READFUNC_ABORT = $10000000 -;{ #CURLINFO -#CURLINFO_STRING = $100000 -#CURLINFO_LONG = $200000 -#CURLINFO_DOUBLE = $300000 -#CURLINFO_SLIST = $400000 -#CURLINFO_MASK = $0fffff -#CURLINFO_TYPEMASK = $f00000 - -#CURLINFO_EFFECTIVE_URL = #CURLINFO_STRING + 1 -#CURLINFO_RESPONSE_CODE = #CURLINFO_LONG + 2 -#CURLINFO_TOTAL_TIME = #CURLINFO_DOUBLE + 3 -#CURLINFO_NAMELOOKUP_TIME = #CURLINFO_DOUBLE + 4 -#CURLINFO_CONNECT_TIME = #CURLINFO_DOUBLE + 5 -#CURLINFO_PRETRANSFER_TIME = #CURLINFO_DOUBLE + 6 -#CURLINFO_SIZE_UPLOAD = #CURLINFO_DOUBLE + 7 -#CURLINFO_SIZE_DOWNLOAD = #CURLINFO_DOUBLE + 8 -#CURLINFO_SPEED_DOWNLOAD = #CURLINFO_DOUBLE + 9 -#CURLINFO_SPEED_UPLOAD = #CURLINFO_DOUBLE + 10 -#CURLINFO_HEADER_SIZE = #CURLINFO_LONG + 11 -#CURLINFO_REQUEST_SIZE = #CURLINFO_LONG + 12 -#CURLINFO_SSL_VERIFYRESULT = #CURLINFO_LONG + 13 -#CURLINFO_FILETIME = #CURLINFO_LONG + 14 -#CURLINFO_CONTENT_LENGTH_DOWNLOAD = #CURLINFO_DOUBLE + 15 -#CURLINFO_CONTENT_LENGTH_UPLOAD = #CURLINFO_DOUBLE + 16 -#CURLINFO_STARTTRANSFER_TIME = #CURLINFO_DOUBLE + 17 -#CURLINFO_CONTENT_TYPE = #CURLINFO_STRING + 18 -#CURLINFO_REDIRECT_TIME = #CURLINFO_DOUBLE + 19 -#CURLINFO_REDIRECT_COUNT = #CURLINFO_LONG + 20 -#CURLINFO_PRIVATE = #CURLINFO_STRING + 21 -#CURLINFO_HTTP_CONNECTCODE = #CURLINFO_LONG + 22 -#CURLINFO_HTTPAUTH_AVAIL = #CURLINFO_LONG + 23 -#CURLINFO_PROXYAUTH_AVAIL = #CURLINFO_LONG + 24 -#CURLINFO_OS_ERRNO = #CURLINFO_LONG + 25 -#CURLINFO_NUM_CONNECTS = #CURLINFO_LONG + 26 -#CURLINFO_SSL_ENGINES = #CURLINFO_SLIST + 27 -#CURLINFO_COOKIELIST = #CURLINFO_SLIST + 28 -#CURLINFO_LASTSOCKET = #CURLINFO_LONG + 29 -#CURLINFO_FTP_ENTRY_PATH = #CURLINFO_STRING + 30 -#CURLINFO_LASTONE = 30 -#CURLINFO_HTTP_CODE = #CURLINFO_RESPONSE_CODE -;} -;{ #CURLOPT -#CURLOPTTYPE_LONG = 0 -#CURLOPTTYPE_OBJECTPOINT = 10000 -#CURLOPTTYPE_FUNCTIONPOINT = 20000 -#CURLOPTTYPE_OFF_T = 30000 - -;This Macro-mania below setups the CURLOPT_[what] enum + To be used With -;curl_easy_setopt(). The first argument in the CURLOPT_) Macro is the [what] word. - -; This is the FILE;Or void;the regular output should be written To. -#CURLOPT_FILE = #CURLOPTTYPE_OBJECTPOINT + 1 -; The full URL To get/put -#CURLOPT_URL= #CURLOPTTYPE_OBJECTPOINT + 2 -; Port number To connect To + If other than Default. -#CURLOPT_PORT= #CURLOPTTYPE_LONG + 3 -; Name of proxy To use. -#CURLOPT_PROXY= #CURLOPTTYPE_OBJECTPOINT + 4 -; "name:password" To use when fetching. -#CURLOPT_USERPWD= #CURLOPTTYPE_OBJECTPOINT + 5 -; "name:password" To use With proxy. -#CURLOPT_PROXYUSERPWD= #CURLOPTTYPE_OBJECTPOINT + 6 -; Range To get + specified As an ASCII string. -#CURLOPT_RANGE= #CURLOPTTYPE_OBJECTPOINT + 7 -; Specified file stream To upload from (use As input): -#CURLOPT_INFILE= #CURLOPTTYPE_OBJECTPOINT + 9 -; Buffer To receive error messages in + must be at least CURL_ERROR_SIZE -; bytes big. If this is Not used + error messages go To stderr instead: -#CURLOPT_ERRORBUFFER= #CURLOPTTYPE_OBJECTPOINT + 10 -; Function that will be called To store the output (instead of fwrite). The -; parameters will use fwrite() syntax + make sure To follow them. -#CURLOPT_WRITEFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 11 -; Function that will be called To Read the Input (instead of fread). The -; parameters will use fread() syntax + make sure To follow them. -#CURLOPT_READFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 12 -; Time-out the Read operation after this amount of seconds -#CURLOPT_TIMEOUT= #CURLOPTTYPE_LONG + 13 -; If the CURLOPT_INFILE is used + this can be used To inform libcurl about -; how large the file being sent really is. That allows better error -; checking And better verifies that the upload was succcessful. -1 means -; unknown size. -; For large file support + there is also a _LARGE version of the key -; which takes an off_t type + allowing platforms With larger off_t -; sizes To handle larger files. See below For INFILESIZE_LARGE. -#CURLOPT_INFILESIZE= #CURLOPTTYPE_LONG + 14 -; POST input fields. -#CURLOPT_POSTFIELDS= #CURLOPTTYPE_OBJECTPOINT + 15 -; Set the referer page (needed by some CGIs) -#CURLOPT_REFERER= #CURLOPTTYPE_OBJECTPOINT + 16 -; Set the FTP PORT string (Interface name + named Or numerical IP address) -; Use i.e '-' To use Default address. -#CURLOPT_FTPPORT= #CURLOPTTYPE_OBJECTPOINT + 17 -; Set the User-Agent string (examined by some CGIs) -#CURLOPT_USERAGENT= #CURLOPTTYPE_OBJECTPOINT + 18 -; If the download receives less than "low speed limit" bytes/second -; during "low speed time" seconds + the operations is aborted. -; You could i.e If you have a pretty high speed connection + abort If -; it is less than 2000 bytes/sec during 20 seconds. -; Set the "low speed limit" -#CURLOPT_LOW_SPEED_LIMIT= #CURLOPTTYPE_LONG + 19 -; Set the "low speed time" -#CURLOPT_LOW_SPEED_TIME= #CURLOPTTYPE_LONG + 20 -; Set the continuation offset. -; Note there is also a _LARGE version of this key which uses -; off_t types + allowing For large file offsets on platforms which -; use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. -#CURLOPT_RESUME_FROM= #CURLOPTTYPE_LONG + 21 -; Set cookie in request: -#CURLOPT_COOKIE= #CURLOPTTYPE_OBJECTPOINT + 22 -; This points To a linked list of headers + struct curl_slist kind -#CURLOPT_HTTPHEADER= #CURLOPTTYPE_OBJECTPOINT + 23 -; This points To a linked list of post entries + struct HttpPost -#CURLOPT_HTTPPOST= #CURLOPTTYPE_OBJECTPOINT + 24 -; name of the file keeping your private SSL-certificate -#CURLOPT_SSLCERT= #CURLOPTTYPE_OBJECTPOINT + 25 -; password For the SSL Or SSH private key -#CURLOPT_KEYPASSWD= #CURLOPTTYPE_OBJECTPOINT + 26 -; send TYPE parameter? -#CURLOPT_CRLF= #CURLOPTTYPE_LONG + 27 -; send linked-list of QUOTE commands -#CURLOPT_QUOTE= #CURLOPTTYPE_OBJECTPOINT + 28 -; send FILE;Or void;To store headers To + If you use a callback it -; is simply passed To the callback unmodified -#CURLOPT_WRITEHEADER= #CURLOPTTYPE_OBJECTPOINT + 29 -; point To a file To Read the initial cookies from + also enables -; "cookie awareness" -#CURLOPT_COOKIEFILE= #CURLOPTTYPE_OBJECTPOINT + 31 -; What version To specifly try To use. -; See CURL_SSLVERSION defines below. -#CURLOPT_SSLVERSION= #CURLOPTTYPE_LONG + 32 -; What kind of HTTP time condition To use + see defines -#CURLOPT_TIMECONDITION= #CURLOPTTYPE_LONG + 33 -; Time To use With the above condition. Specified in number of seconds -; since 1 Jan 1970 -#CURLOPT_TIMEVALUE= #CURLOPTTYPE_LONG + 34 -; Custom request= #CURLOPTTYPE_For customizing the get command like -; HTTP: DELETE + TRACE And others -; FTP: To use a different list command -#CURLOPT_CUSTOMREQUEST= #CURLOPTTYPE_OBJECTPOINT + 36 -; HTTP request= #CURLOPTTYPE_For odd commands like DELETE + TRACE And others -#CURLOPT_STDERR= #CURLOPTTYPE_OBJECTPOINT + 37 -; send linked-list of post-transfer QUOTE commands -#CURLOPT_POSTQUOTE= #CURLOPTTYPE_OBJECTPOINT + 39 -; Pass a pointer To string of the output using full variable-replacement -; As described elsewhere. -#CURLOPT_WRITEINFO= #CURLOPTTYPE_OBJECTPOINT + 40 -#CURLOPT_VERBOSE= #CURLOPTTYPE_LONG + 41 ; talk a lot -#CURLOPT_HEADER= #CURLOPTTYPE_LONG + 42 ; throw the header out too -#CURLOPT_NOPROGRESS= #CURLOPTTYPE_LONG + 43 ; shut off the progress meter -#CURLOPT_NOBODY= #CURLOPTTYPE_LONG + 44 ; use HEAD To get http document -#CURLOPT_FAILONERROR= #CURLOPTTYPE_LONG + 45 ; no output on http error codes >= 300 -#CURLOPT_UPLOAD= #CURLOPTTYPE_LONG + 46 ; this is an upload -#CURLOPT_POST= #CURLOPTTYPE_LONG + 47 ; HTTP POST method -#CURLOPT_DIRLISTONLY= #CURLOPTTYPE_LONG + 48 ; Return bare names when listing directories -#CURLOPT_APPEND= #CURLOPTTYPE_LONG + 50 ; Append instead of overwrite on upload! - ; Specify whether To Read the user+password from the .netrc Or the URL. - ; This must be one of the CURL_NETRC_* enums below. -#CURLOPT_NETRC= #CURLOPTTYPE_LONG + 51 -#CURLOPT_FOLLOWLOCATION= #CURLOPTTYPE_LONG + 52 ; use Location: Luke! -#CURLOPT_TRANSFERTEXT= #CURLOPTTYPE_LONG + 53 ; transfer Data in text/ASCII format -#CURLOPT_PUT= #CURLOPTTYPE_LONG + 54 ; HTTP PUT - ; Function that will be called instead of the internal progress display - ; function. This function should be defined As the curl_progress_callback - ; Prototype defines. -#CURLOPT_PROGRESSFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 56 -; Data passed To the progress callback -#CURLOPT_PROGRESSDATA= #CURLOPTTYPE_OBJECTPOINT + 57 -; We want the referer field set automatically when following locations -#CURLOPT_AUTOREFERER= #CURLOPTTYPE_LONG + 58 -; Port of the proxy + can be set in the proxy string As well With: -; "[host]:[port]" -#CURLOPT_PROXYPORT= #CURLOPTTYPE_LONG + 59 -; size of the POST input Data + If strlen() is Not good To use -#CURLOPT_POSTFIELDSIZE= #CURLOPTTYPE_LONG + 60 -; tunnel non-http operations through a HTTP proxy -#CURLOPT_HTTPPROXYTUNNEL= #CURLOPTTYPE_LONG + 61 -; Set the Interface string To use As outgoing network Interface -#CURLOPT_INTERFACE= #CURLOPTTYPE_OBJECTPOINT + 62 -; Set the krb4/5 security level + this also enables krb4/5 awareness. This -; is a string + 'clear' + 'safe' + 'confidential' Or 'private'. If the string -; is set but doesn't match one of these + 'private' will be used. -#CURLOPT_KRBLEVEL= #CURLOPTTYPE_OBJECTPOINT + 63 -; Set If we should verify the peer in ssl handshake + set 1 To verify. -#CURLOPT_SSL_VERIFYPEER= #CURLOPTTYPE_LONG + 64 -; The CApath Or CAfile used To validate the peer certificate -; this option is used only If SSL_VERIFYPEER is true -#CURLOPT_CAINFO= #CURLOPTTYPE_OBJECTPOINT + 65 -; Maximum number of http redirects To follow -#CURLOPT_MAXREDIRS= #CURLOPTTYPE_LONG + 68 -; Pass a long set To 1 To get the date of the requested document (If -; possible)! Pass a zero To shut it off. -#CURLOPT_FILETIME= #CURLOPTTYPE_LONG + 69 -; This points To a linked list of telnet options -#CURLOPT_TELNETOPTIONS= #CURLOPTTYPE_OBJECTPOINT + 70 -; Max amount of cached alive connections -#CURLOPT_MAXCONNECTS= #CURLOPTTYPE_LONG + 71 -; What policy To use when closing connections when the cache is filled up -#CURLOPT_CLOSEPOLICY= #CURLOPTTYPE_LONG + 72 -; Set To explicitly use a new connection For the upcoming transfer. -; Do Not use this unless you're absolutely sure of this + as it makes the -; operation slower And is less friendly For the network. -#CURLOPT_FRESH_CONNECT= #CURLOPTTYPE_LONG + 74 -; Set To explicitly forbid the upcoming transfer's connection to be re-used -; when done. Do Not use this unless you're absolutely sure of this + as it -; makes the operation slower And is less friendly For the network. -#CURLOPT_FORBID_REUSE= #CURLOPTTYPE_LONG + 75 -; Set To a file name that contains random Data For libcurl To use To -; seed the random engine when doing SSL connects. -#CURLOPT_RANDOM_FILE= #CURLOPTTYPE_OBJECTPOINT + 76 -; Set To the Entropy Gathering Daemon socket pathname -#CURLOPT_EGDSOCKET= #CURLOPTTYPE_OBJECTPOINT + 77 -; Time-out connect operations after this amount of seconds + If connects -; are OK within this time + then fine... This only aborts the connect -; phase. [Only works on unix-style/SIGALRM operating systems] -#CURLOPT_CONNECTTIMEOUT= #CURLOPTTYPE_LONG + 78 -; Function that will be called To store headers (instead of fwrite). The -; parameters will use fwrite() syntax + make sure To follow them. -#CURLOPT_HEADERFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 79 -; Set this To force the HTTP request To get back To GET. Only really usable -; If POST + PUT Or a custom request have been used first. -#CURLOPT_HTTPGET= #CURLOPTTYPE_LONG + 80 -; Set If we should verify the Common name from the peer certificate in ssl -; handshake + set 1 To check existence + 2 To ensure that it matches the -; provided hostname. -#CURLOPT_SSL_VERIFYHOST= #CURLOPTTYPE_LONG + 81 -; Specify which file name To write all known cookies in after completed -; operation. Set file name To "-" (dash) To make it go To stdout. -#CURLOPT_COOKIEJAR= #CURLOPTTYPE_OBJECTPOINT + 82 -; Specify which SSL ciphers To use -#CURLOPT_SSL_CIPHER_LIST= #CURLOPTTYPE_OBJECTPOINT + 83 -; Specify which HTTP version To use! This must be set To one of the -; CURL_HTTP_VERSION* enums set below. -#CURLOPT_HTTP_VERSION= #CURLOPTTYPE_LONG + 84 -; Specificly switch on Or off the FTP engine's use of the EPSV command. By -; Default + that one will always be attempted before the more traditional -; PASV command. -#CURLOPT_FTP_USE_EPSV= #CURLOPTTYPE_LONG + 85 -; type of the file keeping your SSL-certificate ("DER" + "PEM" + "ENG") -#CURLOPT_SSLCERTTYPE= #CURLOPTTYPE_OBJECTPOINT + 86 -; name of the file keeping your private SSL-key -#CURLOPT_SSLKEY= #CURLOPTTYPE_OBJECTPOINT + 87 -; type of the file keeping your private SSL-key ("DER" + "PEM" + "ENG") -#CURLOPT_SSLKEYTYPE= #CURLOPTTYPE_OBJECTPOINT + 88 -; crypto engine For the SSL-sub system -#CURLOPT_SSLENGINE= #CURLOPTTYPE_OBJECTPOINT + 89 -; set the crypto engine For the SSL-sub system As Default -; the param has no meaning... -#CURLOPT_SSLENGINE_DEFAULT= #CURLOPTTYPE_LONG + 90 -; Non-zero value means To use the Global dns cache -#CURLOPT_DNS_USE_GLOBAL_CACHE= #CURLOPTTYPE_LONG + 91 ; To become OBSOLETE soon - ; DNS cache timeout -#CURLOPT_DNS_CACHE_TIMEOUT= #CURLOPTTYPE_LONG + 92 -; send linked-list of pre-transfer QUOTE commands (Wesley Laxton) -#CURLOPT_PREQUOTE= #CURLOPTTYPE_OBJECTPOINT + 93 -; set the Debug function -#CURLOPT_DEBUGFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 94 -; set the Data For the Debug function -#CURLOPT_DEBUGDATA= #CURLOPTTYPE_OBJECTPOINT + 95 -; mark this As start of a cookie session -#CURLOPT_COOKIESESSION= #CURLOPTTYPE_LONG + 96 -; The CApath directory used To validate the peer certificate -; this option is used only If SSL_VERIFYPEER is true -#CURLOPT_CAPATH= #CURLOPTTYPE_OBJECTPOINT + 97 -; Instruct libcurl To use a smaller receive buffer -#CURLOPT_BUFFERSIZE= #CURLOPTTYPE_LONG + 98 -; Instruct libcurl To Not use any signal/alarm handlers + even when using -; timeouts. This option is useful For multi-threaded applications. -; See libcurl-the-guide For more background information. -#CURLOPT_NOSIGNAL= #CURLOPTTYPE_LONG + 99 -; Provide a CURLShare For mutexing non-ts Data -#CURLOPT_SHARE= #CURLOPTTYPE_OBJECTPOINT + 100 -; indicates type of proxy. accepted values are CURLPROXY_HTTP (Default -; CURLPROXY_SOCKS4 And CURLPROXY_SOCKS5. -#CURLOPT_PROXYTYPE= #CURLOPTTYPE_LONG + 101 -; Set the Accept-Encoding string. Use this To tell a server you would like -; the response To be compressed. -#CURLOPT_ENCODING= #CURLOPTTYPE_OBJECTPOINT + 102 -; Set pointer To private Data -#CURLOPT_PRIVATE= #CURLOPTTYPE_OBJECTPOINT + 103 -; Set aliases For HTTP 200 in the HTTP Response header -#CURLOPT_HTTP200ALIASES= #CURLOPTTYPE_OBJECTPOINT + 104 -; Continue To send authentication (user+password) when following locations, -; even when hostname changed. This can potentionally send off the name -; And password To whatever host the server decides. -#CURLOPT_UNRESTRICTED_AUTH= #CURLOPTTYPE_LONG + 105 -; Specificly switch on Or off the FTP engine's use of the EPRT command ( it -; also disables the LPRT attempt). By Default + those ones will always be -; attempted before the good old traditional PORT command. -#CURLOPT_FTP_USE_EPRT= #CURLOPTTYPE_LONG + 106 -; Set this To a bitmask value To enable the particular authentications -; methods you like. Use this in combination With CURLOPT_USERPWD. -; Note that setting multiple bits may cause extra network round-trips. -#CURLOPT_HTTPAUTH= #CURLOPTTYPE_LONG + 107 -; Set the ssl context callback function + currently only For OpenSSL ssl_ctx -; in second argument. The function must be matching the -; curl_ssl_ctx_callback proto. -#CURLOPT_SSL_CTX_FUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 108 -; Set the userdata For the ssl context callback function's third -; argument -#CURLOPT_SSL_CTX_DATA= #CURLOPTTYPE_OBJECTPOINT + 109 -; FTP Option that causes missing dirs To be created on the remote server -#CURLOPT_FTP_CREATE_MISSING_DIRS= #CURLOPTTYPE_LONG + 110 -; Set this To a bitmask value To enable the particular authentications -; methods you like. Use this in combination With CURLOPT_PROXYUSERPWD. -; Note that setting multiple bits may cause extra network round-trips. -#CURLOPT_PROXYAUTH= #CURLOPTTYPE_LONG + 111 -; FTP option that changes the timeout + in seconds + associated With -; getting a response. This is different from transfer timeout time And -; essentially places a demand on the FTP server To acknowledge commands -; in a timely manner. -#CURLOPT_FTP_RESPONSE_TIMEOUT= #CURLOPTTYPE_LONG + 112 -; Set this option To one of the CURL_IPRESOLVE_* defines (see below) To -; tell libcurl To resolve names To those IP versions only. This only has -; affect on systems With support For more than one + i.e IPv4 _and_ IPv6. -#CURLOPT_IPRESOLVE= #CURLOPTTYPE_LONG + 113 -; Set this option To limit the size of a file that will be downloaded from -; an HTTP Or FTP server. -; Note there is also _LARGE version which adds large file support For -; platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. -#CURLOPT_MAXFILESIZE= #CURLOPTTYPE_LONG + 114 -; See the comment For INFILESIZE above + but in short + specifies -; the size of the file being uploaded. -1 means unknown. -#CURLOPT_INFILESIZE_LARGE= #CURLOPTTYPE_OFF_T + 115 -; Sets the continuation offset. There is also a LONG version of this; -; look above For RESUME_FROM. -#CURLOPT_RESUME_FROM_LARGE= #CURLOPTTYPE_OFF_T + 116 -; Sets the maximum size of Data that will be downloaded from -; an HTTP Or FTP server. See MAXFILESIZE above For the LONG version. -#CURLOPT_MAXFILESIZE_LARGE= #CURLOPTTYPE_OFF_T + 117 -; Set this option To the file name of your .netrc file you want libcurl -; To parse (using the CURLOPT_NETRC option). If Not set= #CURLOPTTYPE_Libcurl will do -; a poor attempt To find the user's home directory and check for a .netrc -; file in there. -#CURLOPT_NETRC_FILE= #CURLOPTTYPE_OBJECTPOINT + 118 -; Enable SSL/TLS For FTP + pick one of: -; CURLFTPSSL_TRY - try using SSL + proceed anyway otherwise -; CURLFTPSSL_CONTROL - SSL For the control connection Or fail -; CURLFTPSSL_ALL - SSL For all communication Or fail -#CURLOPT_USE_SSL= #CURLOPTTYPE_LONG + 119 -; The _LARGE version of the standard POSTFIELDSIZE option -#CURLOPT_POSTFIELDSIZE_LARGE= #CURLOPTTYPE_OFF_T + 120 -; Enable/disable the TCP Nagle algorithm -#CURLOPT_TCP_NODELAY= #CURLOPTTYPE_LONG + 121 -; 122 OBSOLETE + used in 7.12.3. Gone in 7.13.0 -; 123 OBSOLETE. Gone in 7.16.0 -; 124 OBSOLETE + used in 7.12.3. Gone in 7.13.0 -; 125 OBSOLETE + used in 7.12.3. Gone in 7.13.0 -; 126 OBSOLETE + used in 7.12.3. Gone in 7.13.0 -; 127 OBSOLETE. Gone in 7.16.0 -; 128 OBSOLETE. Gone in 7.16.0 -; When FTP over SSL/TLS is selected (With CURLOPT_USE_SSL this option -; can be used To change libcurl's default action which is to first try -; "AUTH SSL" And then "AUTH TLS" in this order + And proceed when a OK -; response has been received. -; Available parameters are: -; CURLFTPAUTH_DEFAULT - let libcurl decide -; CURLFTPAUTH_SSL - try "AUTH SSL" first + then TLS -; CURLFTPAUTH_TLS - try "AUTH TLS" first + then SSL -#CURLOPT_FTPSSLAUTH= #CURLOPTTYPE_LONG + 129 -#CURLOPT_IOCTLFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 130 -#CURLOPT_IOCTLDATA= #CURLOPTTYPE_OBJECTPOINT + 131 -; 132 OBSOLETE. Gone in 7.16.0 -; 133 OBSOLETE. Gone in 7.16.0 -; zero terminated string For pass on To the FTP server when asked For -; "account" info -#CURLOPT_FTP_ACCOUNT= #CURLOPTTYPE_OBJECTPOINT + 134 -; feed cookies into cookie engine -#CURLOPT_COOKIELIST= #CURLOPTTYPE_OBJECTPOINT + 135 -; ignore Content-Length -#CURLOPT_IGNORE_CONTENT_LENGTH= #CURLOPTTYPE_LONG + 136 -; Set To non-zero To skip the IP address received in a 227 PASV FTP server -; response. Typically used For FTP-SSL purposes but is Not restricted To -; that. libcurl will then instead use the same IP address it used For the -; control connection. -#CURLOPT_FTP_SKIP_PASV_IP= #CURLOPTTYPE_LONG + 137 -; Select "file method" To use when doing FTP + see the curl_ftpmethod -; above. -#CURLOPT_FTP_FILEMETHOD= #CURLOPTTYPE_LONG + 138 -; Local port number To bind the socket To -#CURLOPT_LOCALPORT= #CURLOPTTYPE_LONG + 139 -; Number of ports To try + including the first one set With LOCALPORT. -; Thus + setting it To 1 will make no additional attempts but the first. -#CURLOPT_LOCALPORTRANGE= #CURLOPTTYPE_LONG + 140 -; no transfer + set up connection And let application use the socket by -; extracting it With CURLINFO_LASTSOCKET -#CURLOPT_CONNECT_ONLY= #CURLOPTTYPE_LONG + 141 -; Function that will be called To convert from the -; network encoding (instead of using the iconv calls in libcurl) -#CURLOPT_CONV_FROM_NETWORK_FUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 142 -; Function that will be called To convert To the -; network encoding (instead of using the iconv calls in libcurl) -#CURLOPT_CONV_TO_NETWORK_FUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 143 -; Function that will be called To convert from UTF8 -; (instead of using the iconv calls in libcurl) -; Note that this is used only For SSL certificate processing -#CURLOPT_CONV_FROM_UTF8_FUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 144 -; If the connection proceeds too quickly then need To slow it down -; limit-rate: maximum number of bytes per second To send Or receive -#CURLOPT_MAX_SEND_SPEED_LARGE= #CURLOPTTYPE_OFF_T + 145 -#CURLOPT_MAX_RECV_SPEED_LARGE= #CURLOPTTYPE_OFF_T + 146 -; Pointer To command string To send If USER/PASS fails. -#CURLOPT_FTP_ALTERNATIVE_TO_USER= #CURLOPTTYPE_OBJECTPOINT + 147 -; callback function For setting socket options -#CURLOPT_SOCKOPTFUNCTION= #CURLOPTTYPE_FUNCTIONPOINT + 148 -#CURLOPT_SOCKOPTDATA= #CURLOPTTYPE_OBJECTPOINT + 149 -; set To 0 To disable session ID re-use For this transfer + Default is -; enabled (== 1) -#CURLOPT_SSL_SESSIONID_CACHE= #CURLOPTTYPE_LONG + 150 -; allowed SSH authentication methods -#CURLOPT_SSH_AUTH_TYPES= #CURLOPTTYPE_LONG + 151 -; Used by scp/sftp To do public/private key authentication -#CURLOPT_SSH_PUBLIC_KEYFILE= #CURLOPTTYPE_OBJECTPOINT + 152 -#CURLOPT_SSH_PRIVATE_KEYFILE= #CURLOPTTYPE_OBJECTPOINT + 153 -; Send CCC (Clear Command Channel) after authentication -#CURLOPT_FTP_SSL_CCC= #CURLOPTTYPE_LONG + 154 -; Same As TIMEOUT And CONNECTTIMEOUT + but With ms resolution -#CURLOPT_TIMEOUT_MS= #CURLOPTTYPE_LONG + 155 -#CURLOPT_CONNECTTIMEOUT_MS= #CURLOPTTYPE_LONG + 156 -; set To zero To disable the libcurl's decoding and thus pass the raw body -; Data To the appliction even when it is encoded/compressed -#CURLOPT_HTTP_TRANSFER_DECODING= #CURLOPTTYPE_LONG + 157 -#CURLOPT_HTTP_CONTENT_DECODING= #CURLOPTTYPE_LONG + 158 -; Permission used when creating new files And directories on the remote -; server For protocols that support it + SFTP/SCP/FILE -#CURLOPT_NEW_FILE_PERMS= #CURLOPTTYPE_LONG + 159 -#CURLOPT_NEW_DIRECTORY_PERMS= #CURLOPTTYPE_LONG + 160 -; CURLOPT_LASTENTRY ; the last unused -#CURLOPT_FTPLISTONLY = #CURLOPT_DIRLISTONLY -;} -;{ #HTTPPOST -#HTTPPOST_FILENAME = 1<<0 ; specified content is a file name -#HTTPPOST_READFILE = 1<<1 ; specified content is a file name -#HTTPPOST_PTRNAME = 1<<2 ; name is only stored pointer - ; do Not free in formfree -#HTTPPOST_PTRCONTENTS = 1<<3 ; contents is only stored pointer - ; do Not free in formfree -#HTTPPOST_BUFFER = 1<<4 ; upload file from buffer -#HTTPPOST_PTRBUFFER = 1<<5 ; upload file from pointer contents - ;} - -; #CURLE_OBSOLETE = #CURLE_OBSOLETE50 ; noone should be using this! -; #CURLE_BAD_PASSWORD_ENTERED = #CURLE_OBSOLETE46 -; #CURLE_BAD_CALLING_ORDER = #CURLE_OBSOLETE44 -; #CURLE_FTP_USER_PASSWORD_INCORRECT = #CURLE_OBSOLETE10 -; #CURLE_FTP_CANT_RECONNECT = #CURLE_OBSOLETE16 -; #CURLE_FTP_COULDNT_GET_SIZE = #CURLE_OBSOLETE32 -; #CURLE_FTP_COULDNT_SET_ASCII = #CURLE_OBSOLETE29 -; #CURLE_FTP_WEIRD_USER_REPLY = #CURLE_OBSOLETE12 -; #CURLE_FTP_WRITE_ERROR = #CURLE_OBSOLETE20 -; #CURLE_LIBRARY_NOT_FOUND = #CURLE_OBSOLETE40 -; #CURLE_MALFORMAT_USER = #CURLE_OBSOLETE24 -; #CURLE_SHARE_IN_USE = #CURLE_OBSOLETE57 -; #CURLE_URL_MALFORMAT_USER = #CURLE_OBSOLETE4 - -; #CURLE_FTP_ACCESS_DENIED = #CURLE_REMOTE_ACCESS_DENIED -; #CURLE_FTP_COULDNT_SET_BINARY = #CURLE_FTP_COULDNT_SET_TYPE -; #CURLE_FTP_QUOTE_ERROR = #CURLE_QUOTE_ERROR -; #CURLE_TFTP_DISKFULL = #CURLE_REMOTE_DISK_FULL -; #CURLE_TFTP_EXISTS = #CURLE_REMOTE_FILE_EXISTS -; #CURLE_HTTP_RANGE_ERROR = #CURLE_RANGE_ERROR -; #CURLE_FTP_SSL_FAILED = #CURLE_USE_SSL_FAILED - -; #CURLE_OPERATION_TIMEOUTED = #CURLE_OPERATION_TIMEDOUT - -#CURLE_HTTP_NOT_FOUND = #CURLE_HTTP_RETURNED_ERROR -#CURLE_HTTP_PORT_FAILED = #CURLE_INTERFACE_FAILED -; #CURLE_FTP_COULDNT_STOR_FILE = #CURLE_UPLOAD_FAILED - -#CURLE_FTP_PARTIAL_FILE = #CURLE_PARTIAL_FILE -#CURLE_FTP_BAD_DOWNLOAD_RESUME = #CURLE_BAD_DOWNLOAD_RESUME - -#CURLE_ALREADY_COMPLETE = 99999 - -#CURLAUTH_NONE = 0 ; nothing -#CURLAUTH_BASIC = 1<<0 ; Basic (Default) -#CURLAUTH_DIGEST = 1<<1 ; Digest -#CURLAUTH_GSSNEGOTIATE = 1<<2 ; GSS-Negotiate -#CURLAUTH_NTLM = 1<<3 ; NTLM -#CURLAUTH_ANY = ~0 ; all types set -#CURLAUTH_ANYSAFE = ~#CURLAUTH_BASIC - -#CURLSSH_AUTH_ANY = ~0 ; all types supported by the server -#CURLSSH_AUTH_NONE = 0 ; none allowed, silly but complete -#CURLSSH_AUTH_PUBLICKEY = 1<<0 ; public/private key files -#CURLSSH_AUTH_PASSWORD = 1<<1 ; password -#CURLSSH_AUTH_HOST = 1<<2 ; host key files -#CURLSSH_AUTH_KEYBOARD = 1<<3 ; keyboard interactive -#CURLSSH_AUTH_DEFAULT = #CURLSSH_AUTH_ANY - -#CURL_ERROR_SIZE = 256 - - -#CURLFTPSSL_NONE = #CURLUSESSL_NONE -#CURLFTPSSL_TRY = #CURLUSESSL_TRY -#CURLFTPSSL_CONTROL = #CURLUSESSL_CONTROL -#CURLFTPSSL_ALL = #CURLUSESSL_ALL -#CURLFTPSSL_LAST = #CURLUSESSL_LAST - -#CURLOPT_SSLKEYPASSWD = #CURLOPT_KEYPASSWD -#CURLOPT_FTPAPPEND = #CURLOPT_APPEND -#CURLOPT_FTPLISTONLY = #CURLOPT_DIRLISTONLY -#CURLOPT_FTP_SSL = #CURLOPT_USE_SSL - -#CURLOPT_SSLCERTPASSWD = #CURLOPT_KEYPASSWD -#CURLOPT_KRB4LEVEL = #CURLOPT_KRBLEVEL -; Below here follows defines for the CURLOPT_IPRESOLVE option. If a host -; name resolves addresses using more than one IP protocol version, this -; option might be handy to force libcurl to use a specific IP version. -#CURL_IPRESOLVE_WHATEVER = 0 ; Default, resolves addresses To all IP versions that your system allows -#CURL_IPRESOLVE_V4 = 1 ; resolve To ipv4 addresses -#CURL_IPRESOLVE_V6 = 2 ; resolve To ipv6 addresses - -; three convenient "aliases" that follow the name scheme better -#CURLOPT_WRITEDATA = #CURLOPT_FILE -#CURLOPT_READDATA = #CURLOPT_INFILE -#CURLOPT_HEADERDATA = #CURLOPT_WRITEHEADER -; CURLINFO_RESPONSE_CODE is the new name For the option previously known As -; CURLINFO_HTTP_CODE -#CURLINFO_HTTP_CODE = #CURLINFO_RESPONSE_CODE - -#CURL_GLOBAL_SSL = 1<<0 -#CURL_GLOBAL_WIN32 = 1<<1 -#CURL_GLOBAL_ALL = #CURL_GLOBAL_SSL|#CURL_GLOBAL_WIN32 -#CURL_GLOBAL_NOTHING= 0 -#CURL_GLOBAL_DEFAULT= #CURL_GLOBAL_ALL -;The 'CURLVERSION_NOW' is the symbolic name meant To be used by -; basicly all programs ever, that want To get version information. It is -; meant To be a built-in version number For what kind of struct the caller -; expects. If the struct ever changes, we rethe NOW To another enum -; from above. -#CURLVERSION_NOW = #CURLVERSION_FOURTH - -#CURL_VERSION_IPV6 = 1<<0 ;IPv6-enabled -#CURL_VERSION_KERBEROS4 = 1<<1 ;kerberos auth is supported -#CURL_VERSION_SSL = 1<<2 ;SSL options are present -#CURL_VERSION_LIBZ = 1<<3 ;libz features are present -#CURL_VERSION_NTLM = 1<<4 ;NTLM auth is supported -#CURL_VERSION_GSSNEGOTIATE = 1<<5; Negotiate auth support -#CURL_VERSION_DEBUG = 1<<6 ;built With Debug capabilities -#CURL_VERSION_ASYNCHDNS = 1<<7 ;asynchronous dns resolves -#CURL_VERSION_SPNEGO = 1<<8 ;SPNEGO auth -#CURL_VERSION_LARGEFILE = 1<<9 ;supports files bigger than 2GB -#CURL_VERSION_IDN = 1<<10 ;International Domain Names support -#CURL_VERSION_SSPI = 1<<11 ;SSPI is supported -#CURL_VERSION_CONV = 1<<12 ;character conversions are supported - -Structure Curl_HTTPPost - *Next_.Curl_HTTPPost ; Next entry in the list - *name.String ; Ptr to allocated name - namelength.l ; Length of name length - *contents.String ; Ptr to allocated data contents - contentslength.l ; Length of contents field - *buffer.String ; Ptr to allocated buffer contents - bufferlength.l ; Length of buffer field - *contenttype.String ; Content-Type - *contentheader ; List of extra headers for this form - *more.Curl_HTTPPost ; If one field name has more than one - ; file, this link should link To following files - flags.l ; constante #HTTPPOST - *showfilename ; The file name to show. If not set, the - ; actual file name will be used (If this - ; is a file part) -EndStructure - -; Structure To be used As parameter For CURLFORM_ARRAY -Structure Curl_Forms - option.l - *value.String -EndStructure - -; linked-list Structure For the CURLOPT_QUOTE option (And other) -Structure Curl_Slist - *Data.String - *Next_.curl_slist -EndStructure - -Structure curl_version_info_data - age.l ; age of the returned struct - *version.String ; LIBCURL_VERSION - version_num.l ; LIBCURL_VERSION_NUM - *host.String ; OS/host/cpu/machine when configured - features.l ; bitmask, see defines below - *ssl_version.String ; human readable string - ssl_version_num.l ; not used anymore, always 0 - *libz_version.String; human readable string - ; protocols is terminated by an entry With a NULL protoname - *protocols.String - ; The fields below this were added in CURLVERSION_SECOND - *ares.String - ares_num.l - ; This field was added in CURLVERSION_THIRD - *libidn.String; - ; These field were added in CURLVERSION_FOURTH - ; Same As '_libiconv_version' If built With HAVE_ICONV - iconv_ver_num.l - *libssh_version.String ; human readable string -EndStructure - -CompilerIf #PB_Compiler_OS = #PB_OS_Windows - ImportC "libcurl.lib" - curl_easy_cleanup(handle.i) - curl_easy_duphandle(handle.i) - curl_easy_getinfo(curl.i, info_type.i, info.i) - curl_easy_init() - curl_easy_perform(handle.i) - curl_easy_reset(handle.i) - curl_easy_setopt(handle.i, option.i, parameter.i) - curl_easy_strerror(errornum.i) - curl_escape(url.i, length.i) - curl_formadd(firstitem.i, lastitem.i) - curl_formfree(form.i) - curl_free(ptr.i) - curl_getdate(datestring.i, now.i) - curl_getenv(name.i) - curl_global_cleanup() - curl_global_init(flags.i) - curl_global_init_mem(flags.i, m.i, f.i, r.i, s.i, c.i) - curl_mprintf(format.i) - curl_mfprintf(fd.i, format.i) - curl_msprintf(buffer.i, format.i) - curl_msnprintf(buffer.i, maxlength.i, format.i) - curl_mvprintf(format.i, args.i) - curl_mvfprintf(fd.i, format.i, args.i) - curl_mvsprintf(buffer.i, format.i, args.i) - curl_mvsnprintf(buffer.i, maxlength.i, format.i, args.i) - curl_maprintf(format.i) - curl_mvaprintf(format.i, args.i) - curl_multi_add_handle(multi_handle.i, easy_handle.i) - curl_multi_cleanup(multi_handle.i) - curl_multi_fdset(multi_handle.i, read_fd_set.i, write_fd_set.i, exc_fd_set.i, max_fd.i) - curl_multi_info_read(multi_handle.i, msgs_in_queue.i) - curl_multi_init() - curl_multi_perform(multi_handle.i, running_handles.i) - curl_multi_remove_handle(multi_handle.i, easy_handle.i) - curl_multi_strerror(errornum.i) - curl_share_cleanup(share_handle.i) - curl_share_init() - curl_share_setopt(share.i, option.i, parameter.i) - curl_share_strerror(errornum.i) - curl_slist_append(slist.i, string.p-utf8) - curl_slist_free_all(slist.i) - curl_strequal(str1.i, str2.i) - curl_strnequal(str1.i, str2.i, len.i) - curl_unescape(url.i, length.i) - curl_version() - curl_version_info(type.i) - EndImport -CompilerElse - ImportC "-lcurl" - curl_easy_cleanup(handle.i) - curl_easy_duphandle(handle.i) - curl_easy_getinfo(curl.i, info_type.i, info.i) - curl_easy_init() - curl_easy_perform(handle.i) - curl_easy_reset(handle.i) - curl_easy_setopt(handle.i, option.i, parameter.i) - curl_easy_strerror(errornum.i) - curl_escape(url.i, length.i) - curl_formadd(firstitem.i, lastitem.i) - curl_formfree(form.i) - curl_free(ptr.i) - curl_getdate(datestring.i, now.i) - curl_getenv(name.i) - curl_global_cleanup() - curl_global_init(flags.i) - curl_global_init_mem(flags.i, m.i, f.i, r.i, s.i, c.i) - curl_mprintf(format.i) - curl_mfprintf(fd.i, format.i) - curl_msprintf(buffer.i, format.i) - curl_msnprintf(buffer.i, maxlength.i, format.i) - curl_mvprintf(format.i, args.i) - curl_mvfprintf(fd.i, format.i, args.i) - curl_mvsprintf(buffer.i, format.i, args.i) - curl_mvsnprintf(buffer.i, maxlength.i, format.i, args.i) - curl_maprintf(format.i) - curl_mvaprintf(format.i, args.i) - curl_multi_add_handle(multi_handle.i, easy_handle.i) - curl_multi_cleanup(multi_handle.i) - curl_multi_fdset(multi_handle.i, read_fd_set.i, write_fd_set.i, exc_fd_set.i, max_fd.i) - curl_multi_info_read(multi_handle.i, msgs_in_queue.i) - curl_multi_init() - curl_multi_perform(multi_handle.i, running_handles.i) - curl_multi_remove_handle(multi_handle.i, easy_handle.i) - curl_multi_strerror(errornum.i) - curl_share_cleanup(share_handle.i) - curl_share_init() - curl_share_setopt(share.i, option.i, parameter.i) - curl_share_strerror(errornum.i) - curl_slist_append(slist.i, string.p-utf8) - curl_slist_free_all(slist.i) - curl_strequal(str1.i, str2.i) - curl_strnequal(str1.i, str2.i, len.i) - curl_unescape(url.i, length.i) - curl_version() - curl_version_info(type.i) - EndImport -CompilerEndIf - -CompilerIf #PB_Compiler_OS = #PB_OS_Windows - ImportC "ws2_32.lib" - EndImport -CompilerEndIf - -; ProcedureC curlWriteData(*ptr, Size, NMemB, *Stream) -; ;retreives utf-8/ascii encoded data -; Protected SizeProper.i = Size & 255 -; Protected NMemBProper.i = NMemB -; Protected MyDataS.s -; ;Shared ReceivedData.s -; -; MyDataS = PeekS(*ptr, SizeProper * NMemBProper, #PB_UTF8) -; ReceivedData + MyDataS -; ProcedureReturn SizeProper * NMemBProper -; EndProcedure - -; Procedure.s curlGetData() -; ;Shared ReceivedData.s -; Protected ReturnData.s -; -; ReturnData.s = ReceivedData.s -; ReceivedData.s = "" -; -; ProcedureReturn ReturnData.s -; EndProcedure - -Procedure.s str2curl(string.s) - Protected *curlstring, newstring.s - *curlstring = AllocateMemory(Len(string) + 1) - If *curlstring - PokeS(*curlstring,string,-1,#PB_Ascii) - newstring = PeekS(*curlstring,-1) - FreeMemory(*curlstring) - ProcedureReturn newstring - Else - ProcedureReturn "" - EndIf -EndProcedure - - -; IDE Options = PureBasic 5.42 LTS (Windows - x86) -; CursorPosition = 1063 -; FirstLine = 1006 -; Folding = -- -; EnableUnicode -; EnableXP \ No newline at end of file diff --git a/screenshot.png b/screenshot.png index 4284dac..a1b937d 100644 Binary files a/screenshot.png and b/screenshot.png differ