|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67003 - sandbox/geometry/libs/geometry/example
From: barend.gehrels_at_[hidden]
Date: 2010-12-04 07:11:22
Author: barendgehrels
Date: 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
New Revision: 67003
URL: http://svn.boost.org/trac/boost/changeset/67003
Log:
Samples now without cartesian2d headerfile
Text files modified:
sandbox/geometry/libs/geometry/example/01_point_example.cpp | 27 ++++++-----
sandbox/geometry/libs/geometry/example/02_linestring_example.cpp | 91 ++++++++++++++++++++-------------------
sandbox/geometry/libs/geometry/example/03_polygon_example.cpp | 47 ++++++++++---------
sandbox/geometry/libs/geometry/example/05_a_overlay_polygon_example.cpp | 17 ++++---
sandbox/geometry/libs/geometry/example/05_b_overlay_linestring_polygon_example.cpp | 12 ++--
sandbox/geometry/libs/geometry/example/06_a_transformation_example.cpp | 10 ++--
sandbox/geometry/libs/geometry/example/06_b_transformation_example.cpp | 19 ++++---
sandbox/geometry/libs/geometry/example/07_a_graph_route_example.cpp | 3
sandbox/geometry/libs/geometry/example/07_b_graph_route_example.cpp | 3
9 files changed, 119 insertions(+), 110 deletions(-)
Modified: sandbox/geometry/libs/geometry/example/01_point_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/01_point_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/01_point_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -13,19 +13,18 @@
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/adapted/tuple_cartesian.hpp>
#include <boost/geometry/geometries/adapted/c_array_cartesian.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
int main()
{
using namespace boost::geometry;
- // GGL contains several point types:
- // 1: it's own generic type
+ // Boost.Geometry contains several point types:
+ // 1: its own generic type
model::point<double, 2, cs::cartesian> pt1;
- // 2: it's own type targetted to Cartesian (x,y) coordinates
- model::d2::point pt2;
+ // 2: its own type targetted to Cartesian (x,y) coordinates
+ model::d2::point_xy<double> pt2;
// 3: it supports Boost tuple's (by including the headerfile)
boost::tuple<double, double> pt3;
@@ -33,7 +32,11 @@
// 4: it supports normal arrays
double pt4[2];
- // 5: there are more variants, and you can create your own.
+ // 5: in the past there was a typedef. But users can do that themselves:
+ typedef model::d2::point_xy<double> point_2d;
+ point_2d pt5;
+
+ // 6: there are more variants, and you can create your own.
// (see therefore the custom_point example)
// All these types are handled the same way. We show here
@@ -53,16 +56,16 @@
// Several ways of construction and setting point values
// 1: default, empty constructor, causing no initialization at all
- model::d2::point p1;
+ model::d2::point_xy<double> p1;
// 2: as shown above, assign
- model::d2::point p2;
+ model::d2::point_xy<double> p2;
assign(p2, 1, 1);
// 3: using "set" function
// set uses the concepts behind, such that it can be applied for
// every point-type (like assign)
- model::d2::point p3;
+ model::d2::point_xy<double> p3;
set<0>(p3, 1);
set<1>(p3, 1);
// set<2>(p3, 1); //will result in compile-error
@@ -71,11 +74,11 @@
// 3: for any point type, and other geometry objects:
// there is the "make" object generator
// (this one requires to specify the point-type).
- model::d2::point p4 = make<model::d2::point>(1,1);
+ model::d2::point_xy<double> p4 = make<model::d2::point_xy<double>>(1,1);
- // 5: for the d2::point type only: constructor with two values
- model::d2::point p5(1,1);
+ // 5: for the d2::point_xy<...> type only: constructor with two values
+ model::d2::point_xy<double> p5(1,1);
// 6: for boost tuples you can of course use make_tuple
Modified: sandbox/geometry/libs/geometry/example/02_linestring_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/02_linestring_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/02_linestring_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -15,7 +15,6 @@
#include <vector>
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
// Optional includes to handle c-arrays as points, std::vectors as linestrings
#include <boost/geometry/geometries/adapted/c_array_cartesian.hpp>
#include <boost/geometry/geometries/adapted/std_as_linestring.hpp>
@@ -71,23 +70,26 @@
// Define a linestring, which is a vector of points, and add some points
// (we add them deliberately in different ways)
- model::d2::linestring ls;
+ typedef model::d2::point_xy<double> point_2d;
+ typedef model::linestring<point_2d> linestring_2d;
+ linestring_2d ls;
// points can be created using "make" and added to a linestring using the std:: "push_back"
- ls.push_back(make<model::d2::point>(1.1, 1.1));
+ ls.push_back(make<point_2d>(1.1, 1.1));
// points can also be assigned using "assign" and added to a linestring using "append"
- model::d2::point lp;
+ point_2d lp;
assign(lp, 2.5, 2.1);
append(ls, lp);
// Lines can be streamed using DSV (delimiter separated values)
- std::cout << boost::geometry::dsv(ls) << std::endl;
+ std::cout << dsv(ls) << std::endl;
// The bounding box of linestrings can be calculated
- model::d2::box b;
+ typedef model::box<point_2d> box_2d;
+ box_2d b;
envelope(ls, b);
- std::cout << boost::geometry::dsv(b) << std::endl;
+ std::cout << dsv(b) << std::endl;
// The length of the line can be calulated
std::cout << "length: " << length(ls) << std::endl;
@@ -102,44 +104,44 @@
std::cout << "number of points 3: " << num_points(ls) << std::endl;
// The distance from a point to a linestring can be calculated
- model::d2::point p(1.9, 1.2);
- std::cout << "distance of " << boost::geometry::dsv(p)
+ point_2d p(1.9, 1.2);
+ std::cout << "distance of " << dsv(p)
<< " to line: " << distance(p, ls) << std::endl;
// A linestring is a vector. However, some algorithms consider "segments",
// which are the line pieces between two points of a linestring.
- double d = distance(p, model::segment<model::d2::point >(ls.front(), ls.back()));
+ double d = distance(p, model::segment<point_2d >(ls.front(), ls.back()));
std::cout << "distance: " << d << std::endl;
// Add some three points more, let's do it using a classic array.
// (See documentation for picture of this linestring)
const double c[][2] = { {3.1, 3.1}, {4.9, 1.1}, {3.1, 1.9} };
append(ls, c);
- std::cout << "appended: " << boost::geometry::dsv(ls) << std::endl;
+ std::cout << "appended: " << dsv(ls) << std::endl;
// Output as iterator-pair on a vector
{
- std::vector<model::d2::point> v;
+ std::vector<point_2d> v;
std::copy(ls.begin(), ls.end(), std::back_inserter(v));
std::cout
<< "as vector: "
- << boost::geometry::dsv(v)
+ << dsv(v)
<< std::endl;
std::cout
<< "as it-pair: "
- << boost::geometry::dsv(std::make_pair(v.begin(), v.end()))
+ << dsv(std::make_pair(v.begin(), v.end()))
<< std::endl;
}
// All algorithms from std can be used: a linestring is a vector
std::reverse(ls.begin(), ls.end());
- std::cout << "reversed: " << boost::geometry::dsv(ls) << std::endl;
+ std::cout << "reversed: " << dsv(ls) << std::endl;
std::reverse(boost::begin(ls), boost::end(ls));
// The other way, using a vector instead of a linestring, is also possible
- std::vector<model::d2::point> pv(ls.begin(), ls.end());
+ std::vector<point_2d> pv(ls.begin(), ls.end());
std::cout << "length: " << length(pv) << std::endl;
// If there are double points in the line, you can use unique to remove them
@@ -148,24 +150,24 @@
// (sidenote, we have to make copies, because
// ls.push_back(ls.back()) often succeeds but
// IS dangerous and erroneous!
- model::d2::point last = ls.back(), first = ls.front();
+ point_2d last = ls.back(), first = ls.front();
ls.push_back(last);
ls.insert(ls.begin(), first);
}
- std::cout << "extra duplicate points: " << boost::geometry::dsv(ls) << std::endl;
+ std::cout << "extra duplicate points: " << dsv(ls) << std::endl;
{
- model::d2::linestring ls_copy;
+ linestring_2d ls_copy;
std::unique_copy(ls.begin(), ls.end(), std::back_inserter(ls_copy),
- boost::geometry::equal_to<model::d2::point>());
+ boost::geometry::equal_to<point_2d>());
ls = ls_copy;
- std::cout << "uniquecopy: " << boost::geometry::dsv(ls) << std::endl;
+ std::cout << "uniquecopy: " << dsv(ls) << std::endl;
}
// Lines can be simplified. This removes points, but preserves the shape
- model::d2::linestring ls_simplified;
+ linestring_2d ls_simplified;
simplify(ls, ls_simplified, 0.5);
- std::cout << "simplified: " << boost::geometry::dsv(ls_simplified) << std::endl;
+ std::cout << "simplified: " << dsv(ls_simplified) << std::endl;
// for_each:
@@ -175,51 +177,50 @@
// 4) loop is defined for geometries to visit segments
// with state apart, and to be able to break out (not shown here)
{
- model::d2::linestring lscopy = ls;
- std::for_each(lscopy.begin(), lscopy.end(), translate_function<model::d2::point>);
- for_each_point(lscopy, scale_functor<model::d2::point>());
- for_each_point(lscopy, translate_function<model::d2::point>);
- std::cout << "modified line: " << boost::geometry::dsv(lscopy) << std::endl;
+ linestring_2d lscopy = ls;
+ std::for_each(lscopy.begin(), lscopy.end(), translate_function<point_2d>);
+ for_each_point(lscopy, scale_functor<point_2d>());
+ for_each_point(lscopy, translate_function<point_2d>);
+ std::cout << "modified line: " << dsv(lscopy) << std::endl;
}
// Lines can be clipped using a clipping box. Clipped lines are added to the output iterator
- model::d2::box cb(model::d2::point(1.5, 1.5), model::d2::point(4.5, 2.5));
+ box_2d cb(point_2d(1.5, 1.5), point_2d(4.5, 2.5));
- std::vector<model::d2::linestring> clipped;
- intersection_inserter<model::d2::linestring> (cb, ls, std::back_inserter(clipped));
+ std::vector<linestring_2d> clipped;
+ intersection_inserter<linestring_2d> (cb, ls, std::back_inserter(clipped));
// Also possible: clip-output to a vector of vectors
- std::vector<std::vector<model::d2::point> > vector_out;
- intersection_inserter<std::vector<model::d2::point> >(cb, ls, std::back_inserter(vector_out));
+ std::vector<std::vector<point_2d> > vector_out;
+ intersection_inserter<std::vector<point_2d> >(cb, ls, std::back_inserter(vector_out));
std::cout << "clipped output as vector:" << std::endl;
- for (std::vector<std::vector<model::d2::point> >::const_iterator it
+ for (std::vector<std::vector<point_2d> >::const_iterator it
= vector_out.begin(); it != vector_out.end(); ++it)
{
- std::cout << boost::geometry::dsv(*it) << std::endl;
+ std::cout << dsv(*it) << std::endl;
}
// Calculate the convex hull of the linestring
- model::d2::polygon hull;
+ model::polygon<point_2d> hull;
convex_hull(ls, hull);
- std::cout << "Convex hull:" << boost::geometry::dsv(hull) << std::endl;
+ std::cout << "Convex hull:" << dsv(hull) << std::endl;
// All the above assumed 2D Cartesian linestrings. 3D is possible as well
// Let's define a 3D point ourselves, this time using 'float'
- typedef model::point<float, 3, cs::cartesian> point_type;
- typedef model::linestring<point_type> line_type;
- line_type line3d;
- line3d.push_back(make<point_type>(1,2,3));
- line3d.push_back(make<point_type>(4,5,6));
- line3d.push_back(make<point_type>(7,8,9));
+ typedef model::point<float, 3, cs::cartesian> point_3d;
+ model::linestring<point_3d> line3;
+ line3.push_back(make<point_3d>(1,2,3));
+ line3.push_back(make<point_3d>(4,5,6));
+ line3.push_back(make<point_3d>(7,8,9));
// Not all algorithms work on 3d lines. For example convex hull does NOT.
// But, for example, length, distance, simplify, envelope and stream do.
- std::cout << "3D: length: " << length(line3d) << " line: " << boost::geometry::dsv(line3d) << std::endl;
+ std::cout << "3D: length: " << length(line3) << " line: " << dsv(line3) << std::endl;
// With DSV you can also use other delimiters, e.g. JSON style
std::cout << "JSON: "
- << boost::geometry::dsv(ls, ", ", "[", "]", ", ", "[ ", " ]")
+ << dsv(ls, ", ", "[", "]", ", ", "[ ", " ]")
<< std::endl;
return 0;
Modified: sandbox/geometry/libs/geometry/example/03_polygon_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/03_polygon_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/03_polygon_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -13,7 +13,6 @@
#include <string>
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/c_array_cartesian.hpp>
#include <boost/geometry/geometries/adapted/std_as_linestring.hpp>
#include <boost/geometry/multi/multi.hpp>
@@ -27,9 +26,13 @@
{
using namespace boost::geometry;
+ typedef model::d2::point_xy<double> point_2d;
+ typedef model::polygon<point_2d> polygon_2d;
+ typedef model::box<point_2d> box_2d;
+
// Define a polygon and fill the outer ring.
// In most cases you will read it from a file or database
- model::d2::polygon poly;
+ polygon_2d poly;
{
const double coor[][2] = {
{2.0, 1.3}, {2.4, 1.7}, {2.8, 1.8}, {3.4, 1.2}, {3.7, 1.6},
@@ -48,7 +51,7 @@
std::cout << dsv(poly) << std::endl;
// As with lines, bounding box of polygons can be calculated
- model::d2::box b;
+ box_2d b;
envelope(poly, b);
std::cout << dsv(b) << std::endl;
@@ -56,7 +59,7 @@
std::cout << "area: " << area(poly) << std::endl;
// And the centroid, which is the center of gravity
- model::d2::point cent;
+ point_2d cent;
centroid(poly, cent);
std::cout << "centroid: " << dsv(cent) << std::endl;
@@ -65,11 +68,11 @@
// or per polygon (using num_points)
std::cout << "number of points in outer ring: " << poly.outer().size() << std::endl;
- // Polygons can have one or more inner rings, also called holes, donuts, islands, interior rings.
+ // Polygons can have one or more inner rings, also called holes, islands, interior rings.
// Let's add one
{
poly.inners().resize(1);
- model::linear_ring<model::d2::point>& inner = poly.inners().back();
+ model::linear_ring<point_2d>& inner = poly.inners().back();
const double coor[][2] = { {4.0, 2.0}, {4.2, 1.4}, {4.8, 1.9}, {4.4, 2.2}, {4.0, 2.0} };
assign(inner, coor);
@@ -85,18 +88,18 @@
// You can test whether points are within a polygon
std::cout << "point in polygon:"
- << " p1: " << boolstr(within(make<model::d2::point>(3.0, 2.0), poly))
- << " p2: " << boolstr(within(make<model::d2::point>(3.7, 2.0), poly))
- << " p3: " << boolstr(within(make<model::d2::point>(4.4, 2.0), poly))
+ << " p1: " << boolstr(within(make<point_2d>(3.0, 2.0), poly))
+ << " p2: " << boolstr(within(make<point_2d>(3.7, 2.0), poly))
+ << " p3: " << boolstr(within(make<point_2d>(4.4, 2.0), poly))
<< std::endl;
// As with linestrings and points, you can derive from polygon to add, for example,
// fill color and stroke color. Or SRID (spatial reference ID). Or Z-value. Or a property map.
// We don't show this here.
- // Clip the polygon using a bounding box
- model::d2::box cb(make<model::d2::point>(1.5, 1.5), make<model::d2::point>(4.5, 2.5));
- typedef std::vector<model::d2::polygon> polygon_list;
+ // Clip the polygon using a box
+ box_2d cb(make<point_2d>(1.5, 1.5), make<point_2d>(4.5, 2.5));
+ typedef std::vector<polygon_2d> polygon_list;
polygon_list v;
intersection(cb, poly, v);
@@ -106,11 +109,11 @@
std::cout << dsv(*it) << std::endl;
}
- typedef model::multi_polygon<model::d2::polygon> polygon_set;
+ typedef model::multi_polygon<polygon_2d> polygon_set;
polygon_set ps;
union_(cb, poly, ps);
- model::d2::polygon hull;
+ polygon_2d hull;
convex_hull(poly, hull);
std::cout << "Convex hull:" << dsv(hull) << std::endl;
@@ -118,14 +121,14 @@
// You don't have to use a vector, you can define a polygon with a deque
// You can specify the container for the points and for the inner rings independantly
- typedef model::polygon<model::d2::point, true, true, std::deque, std::deque> polygon_type;
- polygon_type poly2;
- ring_type<polygon_type>::type& ring = exterior_ring(poly2);
- append(ring, make<model::d2::point>(2.8, 1.9));
- append(ring, make<model::d2::point>(2.9, 2.4));
- append(ring, make<model::d2::point>(3.3, 2.2));
- append(ring, make<model::d2::point>(3.2, 1.8));
- append(ring, make<model::d2::point>(2.8, 1.9));
+ typedef model::polygon<point_2d, true, true, std::deque, std::deque> deque_polygon;
+ deque_polygon poly2;
+ ring_type<deque_polygon>::type& ring = exterior_ring(poly2);
+ append(ring, make<point_2d>(2.8, 1.9));
+ append(ring, make<point_2d>(2.9, 2.4));
+ append(ring, make<point_2d>(3.3, 2.2));
+ append(ring, make<point_2d>(3.2, 1.8));
+ append(ring, make<point_2d>(2.8, 1.9));
std::cout << dsv(poly2) << std::endl;
return 0;
Modified: sandbox/geometry/libs/geometry/example/05_a_overlay_polygon_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/05_a_overlay_polygon_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/05_a_overlay_polygon_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -16,7 +16,6 @@
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/c_array_cartesian.hpp>
#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
@@ -26,11 +25,15 @@
{
namespace bg = boost::geometry;
+ typedef bg::model::d2::point_xy<double> point_2d;
+ typedef bg::model::polygon<point_2d> polygon_2d;
+
+
std::ofstream stream("05_a_intersection_polygon_example.svg");
- bg::svg_mapper<bg::model::d2::point> svg(stream, 500, 500);
+ bg::svg_mapper<point_2d> svg(stream, 500, 500);
// Define a polygons and fill the outer rings.
- bg::model::d2::polygon a;
+ polygon_2d a;
{
const double c[][2] = {
{160, 330}, {60, 260}, {20, 150}, {60, 40}, {190, 20}, {270, 130}, {260, 250}, {160, 330}
@@ -41,7 +44,7 @@
std::cout << "A: " << bg::dsv(a) << std::endl;
svg.add(a);
- bg::model::d2::polygon b;
+ polygon_2d b;
{
const double c[][2] = {
{300, 330}, {190, 270}, {150, 170}, {150, 110}, {250, 30}, {380, 50}, {380, 250}, {300, 330}
@@ -57,11 +60,11 @@
// Calculate interesection(s)
- std::vector<bg::model::d2::polygon > intersection;
- bg::intersection<bg::model::d2::polygon>(a, b, intersection);
+ std::vector<polygon_2d> intersection;
+ bg::intersection(a, b, intersection);
std::cout << "Intersection of polygons A and B" << std::endl;
- BOOST_FOREACH(bg::model::d2::polygon const& polygon, intersection)
+ BOOST_FOREACH(polygon_2d const& polygon, intersection)
{
std::cout << bg::dsv(polygon) << std::endl;
svg.map(polygon, "opacity:0.5;fill:none;stroke:rgb(255,0,0);stroke-width:6");
Modified: sandbox/geometry/libs/geometry/example/05_b_overlay_linestring_polygon_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/05_b_overlay_linestring_polygon_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/05_b_overlay_linestring_polygon_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -16,7 +16,6 @@
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/c_array_cartesian.hpp>
#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
@@ -26,14 +25,15 @@
{
namespace bg = boost::geometry;
- // Define a polygons and fill the outer rings.
- bg::model::d2::linestring ls;
+ typedef bg::model::d2::point_xy<double> point_2d;
+
+ bg::model::linestring<point_2d> ls;
{
const double c[][2] = { {0, 1}, {2, 5}, {5, 3} };
bg::assign(ls, c);
}
- bg::model::d2::polygon p;
+ bg::model::polygon<point_2d> p;
{
const double c[][2] = { {3, 0}, {0, 3}, {4, 5}, {3, 0} };
bg::assign(p, c);
@@ -42,7 +42,7 @@
// Create SVG-mapper
std::ofstream stream("05_b_overlay_linestring_polygon_example.svg");
- bg::svg_mapper<bg::model::d2::point> svg(stream, 500, 500);
+ bg::svg_mapper<point_2d> svg(stream, 500, 500);
// Determine extend by adding geometries
svg.add(p);
svg.add(ls);
@@ -52,7 +52,7 @@
// Calculate intersection points (turn points)
- typedef bg::detail::overlay::turn_info<bg::model::d2::point> turn_info;
+ typedef bg::detail::overlay::turn_info<point_2d> turn_info;
std::vector<turn_info> turns;
bg::detail::get_turns::no_interrupt_policy policy;
bg::get_turns<bg::detail::overlay::assign_null_policy>(ls, p, turns, policy);
Modified: sandbox/geometry/libs/geometry/example/06_a_transformation_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/06_a_transformation_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/06_a_transformation_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -11,7 +11,6 @@
#include <iostream>
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/c_array_cartesian.hpp>
#include <boost/geometry/geometries/adapted/std_as_linestring.hpp>
@@ -19,17 +18,18 @@
{
using namespace boost::geometry;
- model::d2::point p(1, 1);
- model::d2::point p2;
+ typedef model::d2::point_xy<double> point_2d;
+ point_2d p(1, 1);
+ point_2d p2;
// Example: translate a point over (5,5)
- strategy::transform::translate_transformer<model::d2::point, model::d2::point> translate(5, 5);
+ strategy::transform::translate_transformer<point_2d, point_2d> translate(5, 5);
transform(p, p2, translate);
std::cout << "transformed point " << boost::geometry::dsv(p2) << std::endl;
// Transform a polygon
- model::d2::polygon poly, poly2;
+ model::polygon<point_2d> poly, poly2;
const double coor[][2] = { {0, 0}, {0, 7}, {2, 2}, {2, 0}, {0, 0} };
// note that for this syntax you have to include the two
// include files above (c_array_cartesian.hpp, std_as_linestring.hpp)
Modified: sandbox/geometry/libs/geometry/example/06_b_transformation_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/06_b_transformation_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/06_b_transformation_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -16,7 +16,6 @@
#include <sstream>
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/strategies/transform.hpp>
#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
@@ -106,6 +105,8 @@
{
using namespace boost::geometry::strategy::transform;
+ typedef boost::geometry::model::d2::point_xy<double> point_2d;
+
try
{
std::string file("06_b_transformation_example.svg");
@@ -113,36 +114,36 @@
svg_output<std::ofstream> svg(ofs, 0.5);
// G1 - create subject for affine transformations
- model::d2::polygon g1;
+ model::polygon<point_2d> g1;
read_wkt("POLYGON((50 250, 400 250, 150 50, 50 250))", g1);
std::clog << "source box:\t" << boost::geometry::dsv(g1) << std::endl;
svg.put(g1, "g1");
// G1 - Translate -> G2
- translate_transformer<model::d2::point, model::d2::point> translate(0, 250);
- model::d2::polygon g2;
+ translate_transformer<point_2d, point_2d> translate(0, 250);
+ model::polygon<point_2d> g2;
transform(g1, g2, translate);
std::clog << "translated:\t" << boost::geometry::dsv(g2) << std::endl;
svg.put(g2, "g2=g1.translate(0,250)");
// G2 - Scale -> G3
- scale_transformer<model::d2::point, model::d2::point> scale(0.5, 0.5);
- model::d2::polygon g3;
+ scale_transformer<point_2d, point_2d> scale(0.5, 0.5);
+ model::polygon<point_2d> g3;
transform(g2, g3, scale);
std::clog << "scaled:\t" << boost::geometry::dsv(g3) << std::endl;
svg.put(g3, "g3=g2.scale(0.5,0.5)");
// G3 - Combine rotate and translate -> G4
- rotate_transformer<model::d2::point, model::d2::point, degree> rotate(45);
+ rotate_transformer<point_2d, point_2d, degree> rotate(45);
// Compose matrix for the two transformation
// Create transformer attached to the transformation matrix
- ublas_transformer<model::d2::point, model::d2::point, 2, 2>
+ ublas_transformer<point_2d, point_2d, 2, 2>
combined(boost::numeric::ublas::prod(rotate.matrix(), translate.matrix()));
//combined(rotate.matrix());
// Apply transformation to subject geometry point-by-point
- model::d2::polygon g4;
+ model::polygon<point_2d> g4;
transform(g3, g4, combined);
std::clog << "rotated & translated:\t" << boost::geometry::dsv(g4) << std::endl;
Modified: sandbox/geometry/libs/geometry/example/07_a_graph_route_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/07_a_graph_route_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/07_a_graph_route_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -22,7 +22,6 @@
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
// Yes, this example currently uses some extensions:
@@ -281,7 +280,7 @@
// Init a bounding box, lateron used to define SVG map
- boost::geometry::model::d2::box box;
+ boost::geometry::model::box<point_type> box;
boost::geometry::assign_inverse(box);
// Read the cities
Modified: sandbox/geometry/libs/geometry/example/07_b_graph_route_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/07_b_graph_route_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/07_b_graph_route_example.cpp 2010-12-04 07:11:17 EST (Sat, 04 Dec 2010)
@@ -26,7 +26,6 @@
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/geometries/cartesian2d.hpp>
// Yes, this example currently uses some extensions:
@@ -269,7 +268,7 @@
// Init a bounding box, lateron used to define SVG map
- boost::geometry::model::d2::box box;
+ boost::geometry::model::box<point_type> box;
boost::geometry::assign_inverse(box);
graph_type graph;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk