Boost logo

Geometry :

Subject: [ggl] abs warning on Linux
From: Barend Gehrels (barend)
Date: 2011-10-22 13:38:58


Hi,

On 22-10-2011 4:49, 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)'/
>

The cause is that ttmath does not support std::abs. Therefore there is a
small stub necessary, which should be included like this:

#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>

The stub does not much but is essential:

- it enables the ADL finding of: sqrt,abs,sin,cos and some other
math-functions (IMO ttmath should do this itself, I have to contact the
author if he agrees and is willing to do this)

- it defines ttmath_big, which is alas necessary everywhere T() is used
(in quite some places). The reason is that ttmath's default constructor
does not initialize to zero. Which is what T() expects. Have to contact
about this too.

- it defines pi

- it can cast coordinates from/to strings (necessary to read from WKT)

- it can cast coordinates numerically (supporting boost::numeric_cast)
(which is not supported by ttmath intentionally, but sometimes, e.g. by
writing to non-ttmath SVG map's, necessary

So alas you need this stub.

The ggl's ttmath_big is not templated, which is actually (now that I
review it) limiting but we can easily add a templated version.

Regards, Barend

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20111022/965ba004/attachment.html


Geometry list run by mateusz at loskot.net