Re: OpenStreetMap embarqué dans votre application
Publié : lun. 19/mai/2014 10:48
Tiens, modifie le OpenStreetMap avec le code ci-après, tu sauras (en regardant dans le débogueur) pourquoi tu ne vois rien :
Code : Tout sélectionner
Procedure OSM_GetImage(Image.l, Zoom.l, XTile.l, YTile.l)
Protected psProxyURL.s = gRWCurl_ProxyIP+":"+gRWCurl_ProxyPort
Protected psProxyAuth.s = gRWCurl_ProxyAuthLogin+":"+gRWCurl_ProxyAuthPwd
Protected plMemory.l
Protected psURL.s = OSM_Layers_Dim(glLayerCur)\sURL+Str(Zoom)+"/"+Str(XTile)+"/"+Str(YTile)+".png"
Protected gPWRCurl = curl_easy_init()
Protected plImageSize.l
Protected plImageMem.l
Protected psSQLRequest.s
Protected pbImageOK.b
Protected plRes.l
Protected error.l
; Test if in cache else download it
DatabaseQuery(glSQLiteDB, "SELECT * FROM cache WHERE cache_layer="+#_DQ_+Str(glLayerCur)+#_DQ_+" AND cache_zoom="+#_DQ_+Str(Zoom)+#_DQ_+" AND cache_x="+#_DQ_+Str(XTile)+#_DQ_+" AND cache_y="+#_DQ_+Str(YTile)+#_DQ_+"")
If FirstDatabaseRow(glSQLiteDB)
Debug "CACHE : "+Str(glLayerCur)+"\"+Str(Zoom)+"\"+Str(XTile)+"\"+Str(Ytile)
plImageSize = GetDatabaseLong(glSQLiteDB,6)
If plImageSize
plImageMem = AllocateMemory(plImageSize)
GetDatabaseBlob(glSQLiteDB, 5, plImageMem, plImageSize)
FinishDatabaseQuery(glSQLiteDB)
If IsImage(Image)
FreeImage(Image)
EndIf
If CatchImage(Image, plImageMem)
SetGadgetState(#Image_0+Image, ImageID(Image))
FreeMemory(plImageMem)
EndIf
pbImageOK = #True
EndIf
Else
Debug DatabaseError()
EndIf
If pbImageOK = #False
Debug "DOWNLOAD : "+Str(glLayerCur)+"\"+Str(Zoom)+"\"+Str(XTile)+"\"+Str(Ytile)
RW_LibCurl_InitData()
If gRWCurl_Proxy = #True
curl_easy_setopt(gPWRCurl, #CURLOPT_HTTPPROXYTUNNEL, #True)
curl_easy_setopt(gPWRCurl, #CURLOPT_PROXY, @psProxyURL)
If psProxyAuth <> ""
curl_easy_setopt(gPWRCurl, #CURLOPT_PROXYUSERPWD, @psProxyAuth)
EndIf
EndIf
curl_easy_setopt(gPWRCurl, #CURLOPT_URL, @psURL)
curl_easy_setopt(gPWRCurl, #CURLOPT_WRITEFUNCTION, @RW_LibCurl_WriteDataFunction())
error = curl_easy_perform(gPWRCurl)
curl_easy_cleanup(gPWRCurl)
plMemory = 0
If error <> 0
Debug PeekS(curl_easy_strerror(error))
Else
plMemory = RW_LibCurl_GetData()
EndIf
If plMemory
psSQLRequest = "INSERT INTO cache(cache_layer, cache_zoom, cache_x, cache_y, cache_image, cache_imagesize) VALUES ("
psSQLRequest + Str(glLayerCur)+","
psSQLRequest + Str(Zoom)+","
psSQLRequest + Str(XTile)+","
psSQLRequest + Str(YTile)+","
psSQLRequest + "?,"
psSQLRequest + Str(MemorySize(plMemory))+")"
SetDatabaseBlob(glSQLiteDB, 0, plMemory, MemorySize(plMemory))
plRes = DatabaseUpdate(glSQLiteDB, psSQLRequest)
If plRes = 0
Debug psSQLRequest
Debug DatabaseError()
EndIf
If IsImage(Image)
FreeImage(Image)
EndIf
If CatchImage(Image, plMemory, MemorySize(plMemory))
SetGadgetState(#Image_0+Image, ImageID(Image))
FreeMemory(plMemory)
EndIf
EndIf
EndIf
EndProcedure