Boost logo

Geometry :

Subject: Re: [geometry] extensions
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2012-01-18 14:34:01


>
> I'm thinking of taking a snapshot of the boost/geometry directory from
> trunk, and adding it to my projects' include dirs before boost-1.48 itself.
> An reason this shouldn't work or suggestions for a better solution?
>
>
> I think this will work but never tried it like this myself. Boost.Geometry
> will then use other versions of the Boost libraries it depends on, but I
> don't think that will give any problems, we're not using the brand new
> features from other libs.
>

Hi Barend, hi list,

I'm happy to anounce, that it works, set up as stated above, and I'll share
my experience below ;-) My current setup is geometry from trunk 76449,
boost-1.48, mingw-gcc-4.5.0.

I use two projections: stere_ellipsoid, and sterea_ellipsoid, depending
whether the center of the projection is closer to the equator, or to
north/south pole. So I prepared a shared_ptr<projection> and used the
provided factory class. But the factory is huge, and I only need the 2
projections, so I wanted to do the type erasure myself. I dug through the
header files for a few minutes, and here's what I came up with:

[code]
    // Geo is my latlong point type, and Xy is my cartesian point type
    typedef boost::geometry::projection::parameters Par;
    typedef boost::geometry::projection::stere_ellipsoid<Geo,Xy> ProjStere;
    typedef boost::geometry::projection::sterea_ellipsoid<Geo,Xy>
ProjSterea;
    typedef boost::geometry::projection::projection<Geo,Xy> Proj_base;
    typedef
boost::geometry::projection::detail::base_v_fi<ProjStere,Geo,Xy,Par>
ProjStere_der;
    typedef
boost::geometry::projection::detail::base_v_fi<ProjSterea,Geo,Xy,Par>
ProjSterea_der;

    boost::shared_ptr<Proj_base> proj_o_;

    Par par = ...; // prepare parameters, containing the center of
projection

    if ( [center is near the equator] )
        proj_o_ = boost::make_shared<ProjSterea_der>(par);
    else
        proj_o_ = boost::make_shared<ProjStere_der>(par);
[endcode]

As you can see, I used detail::base_v_fi. It would be nice, if something
like this was in the public interface, so that it is possible to create a
type-erased projection without using the whole factory. Or maybe there is
an easy a way to do this?

Something like:
template < class Proj,class Par >
detail::base_v_fi<Proj,...,Par>* make_new_projection( Par const& par );

It should be fairly easy to implement such a function, and I am willing to
do it, if you guys think it's a good idea ;-)

Anyhow, Boost.Geometry rocks! I have only tried using a small part and I
love it ;-)

Cheers,
Kris



Geometry list run by mateusz at loskot.net