Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 30-06-2012, 16:27   #46
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 guys, really appreciate the support.

Another quick C++ question. I want to store a table of data, available to be used for looping through, and lookups. The data is something like this:

Name Elem S-57 Attributes Description
anchorage Area,Node ACHARE category,restriction An area in which vessels anchor.

and so on.

What's the best mechanism for storing this data, should I load in a CSV and construct some kind of array of structs? Or declare a collection of const char arrays or use a map, or vector? Bit confused about whats best in this situation...

thanks
Keith
__________________

__________________
globalkeith is offline   Reply With Quote
Old 01-07-2012, 06:30   #47
Registered User

Join Date: Jan 2011
Location: North Yorkshire, UK
Posts: 32
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith,

The OpenSeaMap chart symbol library is in SVG format, so you could generate PNGs from these. That way you can choose a bit density to suit your application. There are two places you can find our symbols: the recently-retired set of pre-coloured symbols at SourceForge.net Repository - [openseamap] Index of /renderer/archive/SeaMapSymbols or the new library for my recently-launched renderer at SourceForge.net Repository - [openseamap] Index of /renderer/searender/symbols .

You will probably want to use the old set, since the new set has no colouring for the buoys & beacons - I dynamically colour the symbols at rendering time.

To generate a set of PNGs from these, install Inkscape & from the command line type: for i in path_to_symbols/*.svg; do inkscape $i -d 18 -e `echo $i | sed -e 'sX^path_to_symbolsXiconsX' -e 's/.svg$/.png/'`; done

I will cross-post this to your thread on OpenCPN as others may also need a source of (finely-crafted!) symbols.

Regards,
Malcolm
__________________

__________________
malcolmh is offline   Reply With Quote
Old 01-07-2012, 06:46   #48
Registered User

Join Date: Jan 2011
Location: North Yorkshire, UK
Posts: 32
Re: osm_pi - OpenSeaMap plugin for OpenCPN

I should have stated that the parameter after "-d" is the bit density & should be tweaked to suit.
__________________
malcolmh is offline   Reply With Quote
Old 02-07-2012, 02:08   #49
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 man I'm so tired of not being able to do what I want in C++!

Ok so I'm trying to create some kind of lookup table for all the different seamark types:

I've got a header file with

enum SeamarkType
{
ANCHORAGE,
ANCHOR_BERTH,
blah
}

WX_DECLARE_STRING_HASH_MAP( int, SeamarkTypes );
SeamarkTypes["anchorage"]=ANCHORAGE;

The idea being, when I retrieve data from the database i can do something like:

while (ret == SQLITE_ROW) {
Node node;
node.id = sqlite3_column_int64(m_params.select_nodes_stmt, 0);
node.seamark_type = SeamarkTypes.find(sqlite3_column_text(m_params.sel ect_nodes_stmt, 1))->second;

(The database contains strings like "anchorage" for the seamark type column)

Following that, I would be able to do something like this in the renderer:

switch(m_node.seamark_type)
{
case ANCHORAGE:
DoDrawBitmap( *_img_anchorage, pt.x-16, pt.y-16, true );
break;


Trouble is, when I try to compile I just get an error:


/osm_pi/src/../include/osm.h:59:13: error: expected unqualified-id before ‘[’ token



I've tried all sorts of things to fix, but alas I'm just stabbing in the dark.


please help!!!!
__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 02:16   #50
Registered User
 
globalkeith's Avatar

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

ps - i don't mind if there's another way to achieve this - just want it to work!
__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 03:13   #51
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,020
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Keith...
wxHashMap
SeamarkTypes is a datatype, not a variable

Pavel
__________________
nohal is online now   Reply With Quote
Old 02-07-2012, 03:46   #52
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 nohal View Post
Keith...
wxHashMap
SeamarkTypes is a datatype, not a variable

Pavel

Hi Pavel,

Thats where I got the original idea:

Even if I just have:

WX_DECLARE_STRING_HASH_MAP( wxString, SeamarkTypeHashMap );
SeamarkTypeHashMap SeamarkTypes;

SeamarkTypes["anchorage"]="hello world";


I still get error:

osm_pi/src/../include/osm.h:62:1: error: ‘SeamarkTypes’ does not name a type

me & C++ =
__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 03:55   #53
Registered User
 
globalkeith's Avatar

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

It in the refactor branch if you've got time to look.

Reading up it seems its not good practice to declare global variables in a header file. Basically I want a lookup table which defines all the seamark types, and allows me to translate what comes back from the database to C++ type. A hashmap should allow me to do this, but should I be wrapping it in a DataTypes class and declaring it as a static property of that class or something?
__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 04:01   #54
Registered User

Join Date: Jan 2011
Location: North Yorkshire, UK
Posts: 32
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Your use of SeaMarkTypes is an enum tag, not a typedef. Is this what you meant to do?:

typedef enum {foo, bar, ...} SeaMarkType;
__________________
malcolmh is offline   Reply With Quote
Old 02-07-2012, 04:16   #55
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 malcolmh View Post
Your use of SeaMarkTypes is an enum tag, not a typedef. Is this what you meant to do?:

typedef enum {foo, bar, ...} SeaMarkType;

Maybe I honestly don't really know what I'm doing here, just making it up as I go. But I've now taken that out of the equation with this:

std::map<int, int> Keiths;
Keiths[0]=1;

and I'm STILL getting

../include/osm.hpp:64:1: error: ‘Keiths’ does not name a type


__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 04:46   #56
Registered User
 
globalkeith's Avatar

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

managed to get it working with

typedef std::map<const char*, int> SeamarkTypes;

const SeamarkTypes::value_type x[] = {
std::make_pair("anchorage", ANCHORAGE),
std::make_pair("anchor_berth", ANCHOR_BERTH),
std::make_pair("berth", BERTH),
std::make_pair("building", BUILDING)
};
__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 05:02   #57
Registered User

Join Date: Jan 2011
Location: North Yorkshire, UK
Posts: 32
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Now I see what you were trying to achieve - you are making a C++ map version of the array "osmtypes" that I have made in Searender "s57obj.c". Did you see my reply to you in the OpenSeaMap newsgroup that references this?
__________________
malcolmh is offline   Reply With Quote
Old 02-07-2012, 05:26   #58
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 malcolmh View Post
Now I see what you were trying to achieve - you are making a C++ map version of the array "osmtypes" that I have made in Searender "s57obj.c". Did you see my reply to you in the OpenSeaMap newsgroup that references this?

Oh man, if you've already written some code for this that would be a huge help. Really feel like I'm all day today. Where could I find that file?
__________________
globalkeith is offline   Reply With Quote
Old 02-07-2012, 05:45   #59
Registered User

Join Date: Jan 2011
Location: North Yorkshire, UK
Posts: 32
Re: osm_pi - OpenSeaMap plugin for OpenCPN

Re-posted from gmane.comp.gis.openseamap.devel:

Take a look a my new renderer code (SourceForge.net Repository - [openseamap] Index of /renderer/searender) - in particular at the modules "s57obj", "s57att" and "s57val". These provide look-up tables and methods to use them, both for (text-format) S57 conversions and for OSM conversions. It is this latter set of conversions that you need. A brief outline of their use:
1. Extract the object substring from a seamark: tag key and call enumType() to obtain its object enumeration value.
2. Extract the attribute substring from the tag key and call enumAttribute() to obtain its attribute enumeration value. (This call requires the object enum from step1 as one of the arguments.)
3. Use tag value string, attribute & object enums to call convertValue(), which will return a struct with the appropriate type conversion in the value union.
__________________
malcolmh is offline   Reply With Quote
Old 06-07-2012, 16:00   #60
Senior Cruiser
 
sinbad7's Avatar

Cruisers Forum Supporter

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,717
Images: 57
Send a message via Skype™ to sinbad7
Re: osm_pi - OpenSeaMap plugin for OpenCPN

I manged to import OpenSeaMap into the on-line directory of OruxMaps but the map looks very fragmented.

In SeaMap the OpenSeaMap looks very good,showing sea markers etc. where they have been added. The area best covered is obviously Europe,but also a few lights here in Brazil as you see from the attachment. Here also with my GPS position.

Tore
Attached Thumbnails
Click image for larger version

Name:	2012-07-06 18.19.50.jpg
Views:	111
Size:	224.0 KB
ID:	43100   Click image for larger version

Name:	2012-07-06 19.09.58.jpg
Views:	103
Size:	214.4 KB
ID:	43101  

__________________

__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Reply

Tags
opencpn

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 22:17.


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.