PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by Andre »

I'm using the PBMap regularly too (in my internal GeoWorldEditor, showed before), so thanks again to djes and team! :D

I know the crashes too. They happen from time to time, even if I regularly clear the cache (by standard at program end).
But I can't find any specific reason or a way to reproduce.... probably it has something to do with high traffic on the OSM servers (it's only a thought, because the crash happens during day/evening but not later in the night).
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by djes »

Thank you Andre. It shouldn't crash anyway. I'll take a look.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by djes »

I've corrected some parts of the code there in the 'djes' branch : https://github.com/djes/PBMap/blob/djes/PBMap.pb

Sadly, I think there's a PB bug in the PB's internal PNG image library, leading to a crash when a malformed PNG file is loaded. I've already had something similar in the past. I've sent a bug report, I'm waiting for a fix. It should be possible to use another image library, but I think it easier to wait.

By now, could you test the updated code ? Thank you !
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by idle »

haven't tested it on a range of pngs but workaround for now, check to see if IEND tag is set in the image

Code: Select all

Procedure _LoadImage(ImageNumber,File.s) 
  Protected fn,pat,pos
  pat = $444E4549
  fn= ReadFile(#PB_Any,file) 
  If fn 
    pos = Lof(fn)
    FileSeek(fn,pos-8)
    res = ReadLong(fn)
    CloseFile(fn)
    If res = pat 
      ProcedureReturn LoadImage(ImageNumber,file)  
    EndIf   
  EndIf   
EndProcedure   
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by djes »

Thank you Idle ! It could do the trick and be faster than pngcheck. I'll test today. I've also added a function to delete incomplete file, even if we don't have by now the possibility without another request to know size of downloaded file.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by djes »

Code updated with idle's trick. Merged into master.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by Andre »

Thank you very much idle and djes! (and thanks too for the credits in your Readme :-) - you're the ones, who deserve them - later in my project :D)

I've included the updated PBMap.pb code into my GeoWorldEditor.
It runs fine.... if it helps in the long term to avoid the randomly crashes we will see... but your approach to make tests for valid map tiles before loading them as image sounds like a good idea :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
l1marik
User
User
Posts: 49
Joined: Tue Jun 30, 2020 6:22 am

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by l1marik »

Has somebody implemented OpenWeather(or any other) precipitation map layers in PBMap?

Lukas
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PBMap - OSM, Here, Geoserver maps in a Canvas gadget

Post by djes »

Did you try to change the demo application ?

Edit : BTW, I just found that including the demo in the module can be difficult to understand. And the demo code is maybe a bit confusing with too many options... I just separated the basic demo, and if I have time I'll do a very basic demo.

Could you test by altering the demo.pb code at the line 300 :

Code: Select all

PBMap::AddOSMServerLayer(#Map, "OpenSeaMap", 3, "http://t1.openseamap.org/seamark/") ; Add a special osm overlay map on layer nb 3
Change the URL as explained in https://openweathermap.org/current
api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
Don't include lat and long as it's PBMap's job. So you should have

Code: Select all

PBMap::AddOSMServerLayer(#Map, "OpenWeatherMap", 3, "http://api.openweathermap.org/data/2.5/weather?appid=your_key") ; Add a special openweathermap overlay map on layer nb 3
The code is there : https://github.com/djes/PBMap
Post Reply