Boost logo

Geometry :

Subject: [ggl] Re: maps-charts-graphs
From: barend (barend.gehrels)
Date: 2010-03-27 08:50:01


Hi Fausto,

> An example that shows me how I can get the attributes

> of a country (for ex. the list of the polylines

> vertices) would be really helpful.

There are several samples you can look into.

The 07_graph_route_example reads vertices from an ASCII file,

including attributes (in this case city-name). You can

implement extra attributes as color yourself. You can also

use a shapefile, or a database, there are samples available,

but you then need an external library.

A datafile with world countries (world.wkt) is in the

distribution, however that one does not have country names.

The x04_wxwidgets_world_mapper (a new sample using WxWidgets)

is reading from this world.wkt.

If you need to access countries by name I would use something like this:

struct my_country

{

    multi_polygon<polygon_2d> boundary;

    int color; // or rgb tuple or string, etc

    std::string name; // might be omitted as well

};

and register this as a multi polygon. There is not yet a

registration macro, but it is trivial:

namespace boost { namespace geometry { namespace traits

{

struct tag<my_country>

{

    typedef multi_polygon_tag type;

};

}}}

and then have a

std::map<string, my_country> which is then filled by

country name and boundaries.

So there is not one complete example doing the thing you want

(maybe it will be added once) but with some other pieces and

this mail you should be able to do the trick.

Regards, Barend
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20100327/d2aeefb0/attachment.html


Geometry list run by mateusz at loskot.net