|
Geometry : |
Subject: [geometry] warnings in algorithms for integer coordinate types
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2012-08-22 16:00:27
Hi,
I'm finishing writing tests for the R-tree 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
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;
Regards,
Adam
Geometry list run by mateusz at loskot.net