Boost logo

Geometry :

Subject: Re: [geometry] warnings in algorithms for integer coordinate types
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-08-22 17:29:20


Hi Adam,

On 22-8-2012 22:00, Adam Wulkiewicz wrote:
> Hi,
>
> I'm finishing writing tests for the R-tree

Good to hear!

> and noticed some rather harmless issues related to integer coordinate
> types. Just thought it may be helpful in some way ;)
>
> 1. In bg::comparable_distance() returned value (default_distance_type)
> has different type than distance() which is used to calculate the
> distance:
>
> This code:
>
> typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
> bg::default_distance_result<P2ic, P2ic>::type d =
> bg::comparable_distance(P2ic(), P2ic());
>
> Produces a warning:
>
> boost\geometry\algorithms\comparable_distance.hpp(67): warning C4244:
> 'return' : conversion from '__int64' to 'double', possible loss of data

OK, that is a bit surprising indeed and not the intention. I will have a
look.

>
> In line:
>
> return distance(geometry1, geometry2, strategy_type());
>
> 2. In bg::centroid() -> centroid_box_calculator() warning related to
> dividing int by double:
>
> Code:
>
> P2ic pt;
> typedef bg::model::box<P2ic> B;
> bg::centroid(B(), pt);
>
> Produces:
>
> boost\geometry\algorithms\centroid.hpp(108): warning C4244: '/=' :
> conversion from 'double' to 'int', possible loss of data
>
> In line:
>
> m /= 2.0;

That is easy to fix and will be done soon.

Thanks for your report.

Regards, Barend


Geometry list run by mateusz at loskot.net