Skip to content

Commit

Permalink
Reorganize bg_operators.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
eyal0 committed Jul 1, 2020
1 parent b2e515d commit 8e76b2e
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions bg_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ bg::model::multi_polygon<polygon_type_t> operator-(
}

template multi_polygon_type_fp operator-(const multi_polygon_type_fp&, const multi_polygon_type_fp&);
template multi_polygon_type_fp operator-(const multi_polygon_type_fp&, const ring_type_fp&);

template <typename rhs_t>
multi_polygon_type_fp operator-(const polygon_type_fp& lhs, const rhs_t& rhs) {
return multi_polygon_type_fp{lhs} - rhs;
template <> multi_polygon_type_fp operator-(const multi_polygon_type_fp& lhs, const ring_type_fp& rhs) {
multi_polygon_type_fp rhs_mp{polygon_type_fp{rhs}};
return lhs - rhs_mp;
}

template multi_polygon_type_fp operator-(const polygon_type_fp&, const ring_type_fp&);

template <typename rhs_t>
multi_polygon_type_fp operator-(const box_type_fp& lhs, const rhs_t& rhs) {
auto box_mp = multi_polygon_type_fp();
Expand All @@ -43,6 +40,9 @@ bg::model::multi_linestring<linestring_type_t> operator-(
return lhs;
}
bg::model::multi_linestring<linestring_type_t> ret;
if (bg::length(lhs) <= 0) {
return ret;
}
bg::difference(lhs, rhs, ret);
return ret;
}
Expand All @@ -64,12 +64,9 @@ bg::model::multi_linestring<linestring_type_t> operator&(
return ret;
}

template multi_linestring_type_fp operator&(const multi_linestring_type_fp&, const multi_polygon_type_fp&);
template multi_linestring_type_fp operator&(const multi_linestring_type_fp&, const box_type_fp&);

template <typename rhs_t>
multi_linestring_type_fp operator&(const linestring_type_fp& lhs,
const rhs_t& rhs) {
const rhs_t& rhs) {
multi_linestring_type_fp ret;
if (bg::area(rhs) <= 0) {
return ret;
Expand All @@ -82,23 +79,8 @@ multi_linestring_type_fp operator&(const linestring_type_fp& lhs,
}

template multi_linestring_type_fp operator&(const linestring_type_fp&, const box_type_fp&);

template <typename polygon_type_t, typename rhs_t>
bg::model::multi_polygon<polygon_type_t> operator^(
const bg::model::multi_polygon<polygon_type_t>& lhs,
const rhs_t& rhs) {
if (bg::area(rhs) <= 0) {
return lhs;
}
if (bg::area(lhs) <= 0) {
return rhs;
}
bg::model::multi_polygon<polygon_type_t> ret;
bg::sym_difference(lhs, rhs, ret);
return ret;
}

template multi_polygon_type_fp operator^(const multi_polygon_type_fp&, const multi_polygon_type_fp&);
template multi_linestring_type_fp operator&(const multi_linestring_type_fp&, const multi_polygon_type_fp&);
template multi_linestring_type_fp operator&(const multi_linestring_type_fp&, const box_type_fp&);

template <typename polygon_type_t, typename rhs_t>
bg::model::multi_polygon<polygon_type_t> operator&(const bg::model::multi_polygon<polygon_type_t>& lhs,
Expand Down Expand Up @@ -134,6 +116,23 @@ multi_polygon_type_fp operator&(const bg::model::polygon<point_type_t>& lhs,

template multi_polygon_type_fp operator&(polygon_type_fp const&, multi_polygon_type_fp const&);

template <typename polygon_type_t, typename rhs_t>
bg::model::multi_polygon<polygon_type_t> operator^(
const bg::model::multi_polygon<polygon_type_t>& lhs,
const rhs_t& rhs) {
if (bg::area(rhs) <= 0) {
return lhs;
}
if (bg::area(lhs) <= 0) {
return rhs;
}
bg::model::multi_polygon<polygon_type_t> ret;
bg::sym_difference(lhs, rhs, ret);
return ret;
}

template multi_polygon_type_fp operator^(const multi_polygon_type_fp&, const multi_polygon_type_fp&);

template <typename polygon_type_t, typename rhs_t>
bg::model::multi_polygon<polygon_type_t> operator+(const bg::model::multi_polygon<polygon_type_t>& lhs,
const rhs_t& rhs);
Expand Down

0 comments on commit 8e76b2e

Please sign in to comment.