Cruisers Forum
 

Go Back   Cruisers & Sailing Forums > Seamanship, Navigation & Boat Handling > OpenCPN
Cruiser Wiki Click Here to Login
Register Vendors FAQ Community Calendar Today's Posts Log in

Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 23-05-2012, 00:03   #16
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith...
I have never used wxCurl myself... OpenCPN uses the stable wx2.8, so perhaps you will have to rollback some of the changes made in the wxCurl source tree to support 2.9 - It's really a task with which I can't help you right now.
You have to include the needed libraries with your plugin - if they will be linked dynamically or statically does not matter all that much. With wxcurl and the like, I would go the static way as they are not available prepackaged anywhere. With standard stuff like XML parsers etc. linking dynamically makes sense if the shared libs are prepackaged somewhere. The basic guidance is: If the needed library exists in debian repositories, link it dynamically. But as you usually have to ship it's source to be able to build on Windows anyway, it's not bringing just the good - all this depends on your judgement.

Pavel
nohal is online now   Reply With Quote
Old 23-05-2012, 01:46   #17
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Ok need some help from someone with C++ knowledge here - need to get either "wxCurl" even "curlpp" integrated into this project, correctly linked - this is where my knowledge of C++ fails miserably.

If you know C++ and have a space 1/2 hour, please checkout https://github.com/ktec/osm_pi and add the relevant files:

All I need is an example of a web request and handle to the result in the method:

void osm_pi::SetCurrentViewPort(PlugIn_ViewPort &vp)

in the file:

osm_pi.cpp



If this was python or ruby I'd be able to work it out....


thanks
Keith
globalkeith is offline   Reply With Quote
Old 03-06-2012, 04:39   #18
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Is there any way to tell opencpn to use the current directory for locating plugins?
(I'm finding the only way to get opencpn to load my new plugin is to do sudo make install each time!!)
globalkeith is offline   Reply With Quote
Old 03-06-2012, 06:57   #19
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,402
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Globalkeith....

There is no built-in way to redirect PlugIn location.

The PlugIn needs to be made anyway. What's 13 more keystrokes?

Or, you could quick hack pluginmanager.cpp.

Code:
bool PlugInManager::LoadAllPlugIns(wxString &plugin_dir)
{

//  Keith insert this

      m_plugin_location = _T("Keiths dir"); //plugin_dir;

      wxString msg(_T("PlugInManager searching for PlugIns in location "));
      msg += m_plugin_location;
      wxLogMessage(msg);
Dave
bdbcat is offline   Reply With Quote
Old 03-06-2012, 07:27   #20
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Thanks Dave, while I have your attention, could I ask another:

So I'm trying to use LibCurl in my plugin, and I've successfully got it compiling now but when I run OpenCPN I get this error:

22:14:36 CST: PlugInManager: Loading PlugIn: /usr/local/lib/opencpn/libosm_pi.so
22:14:36 CST: Error: /usr/local/lib/opencpn/libosm_pi.so: undefined symbol: curl_easy_perform
22:14:36 CST: PlugInManager: Cannot load library: /usr/local/lib/opencpn/libosm_pi.so

Now, in my plugin I have:

#define CURL_STATICLIB
#include <curl/curl.h>
#include <curl/easy.h>

Which I thought would be sufficient to link the library, but it seems not.

On stackoverflow I found this suggestion:

you must link your program with the curl library
-L/path/of/curl/lib/libcurl.a (g++)


But I dont get how I should get cmake to do that? Any ideas?

thanks\
Keith
globalkeith is offline   Reply With Quote
Old 03-06-2012, 07:46   #21
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,402
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith....

I don't have a copy of your CMakeLists.txt, but you need to add a line like this:

Code:
TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} /path/of/curl/lib/libcurl.so )
Post your CMakeLists.txt if this does not work, and we'll investigate.

Dave
bdbcat is offline   Reply With Quote
Old 03-06-2012, 07:59   #22
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Ah brilliant, I just discovered that myself - came up with this:

FIND_PACKAGE(CURL REQUIRED)
TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${CURL_LIBRARIES} )

Which works on my linux machine!!!

Sweet, now I can get on with the fun.....
globalkeith is offline   Reply With Quote
Old 03-06-2012, 08:06   #23
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,402
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith...

Even better! Looking forward to the PlugIn!

Dave
bdbcat is offline   Reply With Quote
Old 03-06-2012, 08:27   #24
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Woooohooo!! Got my first data download!!!

1. Implement basic plugin structure*
2. Establish getting lat/lon bounds from OpenCPN view
3. Implement API calls to retrieve OSM data**
4. Implement a local data store***
5. Implement API calls to retrieve change sets (new or changes to data based on date)
6. Implement plugin UI to specify data types
7. Implement plugin UI to support API authentication to OpenStreetMap
8. Implement UI to add/edit/update seamark data


Ok, so right now I've only implemented getting ALL data (which it gets when you press the button), but either way its a good start.

Next up is working out how to parse the data and store it in a local database.
globalkeith is offline   Reply With Quote
Old 05-06-2012, 02:19   #25
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Question Re: osm_pi - OpenSeaMap plugin for OpenCPN

Ok, I'm at a cross roads and I need some advice from the wise!

I'm looking into local storage for OSM data and my options are:

1. Spatialite with some custom queries
2. Postgres GIS with Osmosis library

Basically if I go with spatialite it will be easier to implement because I can utilise much of the great work from Nohal's Survey plugin, but there'll come a time when it craps out with too much data.

Going with postgres will probably end up with larger plugin/more dependencies - possible cross platform issues. And its probably more complicated integration. And I have no example to follow.


Any suggestions/advice?
globalkeith is offline   Reply With Quote
Old 05-06-2012, 02:28   #26
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith...
Postgres, being several time bigger than the whole OpenCPN seems a bit too fat for the task, just go with spatialite and keep the code well organized so you can switch to another backend if needed in the future.
My 2 cents

Pavel
nohal is online now   Reply With Quote
Old 06-06-2012, 10:14   #27
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Thanks Pavel, I've found a C++ library called Osmium which should provide a good abstraction from the db. And it looks like people have had reasonable success pushing sqlite's size limits - off to hawaii tomorrow so hopefully I can get lots done on the flight.
globalkeith is offline   Reply With Quote
Old 09-06-2012, 06:00   #28
Registered User

Join Date: Jun 2012
Location: on SaltyPaws
Boat: Helia 44
Posts: 66
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Hi Keith,

At the moment I am also working on building an OpenCPN plugin. I see that you are making your way from scratch with OSM_pi, and I hope I can learn from you. BTW I really the way you have set up the icons and generate.sh script. The plugin (version osm_pi.cpp,v 1.0 2011/02/26 01:54:37 nohal Exp $) compiles ok on Ubuntu 12.04. When I run OpenCPN I can enable the plugin and I see the icon. Nothing happens when I click on the icon (or maybe I am looking in the wrong place, should the data be stored somewhere?).

I am looking for you bare bones plugin since the demo_pi does not work, would you be able to send me a link to this?

Also, are you using Code Blocks, or another IDE? Would you be able to share your project file?

Much appreciated!

Brazil
SaltyPaws is offline   Reply With Quote
Old 09-06-2012, 18:29   #29
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Hi Brazil,

I can't really take much credit as all I did was copy most of it from Pavel (Nohal). A good starting point would be to look at this commit: https://github.com/ktec/osm_pi/tree/...485bac5c8e23f9

That's pretty much the bare bones of a working plugin without any of the extras. Its also worth checking out Pavel's other plugins for ideas on how things work.

What is your plugin going to do?

cheers
Keith
globalkeith is offline   Reply With Quote
Old 09-06-2012, 18:35   #30
Registered User
 
globalkeith's Avatar

Join Date: Sep 2010
Location: Zhuhai, China
Boat: Prout G55
Posts: 76
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Quote:
Originally Posted by SaltyPaws View Post
Hi Keith,
The plugin (version osm_pi.cpp,v 1.0 2011/02/26 01:54:37 nohal Exp $) compiles ok on Ubuntu 12.04. When I run OpenCPN I can enable the plugin and I see the icon. Nothing happens when I click on the icon (or maybe I am looking in the wrong place, should the data be stored somewhere?).
Brazil
As far as the osm_pi (the latest version) - when you click the icon it will get the lat/lon bounds of the screen, and download a file to /tmp/features.xml - and then parse the file to find out whats there. If you tail the log file, you'll see whats going on. I'm in the process of integrating spatialite (sqlite database) and a C++ library calls osmium which will replace the parsing code enabling me to support the pbf format. Once thats in place I will then look at how to draw things on the screen!!
globalkeith is offline   Reply With Quote
Reply

Tags
opencpn


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Advertise Here


All times are GMT -7. The time now is 11:58.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.