Boost logo

Geometry :

Subject: [ggl] user controllable numeric conversion.
From: Barend Gehrels (barend.gehrels)
Date: 2010-05-04 11:55:08


Hi,

> What about use macro to switch between numeric_cast and implicit
> conversion?
>
> for example:
>
> #ifdef USE_IMPLICIT_CONVERSION
> # define NUMERIC_CAST(TargetType, Source) Source
> #else
> # define NUMERIC_CAST(TargetType, Source)
> ::boost::numeric_cast<TargetType>(Source)
> #endif
>
> then, in the code:
> t = NUMERIC_CAST((target type here), (Source value here));
>
> Using numeric_cast as default can make the complier output neat and
> tidy. It should also work smoothly for common use.
> User can define USE_IMPLICIT_CONVERSION when they don't want
> numeric_cast.

Besides that I don't like macro's, this might be useful to enable both
options.

>> We have also the "convert" algorithm, going from e.g. ring to
>> polygon, or vice versa (loosing internal rings), which is also
>> suitable to convert numeric types.
>
> Well, from the doc, "transform" is for point-based transformation,
> while "convert" is for conversion between different geometries. So I
> think it is more suitable to put such numeric conversion in the
> transform part.
>
>
- Actually transform is not only point-based, but might also add points
in between (for linestrings from earth to globe, or vice versa).
- I'm sorry the doc is out of date there. From the source: "// Same
geometry type -> copy coordinates from G1 to G2"

So yes, I think convert is useful to convert geometries, either same
type (but different underlying point type, or different coordinate type)
or different types

Regards, Barend


Geometry list run by mateusz at loskot.net