diff --git a/doc/geometry.qbk b/doc/geometry.qbk index 48b727894..6adfee7d6 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -60,18 +60,19 @@ [*In progress] +[import src/examples/quick_start.cpp] [import src/examples/algorithms/area.cpp] [import src/examples/algorithms/area_with_strategy.cpp] +[import src/examples/algorithms/length.cpp] +[import src/examples/algorithms/length_with_strategy.cpp] +[import src/examples/algorithms/intersection_ls_ls_point.cpp] +[import src/examples/algorithms/intersection_segment.cpp] +[import src/examples/algorithms/intersects_linestring.cpp] +[import src/examples/algorithms/simplify.cpp] +[import src/examples/algorithms/simplify_inserter.cpp] [import src/examples/geometries/point.cpp] [import src/examples/geometries/register/point.cpp] -[/obsolete structure] -[import snippets/qbk_1.cpp] -[import snippets/qbk_2.cpp] -[import snippets/qbk_3.cpp] -[import snippets/qbk_4.cpp] -[import snippets/qbk_5.cpp] - [include introduction.qbk] [include quickstart.qbk] diff --git a/doc/reference/intersection.qbk b/doc/reference/intersection.qbk index f1c7259ee..a946113d1 100644 --- a/doc/reference/intersection.qbk +++ b/doc/reference/intersection.qbk @@ -54,8 +54,10 @@ Or [heading Examples] -[intersection_linestring] +[intersection_ls_ls_point] +[intersection_ls_ls_point_output] [intersection_segment] +[intersection_segment_output] [endsect] diff --git a/doc/reference/intersects.qbk b/doc/reference/intersects.qbk index e4f419b91..fa9626f2d 100644 --- a/doc/reference/intersects.qbk +++ b/doc/reference/intersects.qbk @@ -44,7 +44,7 @@ Or [heading Examples] [intersects_linestring] -[intersects_segment] +[intersects_linestring_output] [endsect] diff --git a/doc/reference/length.qbk b/doc/reference/length.qbk index c15ad8a1c..5f66ba492 100644 --- a/doc/reference/length.qbk +++ b/doc/reference/length.qbk @@ -58,7 +58,8 @@ Or Linear [heading Examples] -[length_strategy] +[length_with_strategy] +[length_with_strategy_output] [endsect] @@ -108,6 +109,7 @@ Linear [heading Examples] [length] +[length_output] [endsect] diff --git a/doc/reference/simplify.qbk b/doc/reference/simplify.qbk index 8bd9b02ec..d4f811b03 100644 --- a/doc/reference/simplify.qbk +++ b/doc/reference/simplify.qbk @@ -40,6 +40,10 @@ Or `#include ` +[heading Examples] +[simplify] +[simplify_output] + [endsect] @@ -90,7 +94,7 @@ void simplify_inserter (Geometry const &geometry, OutputIterator out, Distance c [[Type] [Concept] [Name] [Description] ] [[Geometry const &] [Any type fulfilling a Geometry Concept ] [geometry] [input geometry, to be simplified ]] [[OutputIterator] [] [out] [output iterator, outputs all simplified points ]] -[[Distance const &] [] [max_distance] [distance (in units of input coordinates) of a vertex to other segments to be removed ]] +[[Distance const &] [] [max_distance] [distance (in units of input coordinates) of a vertex to other segments to be removed]] ] @@ -103,6 +107,10 @@ Or `#include ` +[heading Examples] +[simplify_inserter] +[simplify_inserter_output] + [endsect] @@ -121,7 +129,7 @@ void simplify_inserter (Geometry const &geometry, OutputIterator out, Distance c [[Geometry const &] [Any type fulfilling a Geometry Concept ] [geometry] [input geometry, to be simplified ]] [[OutputIterator] [] [out] [output iterator, outputs all simplified points ]] [[Distance const &] [] [max_distance] [distance (in units of input coordinates) of a vertex to other segments to be removed ]] -[[Strategy const &] [] [strategy] [simplify strategy to be used for simplification, might include point-distance strategy ]] +[[Strategy const &] [] [strategy] [simplify strategy to be used for simplification, might include point-distance strategy]] ] @@ -134,9 +142,6 @@ Or `#include ` -[heading Examples] -[simplify_inserter] - [endsect] diff --git a/doc/snippets/qbk_1.cpp b/doc/snippets/qbk_1.cpp deleted file mode 100644 index 4cdb779fe..000000000 --- a/doc/snippets/qbk_1.cpp +++ /dev/null @@ -1,530 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands -// Copyright Bruno Lalande 2008, 2009 -// 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) -// -// Quickbook Examples, referred to from the sources - -#include - -#if defined(_MSC_VER) -// We deliberately mix float/double's here so turn off warning -#pragma warning( disable : 4244 ) -#endif // defined(_MSC_VER) - -#include -#include -#include -#include - -#include - - - - - - -void example_as_wkt_point() -{ - typedef boost::geometry::model::d2::point_xy P; - P p(5.12, 6.34); - // Points can be streamed like this: - std::cout << boost::geometry::dsv

(p) << std::endl; - - // or like this: - std::cout << boost::geometry::dsv(p) << std::endl; - - // or (with extension) like this: - std::cout << boost::geometry::wkt(p) << std::endl; -} - -void example_as_wkt_vector() -{ - std::vector > v; - boost::geometry::read_wkt >("linestring(1 1,2 2,3 3,4 4)", std::back_inserter(v)); - - std::cout << boost::geometry::dsv(std::make_pair(v.begin(), v.end())) << std::endl; -} - - -void example_centroid_polygon() -{ - boost::geometry::model::polygon > poly; - boost::geometry::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly); - // Center of polygon might have different type than points of polygon - boost::geometry::model::d2::point_xy center; - boost::geometry::centroid(poly, center); - std::cout << "Centroid: " << boost::geometry::dsv(center) << std::endl; -} - - -void example_distance_point_point() -{ - boost::geometry::model::d2::point_xy p1(1, 1); - boost::geometry::model::d2::point_xy p2(2, 3); - std::cout << "Distance p1-p2 is " - << boost::geometry::distance(p1, p2) - << " units" << std::endl; - - /* - Extension, other coordinate system: - // Read 2 Dutch cities from WKT texts (in decimal degrees) - boost::geometry::point_ll > a, r; - boost::geometry::read_wkt("POINT(4.89222 52.3731)", a); - boost::geometry::read_wkt("POINT(4.47917 51.9308)", r); - - std::cout << "Distance Amsterdam-Rotterdam is " - << boost::geometry::distance(a, r) / 1000.0 - << " kilometers " << std::endl; - */ -} - -void example_distance_point_point_strategy() -{ - /* - Extension, other coordinate system: - typedef boost::geometry::point_ll > LL; - LL a, r; - boost::geometry::read_wkt("POINT(4.89222 52.3731)", a); - boost::geometry::read_wkt("POINT(4.47917 51.9308)", r); - - std::cout << "Distance Amsterdam-Rotterdam is " - << boost::geometry::distance(a, r, - boost::geometry::strategy::distance::vincenty() ) - / 1000.0 - << " kilometers " << std::endl; - */ -} - -void example_from_wkt_point() -{ - boost::geometry::model::d2::point_xy point; - boost::geometry::read_wkt("Point(1 2)", point); - std::cout << point.x() << "," << point.y() << std::endl; -} - -void example_from_wkt_output_iterator() -{ - std::vector > v; - boost::geometry::read_wkt >("linestring(1 1,2 2,3 3,4 4)", std::back_inserter(v)); - std::cout << "vector has " << v.size() << " coordinates" << std::endl; -} - -void example_from_wkt_linestring() -{ - boost::geometry::model::linestring > line; - boost::geometry::read_wkt("linestring(1 1,2 2,3 3,4 4)", line); - std::cout << "linestring has " << line.size() << " coordinates" << std::endl; -} - -void example_from_wkt_polygon() -{ - boost::geometry::model::polygon > poly; - boost::geometry::read_wkt("POLYGON((0 0,0 1,1 1,1 0,0 0))", poly); - std::cout << "Polygon has " << poly.outer().size() << " coordinates in outer ring" << std::endl; -} - -void example_point_ll_convert() -{ - /* - Extension, other coordinate system: - boost::geometry::point_ll > deg(boost::geometry::latitude<>(33.0), boost::geometry::longitude<>(-118.0)); - boost::geometry::point_ll > rad; - boost::geometry::transform(deg, rad); - - std::cout << "point in radians: " << rad << std::endl; - */ -} - -void example_intersection_linestring() -{ - //[intersection_linestring - typedef boost::geometry::model::d2::point_xy P; - std::vector

line1, line2; - boost::geometry::read_wkt("linestring(1 1,2 2)", line1); - boost::geometry::read_wkt("linestring(2 1,1 2)", line2); - - std::deque

intersection_points; - boost::geometry::intersection(line1, line2, intersection_points); - //] -} - -void example_intersects_linestring() -{ - //[intersects_linestring - //` Check if two linestrings (here: vectors) intersect each other - typedef boost::geometry::model::d2::point_xy P; - std::vector

line1, line2; - boost::geometry::read_wkt("linestring(1 1,2 2)", line1); - boost::geometry::read_wkt("linestring(2 1,1 2)", line2); - - bool b = boost::geometry::intersects(line1, line2); - //] -} - - - -void example_intersection_segment() -{ - //[intersection_segment - typedef boost::geometry::model::d2::point_xy P; - boost::geometry::model::segment

segment1, segment2; - boost::geometry::read_wkt("linestring(1 1,2 2)", segment1); - boost::geometry::read_wkt("linestring(2 1,1 2)", segment2); - - std::vector

intersections; - boost::geometry::intersection(segment1, segment2, intersections); - //] -} - -void example_intersection_inserter_segment() -{ - //[intersection_segment_inserter - - typedef boost::geometry::model::d2::point_xy P; - boost::geometry::model::segment

segment1, segment2; - boost::geometry::read_wkt("linestring(1 1,2 2)", segment1); - boost::geometry::read_wkt("linestring(2 1,1 2)", segment2); - - std::vector

intersections; - boost::geometry::intersection_inserter

(segment1, segment2, std::back_inserter(intersections)); - //` The vector [*intersection] now contains one point: the intersection of the two segments. - //` If segments do not intersect, the vector is empty. - //` If segments happen to be collinear, the vector contains two points. - - //] -} - -void example_intersects_segment() -{ - //[intersects_segment - //` Check if two segments intersect each other - typedef boost::geometry::model::d2::point_xy P; - boost::geometry::model::segment

line1, line2; - boost::geometry::read_wkt("linestring(1 1,2 2)", line1); - boost::geometry::read_wkt("linestring(2 1,1 2)", line2); - - bool b = boost::geometry::intersects(line1, line2); - //] -} - - -void example_clip_linestring1() -{ - typedef boost::geometry::model::d2::point_xy P; - boost::geometry::model::linestring

line; - boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line); - boost::geometry::model::box

cb(P(1.5, 1.5), P(4.5, 2.5)); - std::cout << "Clipped linestring(s) " << std::endl; - - std::vector > intersection; - boost::geometry::intersection_inserter >(cb, line, std::back_inserter(intersection)); -} - -void example_clip_linestring2() -{ - typedef boost::geometry::model::d2::point_xy P; - std::vector

vector_in; - boost::geometry::read_wkt

("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", - std::back_inserter(vector_in)); - - boost::geometry::model::box

cb(P(1.5, 1.5), P(4.5, 2.5)); - typedef std::vector > VV; - VV vector_out; - boost::geometry::intersection_inserter >(cb, vector_in, std::back_inserter(vector_out)); - - std::cout << "Clipped vector(s) " << std::endl; - for (VV::const_iterator it = vector_out.begin(); it != vector_out.end(); it++) - { - // TODO FIX THIS std::copy(it->begin(), it->end(), std::ostream_iterator

(std::cout, " ")); - std::cout << std::endl; - } -} - - - - - -void example_intersection_polygon1() -{ - typedef boost::geometry::model::d2::point_xy P; - typedef std::vector > PV; - - boost::geometry::model::box

cb(P(1.5, 1.5), P(4.5, 2.5)); - boost::geometry::model::polygon

poly; - boost::geometry::read_wkt("POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)" - ",(4 2,4.2 1.4,4.8 1.9,4.4 2.2,4 2))", poly); - - PV v; - boost::geometry::intersection_inserter >(cb, poly, std::back_inserter(v)); - - std::cout << "Clipped polygon(s) " << std::endl; - for (PV::const_iterator it = v.begin(); it != v.end(); it++) - { - std::cout << boost::geometry::dsv(*it) << std::endl; - } -} - -void example_simplify_linestring1() -{ - //[simplify - //` Simplify a linestring - boost::geometry::model::linestring > line, simplified; - boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line); - boost::geometry::simplify(line, simplified, 0.5); /*< Simplify it, using distance of 0.5 units >*/ - std::cout - << " original line: " << boost::geometry::dsv(line) << std::endl - << "simplified line: " << boost::geometry::dsv(simplified) << std::endl; - //] -} - -void example_simplify_linestring2() -{ - //[simplify_inserter - //` Simplify a linestring using an output iterator - typedef boost::geometry::model::d2::point_xy P; - typedef boost::geometry::model::linestring

L; - L line; - - boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line); - - typedef boost::geometry::strategy::distance::projected_point DS; - typedef boost::geometry::strategy::simplify::douglas_peucker simplification; - // TODO FIX THIS boost::geometry::simplify_inserter(line, std::ostream_iterator

(std::cout, "\n"), 0.5, simplification()); - //] -} - - - -void example_within() -{ - boost::geometry::model::polygon > poly; - boost::geometry::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly); - boost::geometry::model::d2::point_xy point(3, 3); - std::cout << "Point is " - << (boost::geometry::within(point, poly) ? "IN" : "NOT in") - << " polygon" - << std::endl; -} - -/* -void example_within_strategy() -{ - // TO BE UPDATED/FINISHED - typedef boost::geometry::model::d2::point_xy P; - typedef boost::geometry::model::polygon

POLY; - P p; - std::cout << within(p, poly, strategy::within::cross_count

) << std::endl; -} -*/ - -void example_length_linestring() -{ - //[length - //` The following simple example shows the calculation of the length of a linestring containing three points - using namespace boost::geometry; - model::linestring > line; - read_wkt("linestring(0 0,1 1,4 8,3 2)", line); - std::cout << "linestring length is " - << length(line) - << " units" << std::endl; - //] - - /* - Extension, other coordinate system: - // Linestring in latlong, filled with - // explicit degree-minute-second values - typedef point_ll > LL; - linestring line_ll; - line_ll.push_back(LL( - latitude(dms(52, 22, 23)), - longitude(dms(4, 53, 32)))); - line_ll.push_back(LL( - latitude(dms(51, 55, 51)), - longitude(dms(4, 28, 45)))); - line_ll.push_back(LL( - latitude(dms(52, 4, 48)), - longitude(dms(4, 18, 0)))); - std::cout << "linestring length is " - << length(line_ll) / 1000 - << " kilometers " << std::endl; - */ -} - -void example_length_linestring_iterators2() -{ - std::vector > line; - boost::geometry::read_wkt >("linestring(0 0,1 1,4 8,3 2)", std::back_inserter(line)); - std::cout << "linestring length is " - << boost::geometry::length(line) - << " units" << std::endl; -} - -void example_length_linestring_iterators3() -{ - /* - Extension, other coordinate system: - using namespace boost::geometry; - typedef point_ll > LL; - std::deque line; - boost::geometry::read_wkt("linestring(0 51,1 51,2 52)", std::back_inserter(line)); - std::cout << "linestring length is " - << 0.001 * boost::geometry::length(line, boost::geometry::strategy::distance::vincenty()) - << " kilometers" << std::endl; - */ -} - - -void example_length_linestring_strategy() -{ - //[length_strategy - //`The following example shows the length measured over a sphere, expressed in kilometers. To do that the radius of the sphere must be specified in the constructor of the strategy. - - using namespace boost::geometry; - typedef model::point > P; - model::linestring

line; - line.push_back(P(2, 41)); - line.push_back(P(2, 48)); - line.push_back(P(5, 52)); - double const mean_radius = 6371.0; /*< [@http://en.wikipedia.org/wiki/Earth_radius Wiki] >*/ - std::cout << "length is " - << length(line, strategy::distance::haversine

(mean_radius) ) - << " kilometers " << std::endl; - //] -} - - -void example_envelope_linestring() -{ - boost::geometry::model::linestring > line; - boost::geometry::read_wkt("linestring(0 0,1 1,4 8,3 2)", line); - boost::geometry::model::box > box; - boost::geometry::envelope(line, box); - - std::cout << "envelope is " << boost::geometry::dsv(box) << std::endl; -} - -void example_envelope_polygon() -{ - /* - Extension, other coordinate system: - using namespace boost::geometry; - typedef model::point_ll > LL; - - // Wrangel island, 180 meridian crossing island above Siberia. - model::polygon wrangel; - wrangel.outer().push_back(LL(latitude<>(dms(70, 47, 7)), longitude<>(dms(178, 47, 9)))); - wrangel.outer().push_back(LL(latitude<>(dms(71, 14, 0)), longitude<>(dms(177, 28, 33)))); - wrangel.outer().push_back(LL(latitude<>(dms(71, 34, 24)), longitude<>(dms(179, 44, 37)))); - // Close it - wrangel.outer().push_back(wrangel.outer().front()); - - boost::geometry::model::box box; - boost::geometry::envelope(wrangel, box); - - dms minlat(box.min_corner().lat()); - dms minlon(box.min_corner().lon()); - - dms maxlat(box.max_corner().lat()); - dms maxlon(box.max_corner().lon()); - - std::cout << wrangel << std::endl; - std::cout << "min: " << minlat.get_dms() << " , " << minlon.get_dms() << std::endl; - std::cout << "max: " << maxlat.get_dms() << " , " << maxlon.get_dms() << std::endl; - */ -} - - -void example_dms() -{ - /* - Extension, other coordinate system: - // Construction with degree/minute/seconds - boost::geometry::dms d1(4, 53, 32.5); - - // Explicit conversion to double. - std::cout << d1.as_value() << std::endl; - - // Conversion to string, with optional strings - std::cout << d1.get_dms(" deg ", " min ", " sec") << std::endl; - - // Combination with latitude/longitude and cardinal directions - { - using namespace boost::geometry; - point_ll > canberra( - latitude<>(dms(35, 18, 27)), - longitude<>(dms(149, 7, 27.9))); - std::cout << canberra << std::endl; - } - */ -} - -void example_point_ll_construct() -{ - /* - Extension, other coordinate system: - using namespace boost::geometry; - typedef point_ll > ll; - - // Constructions in both orders possible - ll juneau( - latitude<>(dms(58, 21, 5)), - longitude<>(dms(134, 30, 42))); - ll wladiwostok( - longitude<>(dms(131, 54)), - latitude<>(dms(43, 8)) - ); - */ -} - - - -int main(void) -{ - - example_centroid_polygon(); - - example_intersection_linestring(); - example_intersects_linestring(); - example_intersection_segment(); - example_intersection_inserter_segment(); - example_intersects_segment(); - - - example_distance_point_point(); - example_distance_point_point_strategy(); - - example_from_wkt_point(); - example_from_wkt_output_iterator(); - example_from_wkt_linestring(); - example_from_wkt_polygon(); - - example_as_wkt_point(); - - example_clip_linestring1(); - example_clip_linestring2(); - example_intersection_polygon1(); - - example_simplify_linestring1(); - example_simplify_linestring2(); - - example_length_linestring(); - example_length_linestring_iterators2(); - example_length_linestring_iterators3(); - example_length_linestring_strategy(); - - example_envelope_linestring(); - example_envelope_polygon(); - - example_within(); - - example_point_ll_convert(); - example_point_ll_construct(); - example_dms(); - - - return 0; -} diff --git a/doc/snippets/qbk_1.vcproj b/doc/snippets/qbk_1.vcproj deleted file mode 100644 index 7b46fe01c..000000000 --- a/doc/snippets/qbk_1.vcproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/snippets/qbk_2.vcproj b/doc/snippets/qbk_2.vcproj deleted file mode 100644 index 585c73feb..000000000 --- a/doc/snippets/qbk_2.vcproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/snippets/qbk_3.cpp b/doc/snippets/qbk_3.cpp deleted file mode 100644 index 50d3a143c..000000000 --- a/doc/snippets/qbk_3.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands -// Copyright Bruno Lalande 2008, 2009 -// 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) -// -// Quickbook Examples, for e.g. email formal review - -#include - -#include -#include -#include -#include - - - -void example_distance() -{ - int a[2] = {1,2}; - int b[2] = {3,4}; - double d = boost::geometry::distance(a, b); - std::cout << d << std::endl; -} - -void example_length1() -{ - std::vector > line; - line.push_back(boost::make_tuple(1, 2, 3)); - line.push_back(boost::make_tuple(4, 5, 6)); - line.push_back(boost::make_tuple(7, 8, 9)); - double length = boost::geometry::length(line); - std::cout << length << std::endl; -} - -void example_length2() -{ - std::vector > line; - line.push_back(boost::make_tuple(1.1, 2.2)); - line.push_back(boost::make_tuple(3.3, 4.4)); - line.push_back(boost::make_tuple(5.5, 6.6)); - std::cout << boost::geometry::length( - std::make_pair(boost::begin(line), boost::end(line) + -1) - ) - << std::endl; -} - -void example_less() -{ - typedef boost::tuple P; - std::vector

line; - line.push_back(boost::make_tuple(8.1, 1.9)); - line.push_back(boost::make_tuple(4.2, 7.5)); - line.push_back(boost::make_tuple(2.3, 3.6)); - std::sort(line.begin(), line.end(), boost::geometry::less

()); - - // Display ordered points - BOOST_FOREACH(P const& p, line) - { - std::cout << boost::geometry::dsv(p) << std::endl; - } -} - - - -int main(void) -{ - example_distance(); - example_length1(); - example_length2(); - example_less(); - return 0; -} diff --git a/doc/snippets/qbk_3.vcproj b/doc/snippets/qbk_3.vcproj deleted file mode 100644 index ea534c93a..000000000 --- a/doc/snippets/qbk_3.vcproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/snippets/qbk_4.cpp b/doc/snippets/qbk_4.cpp deleted file mode 100644 index d8f0374de..000000000 --- a/doc/snippets/qbk_4.cpp +++ /dev/null @@ -1,326 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands -// Copyright Bruno Lalande 2008, 2009 -// 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) -// -// Quickbook Examples, for documentation images - -#include - -#include - -#include - -#include -#include - -#include - - -static const int wkt_countries_count = 1; -std::string wkt_countries[wkt_countries_count] = { - "MULTIPOLYGON(((3.369472 51.37461,3.31712 51.33633,3.338228 51.27769,3.476597 51.23314,3.474252 51.2988,3.553989 51.3246,3.720502 51.27535,3.753336 51.2261,3.887015 51.21203,3.983169 51.25659,4.123883 51.28942,4.222384 51.33163,4.311502 51.38792,4.442835 51.35274,4.38655 51.46297,4.541337 51.4747,4.517883 51.40903,4.67267 51.42075,4.759444 51.48642,4.848564 51.48642,4.771171 51.3973,4.968171 51.3973,5.022111 51.48642,5.099504 51.44186,5.06667 51.36447,5.132337 51.26597,5.20973 51.33163,5.219111 51.22141,5.448946 51.26597,5.514612 51.31991,5.592005 51.27769,5.570898 51.21203,5.711612 51.18858,5.800732 51.16747,5.878123 51.13464,5.800732 51.05724,5.767898 50.93763,5.645946 50.86024,5.678778 50.76174,5.821838 50.76174,6.025336 50.75425,6.403867 50.32674,6.13802 50.1329,5.73455 49.89968,5.816617 49.54663,5.477649 49.49361,4.856486 49.79186,4.877701 50.15532,4.148557 49.97853,4.206795 50.27324,3.694881 50.31094,3.139944 50.79072,2.795442 50.72651,2.546947 51.09281,3.369472 51.37461)))" - //"MULTIPOLYGON(((4.222384 51.33163,4.201276 51.38792,4.13561 51.36447,4.025384 51.40903,4.016003 51.48642,4.091051 51.43013,4.213003 51.42075,4.288051 51.46297,4.234109 51.4958,4.048835 51.52864,3.971442 51.58492,4.058217 51.58492,4.156717 51.58492,4.156717 51.65059,4.255217 51.61776,4.344337 51.63886,4.419384 51.6717,4.574171 51.68342,4.705504 51.70453,4.81573 51.72564,4.750063 51.73736,4.541337 51.71626,4.353717 51.72564,4.255217 51.75847,4.069943 51.83586,3.99255 51.95547,4.180169 52.04459,4.365444 52.18765,4.550717 52.45031,4.67267 52.71298,4.738337 52.94281,4.804003 52.94281,4.881396 52.86542,4.968171 52.89826,5.054944 52.90998,5.111231 52.84431,5.111231 52.77161,5.162826 52.73643,5.228492 52.74582,5.287123 52.74112,5.287123 52.69188,5.233183 52.64497,5.125301 52.61683,5.071361 52.64262,5.015075 52.61214,5.080742 52.49018,5.01742 52.44328,5.080742 52.42921,4.956444 52.35885,5.031492 52.33071,5.120612 52.31898,5.183933 52.30257,5.244909 52.30491,5.341063 52.26739,5.399694 52.23924,5.523993 52.25566,5.566207 52.3096,5.676433 52.36354,5.793696 52.41279,5.861708 52.47611,5.859363 52.53709,5.796041 52.57227,5.849981 52.59806,5.645946 52.60979,5.58966 52.64262,5.592005 52.75989,5.6436 52.80914,5.716303 52.8279,5.645946 52.84431,5.561516 52.82555,5.484123 52.84197,5.413766 52.83025,5.348099 52.87715,5.404385 52.89826,5.40673 52.9991,5.383279 53.07415,5.448946 53.21721,5.580279 53.30398,5.845291 53.36965,5.976624 53.38138,6.140792 53.39076,6.183005 53.32509,6.206459 53.39076,6.370625 53.40248,6.764627 53.47988,6.851399 53.40248,6.928792 53.33682,7.048399 53.28288,7.158627 53.25004,7.179733 53.17265,7.137519 53.12809,7.179733 52.98738,7.048399 52.87715,7.060126 52.62386,6.973351 52.63559,6.698958 52.64732,6.720066 52.56992,6.675507 52.52536,6.7529 52.47142,6.872507 52.42686,6.994459 52.48315,7.060126 52.38465,7.015567 52.29553,7.060126 52.25331,6.884233 52.13136,6.731792 52.09853,6.687233 52.02114,6.80684 52.01176,6.851399 51.94609,6.797459 51.90153,6.666125 51.90153,6.424565 51.83586,6.281507 51.85697,6.140792 51.90153,6.150171 51.83586,5.953171 51.83586,5.953171 51.74909,6.018838 51.70453,6.117339 51.6928,6.107958 51.61776,6.227565 51.51925,6.239291 51.42075,6.194732 51.34336,6.084505 51.25424,6.096231 51.1792,6.173625 51.21203,6.194732 51.14636,5.986005 51.03613,5.943792 51.08069,5.878123 51.03613,5.899231 50.97047,6.030564 50.97047,6.030564 50.9048,6.107958 50.9048,6.096231 50.83913,6.030564 50.82741,6.025336 50.75425,5.821838 50.76174,5.678778 50.76174,5.645946 50.86024,5.767898 50.93763,5.800732 51.05724,5.878123 51.13464,5.800732 51.16747,5.711612 51.18858,5.570898 51.21203,5.592005 51.27769,5.514612 51.31991,5.448946 51.26597,5.219111 51.22141,5.20973 51.33163,5.132337 51.26597,5.06667 51.36447,5.099504 51.44186,5.022111 51.48642,4.968171 51.3973,4.771171 51.3973,4.848564 51.48642,4.759444 51.48642,4.67267 51.42075,4.517883 51.40903,4.541337 51.4747,4.38655 51.46297,4.442835 51.35274,4.311502 51.38792,4.222384 51.33163)),((5.455981 52.55116,5.514612 52.5582,5.573243 52.59103,5.634219 52.59103,5.73272 52.57462,5.791351 52.56758,5.854672 52.52771,5.8406 52.46908,5.756171 52.41279,5.674088 52.39403,5.573243 52.37058,5.540409 52.31664,5.507576 52.26504,5.397349 52.25097,5.294159 52.30725,5.198003 52.33305,5.134682 52.32836,5.153444 52.39403,5.411421 52.49488,5.455981 52.55116)),((4.222384 51.33163,4.123883 51.28942,3.983169 51.25659,3.887015 51.21203,3.753336 51.2261,3.720502 51.27535,3.553989 51.3246,3.474252 51.2988,3.476597 51.23314,3.338228 51.27769,3.31712 51.33633,3.369472 51.37461,3.467216 51.41137,3.600895 51.37854,3.718157 51.34336,3.840109 51.34805,3.924538 51.36447,3.952681 51.41607,4.011312 51.39496,4.072289 51.35509,4.128574 51.32225,4.222384 51.33163)),((3.40155 51.54036,3.500049 51.58258,3.56337 51.59665,3.619656 51.57554,3.659526 51.5216,3.720502 51.51456,3.781478 51.54036,3.887015 51.54271,3.971442 51.52864,4.016003 51.50753,3.999586 51.43717,3.9433 51.46062,3.879979 51.44186,3.854181 51.38792,3.753336 51.39027,3.65249 51.46062,3.556334 51.44421,3.483632 51.48173,3.429692 51.51456,3.40155 51.54036)),((3.973788 51.84524,4.037109 51.81241,4.123883 51.7913,4.196586 51.76081,4.269289 51.71391,4.360754 51.69515,4.313848 51.65293,4.248181 51.65293,4.177824 51.67873,4.119193 51.69984,4.044145 51.71391,4.023039 51.7913,3.933919 51.80537,3.870598 51.77958,3.847145 51.83821,3.973788 51.84524)),((3.793204 51.74674,3.933919 51.73502,3.985514 51.68577,4.076979 51.667,4.116848 51.65293,4.023039 51.62714,3.931574 51.6201,3.865907 51.6459,3.826037 51.6928,3.76037 51.69984,3.692358 51.66935,3.647799 51.70922,3.713466 51.73502,3.793204 51.74674)),((4.806348 53.12574,4.879051 53.175,4.92361 53.13278,4.91423 53.0718,4.86967 53.0249,4.801658 52.99676,4.747718 52.97096,4.72192 53.0249,4.754754 53.0765,4.806348 53.12574)),((5.216766 53.39545,5.507576 53.4447,5.559171 53.43766,5.493505 53.41655,5.460672 53.39545,5.387969 53.3931,5.336373 53.37669,5.240219 53.36027,5.183933 53.33682,5.165171 53.36027,5.216766 53.39545)),((3.596204 51.60134,3.720502 51.60134,3.840109 51.61306,3.877634 51.55443,3.774442 51.56147,3.718157 51.52864,3.645454 51.56147,3.596204 51.60134)),((5.636564 53.46346,5.728029 53.44939,5.852327 53.46112,5.941446 53.45877,5.88985 53.44001,5.800732 53.43063,5.716303 53.43063,5.674088 53.41421,5.622492 53.42828,5.60373 53.45408,5.636564 53.46346)),((5.008039 53.28757,5.050254 53.30398,5.094813 53.31102,5.120612 53.28991,5.001003 53.2688,4.982243 53.24066,4.932992 53.20548,4.862634 53.19845,4.890778 53.22659,4.970516 53.2688,5.008039 53.28757)),((6.138446 53.49395,6.27447 53.50567,6.307303 53.49629,6.236946 53.46815,6.154862 53.46581,6.12672 53.44939,6.100922 53.46581,6.138446 53.49395)),((6.419876 53.54085,6.483197 53.51974,6.42691 53.51506,6.396423 53.53382,6.419876 53.54085)))", -}; - -static const int wkt_cities_count = 1; -std::string wkt_cities[wkt_cities_count] = { - "MULTIPOINT(( -71.03 42.37), (-87.65 41.90), (-95.35 29.97), (-118.40 33.93), (-80.28 25.82), (-73.98 40.77), (-112.02 33.43), ( -77.04 38.85))" -}; - - - -// Read an ASCII file containing WKT's, fill a vector of tuples -// The tuples consist of at least <0> a geometry and <1> an identifying string -template -void read_wkt(std::string const& filename, std::vector& tuples, Box& box) -{ - std::ifstream cpp_file(filename.c_str()); - if (cpp_file.is_open()) - { - while (! cpp_file.eof() ) - { - std::string line; - std::getline(cpp_file, line); - Geometry geometry; - boost::trim(line); - if (! line.empty() && ! boost::starts_with(line, "#")) - { - std::string name; - - // Split at ';', if any - std::string::size_type pos = line.find(";"); - if (pos != std::string::npos) - { - name = line.substr(pos + 1); - line.erase(pos); - - boost::trim(line); - boost::trim(name); - } - - Geometry geometry; - boost::geometry::read_wkt(line, geometry); - - Tuple tuple(geometry, name); - - tuples.push_back(tuple); - boost::geometry::combine(box, boost::geometry::make_envelope(geometry)); - } - } - } -} - - - - -void svg_simplify_road() -{ - static const int n = 1; - std::string wkt[n] = { - "LINESTRING(-122.191 47.9758,-122.181 47.9958,-122.177 48.0022,-122.171 48.0081,-122.174 48.0402,-122.178 48.0718,-122.181 48.1036,-122.183 48.1361,-122.189 48.143,-122.206 48.205,-122.231 48.2515,-122.261 48.2977,-122.291 48.3592,-122.297 48.4234,-122.299 48.5183,-122.324 48.6237,-122.41 48.7339,-122.407 48.7538,-122.4 48.7749,-122.399 48.793,-122.423 48.8044,-122.45 48.8124,-122.481 48.8304,-122.517 48.8718,-122.521 48.8813,-122.523 48.901,-122.527 48.9105,-122.543 48.919,-122.551 48.9305,-122.561 48.9411,-122.585 48.9471,-122.612 48.9669,-122.638 48.9849,-122.661 49.0022)", - //"LINESTRING(-122.191 47.9758,-122.204 47.9372,-122.221 47.9019,-122.242 47.8674,-122.266 47.8312)", - //"LINESTRING(-122.176 47.5801,-122.182 47.5932,-122.185 47.6067,-122.187 47.6202,-122.187 47.6338,-122.187 47.6691,-122.182 47.7052,-122.181 47.7412,-122.192 47.776,-122.2 47.7864,-122.212 47.7945,-122.223 47.8027,-122.232 47.8132,-122.241 47.8168,-122.25 47.821,-122.259 47.8258,-122.266 47.8312)", - //"LINESTRING(-122.193 47.5075,-122.192 47.5108,-122.192 47.5147,-122.192 47.5184,-122.192 47.5224,-122.192 47.5265,-122.192 47.5307,-122.192 47.5327,-122.191 47.5348,-122.19 47.5395,-122.189 47.5443,-122.188 47.549,-122.187 47.5538,-122.185 47.5584,-122.183 47.5609,-122.182 47.563,-122.18 47.5667,-122.179 47.5676,-122.178 47.5711,-122.177 47.5726,-122.177 47.5742,-122.177 47.5762,-122.176 47.5781,-122.176 47.5801)" - }; - - typedef boost::geometry::model::d2::point_xy point_type; - - std::ofstream svg("simplify_road.svg"); - boost::geometry::svg_mapper mapper(svg, 300, 300); - - boost::geometry::model::linestring original[n], simplified[n]; - - for (int i = 0; i < n; i++) - { - boost::geometry::read_wkt(wkt[i], original[i]); - boost::geometry::simplify(original[i], simplified[i], 0.03); - mapper.add(original[i]); - mapper.add(simplified[i]); - std::cout - << "original: " << boost::size(original[i]) - << " simplified: " << boost::size(simplified[i]) - << std::endl; - } - - - for (int i = 0; i < n; i++) - { - mapper.map(original[i], "opacity:0.8;stroke:rgb(0,0,255);stroke-width:3"); - mapper.map(simplified[i], "opacity:0.8;stroke:rgb(0,255,0);stroke-width:2"); - } - -} - - -void svg_simplify_country() -{ - - typedef boost::geometry::model::d2::point_xy point_type; - - std::ofstream svg("simplify_country.svg"); - boost::geometry::svg_mapper mapper(svg, 300, 300); - - boost::geometry::model::multi_polygon > original[wkt_countries_count] - , simplified[wkt_countries_count]; - - for (int i = 0; i < wkt_countries_count; i++) - { - boost::geometry::read_wkt(wkt_countries[i], original[i]); - boost::geometry::simplify(original[i], simplified[i], 0.1); - mapper.add(original[i]); - mapper.add(simplified[i]); - std::cout - << "original: " << boost::geometry::num_points(original[i]) - << " simplified: " << boost::geometry::num_points(simplified[i]) - << std::endl; - } - - - for (int i = 0; i < wkt_countries_count; i++) - { - mapper.map(original[i], "opacity:0.8;fill:none;stroke:rgb(0,0,255);stroke-width:3"); - mapper.map(simplified[i], "opacity:0.8;fill:none;stroke:rgb(0,255,0);stroke-width:2"); - } -} - -void svg_convex_hull_country() -{ - - typedef boost::geometry::model::d2::point_xy point_type; - - std::ofstream svg("convex_hull_country.svg"); - boost::geometry::svg_mapper mapper(svg, 300, 300); - - boost::geometry::model::multi_polygon > original[wkt_countries_count]; - boost::geometry::model::linear_ring hull[wkt_countries_count]; - - for (int i = 0; i < wkt_countries_count; i++) - { - boost::geometry::read_wkt(wkt_countries[i], original[i]); - boost::geometry::convex_hull_inserter(original[i], std::back_inserter(hull[i])); - mapper.add(original[i]); - mapper.add(hull[i]); - std::cout - << "original: " << boost::geometry::num_points(original[i]) - << " hull: " << boost::geometry::num_points(hull[i]) - << std::endl; - } - - - for (int i = 0; i < wkt_countries_count; i++) - { - mapper.map(original[i], "opacity:0.8;fill:rgb(255,255,0);stroke:rgb(0,0,0);stroke-width:3"); - mapper.map(hull[i], "opacity:0.8;fill:none;stroke:rgb(255,0,0);stroke-width:3"); - } - -} - - -void svg_convex_hull_cities() -{ - - typedef boost::geometry::model::d2::point_xy point_type; - - std::ofstream svg("convex_hull_cities.svg"); - boost::geometry::svg_mapper mapper(svg, 300, 300); - - boost::geometry::model::multi_point original[wkt_cities_count]; - - boost::geometry::model::linear_ring hull[wkt_cities_count]; - - for (int i = 0; i < wkt_cities_count; i++) - { - boost::geometry::read_wkt(wkt_cities[i], original[i]); - boost::geometry::convex_hull_inserter(original[i], std::back_inserter(hull[i])); - mapper.add(original[i]); - mapper.add(hull[i]); - std::cout - << "original: " << boost::geometry::num_points(original[i]) - << " hull: " << boost::geometry::num_points(hull[i]) - << std::endl; - } - - - for (int i = 0; i < wkt_cities_count; i++) - { - mapper.map(original[i], "fill:rgb(255,255,0);stroke:rgb(0,0,100);stroke-width:1", 3); - mapper.map(hull[i], "opacity:0.8;fill:none;stroke:rgb(255,0,0);stroke-width:3"); - } -} - -void svg_intersection_roads() -{ - // Read the road network - typedef boost::geometry::model::d2::point_xy point_type; - typedef boost::geometry::model::linestring line_type; - - typedef boost::tuple road_type; - - boost::geometry::model::box bbox; - boost::geometry::assign_inverse(bbox); - - std::vector roads; - read_wkt("../../../example/data/roads.wkt", roads, bbox); - - // intersect - boost::geometry::model::box clip; - std::vector intersected; - - boost::geometry::assign(clip, -100, 25, -90, 50); - for (size_t i = 0; i < roads.size(); i++) - { - boost::geometry::intersection_inserter(clip, roads[i].get<0>(), std::back_inserter(intersected)); - } - - // create map - std::ofstream svg("intersection_roads.svg"); - boost::geometry::svg_mapper mapper(svg, 500, 500); - - mapper.add(bbox); - - for (size_t i = 0; i < roads.size(); i++) - { - mapper.map(roads[i].get<0>(), "stroke:rgb(0,0,255);stroke-width:3"); - } - - for (size_t i = 0; i < intersected.size(); i++) - { - mapper.map(intersected[i], "stroke:rgb(0,255,0);stroke-width:2"); - } - - for (size_t i = 0; i < intersected.size(); i++) - { - mapper.map(clip, "fill:none;stroke:rgb(128,128,128);stroke-width:2"); - } -} - - -void svg_intersection_countries() -{ - // Read the road network - typedef boost::geometry::model::d2::point_xy point_type; - typedef boost::geometry::model::polygon poly_type; - typedef boost::geometry::model::multi_polygon mp_type; - - typedef boost::tuple country_type; - - boost::geometry::model::box bbox; - boost::geometry::assign_inverse(bbox); - - std::vector countries; - read_wkt("../../../example/data/world.wkt", countries, bbox); - - // intersect - boost::geometry::model::box clip; - std::vector intersected; - - boost::geometry::assign(clip, -100, -50, 100, 50); - for (size_t i = 0; i < countries.size(); i++) - { - mp_type const& mp = countries[i].get<0>(); - for (size_t j = 0; j < mp.size(); j++) - { - boost::geometry::intersection_inserter(clip, mp[j], std::back_inserter(intersected)); - } - } - - // create map - std::ofstream svg("intersection_countries.svg"); - boost::geometry::svg_mapper mapper(svg, 800, 800); - - mapper.add(bbox); - - for (size_t i = 0; i < countries.size(); i++) - { - mapper.map(countries[i].get<0>().front(), "fill:rgb(0,0,255);stroke-width:1"); - } - - for (size_t i = 0; i < intersected.size(); i++) - { - mapper.map(intersected[i], "fill:rgb(0,255,0);stroke-width:1"); - } - - for (size_t i = 0; i < intersected.size(); i++) - { - mapper.map(clip, "fill:none;stroke:rgb(128,128,128);stroke-width:2"); - } -} - - - - - -int main(void) -{ - svg_intersection_roads(); - svg_intersection_countries(); - svg_simplify_road(); - svg_simplify_country(); - svg_convex_hull_country(); - svg_convex_hull_cities(); - return 0; -} diff --git a/doc/snippets/qbk_4.vcproj b/doc/snippets/qbk_4.vcproj deleted file mode 100644 index 6b7880bfd..000000000 --- a/doc/snippets/qbk_4.vcproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/snippets/qbk_5.cpp b/doc/snippets/qbk_5.cpp deleted file mode 100644 index 841b15893..000000000 --- a/doc/snippets/qbk_5.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands -// Copyright Bruno Lalande 2008, 2009 -// 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) -// -// Quickbook Examples, for Geometry Concepts - -#include -#include -#include -#include - - - -struct legacy_point1 -{ - double x, y; -}; - -// adapt legacy_point1 -namespace boost { namespace geometry { namespace traits -{ - template <> struct tag { typedef point_tag type; }; - template <> struct coordinate_type { typedef double type; }; - template <> struct coordinate_system { typedef cs::cartesian type; }; - template <> struct dimension: boost::mpl::int_<2> {}; - template <> struct access - { - static double get(legacy_point1 const& p) { return p.x; } - static void set(legacy_point1& p, double const& value) { p.x = value; } - }; - template <> struct access - { - static double get(legacy_point1 const& p) { return p.y; } - static void set(legacy_point1& p, double const& value) { p.y = value; } - }; -}}} // namespace boost::geometry::traits -// end adaptation - -namespace example_legacy_point1 -{ - // The first way to check a concept at compile time: checking if the input is parameter - // or return type is OK. - template - BOOST_CONCEPT_REQUIRES(((boost::geometry::concept::Point

)), (void)) - test1(P& p) - { - } - - // The second way to check a concept at compile time: checking if the provided type, - // inside the function, if OK - template - void test2(P& p) - { - BOOST_CONCEPT_ASSERT((boost::geometry::concept::Point

)); - } - - - void example() - { - legacy_point1 p; - test1(p); - test2(p); - } -} - -// leave comment below for (strange behaviour of) doxygen -class legacy_point2 -{ -public : - double x() const; - double y() const; -}; - -// adapt legacy_point2 -BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(legacy_point2, double, boost::geometry::cs::cartesian, x(), y() ) -// end adaptation - - -double legacy_point2::x() const { return 0; } -double legacy_point2::y() const { return 0; } - -namespace example_legacy_point2 -{ - // test it using boost concept requires - - template - BOOST_CONCEPT_REQUIRES(((boost::geometry::concept::ConstPoint

)), (double)) - test3(P& p) - { - return boost::geometry::get<0>(p); - } - - void example() - { - legacy_point2 p; - test3(p); - } -} - - -template -struct custom_linestring1 : std::deque

-{ - int id; -}; - -// adapt custom_linestring1 -namespace boost { namespace geometry { namespace traits -{ - template - struct tag< custom_linestring1

> { typedef linestring_tag type; }; -}}} // namespace boost::geometry::traits -// end adaptation - -namespace example_custom_linestring1 -{ - void example() - { - typedef custom_linestring1 L; - BOOST_CONCEPT_ASSERT((boost::geometry::concept::Linestring)); - - } -} - -int main(void) -{ - example_legacy_point1::example(); - example_legacy_point2::example(); - example_custom_linestring1::example(); - - return 0; -} diff --git a/doc/snippets/qbk_5.vcproj b/doc/snippets/qbk_5.vcproj deleted file mode 100644 index 310e31550..000000000 --- a/doc/snippets/qbk_5.vcproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/snippets/qbk_examples.sln b/doc/snippets/qbk_examples.sln deleted file mode 100644 index 1d4124f97..000000000 --- a/doc/snippets/qbk_examples.sln +++ /dev/null @@ -1,43 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qbk_1", "qbk_1.vcproj", "{861F130D-2849-4B50-B240-049DBD9D3F18}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qbk_2", "qbk_2.vcproj", "{6CF6A521-57E0-4DA4-9D17-ED5D29E4208C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qbk_3", "qbk_3.vcproj", "{45D4139F-BC5B-4D48-BAB8-9901C53ECCC9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qbk_4", "qbk_4.vcproj", "{CBEDAEC7-EC87-4F91-9C45-F9505A052A44}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qbk_5", "qbk_5.vcproj", "{0CDE9E15-C937-4D05-B9BF-A2D96B8EAD33}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {861F130D-2849-4B50-B240-049DBD9D3F18}.Debug|Win32.ActiveCfg = Debug|Win32 - {861F130D-2849-4B50-B240-049DBD9D3F18}.Debug|Win32.Build.0 = Debug|Win32 - {861F130D-2849-4B50-B240-049DBD9D3F18}.Release|Win32.ActiveCfg = Release|Win32 - {861F130D-2849-4B50-B240-049DBD9D3F18}.Release|Win32.Build.0 = Release|Win32 - {6CF6A521-57E0-4DA4-9D17-ED5D29E4208C}.Debug|Win32.ActiveCfg = Debug|Win32 - {6CF6A521-57E0-4DA4-9D17-ED5D29E4208C}.Debug|Win32.Build.0 = Debug|Win32 - {6CF6A521-57E0-4DA4-9D17-ED5D29E4208C}.Release|Win32.ActiveCfg = Release|Win32 - {6CF6A521-57E0-4DA4-9D17-ED5D29E4208C}.Release|Win32.Build.0 = Release|Win32 - {45D4139F-BC5B-4D48-BAB8-9901C53ECCC9}.Debug|Win32.ActiveCfg = Debug|Win32 - {45D4139F-BC5B-4D48-BAB8-9901C53ECCC9}.Debug|Win32.Build.0 = Debug|Win32 - {45D4139F-BC5B-4D48-BAB8-9901C53ECCC9}.Release|Win32.ActiveCfg = Release|Win32 - {45D4139F-BC5B-4D48-BAB8-9901C53ECCC9}.Release|Win32.Build.0 = Release|Win32 - {CBEDAEC7-EC87-4F91-9C45-F9505A052A44}.Debug|Win32.ActiveCfg = Debug|Win32 - {CBEDAEC7-EC87-4F91-9C45-F9505A052A44}.Debug|Win32.Build.0 = Debug|Win32 - {CBEDAEC7-EC87-4F91-9C45-F9505A052A44}.Release|Win32.ActiveCfg = Release|Win32 - {CBEDAEC7-EC87-4F91-9C45-F9505A052A44}.Release|Win32.Build.0 = Release|Win32 - {0CDE9E15-C937-4D05-B9BF-A2D96B8EAD33}.Debug|Win32.ActiveCfg = Debug|Win32 - {0CDE9E15-C937-4D05-B9BF-A2D96B8EAD33}.Debug|Win32.Build.0 = Debug|Win32 - {0CDE9E15-C937-4D05-B9BF-A2D96B8EAD33}.Release|Win32.ActiveCfg = Release|Win32 - {0CDE9E15-C937-4D05-B9BF-A2D96B8EAD33}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/doc/src/examples/algorithms/Jamfile.v2 b/doc/src/examples/algorithms/Jamfile.v2 index 31845c0b7..54ecd5c77 100644 --- a/doc/src/examples/algorithms/Jamfile.v2 +++ b/doc/src/examples/algorithms/Jamfile.v2 @@ -13,3 +13,14 @@ project boost-geometry-doc-example-algorithms exe area : area.cpp ; exe area_with_strategy : area_with_strategy.cpp ; + +exe intersection_ls_ls_point : intersection_ls_ls_point.cpp ; +exe intersection_segment : intersection_segment.cpp ; + +exe intersects_linestring : intersects_linestring.cpp ; + +exe length : length.cpp ; +exe length_with_strategy : length_with_strategy.cpp ; + +exe simplify : length.cpp ; +exe simplify_inserter : simplify_inserter.cpp ; diff --git a/doc/src/examples/algorithms/intersection_ls_ls_point.cpp b/doc/src/examples/algorithms/intersection_ls_ls_point.cpp new file mode 100644 index 000000000..f422be239 --- /dev/null +++ b/doc/src/examples/algorithms/intersection_ls_ls_point.cpp @@ -0,0 +1,52 @@ +// 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) +// +// Quickbook Example + +//[intersection_ls_ls_point +//` Calculate the intersection of two linestrings + +#include +#include + +#include +#include +#include /*< Adapts std::vector to linestring concept >*/ + +#include + + +int main() +{ + typedef boost::geometry::model::d2::point_xy P; + std::vector

line1, line2; + boost::geometry::read_wkt("linestring(1 1,2 2,3 1)", line1); + boost::geometry::read_wkt("linestring(1 2,2 1,3 2)", line2); + + std::deque

intersection_points; + boost::geometry::intersection(line1, line2, intersection_points); + + BOOST_FOREACH(P const& p, intersection_points) + { + std::cout << " " << boost::geometry::wkt(p); + } + std::cout << std::endl; + + return 0; +} + +//] + + +//[intersection_ls_ls_point_output +/*` +Output: +[pre + POINT(1.5 1.5) POINT(2.5 1.5) +] +*/ +//] diff --git a/doc/src/examples/algorithms/intersection_segment.cpp b/doc/src/examples/algorithms/intersection_segment.cpp new file mode 100644 index 000000000..a473b99bf --- /dev/null +++ b/doc/src/examples/algorithms/intersection_segment.cpp @@ -0,0 +1,51 @@ +// 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) +// +// Quickbook Example + +//[intersection_segment +//` Calculate the intersection point (or points) of two segments + +#include + +#include +#include +#include /*< Adapts std::vector to linestring concept >*/ + +#include + + +int main() +{ + typedef boost::geometry::model::d2::point_xy P; + boost::geometry::model::segment

segment1, segment2; + boost::geometry::read_wkt("linestring(1 1,2 2)", segment1); + boost::geometry::read_wkt("linestring(2 1,1 2)", segment2); + + std::vector

intersections; + boost::geometry::intersection(segment1, segment2, intersections); + + BOOST_FOREACH(P const& p, intersections) + { + std::cout << " " << boost::geometry::wkt(p); + } + std::cout << std::endl; + + return 0; +} + +//] + + +//[intersection_segment_output +/*` +Output: +[pre + POINT(1.5 1.5) +] +*/ +//] diff --git a/doc/src/examples/algorithms/intersects_linestring.cpp b/doc/src/examples/algorithms/intersects_linestring.cpp new file mode 100644 index 000000000..5cefad0fc --- /dev/null +++ b/doc/src/examples/algorithms/intersects_linestring.cpp @@ -0,0 +1,44 @@ +// 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) +// +// Quickbook Example + +//[intersects_linestring +//` Check if two linestrings intersect each other + +#include + +#include +#include + +int main() +{ + // Calculate the intersects of a cartesian polygon + typedef boost::geometry::model::d2::point_xy P; + boost::geometry::model::linestring

line1, line2; + + boost::geometry::read_wkt("linestring(1 1,2 2,3 3)", line1); + boost::geometry::read_wkt("linestring(2 1,1 2,4 0)", line2); + + bool b = boost::geometry::intersects(line1, line2); + + std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl; + + return 0; +} + +//] + + +//[intersects_linestring_output +/*` +Output: +[pre +Intersects: YES +] +*/ +//] diff --git a/doc/src/examples/algorithms/length.cpp b/doc/src/examples/algorithms/length.cpp new file mode 100644 index 000000000..9d6e51183 --- /dev/null +++ b/doc/src/examples/algorithms/length.cpp @@ -0,0 +1,40 @@ +// 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) +// +// Quickbook Example + +//[length + //` The following simple example shows the calculation of the length of a linestring containing three points + +#include +#include +#include + + +int main() +{ + using namespace boost::geometry; + model::linestring > line; + read_wkt("linestring(0 0,1 1,4 8,3 2)", line); + std::cout << "linestring length is " + << length(line) + << " units" << std::endl; + + return 0; +} + +//] + + +//[length_output +/*` +Output: +[pre +linestring length is 15.1127 units +] +*/ +//] diff --git a/doc/src/examples/algorithms/length_with_strategy.cpp b/doc/src/examples/algorithms/length_with_strategy.cpp new file mode 100644 index 000000000..648e65860 --- /dev/null +++ b/doc/src/examples/algorithms/length_with_strategy.cpp @@ -0,0 +1,42 @@ +// 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) +// +// Quickbook Example + +//[length_with_strategy +//`The following example shows the length measured over a sphere, expressed in kilometers. To do that the radius of the sphere must be specified in the constructor of the strategy. + +#include +#include + +int main() +{ + using namespace boost::geometry; + typedef model::point > P; + model::linestring

line; + line.push_back(P(2, 41)); + line.push_back(P(2, 48)); + line.push_back(P(5, 52)); + double const mean_radius = 6371.0; /*< [@http://en.wikipedia.org/wiki/Earth_radius Wiki] >*/ + std::cout << "length is " + << length(line, strategy::distance::haversine

(mean_radius) ) + << " kilometers " << std::endl; + + return 0; +} + +//] + + +//[length_with_strategy_output +/*` +Output: +[pre +length is 1272.03 kilometers +] +*/ +//] diff --git a/doc/src/examples/algorithms/simplify.cpp b/doc/src/examples/algorithms/simplify.cpp new file mode 100644 index 000000000..77803e724 --- /dev/null +++ b/doc/src/examples/algorithms/simplify.cpp @@ -0,0 +1,51 @@ +// 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) +// +// Quickbook Example + +//[simplify +//` Example showing how to simplify a linestring + +#include +#include + +/*< For this example we use Boost.Assign to add points >*/ +#include + +using namespace boost::assign; + + +int main() +{ + typedef boost::geometry::model::d2::point_xy xy; + + boost::geometry::model::linestring line; + line += xy(1.1, 1.1), xy(2.5, 2.1), xy(3.1, 3.1), xy(4.9, 1.1), xy(3.1, 1.9); /*< With Boost.Assign >*/ + + // Simplify it, using distance of 0.5 units + boost::geometry::model::linestring simplified; + boost::geometry::simplify(line, simplified, 0.5); + std::cout + << " original: " << boost::geometry::dsv(line) << std::endl + << "simplified: " << boost::geometry::dsv(simplified) << std::endl; + + + return 0; +} + +//] + + +//[simplify_output +/*` +Output: +[pre + original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +] +*/ +//] diff --git a/doc/src/examples/algorithms/simplify_inserter.cpp b/doc/src/examples/algorithms/simplify_inserter.cpp new file mode 100644 index 000000000..8687518c8 --- /dev/null +++ b/doc/src/examples/algorithms/simplify_inserter.cpp @@ -0,0 +1,49 @@ +// 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) +// +// Quickbook Example + +//[simplify_inserter +//` Simplify a linestring using a back inserter + +#include +#include + +int main() +{ + typedef boost::geometry::model::d2::point_xy P; + typedef boost::geometry::model::linestring

L; + + L line; + line.push_back(P(1.1, 1.1)); + line.push_back(P(2.5, 2.1)); + line.push_back(P(3.1, 3.1)); + line.push_back(P(4.9, 1.1)); + line.push_back(P(3.1, 1.9)); + + L simplified; + boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5); + + std::cout + << " original: " << boost::geometry::dsv(line) << std::endl + << "simplified: " << boost::geometry::dsv(simplified) << std::endl; + + return 0; +} + +//] + + +//[simplify_inserter_output +/*` +Output: +[pre + original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) +] +*/ +//] diff --git a/doc/snippets/qbk_2.cpp b/doc/src/examples/quick_start.cpp similarity index 98% rename from doc/snippets/qbk_2.cpp rename to doc/src/examples/quick_start.cpp index 63cb9047c..dfa0cfba7 100644 --- a/doc/snippets/qbk_2.cpp +++ b/doc/src/examples/quick_start.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp index c4d8a2143..db2417bd7 100644 --- a/include/boost/geometry/algorithms/intersection.hpp +++ b/include/boost/geometry/algorithms/intersection.hpp @@ -186,8 +186,10 @@ struct intersection_reversed \param geometry_out The output geometry, either a multi_point, multi_polygon, multi_linestring, or a box (for intersection of two boxes) -\qbk{example,intersection_linestring} +\qbk{example,intersection_ls_ls_point} +\qbk{example,intersection_ls_ls_point_output} \qbk{example,intersection_segment} +\qbk{example,intersection_segment_output} */ template < diff --git a/include/boost/geometry/algorithms/intersects.hpp b/include/boost/geometry/algorithms/intersects.hpp index 177c1ba87..ceb4a4b5f 100644 --- a/include/boost/geometry/algorithms/intersects.hpp +++ b/include/boost/geometry/algorithms/intersects.hpp @@ -82,7 +82,7 @@ inline bool intersects(Geometry const& geometry) \qbk{distinguish,two geometries} \qbk{example,intersects_linestring} -\qbk{example,intersects_segment} +\qbk{example,intersects_linestring_output} */ template inline bool intersects(Geometry1 const& geometry1, Geometry2 const& geometry2) diff --git a/include/boost/geometry/algorithms/length.hpp b/include/boost/geometry/algorithms/length.hpp index ce24478d3..dd387959d 100644 --- a/include/boost/geometry/algorithms/length.hpp +++ b/include/boost/geometry/algorithms/length.hpp @@ -143,6 +143,7 @@ struct length \qbk{complexity,Linear} \qbk{compliance,__ogc__} \qbk{example,length} +\qbk{example,length_output} */ template inline typename length_result::type length( @@ -175,7 +176,8 @@ inline typename length_result::type length( \return \return_calc{length} \qbk{distinguish,with strategy} -\qbk{example,length_strategy} +\qbk{example,length_with_strategy} +\qbk{example,length_with_strategy_output} */ template inline typename length_result::type length( diff --git a/include/boost/geometry/algorithms/simplify.hpp b/include/boost/geometry/algorithms/simplify.hpp index 14a2b13f1..64799f6c6 100644 --- a/include/boost/geometry/algorithms/simplify.hpp +++ b/include/boost/geometry/algorithms/simplify.hpp @@ -286,13 +286,8 @@ inline void simplify(Geometry const& geometry, Geometry& out, \param max_distance distance (in units of input coordinates) of a vertex to other segments to be removed -\par Example: -Simplify can be used as following: -\dontinclude doxygen_1.cpp -\skip example_simplify_linestring1 -\line { -\until } - +\qbk{example,simplify} +\qbk{example,simplify_output} */ template inline void simplify(Geometry const& geometry, Geometry& out, @@ -326,15 +321,8 @@ inline void simplify(Geometry const& geometry, Geometry& out, to other segments to be removed \param strategy simplify strategy to be used for simplification, might include point-distance strategy -\par Example: -simplify_inserter with strategy is used as following: -\dontinclude doxygen_1.cpp -\skip example_simplify_linestring2 -\line { -\until } \qbk{distinguish,with strategy} -\qbk{example,simplify_inserter} */ template inline void simplify_inserter(Geometry const& geometry, OutputIterator out, @@ -360,6 +348,8 @@ inline void simplify_inserter(Geometry const& geometry, OutputIterator out, \param max_distance distance (in units of input coordinates) of a vertex to other segments to be removed +\qbk{example,simplify_inserter} +\qbk{example,simplify_inserter_output} */ template inline void simplify_inserter(Geometry const& geometry, OutputIterator out,