|
Geometry : |
Subject: [ggl] abs warning on Linux
From: V D (zedxz2)
Date: 2011-10-22 03:31:48
Hi,
Just a follow-up, here is an example (inspired from Barend's blog) that will cause compilation errors (because of abs) when trying to use ttmath:
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <ttmath/ttmath.h>
typedef ttmath::Big<TTMATH_BITS(64), TTMATH_BITS(2048)> ttmath_big;
template <typename T>
void test_difference_parcel_precision()
{
namespace bg = boost::geometry;
typedef bg::model::d2::point_xy<T> point_type;
typedef bg::model::polygon<point_type> polygon_type;
typedef std::vector<boost::uint8_t> byte_vector;
polygon_type p1, p2;
//bg::read_wkt("", p1);
//bg::read_wkt("", b2);
bg::correct(p1);
bg::correct(p2);
std::vector<polygon_type> pieces;
bg::difference(p1, p2, pieces);
}
int main(int, char* [])
{
test_difference_parcel_precision<float>(); // OK
test_difference_parcel_precision<double>(); // OK
test_difference_parcel_precision<ttmath_big >(); // fail
return 0;
}
Any idea how to fix this ?
Thank you very much,
-V
On Oct 21, 2011, at 7:49 PM, V D wrote:
> Hi Barend,
>
> Is it possible to know what/where was the patch for this ? I'm trying to move to TTMath instead of double because I'm having precision problems.
> But I cannot get it to compile because of abs.
>
> I get errors such as:
>
> boost/geometry/algorithms/detail/overlay/assign_parents.hpp:80: error: cannot convert ?ttmath::Big<1ul, 32ul>? to ?int? for argument ?1? to ?int abs(int)?
> boost/geometry/strategies/cartesian/cart_intersect.hpp:350: error: cannot convert ?ttmath::Big<1ul, 32ul>? to ?int? for argument ?1? to ?int abs(int)?
>
> Thanks,
> -v
>
>
> On Sep 14, 2011, at 10:07 AM, Barend Gehrels wrote:
>
>> Hi,
>>
>>> Just wondering if you guys are aware of the following warning with floating-point coordinates on Linux:
>>>
>>> boost-1.47.0/include/boost/geometry/strategies/cartesian/cart_intersect.hpp:350: warning: passing ?double? for argument 1 to ?int abs(int)?
>>> boost-1.47.0/include/boost/geometry/strategies/cartesian/cart_intersect.hpp:351: warning: passing ?double? for argument 1 to ?int abs(int)?
>>>
>>> This happens when running boost::geometry::intersection(my_polygon, my_box) where coordinate_type of points is double, the compiler doesn't like it since only int abs(int) seems to be available on that Linux distro O_o
>>>
>>
>> Thanks for the message!
>>
>> This was not only a warning, it was indeed an error. It was already solved in the Trunk, indeed using geometry::math::abs
>>
>> Regards, Barend
>>
>> _______________________________________________
>> ggl mailing list
>> ggl_at_[hidden]
>> http://lists.osgeo.org/mailman/listinfo/ggl
>
Geometry list run by mateusz at loskot.net