|
Geometry : |
Subject: Re: [geometry] extensions
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2012-02-09 06:44:53
Hello,
Like promised, I present a proposition of functions new_projection() and
make_shared_projection(). They are useful, when:
- you have a small set of types of projections you'll use,
- you know the type of projection during it's creation, and later you want
to use it through an abstract base pointer,
- you want to avoid the overhead of factory: generating code for creating a
projection of every type you don't use, and selecting the type from a
string.
Example usecase:
typedef ... Geo;
typedef ... Xy;
typedef stere_ellipsoid<Geo,Xy> ProjA;
typedef sterea_ellipsoid<Geo,Xy> ProjB;
projection<Geo,Xy>* proj = 0;
if ( some_cond )
proj = new_projection< ProjA, Geo, Xy >( params );
else
proj = new_projection< ProjB, Geo, Xy >( params );
The functions are defined in attached files: new_projection.hpp and
make_shared_projection.hpp, which are intended to reside
in geometry\extensions\gis\projections. An overload of both functions is
provided, which allows a simplified use, omitting the two explicit template
parameters Geo and Xy, which are part of the ProjA type anyway:
proj = new_projection< ProjA >( params );
In order for this to work, the concrete projections must provide typedefs
for these types. So I propose to add these typedefs to struct
detail::base_t_f, and also to the class projection for consistency -
proj_nested_typedefs.patch.
Hope some of the above is useful, and thanks again for Boost.Geometry ;-)
Kris
Geometry list run by mateusz at loskot.net