OpenStreetMap embedded in your application

Share your advanced PureBasic knowledge/code with the community.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Works fine here on Vista but I can't get it to run on XP SP3. Not sure what's missing.
BERESHEIT
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

@srod : Thanks :)
@ts-soft : Thanks :)
@Rook Zimbabwe : Thanks :) Keep me informed :)

@SFSxOI Yes, that use PB 4.40 beta 1. I think that runs with beta2.

@netmaestro :
netmaestro wrote:I dl'd the complete package and tried to run it but I get an error message saying "The application failed to initialize properly (Oxc0150002). What's wrong? (pb 4.4 b2 win xp)
....
Works fine here on Vista but I can't get it to run on XP SP3. Not sure what's missing.
I have found some clues on Internet.
I use Dependancy Walker for viewing all dependances of exe file. (http://www.dependencywalker.com/)
And my application uses these dlls : MSVCR90.DLL.
Could you install Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) and see the result ?

Source > in French
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Thanks Progi1984, that was it. Works fine now, thanks so much for sharing.
BERESHEIT
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

Installing Visual C++ 2008 did indeed resolve the error message
"The application failed to initialize properly (0xc0150002)"
under Windows XP, but I now get a different error. Any ideas as to the cause?

Run-time error: The specified "Memory ID" is not valid.

in the line: FreeMemory(*LibCurl_SharedMem)
in procedure: RW_LibCurl_InitData()
in module: RW_LibCurl_Inc.pb
when ran with the debugger on from LibCurl.pb or OpenStreetMap.pb
under Windows XP SP2 and PB4.40B2

Stack trace (line numbers may differ slightly from your version):

Line 253
OpenStreetMap.pb
OSM_GetImage(3, 7, 65, 4)

Line 186
OpenStreetMap.pb
RW_LibCurl_InitData()

Current code position:
Line 89
RW_Lib_Curl_Inc.pb
Anthony Jordan
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

@netmaestro : Good news :)

@akj : Plz, Could you replace your old function RW_LibCurl_InitData() with this new one :

Code: Select all

Procedure RW_LibCurl_InitData()
  Shared *LibCurl_SharedMem
  If *LibCurl_SharedMem
    FreeMemory(*LibCurl_SharedMem)
    *LibCurl_SharedMem = 0
  EndIf
EndProcedure
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

@Progi1984:

The program is working fine now, thank you.

Could you please add an enhancement:
On mouse-clicking on the map, the clicked point moves to the dead centre of the map. .

Also a window Minimise button would be nice.
Anthony Jordan
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

Here's how to add a minimise button to the main window.
In OpenStreetMap.pb:

Change

Code: Select all

If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
to

Code: Select all

If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap",  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
Change

Code: Select all

If CatchImage(0, plImageMem)
SetGadgetState(#Image_0+Image, ImageID(0))
FreeImage(0)
FreeMemory(plImageMem)
to

Code: Select all

If CatchImage(image, plImageMem)
SetGadgetState(#Image_0+Image, ImageID(image))
FreeMemory(plImageMem)
Change

Code: Select all

If CatchImage(0, plMemory, MemorySize(plMemory))
SetGadgetState(#Image_0+Image, ImageID(0))
FreeImage(0)
FreeMemory(plMemory)
to

Code: Select all

If CatchImage(image, plMemory, MemorySize(plMemory))
SetGadgetState(#Image_0+Image, ImageID(image))
FreeMemory(plMemory)
Anthony Jordan
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Is it possible to color in US zip codes or other regions using this program?
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

@All : I updated the package :
http://partage.rootslabs.net/SourceCode_OSM.zip

Code: Select all

ADDED : Mimize Window
ADDED : Zoom with click on the ImageGadget
@akj ; See the code and say me if it was what you wanted...
@Xombie : I don't understand your request... more explanations, please :)
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Progi,

Say you have a lot of sales people and you want to color-code their territories on a map. Or perhaps you want to color a map to show which parts of the country (by zip code in the US, for example) have the most sales dollars.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

@Xombie : No, after some searchs, i don't find any solution. So sorry for you...
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: OpenStreetMap embedded in your application

Post by jamirokwai »

Hi,

you could add support for Mac OS, if you use this snippet in RW_LibCurl_Inc.pb from line 12 on:

Code: Select all

CompilerCase #PB_OS_MacOS
    Macro SymbolName(Val)
      DQuote#Val#DQuote
    EndMacro
    #LibCurl_ImportLib = "/usr/lib/libcurl.3.dylib"
    #LibCurl_SeparatorDir = "/"
For Mac OS X, you have to change add a "_" before the name of the function:

"curl_easy_init", "curl_easy_setopt", "curl_easy_perform", "curl_easy_cleanup"
become
"_curl_easy_init", "_curl_easy_setopt", "_curl_easy_perform", "_curl_easy_cleanup"

Now it compiles correctly, but won't display any map-data.
Regards,
JamiroKwai
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Re: OpenStreetMap embedded in your application

Post by GG »

It compiles well from my side, but when running with PB 4.41 and Windows XP SP3 with 4Gb RAM, it crashes when it tries to allocate memory in RW_LibCurl_GetData : [ERROR] The specified MemoryID is NULL (Line 149 RW_LibCurl_inc.pb), this line :

Code: Select all

*LibCurl_NewMemory = AllocateMemory(MemorySize(*LibCurl_SharedMem))
Any idea ?
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
kandl
User
User
Posts: 11
Joined: Sat Apr 11, 2009 6:54 am

Re: OpenStreetMap embedded in your application

Post by kandl »

http://vimeo.com/14579414


program based on (this) discussion:

http://purebasic.fr/english/viewtopic.p ... 217ca777be


but significantly modified:

multi-threaded
accelerated graphics
mouse control
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Re: OpenStreetMap embedded in your application

Post by Progi1984 »

Don't hesitate to give your code... I will improve the package and put your credits... Very good job... But what can't do PB ?
Post Reply