Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created June 26, 2015 15:49
Show Gist options
  • Save springmeyer/ed3a35c286dc754e9758 to your computer and use it in GitHub Desktop.
Save springmeyer/ed3a35c286dc754e9758 to your computer and use it in GitHub Desktop.
diff --git a/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp b/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp
index b1a25c9..8d2a398 100644
--- a/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp
+++ b/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp
@@ -51,14 +51,14 @@ class liang_barsky
private:
typedef model::referring_segment<Point> segment_type;
- template <typename T>
- inline bool check_edge(T const& p, T const& q, T& t1, T& t2) const
+ template <typename PointType, typename CalcType>
+ inline bool check_edge(PointType const& p, PointType const& q, CalcType& t1, CalcType& t2) const
{
bool visible = true;
if(p < 0)
{
- T const r = q / p;
+ CalcType const r = static_cast<CalcType>(q) / p;
if (r > t2)
visible = false;
else if (r > t1)
@@ -66,7 +66,7 @@ private:
}
else if(p > 0)
{
- T const r = q / p;
+ CalcType const r = static_cast<CalcType>(q) / p;
if (r < t1)
visible = false;
else if (r < t2)
@@ -86,9 +86,10 @@ public:
inline bool clip_segment(Box const& b, segment_type& s, bool& sp1_clipped, bool& sp2_clipped) const
{
typedef typename select_coordinate_type<Box, Point>::type coordinate_type;
+ typedef double calc_type;
- coordinate_type t1 = 0;
- coordinate_type t2 = 1;
+ calc_type t1 = 0;
+ calc_type t2 = 1;
coordinate_type const dx = get<1, 0>(s) - get<0, 0>(s);
coordinate_type const dy = get<1, 1>(s) - get<0, 1>(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment