diff --git a/include/boost/geometry/algorithms/append.hpp b/include/boost/geometry/algorithms/append.hpp index 620219b87..188a242b1 100644 --- a/include/boost/geometry/algorithms/append.hpp +++ b/include/boost/geometry/algorithms/append.hpp @@ -13,7 +13,7 @@ #include -#include +#include #include #include diff --git a/include/boost/geometry/algorithms/clear.hpp b/include/boost/geometry/algorithms/clear.hpp index f76b28e77..5de18da5c 100644 --- a/include/boost/geometry/algorithms/clear.hpp +++ b/include/boost/geometry/algorithms/clear.hpp @@ -13,9 +13,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/include/boost/geometry/algorithms/correct.hpp b/include/boost/geometry/algorithms/correct.hpp index 3ed69ee89..15c812e97 100644 --- a/include/boost/geometry/algorithms/correct.hpp +++ b/include/boost/geometry/algorithms/correct.hpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/include/boost/geometry/algorithms/simplify.hpp b/include/boost/geometry/algorithms/simplify.hpp index d3c456242..965fba09c 100644 --- a/include/boost/geometry/algorithms/simplify.hpp +++ b/include/boost/geometry/algorithms/simplify.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -130,9 +131,13 @@ struct simplify_polygon exterior_ring(poly_out), max_distance, strategy); - // Note: here a resizeable container is assumed. - // TODO: we should make this part of the concept. - interior_rings(poly_out).resize(num_interior_rings(poly_in)); + traits::resize + < + typename boost::remove_reference + < + typename traits::interior_mutable_type::type + >::type + >::apply(interior_rings(poly_out), num_interior_rings(poly_in)); typename interior_return_type::type rings_in = interior_rings(poly_in); diff --git a/include/boost/geometry/algorithms/transform.hpp b/include/boost/geometry/algorithms/transform.hpp index d3feffa56..3e5cdb911 100644 --- a/include/boost/geometry/algorithms/transform.hpp +++ b/include/boost/geometry/algorithms/transform.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -135,8 +136,13 @@ struct transform_polygon } // Note: here a resizeable container is assumed. - // TODO: we should make this part of the concept. - interior_rings(poly2).resize(num_interior_rings(poly1)); + traits::resize + < + typename boost::remove_reference + < + typename traits::interior_mutable_type::type + >::type + >::apply(interior_rings(poly2), num_interior_rings(poly1)); typename interior_return_type::type rings1 = interior_rings(poly1); diff --git a/include/boost/geometry/algorithms/unique.hpp b/include/boost/geometry/algorithms/unique.hpp index 74b645c42..1a8672286 100644 --- a/include/boost/geometry/algorithms/unique.hpp +++ b/include/boost/geometry/algorithms/unique.hpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -40,9 +41,7 @@ struct range_unique policy ); - // Note: this assumes "resize". - // TODO: look at RangeEx solution - range.resize(it - boost::begin(range)); + traits::resize::apply(range, it - boost::begin(range)); } }; diff --git a/include/boost/geometry/core/container_access.hpp b/include/boost/geometry/core/mutable_range.hpp similarity index 58% rename from include/boost/geometry/core/container_access.hpp rename to include/boost/geometry/core/mutable_range.hpp index 1bcc1c5cf..0e9d7c065 100644 --- a/include/boost/geometry/core/container_access.hpp +++ b/include/boost/geometry/core/mutable_range.hpp @@ -1,21 +1,18 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands. +// Copyright Barend Gehrels 2010-2011, Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_CORE_CONTAINER_ACCESS_HPP -#define BOOST_GEOMETRY_CORE_CONTAINER_ACCESS_HPP +#ifndef BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP +#define BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP + #include -#include -#include - -#include -#include -#include +#include +#include namespace boost { namespace geometry @@ -25,22 +22,27 @@ namespace boost { namespace geometry namespace traits { +/*! +\brief Metafunction to define the argument passed to the three + traits classes clear, push_back and resize +\ingroup mutable_range + */ template struct rvalue_type { typedef typename boost::remove_reference::type& type; }; + /*! \brief Traits class to clear a geometry -\ingroup traits +\ingroup mutable_range */ template struct clear { static inline void apply(typename rvalue_type::type range) { - // The default action: act as it it is a std:: container range.clear(); } }; @@ -48,35 +50,34 @@ struct clear /*! \brief Traits class to append a point to a range (ring, linestring, multi*) -\ingroup traits +\ingroup mutable_range */ template struct push_back { + typedef typename boost::range_value + < + typename boost::remove_reference::type + >::type item_type; + static inline void apply(typename rvalue_type::type range, - typename boost::range_value - < - typename boost::remove_reference::type - >::type const& item) + item_type const& item) { - // The default action: act as it it is a std:: container range.push_back(item); } }; - /*! \brief Traits class to append a point to a range (ring, linestring, multi*) -\ingroup traits +\ingroup mutable_range */ template struct resize { - static inline void apply(typename rvalue_type::type range, + static inline void apply(typename rvalue_type::type range, std::size_t new_size) { - // The default action: act as it it is a std:: container range.resize(new_size); } }; @@ -88,4 +89,4 @@ struct resize }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_CORE_CONTAINER_ACCESS_HPP +#endif // BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP diff --git a/include/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp b/include/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp index 05afa03af..176be813d 100644 --- a/include/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp +++ b/include/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -111,7 +112,7 @@ struct parsing_assigner // Note that it is much slower than atof. However, it is more standard // and in parsing the change in performance falls probably away against // the tokenizing - set(point, finished + set(point, finished ? coordinate_type() : coordinate_cast::apply(*it)); } diff --git a/include/boost/geometry/extensions/gis/io/wkt/read_wkt_multi.hpp b/include/boost/geometry/extensions/gis/io/wkt/read_wkt_multi.hpp index 77863a785..c9d9a4f3b 100644 --- a/include/boost/geometry/extensions/gis/io/wkt/read_wkt_multi.hpp +++ b/include/boost/geometry/extensions/gis/io/wkt/read_wkt_multi.hpp @@ -10,6 +10,7 @@ #include +#include #include #include @@ -27,7 +28,7 @@ struct multi_parser { static inline void apply(std::string const& wkt, MultiGeometry& geometry) { - geometry.clear(); + traits::clear::apply(geometry); tokenizer tokens(wkt, boost::char_separator(" ", ",()")); tokenizer::iterator it; @@ -38,7 +39,7 @@ struct multi_parser // Parse sub-geometries while(it != tokens.end() && *it != ")") { - geometry.resize(geometry.size() + 1); + traits::resize::apply(geometry, boost::size(geometry) + 1); Parser < typename boost::range_value::type diff --git a/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp b/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp index 835882fa6..028140a7f 100644 --- a/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp +++ b/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp @@ -20,10 +20,11 @@ #include +#include #include -#include +#include #include #include @@ -36,21 +37,40 @@ namespace boost { namespace geometry namespace traits { - template - struct tag< boost::array > - { - typedef linestring_tag type; - }; +template +struct tag< boost::array > +{ + typedef linestring_tag type; +}; - // Clear does not exist for a boost::array - // It should not be used, and therefore: throw - template - struct clear< boost::array > - { - static inline void apply(boost::array& ) - { - } - }; +// boost::array is immutable with respect to size +// Therefore, prohibit compilation +template +struct clear< boost::array > +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_BOOST_ARRAY_OF, (types) + ); +}; + +template +struct resize< boost::array > +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_BOOST_ARRAY_OF, (types) + ); +}; + +template +struct push_back< boost::array > +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_BOOST_ARRAY_OF, (types) + ); +}; } #endif diff --git a/include/boost/geometry/geometries/adapted/std_as_linestring.hpp b/include/boost/geometry/geometries/adapted/std_as_linestring.hpp index 9e8145a86..805ccb667 100644 --- a/include/boost/geometry/geometries/adapted/std_as_linestring.hpp +++ b/include/boost/geometry/geometries/adapted/std_as_linestring.hpp @@ -25,7 +25,7 @@ #include -#include +#include #include #include diff --git a/include/boost/geometry/geometries/concepts/linestring_concept.hpp b/include/boost/geometry/geometries/concepts/linestring_concept.hpp index 3acc6314e..5ecaf9ce5 100644 --- a/include/boost/geometry/geometries/concepts/linestring_concept.hpp +++ b/include/boost/geometry/geometries/concepts/linestring_concept.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -81,6 +81,8 @@ public : Geometry* ls; traits::clear::apply(*ls); traits::resize::apply(*ls, 0); + point_type* point; + traits::push_back::apply(*ls, *point); } #endif }; diff --git a/include/boost/geometry/geometries/concepts/polygon_concept.hpp b/include/boost/geometry/geometries/concepts/polygon_concept.hpp index 7a62ea29e..5c35d82db 100644 --- a/include/boost/geometry/geometries/concepts/polygon_concept.hpp +++ b/include/boost/geometry/geometries/concepts/polygon_concept.hpp @@ -25,37 +25,23 @@ namespace boost { namespace geometry { namespace concept { - /*! -\brief Polygon concept +\brief Checks polygon concept \ingroup concepts -\par Formal definition: -The polygon concept is defined as following: -- there must be a specialization of traits::tag defining polygon_tag as type -- there must be a specialization of traits::ring_type defining the type of its -exterior ring and interior rings as type -- there must be a specialization of traits::interior_type defining the type of -the collection of its interior rings as type -- there must be a specialization of traits::exterior_ring - with two functions named "get", - returning the exterior ring, a const version and a mutable version -- there must be a specialization of traits::interior_rings - with two functions named "get", returning the interior rings, - a const version and a mutable version - -\note to fulfil the concepts, no traits class has to be specialized to -define the point type. The point type is extracted from the ring type */ -template +template class Polygon { #ifndef DOXYGEN_NO_CONCEPT_MEMBERS - typedef typename point_type::type point_type; - typedef typename ring_type::type ring_type; - typedef typename traits::ring_const_type::type ring_const_type; - typedef typename traits::ring_mutable_type::type ring_mutable_type; - typedef typename traits::interior_const_type::type interior_const_type; - typedef typename traits::interior_mutable_type::type interior_mutable_type; + typedef typename boost::remove_const::type polygon_type; + + typedef typename traits::ring_const_type::type ring_const_type; + typedef typename traits::ring_mutable_type::type ring_mutable_type; + typedef typename traits::interior_const_type::type interior_const_type; + typedef typename traits::interior_mutable_type::type interior_mutable_type; + + typedef typename point_type::type point_type; + typedef typename ring_type::type ring_type; BOOST_CONCEPT_ASSERT( (concept::Point) ); BOOST_CONCEPT_ASSERT( (concept::Ring) ); @@ -66,29 +52,27 @@ class Polygon { static inline void apply() { - Geometry* poly; - ring_mutable_type e = exterior_ring(*poly); - interior_mutable_type i = interior_rings(*poly); + polygon_type* poly; + polygon_type const* cpoly = poly; + + ring_mutable_type e = traits::exterior_ring::get(*poly); + interior_mutable_type i = traits::interior_rings::get(*poly); + ring_const_type ce = traits::exterior_ring::get(*cpoly); + interior_const_type ci = traits::interior_rings::get(*cpoly); boost::ignore_unused_variable_warning(e); boost::ignore_unused_variable_warning(i); + boost::ignore_unused_variable_warning(ce); + boost::ignore_unused_variable_warning(ci); boost::ignore_unused_variable_warning(poly); + boost::ignore_unused_variable_warning(cpoly); } - }; public: - BOOST_CONCEPT_USAGE(Polygon) { - // Check if it can be modified - // TODO - - //Geometry* poly; - //clear(*poly); - //append(*poly, point_type()); - checker::apply(); } #endif @@ -96,22 +80,21 @@ public: /*! -\brief Polygon concept (const version) +\brief Checks polygon concept (const version) \ingroup const_concepts -\details The ConstPolygon concept check the same as the Polygon concept, -but does not check write access. */ -template +template class ConstPolygon { #ifndef DOXYGEN_NO_CONCEPT_MEMBERS - typedef typename point_type::type point_type; - typedef typename ring_type::type ring_type; - typedef typename ring_return_type::type ring_return_type; - typedef typename interior_return_type::type interior_type; - //typedef typename traits::ring_const_type::type ring_const_type; - //typedef typename traits::interior_const_type::type interior_const_type; + typedef typename boost::remove_const::type const_polygon_type; + + typedef typename traits::ring_const_type::type ring_const_type; + typedef typename traits::interior_const_type::type interior_const_type; + + typedef typename point_type::type point_type; + typedef typename ring_type::type ring_type; BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); BOOST_CONCEPT_ASSERT( (concept::ConstRing) ); @@ -122,17 +105,17 @@ class ConstPolygon { static inline void apply() { - Geometry const* poly; - ring_return_type ce = exterior_ring(*poly); - interior_type ci = interior_rings(*poly); + const_polygon_type const* cpoly; + + ring_const_type ce = traits::exterior_ring::get(*cpoly); + interior_const_type ci = traits::interior_rings::get(*cpoly); boost::ignore_unused_variable_warning(ce); boost::ignore_unused_variable_warning(ci); - boost::ignore_unused_variable_warning(poly); + boost::ignore_unused_variable_warning(cpoly); } }; - public: BOOST_CONCEPT_USAGE(ConstPolygon) diff --git a/include/boost/geometry/geometries/concepts/ring_concept.hpp b/include/boost/geometry/geometries/concepts/ring_concept.hpp index dc05dfb1e..d683e5e97 100644 --- a/include/boost/geometry/geometries/concepts/ring_concept.hpp +++ b/include/boost/geometry/geometries/concepts/ring_concept.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -57,6 +57,8 @@ public : Geometry* ring; traits::clear::apply(*ring); traits::resize::apply(*ring, 0); + point_type* point; + traits::push_back::apply(*ring, *point); } #endif }; diff --git a/include/boost/geometry/geometries/quantity_point.hpp b/include/boost/geometry/geometries/quantity_point.hpp new file mode 100644 index 000000000..1905139e0 --- /dev/null +++ b/include/boost/geometry/geometries/quantity_point.hpp @@ -0,0 +1,128 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, Amsterdam, the Netherlands. +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_QUANTITY_POINT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_QUANTITY_POINT_HPP + +#include + +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace cs +{ + +template +struct units_cartesian {}; + +} + +namespace traits +{ + +template +struct cs_tag > +{ + typedef cartesian_tag type; +}; + +} + + +namespace model +{ + +// Define a point type to interoperate with Boost.Units, having +// 1. a constructor taking quantities +// 2. defining a quantified coordinate system +// Note that all values are still stored in "normal" types as double +template +< + typename Units, + std::size_t DimensionCount = 2, + typename CoordinateType = double, + typename CoordinateSystem = cs::units_cartesian +> +class quantity_point + : public model::point +{ + typedef boost::units::quantity qtype; + +public : + + // Templated constructor to allow constructing with other units then qtype, + // e.g. to convert from centimeters to meters + template + inline quantity_point(Quantity const& x, Quantity const& y) + : model::point( + qtype(x).value(), + qtype(y).value()) + {} +}; + +} + + +// Adapt quantity_point to the Point Concept +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag > +{ + typedef point_tag type; +}; + +template +struct coordinate_type > +{ + typedef CoordinateType type; +}; + +template +struct coordinate_system > +{ + typedef CoordinateSystem type; +}; + +template +struct dimension > + : boost::mpl::int_ +{}; + +template +struct access, Dimension > +{ + static inline CoordinateType get( + model::quantity_point const& p) + { + return p.template get(); + } + + static inline void set(model::quantity_point& p, + CoordinateType const& value) + { + p.template set(value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_QUANTITY_POINT_HPP diff --git a/include/boost/geometry/multi/algorithms/simplify.hpp b/include/boost/geometry/multi/algorithms/simplify.hpp index 6c3b740f7..cb4649943 100644 --- a/include/boost/geometry/multi/algorithms/simplify.hpp +++ b/include/boost/geometry/multi/algorithms/simplify.hpp @@ -11,6 +11,7 @@ #include +#include #include #include @@ -32,7 +33,7 @@ struct simplify_multi static inline void apply(MultiGeometry const& multi, MultiGeometry& out, double max_distance, Strategy const& strategy) { - out.resize(boost::size(multi)); + traits::resize::apply(out, boost::size(multi)); typename boost::range_iterator::type it_out = boost::begin(out); diff --git a/include/boost/geometry/multi/algorithms/transform.hpp b/include/boost/geometry/multi/algorithms/transform.hpp index 7b0db4f9f..967e04b4e 100644 --- a/include/boost/geometry/multi/algorithms/transform.hpp +++ b/include/boost/geometry/multi/algorithms/transform.hpp @@ -11,6 +11,7 @@ #include +#include #include #include @@ -31,7 +32,7 @@ struct transform_multi template static inline bool apply(Multi1 const& multi1, Multi2& multi2, S const& strategy) { - multi2.resize(boost::size(multi1)); + traits::resize::apply(multi2, boost::size(multi1)); typename boost::range_iterator::type it1 = boost::begin(multi1); diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index fef187a4c..ad3ffd1ab 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -11,16 +11,18 @@ test-suite boost-geometry-algorithms [ run append.cpp ] [ run area.cpp ] [ run assign.cpp ] + [ run buffer.cpp ] [ run centroid.cpp ] [ run combine.cpp ] + [ run comparable_distance.cpp ] [ run convert.cpp ] [ run convex_hull.cpp ] [ run correct.cpp ] + [ run difference.cpp ] [ run disjoint.cpp ] - [ run dissolve.cpp ] - [ run equals.cpp ] [ run distance.cpp ] [ run envelope.cpp ] + [ run equals.cpp ] [ run for_each.cpp ] [ run intersection.cpp ] [ run intersects.cpp ] @@ -41,3 +43,4 @@ build-project overlay build-project detail ; + diff --git a/test/algorithms/algorithms_tests.sln b/test/algorithms/algorithms_tests.sln index 8ee7f3582..86bcfbc3c 100644 --- a/test/algorithms/algorithms_tests.sln +++ b/test/algorithms/algorithms_tests.sln @@ -56,8 +56,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique", "unique.vcproj", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reverse", "reverse.vcproj", "{14B5DFC5-D511-4D8C-A231-EE90A05687E1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dissolve", "dissolve.vcproj", "{206F83D5-17F9-4856-A1DE-82301DB94439}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "comparable_distance", "comparable_distance.vcproj", "{F11970B5-BE16-4FF5-9780-4C15082B76A0}" EndProject Global @@ -178,10 +176,6 @@ Global {14B5DFC5-D511-4D8C-A231-EE90A05687E1}.Debug|Win32.Build.0 = Debug|Win32 {14B5DFC5-D511-4D8C-A231-EE90A05687E1}.Release|Win32.ActiveCfg = Release|Win32 {14B5DFC5-D511-4D8C-A231-EE90A05687E1}.Release|Win32.Build.0 = Release|Win32 - {206F83D5-17F9-4856-A1DE-82301DB94439}.Debug|Win32.ActiveCfg = Debug|Win32 - {206F83D5-17F9-4856-A1DE-82301DB94439}.Debug|Win32.Build.0 = Debug|Win32 - {206F83D5-17F9-4856-A1DE-82301DB94439}.Release|Win32.ActiveCfg = Release|Win32 - {206F83D5-17F9-4856-A1DE-82301DB94439}.Release|Win32.Build.0 = Release|Win32 {F11970B5-BE16-4FF5-9780-4C15082B76A0}.Debug|Win32.ActiveCfg = Debug|Win32 {F11970B5-BE16-4FF5-9780-4C15082B76A0}.Debug|Win32.Build.0 = Debug|Win32 {F11970B5-BE16-4FF5-9780-4C15082B76A0}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/test/algorithms/difference.cpp b/test/algorithms/difference.cpp index 62b84e5f3..cf7a3d249 100644 --- a/test/algorithms/difference.cpp +++ b/test/algorithms/difference.cpp @@ -12,12 +12,22 @@ #include #include - +#include #include #include #include +#include +#include +#include +#include + + +#ifdef HAVE_TTMATH +# include +#endif + template void test_all() @@ -95,8 +105,84 @@ void test_all() } +template +void test_difference_parcel_precision() +{ + typedef bg::model::d2::point_xy point_type; + typedef bg::model::polygon polygon_type; + typedef bg::model::linestring linestring_type; + typedef std::vector byte_vector; + + polygon_type parcel, buffer; + + { + byte_vector wkb; + bg::hex2wkb("0103000000010000001A00000023DBF97EE316064146B6F3FDD32513415A643BDFD216064175931804E225134196438B6C52150641C976BE9F34261341F6285C8F06150641022B871641261341F853E3A5D3140641E17A14AE50261341B81E85EBFB120641A4703D8A142713414E6210584D120641AC1C5A64602713414E621058431106414E621058C9271341A01A2FDD1B11064121B07268D8271341F4FDD478571006411904560ECF271341448B6CE7DD0F06418195438BC1271341F6285C8F6A0F06413BDF4F0DA72713410E2DB29D360F06416F1283C091271341E5D022DB070F0641F6285C0F7227134160E5D022DA0E06416F1283404F271341448B6CE7D30E0641F853E3A52427134154E3A59BE60E06411904568E07271341643BDF4F0C0F0641D7A3703DFC2613414A0C022B100F064125068115FB26134191ED7C3F310F0641B6F3FDD4F42613414C378941F11006414A0C022BA0261341EC51B81ECC1206413BDF4F0D40261341022B87167514064125068115F1251341B4C876BE8C160641C74B37897F25134121B07268C6160641508D976E7525134123DBF97EE316064146B6F3FDD3251341", std::back_inserter(wkb)); + bg::read_wkb(wkb.begin(), wkb.end(), parcel); + } + { + byte_vector wkb; + bg::hex2wkb("01030000000100000083000000000032FCD716064100009E998F25134100000706D81606410040A4998F2513410000DA0FD816064100C0E6998F2513410000A819D81606410080659A8F25134100806A23D816064100C0209B8F25134100801E2DD81606410080189C8F2513410000BE36D816064100404D9D8F25134100004540D816064100C0BE9E8F2513410000AF49D816064100806DA08F2513410000F752D8160641008059A28F2513410000195CD816064100C082A48F25134100800F65D81606410080E9A68F2513410000D66DD816064100408EA98F25134100006876D816064100C070AC8F2513410000C17ED8160641000091AF8F2513410080DC86D816064100C0EFB28F25134100009E8ED816064100C081B68F2513410080EC95D816064100803ABA8F2513410080C79CD8160641000018BE8F25134100002FA3D8160641008017C28F251341008022A9D8160641000037C68F2513410080A1AED8160641000074CA8F2513410000ACB3D81606410040CCCE8F251341000042B8D816064100403DD38F251341000062BCD81606410000C5D78F25134100000DC0D8160641000061DC8F251341000042C3D816064100000FE18F251341000001C6D81606410080CCE58F251341008049C8D8160641004097EA8F25134100001BCAD816064100006DEF8F251341008075CBD816064100804BF48F251341008058CCD8160641004030F98F2513410000C4CCD8160641000019FE8F2513410080B7CCD81606410080030390251341008032CCD81606410000ED0790251341000035CBD81606410000D40C902513410080BEC9D81606410040B511902513410000CFC7D816064100408F1690251341008065C5D816064100005F1B90251341008082C2D81606410080222090251341000025BFD81606410080D7249025134100004DBBD816064100807B29902513410080FAB6D816064100800C2E9025134100002DB2D816064100C08732902513410080E3ACD81606410000EB369025134100801EA7D81606410000343B902513410000DEA0D81606410080603F902513410080209AD816064100406E43902513410080209AC015064100406E43302613410080FC92C015064100004F473026134100008B8BC01506410040F64A302613410000D083C015064100C0634E302613410000D17BC0150641008097513026134100009273C015064100409154302613410000186BC015064100C050573026134100806762C01506410000D6593026134100808559C01506410000215C3026134100007650C01506410000315E3026134100003E47C015064100800660302613410000E23DC01506410000A1613026134100006734C015064100800063302613410080D12AC015064100C024643026134100002621C015064100800D653026134100006917C015064100C0BA653026134100809F0DC015064100402C66302613410000CE03C015064100006266302613410000F9F9BF15064100C05B6630261341000026F0BF1506410040196630261341000058E6BF15064100809A6530261341008095DCBF1506410040DF64302613410080E1D2BF1506410080E76330261341000042C9BF15064100C0B262302613410000BBBFBF1506410040416130261341000051B6BF1506410080925F30261341000009ADBF1506410080A65D302613410000E7A3BF15064100407D5B302613410080F09ABF150641008016593026134100002A92BF15064100C071563026134100009889BF15064100408F533026134100003F81BF15064100006F503026134100802379BF1506410040104D3026134100006271BF15064100407E49302613410080136ABF1506410080C5453026134100803863BF1506410000E841302613410000D15CBF1506410080E83D302613410080DD56BF1506410000C9393026134100805E51BF15064100008C35302613410000544CBF15064100C03331302613410000BE47BF15064100C0C22C3026134100009E43BF15064100003B28302613410000F33FBF15064100009F23302613410000BE3CBF1506410000F11E302613410000FF39BF1506410080331A302613410080B637BF15064100C06815302613410000E535BF150641000093103026134100808A34BF1506410080B40B302613410080A733BF15064100C0CF063026134100003C33BF1506410000E7013026134100804833BF1506410080FCFC2F2613410080CD33BF150641000013F82F2613410000CB34BF15064100002CF32F26134100804136BF15064100C04AEE2F26134100003138BF15064100C070E92F26134100809A3ABF1506410000A1E42F26134100807D3DBF1506410080DDDF2F2613410000DB40BF150641008028DB2F2613410000B344BF150641008084D62F26134100800549BF1506410080F3D12F2613410000D34DBF150641004078CD2F26134100801C53BF150641000015C92F2613410080E158BF1506410000CCC42F2613410000225FBF15064100809FC02F2613410080DF65BF15064100C091BC2F2613410080DF65D716064100C091BC8F2513410080036DD71606410000B1B88F25134100007574D716064100C009B58F2513410000307CD716064100409CB18F25134100002F84D7160641008068AE8F25134100006E8CD716064100C06EAB8F2513410000E894D71606410040AFA88F2513410080989DD716064100002AA68F25134100807AA6D71606410000DFA38F25134100008AAFD71606410000CFA18F2513410000C2B8D71606410080F99F8F25134100001EC2D716064100005F9E8F251341000099CBD71606410080FF9C8F25134100802ED5D71606410040DB9B8F2513410000DADED71606410080F29A8F251341000097E8D71606410040459A8F251341008060F2D716064100C0D3998F251341000032FCD716064100009E998F251341", std::back_inserter(wkb)); + bg::read_wkb(wkb.begin(), wkb.end(), buffer); + } + bg::correct(parcel); + bg::correct(buffer); + + std::vector pieces; + bg::difference(parcel, buffer, pieces); + + std::vector filled_out; + bg::difference(parcel, pieces.back(), filled_out); + +#if defined(TEST_OUTPUT) + std::cout << bg::area(parcel) << std::endl; + std::cout << bg::area(buffer) << std::endl; + std::cout << pieces.size() << std::endl; + std::cout << bg::area(pieces.front()) << std::endl; + std::cout << filled_out.size() << std::endl; + std::cout << std::setprecision(16) << bg::wkt(filled_out.front()) << std::endl; + std::cout << bg::wkt(filled_out.front()) << std::endl; + std::cout << bg::area(filled_out.front()) << std::endl; + std::cout << bg::perimeter(filled_out.front()) << std::endl; +#endif + +#if defined(TEST_WITH_SVG) + { + linestring_type cut_line; + bg::read_wkt("linestring(180955 313700,180920 313740)", cut_line); + + std::ostringstream filename; + filename << "difference_precision_" + << string_from_type::name() + << ".svg"; + + std::ofstream svg(filename.str().c_str()); + + bg::svg_mapper mapper(svg, 500, 500); + + mapper.add(cut_line); + + //mapper.map(parcel, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:3"); + mapper.map(pieces.front(), "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:1"); + mapper.map(pieces.back(), "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:1"); + mapper.map(filled_out.front(), "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:3"); + + mapper.map(cut_line, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:5;stroke-dasharray:1,7;stroke-linecap:round"); + //mapper.map(cut_line, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:2"); + } +#endif +} + int test_main(int, char* []) { + test_difference_parcel_precision(); + test_difference_parcel_precision(); + test_all >(); + +#ifdef HAVE_TTMATH + test_difference_parcel_precision(); +#endif + return 0; } diff --git a/test/algorithms/dissolve.cpp b/test/algorithms/dissolve.cpp index e377abb4f..a90d1178e 100644 --- a/test/algorithms/dissolve.cpp +++ b/test/algorithms/dissolve.cpp @@ -87,6 +87,30 @@ void test_all() test_one("case_1", "POLYGON((1 3,0 9,9 5,1 7,9 8,2 5,10 10,9 2,1 3))", 0, 7, 50.48056402439); +/* + // Mail + + // See power point, and http://en.wikipedia.org/wiki/Pentagram + test_one("pentagram", + "POLYGON((5 0,2.5 9,9.5 3.5,0.5 3.5,7.5 9,5 0))", + 0, 11, 25.6158412); + + + //Should be solved (completely) differently + + test_one("mail_denis_1", + "POLYGON((55 10, 141 237, 249 23, 21 171, 252 169, 24 89, 266 73, 55 10))", + 0, 7, 50.48056402439); + // Source: http://upload.wikimedia.org/wikipedia/commons/8/83/Acute_heptagram.svg + test_one("acute_heptagram", + "POLYGON((409 5,229 793.631528,733.348792 161.198146,4.543671 512.172194,813.456329 512.172194,84.651208 161.198146,589 793.631528))", + 0, 11, 25.6158412); + + // Source: http://upload.wikimedia.org/wikipedia/commons/a/a7/Obtuse_heptagram.svg + test_one("obtuse_heptagram", + "POLYGON((409 5,813.456329 512.172194,229 793.631528,84.651208 161.198146,733.348792 161.198146,589 793.631528,4.543671 512.172194))", + 0, 11, 25.6158412); +*/ std::string const ticket17 = "POLYGON ((-122.28139163 37.37319149,-122.28100699 37.37273669,-122.28002186 37.37303123,-122.27979681 37.37290072,-122.28007349 37.37240493,-122.27977334 37.37220360,-122.27819720 37.37288580,-122.27714184 37.37275161,-122.27678628 37.37253167,-122.27766437 37.37180973,-122.27804382 37.37121453,-122.27687664 37.37101354,-122.27645829 37.37203386,-122.27604423 37.37249110,-122.27632234 37.37343339,-122.27760980 37.37391082,-122.27812478 37.37800320,-122.26117222 37.39121007,-122.25572289 37.39566631,-122.25547269 37.39564971,-122.25366304 37.39552993,-122.24919976 37.39580268,-122.24417933 37.39366907,-122.24051443 37.39094143,-122.23246277 37.38100418,-122.23606766 37.38141338,-122.24001587 37.37738940,-122.23666848 37.37609347,-122.23057450 37.37882170,-122.22679803 37.37807143,-122.22525727 37.37448817,-122.22523229 37.37443000,-122.23083199 37.37609347,-122.23033486 37.37777891,-122.23169030 37.37732117,-122.23229178 37.37709687,-122.23237761 37.37631249,-122.23297776 37.37438834,-122.23872850 37.37165986,-122.24044511 37.36934068,-122.24671067 37.36865847,-122.24825570 37.36981819,-122.25151719 37.36947713,-122.25357721 37.36756706,-122.26001451 37.36579354,-122.25615213 37.36545239,-122.25486458 37.36245083,-122.25357721 37.36108651,-122.25194642 37.36013139,-122.24885652 37.35958557,-122.24911401 37.35849399,-122.25357721 37.35808470,-122.25675286 37.35897159,-122.25855539 37.35753887,-122.26181687 37.35828939,-122.26713837 37.35897159,-122.26782510 37.36108651,-122.26662339 37.36456559,-122.27288911 37.36722601,-122.27366159 37.36531602,-122.27168740 37.36470213,-122.27391900 37.36374701,-122.27074326 37.36245083,-122.27134408 37.35951742,-122.27426240 37.36135926,-122.27709482 37.36115474,-122.27966974 37.36231438,-122.27958391 37.36463382,-122.27572152 37.36463382,-122.27563569 37.36524779,-122.27700899 37.36593000,-122.27709482 37.36763529,-122.27554978 37.36838573,-122.27667254 37.36931478,-122.27677932 37.36932073,-122.27769362 37.36853987,-122.27942490 37.36830803,-122.28178776 37.36677917,-122.28509559 37.36443500,-122.28845129 37.36413744,-122.29194403 37.36695946,-122.29382577 37.36726817,-122.29600414 37.36898512,-122.29733083 37.36995398,-122.29593239 37.37141436,-122.29416649 37.37075898,-122.29325026 37.37108436,-122.29652910 37.37311697,-122.29584237 37.37374461,-122.29537583 37.37573372,-122.29487677 37.37752502,-122.30923212 37.37593011,-122.31122484 37.38230086,-122.31467994 37.38092472,-122.31715663 37.38252181,-122.32307970 37.38166978,-122.31985618 37.37667694,-122.32210304 37.37580220,-122.32581446 37.37589532,-122.32401730 37.37331839,-122.32960417 37.37189020,-122.33465527 37.37331906,-122.33425328 37.37623680,-122.33620676 37.37726132,-122.33397986 37.37822382,-122.33358918 37.38036590,-122.33202637 37.37986918,-122.33147954 37.38101784,-122.33394080 37.38198017,-122.33545239 37.38587943,-122.33478058 37.38785697,-122.33386050 37.38723721,-122.33350041 37.38571137,-122.33122003 37.38548891,-122.33140008 37.38650606,-122.33366042 37.38817490,-122.33244019 37.39157602,-122.33298157 37.39419201,-122.33164013 37.39477028,-122.33202017 37.39518351,-122.33358038 37.39499282,-122.33376050 37.39597811,-122.33550067 37.39734478,-122.33556069 37.39481797,-122.33344040 37.39292676,-122.33638094 37.38892189,-122.34240644 37.38852719,-122.34906293 37.38726898,-122.35072321 37.39338769,-122.34910291 37.39445252,-122.34796272 37.39410291,-122.34449043 37.39640534,-122.34500223 37.39729709,-122.34936291 37.39670910,-122.35098322 37.39531066,-122.35364623 37.39554510,-122.35434369 37.39612111,-122.35798429 37.39600988,-122.35768430 37.39478621,-122.36334519 37.39206871,-122.36604726 37.39203267,-122.36778592 37.39335592,-122.36518870 37.40022011,-122.36554552 37.40247752,-122.36370519 37.40331974,-122.36270506 37.40530591,-122.36320512 37.40670418,-122.36149849 37.40851392,-122.36730580 37.41054938,-122.37263720 37.41378932,-122.37161871 37.42076600,-122.36566153 37.42006292,-122.36520547 37.42742106,-122.37165953 37.43661157,-122.35943972 37.44459022,-122.35356359 37.44600810,-122.33792254 37.45796329,-122.35228518 37.47478091,-122.35127080 37.48181199,-122.34867342 37.48487322,-122.34359717 37.48801082,-122.33388431 37.48677650,-122.33142321 37.48429747,-122.32929580 37.48473149,-122.32609609 37.48291144,-122.32344850 37.48228229,-122.31924364 37.48410234,-122.31677299 37.48114051,-122.31431751 37.47848973,-122.31259201 37.47682190,-122.31515972 37.47568196,-122.31691389 37.47360309,-122.31292494 37.46960081,-122.31130153 37.46937743,-122.30889894 37.47124987,-122.30612839 37.47011613,-122.30149630 37.46568378,-122.30064277 37.46363784,-122.29283821 37.45922376,-122.28630141 37.45415497,-122.28883099 37.44629920,-122.28316717 37.44197138,-122.27554148 37.42297597,-122.25597410 37.40553692,-122.25196579 37.40129593,-122.25012043 37.40049143,-122.24823207 37.39897758,-122.24754551 37.39740941,-122.24778582 37.39621607,-122.24934787 37.39599102,-122.25005170 37.39871849,-122.25222328 37.39863668,-122.25342491 37.39737529,-122.25520162 37.39667289,-122.25528737 37.39522726,-122.27747460 37.37809616,-122.27977493 37.37858717,-122.28157729 37.37920106,-122.28322534 37.37952846,-122.28416939 37.38092656,-122.28621223 37.37984219,-122.28638389 37.37613857,-122.28382607 37.37843722,-122.27930278 37.37718220,-122.28196361 37.37652740,-122.28295058 37.37568167,-122.28216101 37.37523148,-122.28114822 37.37543608,-122.27934569 37.37528613,-122.27996369 37.37448121,-122.28104521 37.37454944,-122.28185197 37.37422883,-122.28290767 37.37474038,-122.28376597 37.37467224,-122.28428104 37.37399012,-122.28402346 37.37338989,-122.28610922 37.37364914,-122.28651264 37.37327388,-122.28672722 37.37207343,-122.28628398 37.37205448,-122.28574460 37.37166682,-122.28479711 37.37200981,-122.28327731 37.37137228,-122.28285511 37.37100700,-122.28279409 37.37125669,-122.28315527 37.37173756,-122.28321872 37.37220569,-122.28187007 37.37231918,-122.28193109 37.37294908,-122.28139163 37.37319149))"; diff --git a/test/multi/multi_tests.sln b/test/multi/multi_tests.sln index 950e18169..809a63900 100644 --- a/test/multi/multi_tests.sln +++ b/test/multi/multi_tests.sln @@ -32,8 +32,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_reverse", "algorithms EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_unique", "algorithms\multi_unique.vcproj", "{71879D37-84A8-4949-8CDB-212982F81D80}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_dissolve", "algorithms\multi_dissolve.vcproj", "{4F6E99F2-D93F-4C61-9300-B835874A3F34}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_num_geometries", "algorithms\multi_num_geometries.vcproj", "{8DB68EB9-07CA-4705-859E-B1A7098B5CF3}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_num_points", "algorithms\multi_num_points.vcproj", "{EA4B2EB3-1FBA-42BE-B7D7-5A517BC74E2B}" @@ -110,10 +108,6 @@ Global {71879D37-84A8-4949-8CDB-212982F81D80}.Debug|Win32.Build.0 = Debug|Win32 {71879D37-84A8-4949-8CDB-212982F81D80}.Release|Win32.ActiveCfg = Release|Win32 {71879D37-84A8-4949-8CDB-212982F81D80}.Release|Win32.Build.0 = Release|Win32 - {4F6E99F2-D93F-4C61-9300-B835874A3F34}.Debug|Win32.ActiveCfg = Debug|Win32 - {4F6E99F2-D93F-4C61-9300-B835874A3F34}.Debug|Win32.Build.0 = Debug|Win32 - {4F6E99F2-D93F-4C61-9300-B835874A3F34}.Release|Win32.ActiveCfg = Release|Win32 - {4F6E99F2-D93F-4C61-9300-B835874A3F34}.Release|Win32.Build.0 = Release|Win32 {8DB68EB9-07CA-4705-859E-B1A7098B5CF3}.Debug|Win32.ActiveCfg = Debug|Win32 {8DB68EB9-07CA-4705-859E-B1A7098B5CF3}.Debug|Win32.Build.0 = Debug|Win32 {8DB68EB9-07CA-4705-859E-B1A7098B5CF3}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/test/test_geometries/all_custom_linestring.hpp b/test/test_geometries/all_custom_linestring.hpp index f9e6115df..f66ddf61c 100644 --- a/test/test_geometries/all_custom_linestring.hpp +++ b/test/test_geometries/all_custom_linestring.hpp @@ -13,7 +13,7 @@ #include -#include +#include #include #include diff --git a/test/test_geometries/all_custom_polygon.hpp b/test/test_geometries/all_custom_polygon.hpp index 497c3af7a..6d5a7e046 100644 --- a/test/test_geometries/all_custom_polygon.hpp +++ b/test/test_geometries/all_custom_polygon.hpp @@ -13,7 +13,7 @@ #include -#include +#include #include #include diff --git a/test/test_geometries/all_custom_ring.hpp b/test/test_geometries/all_custom_ring.hpp index 4404781bb..f3a390fbb 100644 --- a/test/test_geometries/all_custom_ring.hpp +++ b/test/test_geometries/all_custom_ring.hpp @@ -13,7 +13,7 @@ #include -#include +#include #include #include diff --git a/test/test_geometries/wrapped_boost_array.hpp b/test/test_geometries/wrapped_boost_array.hpp index 7617238f1..123a0fedc 100644 --- a/test/test_geometries/wrapped_boost_array.hpp +++ b/test/test_geometries/wrapped_boost_array.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include