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 11-06-2012, 12:32   #31
Registered User

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

Hi Keith,

Now at the "Hello World" stage. I have set-up the plugin, icon shows, Menu pops up when I press the icon, and I have a configuration menu. Both menus are linked to a WXformbuilder template. The plugin is to plot great circle routes (I know that this can be done by script, but in 2012 most people like a gui). I am trying to start with an "easy" plugin and work my way up from there. Depending on how well this goes, I may work on something more chewy. Next up on my list, is to make the plugin add waypoints to a route. I couldn't find a function in open_cpn_plugin.h to do this. Is the only way to make route, to create a GPX track and then import it?
SaltyPaws is offline   Reply With Quote
Old 11-06-2012, 13:09   #32
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 Salty,

I'm very happy to hear you're making progress - its pretty much a path unfollowed from my experience - Nohal has been great help - as has Dave too. Looking through the code of other plugins is always useful too.

Unfortunately you're asking the wrong person - I'm literally only a month ahead of you in terms of understanding the OpenCPN code base - hopefully either Seth, Nohal or Dave will see this and give you some specific pointers.

I honestly think O developers would benefit from an IRC channel and/or developer email list - personally I find it difficult locating what I'm looking for in forums. Either that or a developer site using the very helpful Q&A format aka Stackoverflow - any one of these codebases would suit: Stack Overflow clones - Meta Stack Overflow

I don't have the time or resources to set that up, but if there's a motivated soul out there who has the resources, I'm sure it would be a success....
globalkeith is offline   Reply With Quote
Old 19-06-2012, 22:54   #33
Registered User
 
globalkeith's Avatar

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

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

Great things to report, I have successfully downloaded and inserted an OSM file into a local sqlite database using the osm_pi plugin!!

Still very rough around the edges right now, but its a great step forward.

Something yet to decide is how to actually draw data on the chart - my feeling is it should be an overlay, so regardless of what chart (or satellite image) is displayed, the elements are still visible. If anyone has thoughts, suggestions about this, I welcome any input. I've seen mention of osm to svg renderers on the OSM email list, which may be of use. I would like to re-use any of the s57 stuff already implemented for displaying CMAP charts - I've done no research regarding any of this, so please through all ideas on the table.


thanks
Keith

ps - Really Great work on v3.0!!
globalkeith is offline   Reply With Quote
Old 19-06-2012, 23:53   #34
Registered User
 
globalkeith's Avatar

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

Oh and I also have some further thoughts on how this plugin should operate.

For those who dont know, Open Sea Map is effective built on top of the Open Street Map database - all the sea marks are entered into the Streetmap database and marked with a special tag "seamark".

So the plugin consists of a local database - when the user moves the view - the local database is queried for "marks" within that area - those marks will then be drawn to the screen.

The next part is updating the local database - there are a couple of options:
1. When in "active" mode, each time the user moves the view, a request is sent to the "overpass" (Overpass API) database which is basically a "queryable" copy of the openstreetmap database - requesting all the "seamarks" for the visible view. Once downloaded, these marks will be automatically imported into the local database.
2. The user downloads an .osm or .osm.pbf and the plugin provides a method to import the data into the local database.


Using option 1, there is high chance of repeated requesting the same information - its possible to store every request to prevent a call for exactly the same lat/lon bounds, but this is not ideal.

Using option 2 would be great, if the seamarks _only_ were available as a osm or pdf file - and updates were regularly made available the same way Planet.osm - OpenStreetMap Wiki is currently operated - right now, to download the world is about 16Gb compressed - I'm sure the "seamarks" would be less than 500mb.

Lots of options, no decisions yet....
globalkeith is offline   Reply With Quote
Old 27-06-2012, 01:04   #35
Registered User
 
globalkeith's Avatar

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

In an attempt to improve the overall code structure of this plugin, I've separated some code into another .cpp/.h file which are instantiated from the osm_pi.cpp.

During compilation, this new file gets picked up from addition to CMakeLists.txt

SET(SRC_OSM
src/osm_pi.h
src/osm_pi.cpp
src/osmdownloader.h
src/osmdownloader.cpp
...

and then compiled:

Scanning dependencies of target osm_pi
[ 57%] Building CXX object plugins/osm_pi/CMakeFiles/osm_pi.dir/src/osm_pi.cpp.o
[ 57%] Building CXX object plugins/osm_pi/CMakeFiles/osm_pi.dir/src/osmdownloader.cpp.o
[ 57%] Building CXX object plugins/osm_pi/CMakeFiles/osm_pi.dir/src/osmgui_impl.cpp.o
Linking CXX shared library libosm_pi.so

However no matter what I try, the plugin results in a runtime error:

21:49:38 HST: Error: /usr/local/lib/opencpn/libosm_pi.so: undefined symbol: _ZN13OsmDownloader10m_osm_pathE
21:49:38 HST: PlugInManager: Cannot load library: /usr/local/lib/opencpn/libosm_pi.so




It seems like its not getting bundled into the .so but I don't know what I'm missing?

any help appreciated...

thanks
Keith
globalkeith is offline   Reply With Quote
Old 27-06-2012, 01:31   #36
Registered User

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

Keith...
Is your code on github current?

Pavel
nohal is offline   Reply With Quote
Old 27-06-2012, 03:20   #37
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 Pavel,

Its in the refactor branch: https://github.com/ktec/osm_pi/tree/refactor

thanks
Keith
globalkeith is offline   Reply With Quote
Old 27-06-2012, 05:16   #38
Registered User

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

Keith...
You are declaring two static const char* vars but then treat them as instance variables - you have to decide what you actually want
Code:
diff --git a/src/osmdownloader.cpp b/src/osmdownloader.cpp
index 39f0635..d5ccafb 100644
--- a/src/osmdownloader.cpp
+++ b/src/osmdownloader.cpp
@@ -28,12 +28,15 @@
 
 #include "osmdownloader.h"
 
+const char *OsmDownloader::m_osm_path = "/tmp/features.osm";
+const char *OsmDownloader::m_api_url = "http://open.mapquestapi.com/xapi/api/0.6/";
+
 OsmDownloader::OsmDownloader()
 {
 
     // constructor
-    m_osm_path = "/tmp/features.osm";
-    m_api_url = "http://open.mapquestapi.com/xapi/api/0.6/";
+    //m_osm_path = "/tmp/features.osm";
+    //m_api_url = "http://open.mapquestapi.com/xapi/api/0.6/";
     //const char *OsmDownloader::m_api_url = "http://www.overpass-api.de/api/xapi?";
         //url = _("http://www.overpass-api.de/api/xapi?*[bbox=[%f,%f,%f,%f][seamark:type=*]]");
     //const char *OsmDownloader::m_api_url = "http://overpass.osm.rambler.ru/cgi/xapi?";
will make it run, but I didn't have any closer look at the code.

Pavel
nohal is offline   Reply With Quote
Old 27-06-2012, 15:27   #39
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. How did you pin that down, was there something in the compilation logs that pointed to that, or was it just an experienced eye browsing the code?
globalkeith is offline   Reply With Quote
Old 28-06-2012, 00:17   #40
Registered User

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

Keith...
What caused it was pretty obvious from _ZN13OsmDownloader10m_osm_pathE - then I just needed to have a look at what m_osm_path actually is and why is it undefined...

Pavel
nohal is offline   Reply With Quote
Old 29-06-2012, 17:02   #41
Registered User
 
globalkeith's Avatar

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

Fantastic News!!

Seamarks downloaded from OSM database, insert into the local database, and then drawn on to the map:

Click image for larger version

Name:	Screenshot from 2012-06-29 13:54:16.png
Views:	250
Size:	315.2 KB
ID:	42883

tada!!!

It's been a struggle, learning C++ but I'm getting there. I've done some major re-factoring to clean up the code - many thanks to Seth's kmloverlay plugin.

So I have some questions, probably for Dave/Pavel/Seth...

I'm going to be drawing seamarks on stage (in an overlay) - each seamark will need the same functionality as all objects in the CM93 view - right click "Object Query", properties dialog, etc

What's the best way to achieve this, should I import a set of icons (lateral marks, lights, buoys etc) into the icon.cpp class, and just draw bitmaps - OR is there some way to integrate with existing CM93 rendering code.


thanks
Keith
globalkeith is offline   Reply With Quote
Old 29-06-2012, 19:06   #42
Marine Service Provider
 
bdbcat's Avatar

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

Keith...

Great progress! Looking forward to live action.

Icons:
Formally, there is no interface at the API for a PlugIn to access specific chart type rendering logic built into the core. This is by design, so that PlugIns can be managed by the core, be developed independently, and not be subject to obsolescence as the core evolves.

So, I recommend that you find/create a set of icons that you like and bring them into your PlugIn as bitmaps. Render on the overlay as desired.

This may create some (or a lot) of code duplication between the core and your PlugIn, but that is the price to pay for a clean API.

A good source of icons for you to consider is already done, courtesy of Jesperwe. Look at data/s57data/rastersymbols-day.png
Edit and extract the ones you like. Or use the whole file and associated xml file to dynamically render any one you want.

Have fun, and good luck
Dave
bdbcat is online now   Reply With Quote
Old 30-06-2012, 00:33   #43
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith,
Congrats on the good progress!

I notice in the screen-shot that what i think is the OSM objects, the small "barrel with wrench" icons are not on top of the marks in the chart. They seem to be offset the same distance for all the marks.

Why? Is this due to different chart datums of the OSM and the chart or what?

Maybe I just misunderstand this altogether...

regards
Jonas
jonasaberg is offline   Reply With Quote
Old 30-06-2012, 01:56   #44
Registered User
 
maxxflow's Avatar

Join Date: Jun 2010
Location: West coast of Sweden
Boat: 45' ex-trawler
Posts: 15
Re: osm_pi - OpenSeaMap plugin for OpenCPN

My guess is that the 0,0 pixel (upper-left corner) in the icon bitmap is positioned on the actual coordinates, thus the icon will be drawn in a - say - 32x32px square extending down and to the right of the position on the chart. Not a bug - just unfinished display-layer code.

Keith, great work! Keep it up.
This sort of thing shows us the true beauty of open source projects. Making use of the OSM database not only brings added value to the OpenCPN community, but should also draw more people's attention to the OSM project. Just imagine the day that we will have an independent, free (as in liberty) competitor to the charts published by hydrographics institutions.

Joel
maxxflow is offline   Reply With Quote
Old 30-06-2012, 02:00   #45
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Makes perfect sense. Thanks Joel!
jonasaberg 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 13:50.


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.