Added Boost.Geometry examples to boost.sandbox

[SVN r59383]
This commit is contained in:
Barend Gehrels 2010-01-31 21:23:07 +00:00
parent 16df4ca38c
commit 62fde787bc
52 changed files with 10402 additions and 0 deletions

View File

@ -0,0 +1,102 @@
// 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)
//
// Point Example - showing different type of points
#include <iostream>
#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
point<double, 2, cs::cartesian> pt1;
// 2: it's own type targetted to Cartesian (x,y) coordinates
point_2d pt2;
// 3: it supports Boost tuple's (by including the headerfile)
boost::tuple<double, double> pt3;
// 4: it supports normal arrays
double pt4[2];
// 5: 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
// assigning them and calculating distances.
assign(pt1, 1, 1);
assign(pt2, 2, 2);
assign(pt3, 3, 3);
assign(pt4, 4, 4);
double d1 = distance(pt1, pt2);
double d2 = distance(pt3, pt4);
std::cout << "Distances: " << d1 << " and " << d2 << std::endl;
// (in case you didn't note, distances can be calculated
// from points with different point-types)
// Several ways of construction and setting point values
// 1: default, empty constructor, causing no initialization at all
point_2d p1;
// 2: as shown above, assign
point_2d 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)
point_2d p3;
set<0>(p3, 1);
set<1>(p3, 1);
// set<2>(p3, 1); //will result in compile-error
// 3: for any point type, and other geometry objects:
// there is the "make" object generator
// (this one requires to specify the point-type).
point_2d p4 = make<point_2d>(1,1);
// 5: for the point_2d type only: constructor with two values
point_2d p5(1,1);
// 6: for boost tuples you can of course use make_tuple
// Some ways of getting point values
// 1: using the "get" function following the concepts behind
std::cout << get<0>(p2) << "," << get<1>(p2) << std::endl;
// 2: for point-2d only
std::cout << p2.x() << "," << p2.y() << std::endl;
// 3: using boost-tuples you of course can boost-tuple-methods
std::cout << pt3.get<0>() << "," << pt3.get<1>() << std::endl;
// 4: GGL supports various output formats, e.g. DSV
// (delimiter separated values)
std::cout << dsv(pt3) << std::endl;
// Other examples show other types of points, geometries and more algorithms
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="01_point_example"
ProjectGUID="{E7BFC111-F0E5-420F-869C-1FC3212270B5}"
RootNamespace="01_point_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\01_point_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\01_point_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\01_point_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,199 @@
// 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)
//
// Linestring Example
#include <algorithm> // for reverse, unique
#include <iostream>
#include <iterator>
#include <utility>
#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>
template<typename P>
inline void translate_function(P& p)
{
p.x(p.x() + 100.0);
}
template<typename P>
struct scale_functor
{
inline void operator()(P& p)
{
p.x(p.x() * 1000.0);
p.y(p.y() * 1000.0);
}
};
int main(void)
{
using namespace boost::geometry;
// Define a linestring, which is a vector of points, and add some points
// (we add them deliberately in different ways)
linestring_2d ls;
// points can be created using "make" and added to a linestring using the std:: "push_back"
ls.push_back(make<point_2d>(1.1, 1.1));
// points can also be assigned using "assign" and added to a linestring using "append"
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;
// The bounding box of linestrings can be calculated
box_2d b;
envelope(ls, b);
std::cout << boost::geometry::dsv(b) << std::endl;
// The length of the line can be calulated
std::cout << "length: " << length(ls) << std::endl;
// All things from std::vector can be called, because a linestring is a vector
std::cout << "number of points 1: " << ls.size() << std::endl;
// All things from boost ranges can be called because a linestring is considered as a range
std::cout << "number of points 2: " << boost::size(ls) << std::endl;
// Generic function from geometry/OGC delivers the same value
std::cout << "number of points 3: " << num_points(ls) << std::endl;
// The distance from a point to a linestring can be calculated
point_2d p(1.9, 1.2);
std::cout << "distance of " << boost::geometry::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, 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;
// Output as iterator-pair on a vector
{
std::vector<point_2d> v;
std::copy(ls.begin(), ls.end(), std::back_inserter(v));
std::cout
<< "as vector: "
<< boost::geometry::dsv(v)
<< std::endl;
std::cout
<< "as it-pair: "
<< boost::geometry::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::reverse(boost::begin(ls), boost::end(ls));
// The other way, using a vector instead of a linestring, is also possible
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
// So we add the last point, print, make a unique copy and print
{
// (sidenote, we have to make copies, because
// ls.push_back(ls.back()) often succeeds but
// IS dangerous and erroneous!
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;
{
linestring_2d ls_copy;
std::unique_copy(ls.begin(), ls.end(), std::back_inserter(ls_copy),
boost::geometry::equal_to<point_2d>());
ls = ls_copy;
std::cout << "uniquecopy: " << boost::geometry::dsv(ls) << std::endl;
}
// Lines can be simplified. This removes points, but preserves the shape
linestring_2d ls_simplified;
simplify(ls, ls_simplified, 0.5);
std::cout << "simplified: " << boost::geometry::dsv(ls_simplified) << std::endl;
// for_each:
// 1) Lines can be visited with std::for_each
// 2) for_each_point is also defined for all geometries
// 3) for_each_segment is defined for all geometries to all segments
// 4) loop is defined for geometries to visit segments
// with state apart, and to be able to break out (not shown here)
{
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: " << boost::geometry::dsv(lscopy) << std::endl;
}
// Lines can be clipped using a clipping box. Clipped lines are added to the output iterator
box_2d cb(point_2d(1.5, 1.5), point_2d(4.5, 2.5));
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<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<point_2d> >::const_iterator it
= vector_out.begin(); it != vector_out.end(); ++it)
{
std::cout << boost::geometry::dsv(*it) << std::endl;
}
// Calculate the convex hull of the linestring
polygon_2d hull;
convex_hull(ls, hull);
std::cout << "Convex hull:" << boost::geometry::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 point<float, 3, cs::cartesian> point_type;
typedef 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));
// 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;
// With DSV you can also use other delimiters, e.g. JSON style
std::cout << "JSON: "
<< boost::geometry::dsv(ls, ", ", "[", "]", ", ", "[ ", " ]")
<< std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="02_linestring_example"
ProjectGUID="{D5CE1A26-1EB7-44A4-84F9-526CFA8C2B74}"
RootNamespace="02_linestring_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\02_linestring_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="1"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\02_linestring_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\02_linestring_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,132 @@
// 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)
//
// Polygon Example
#include <algorithm> // for reverse, unique
#include <iostream>
#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>
std::string boolstr(bool v)
{
return v ? "true" : "false";
}
int main(void)
{
using namespace boost::geometry;
// Define a polygon and fill the outer ring.
// In most cases you will read it from a file or database
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},
{3.4, 2.0}, {4.1, 3.0}, {5.3, 2.6}, {5.4, 1.2}, {4.9, 0.8}, {2.9, 0.7},
{2.0, 1.3} // closing point is opening point
};
assign(poly, coor);
}
// Polygons should be closed, and directed clockwise. If you're not sure if that is the case,
// call the correct algorithm
correct(poly);
// Polygons can be streamed as text
// (or more precisely: as DSV (delimiter separated values))
std::cout << dsv(poly) << std::endl;
// As with lines, bounding box of polygons can be calculated
box_2d b;
envelope(poly, b);
std::cout << dsv(b) << std::endl;
// The area of the polygon can be calulated
std::cout << "area: " << area(poly) << std::endl;
// And the centroid, which is the center of gravity
point_2d cent;
centroid(poly, cent);
std::cout << "centroid: " << dsv(cent) << std::endl;
// The number of points can be requested per ring (using .size())
// 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.
// Let's add one
{
poly.inners().resize(1);
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);
}
correct(poly);
std::cout << "with inner ring:" << dsv(poly) << std::endl;
// The area of the polygon is changed of course
std::cout << "new area of polygon: " << area(poly) << std::endl;
centroid(poly, cent);
std::cout << "new centroid: " << dsv(cent) << std::endl;
// You can test whether points are within a polygon
std::cout << "point in polygon:"
<< " 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
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_inserter<polygon_2d>(cb, poly, std::back_inserter(v));
std::cout << "Clipped output polygons" << std::endl;
for (polygon_list::const_iterator it = v.begin(); it != v.end(); ++it)
{
std::cout << dsv(*it) << std::endl;
}
typedef multi_polygon<polygon_2d> polygon_set;
polygon_set ps;
union_inserter<polygon_2d>(cb, poly, std::back_inserter(ps));
polygon_2d hull;
convex_hull(poly, hull);
std::cout << "Convex hull:" << dsv(hull) << std::endl;
// If you really want:
// 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 polygon<point_2d, std::vector, std::deque> polygon_type;
polygon_type poly2;
ring_type<polygon_type>::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;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="03_polygon_example"
ProjectGUID="{1E299DA7-CFD1-4586-B0B0-1ABF2A32ED5B}"
RootNamespace="03_polygon_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\03_polygon_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="1"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NOINHERIT)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\03_polygon_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\03_polygon_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,50 @@
// 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)
//
// Transformation Example
#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>
int main()
{
using namespace boost::geometry;
point_2d p(1, 1);
point_2d p2;
// Example: translate a point over (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
polygon_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)
assign(poly, coor);
//read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly);
transform(poly, poly2, translate);
std::cout << "source polygon " << boost::geometry::dsv(poly) << std::endl;
std::cout << "transformed polygon " << boost::geometry::dsv(poly2) << std::endl;
// Many more transformations are possible:
// - from Cartesian to Spherical coordinate systems and back
// - from Cartesian to Cartesian (mapping, affine transformations) and back (inverse)
// - Map Projections
// - from Degree to Radian and back in spherical or geographic coordinate systems
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="06_a_transformation_example"
ProjectGUID="{34346EC5-1EE8-49D5-AF24-D915B4D7D144}"
RootNamespace="06_a_transformation_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\06_a_transformation_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\06_a_transformation_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\06_a_transformation_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,162 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright (c) 2009 Mateusz Loskot (mateusz@loskot.net), London, UK
//
// 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)
//
// Example: Affine Transformation (translate, scale, rotate)
#include <ctime> // for std::time
#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits>
#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>
#include <boost/geometry/extensions/io/svg/write_svg.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
#include <boost/bind.hpp>
#include <boost/random.hpp>
#include <boost/range.hpp>
#include <boost/shared_ptr.hpp>
using namespace boost::geometry;
struct random_style
{
random_style()
: rng(static_cast<int>(std::time(0))), dist(0, 255), colour(rng, dist)
{}
std::string fill(double opacity = 1)
{
std::ostringstream oss;
oss << "fill:rgba(" << colour() << "," << colour() << "," << colour() << "," << opacity << ");";
return oss.str();
}
std::string stroke(int width, double opacity = 1)
{
std::ostringstream oss;
oss << "stroke:rgba(" << colour() << "," << colour() << "," << colour() << "," << opacity << ");";
oss << "stroke-width:" << width << ";";
return oss.str();
}
template <typename T>
std::string text(T x, T y, std::string const& text)
{
std::ostringstream oss;
oss << "<text x=\"" << static_cast<int>(x) - 90 << "\" y=\"" << static_cast<int>(y) << "\" font-family=\"Verdana\">" << text << "</text>";
return oss.str();
}
boost::mt19937 rng;
boost::uniform_int<> dist;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > colour;
};
template <typename OutputStream>
struct svg_output
{
svg_output(OutputStream& os, double opacity = 1) : os(os), opacity(opacity)
{
os << "<?xml version=\"1.0\" standalone=\"no\"?>\n"
<< "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n"
<< "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
<< "<svg width=\"100%\" height=\"100%\" version=\"1.1\"\n"
<< "xmlns=\"http://www.w3.org/2000/svg\">" << std::endl;
}
~svg_output()
{
os << "</svg>" << std::endl;
}
template <typename G>
void put(G const& g, std::string const& label)
{
std::string style_str(style.fill(opacity) + style.stroke(5, opacity));
os << ::boost::geometry::svg(g, style_str) << std::endl;
if (!label.empty())
{
point_type<G>::type c;
centroid(g, c);
os << style.text(static_cast<int>(get<0>(c)), static_cast<int>(get<1>(c)), label);
}
}
private:
OutputStream& os;
double opacity;
random_style style;
};
int main()
{
using namespace boost::geometry::strategy::transform;
try
{
std::string file("06_b_transformation_example.svg");
std::ofstream ofs(file.c_str());
svg_output<std::ofstream> svg(ofs, 0.5);
// G1 - create subject for affine transformations
polygon_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<point_2d, point_2d> translate(0, 250);
polygon_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<point_2d, point_2d> scale(0.5, 0.5);
polygon_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<point_2d, point_2d, degree> rotate(45);
// Compose matrix for the two transformation
// Create transformer attached to the transformation matrix
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
polygon_2d g4;
transform(g3, g4, combined);
std::clog << "rotated & translated:\t" << boost::geometry::dsv(g4) << std::endl;
svg.put(g4, "g4 = g3.(rotate(45) * translate(0,250))");
std::clog << "Saved SVG file:\t" << file << std::endl;
}
catch (std::exception const& e)
{
std::cerr << e.what() << std::endl;
}
catch (...)
{
std::cerr << "unknown error" << std::endl;
}
return 0;
}

View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="06_b_transformation_example"
ProjectGUID="{34346EC5-1EE8-49D5-AC21-D915B4D7D144}"
RootNamespace="06_a_transformation_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\06_a_transformation_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\06_a_transformation_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\06_b_transformation_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,400 @@
// 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)
//
// Example showing GGL combined with Boost.Graph, calculating shortest routes
// input: two WKT's, provided in subfolder data
// output: text, + an SVG, displayable in e.g. Firefox)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <limits>
#include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp>
#include <boost/graph/adjacency_list.hpp>
#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:
// For input:
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
// For output:
#include <boost/geometry/extensions/io/svg/write_svg.hpp>
// For distance-calculations over the Earth:
#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp>
// 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 <typename Geometry, typename Tuple, typename Box>
void read_wkt(std::string const& filename, std::vector<Tuple>& 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<Box>(geometry));
}
}
}
}
// Boilerplate code to initialize the SVG XML.
// Note that this is (on purpose) not part of the library but of this sample.
// GGL itself only streams small pieces of SVG, in any coordinate system
void svg_header(std::ofstream& stream)
{
stream << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
stream << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"" << std::endl;
stream << "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" << std::endl;
stream << "<svg width=\"100%\" height=\"100%\" version=\"1.1\"" << std::endl;
stream << "xmlns=\"http://www.w3.org/2000/svg\">" << std::endl;
}
// Code to define properties for Boost Graph's
enum vertex_ggl_property_t { vertex_ggl_property };
enum edge_ggl_property_t { edge_ggl_property };
namespace boost
{
BOOST_INSTALL_PROPERTY(vertex, ggl_property);
BOOST_INSTALL_PROPERTY(edge, ggl_property);
}
// Define properties for vertex
template <typename Point>
struct ggl_vertex_property
{
ggl_vertex_property()
{
boost::geometry::assign_zero(location);
}
ggl_vertex_property(Point const& loc)
{
location = loc;
}
Point location;
};
// Define properties for edge
template <typename Linestring>
struct ggl_edge_property
{
ggl_edge_property(Linestring const& line)
: m_line(line)
{
m_length = boost::geometry::length(line);
}
inline operator double() const
{
return m_length;
}
inline Linestring const& line() const
{
return m_line;
}
private :
double m_length;
Linestring m_line;
};
// Utility function to add a vertex to a graph. It might exist already. Then do not insert,
// but return vertex descriptor back. It might not exist. Then add it (and return).
// To efficiently handle this, a std::map is used.
template <typename M, typename K, typename G>
inline typename boost::graph_traits<G>::vertex_descriptor find_or_insert(M& map, K const& key, G& graph)
{
typename M::const_iterator it = map.find(key);
if (it == map.end())
{
// Add a vertex to the graph
typename boost::graph_traits<G>::vertex_descriptor new_vertex
= boost::add_vertex(graph);
// Set the property (= location)
boost::put(boost::get(vertex_ggl_property, graph), new_vertex,
ggl_vertex_property<typename M::key_type>(key));
// Add to the map, using POINT as key
map[key] = new_vertex;
return new_vertex;
}
return it->second;
}
template
<
typename Line,
typename Graph,
typename RoadTupleVector,
typename CityTupleVector
>
void add_roads_and_connect_cities(Graph& graph,
RoadTupleVector const& roads,
CityTupleVector& cities)
{
typedef typename boost::geometry::point_type<Line>::type point_type;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_type;
// Define a map to be used during graph filling
// Maps from point to vertex-id's
typedef std::map<point_type, vertex_type, boost::geometry::less<point_type> > map_type;
map_type map;
// Fill the graph
typedef typename boost::range_value<RoadTupleVector>::type road_type;
BOOST_FOREACH(road_type const& road, roads)
{
// Find or add begin/end point of these line
vertex_type from = find_or_insert(map, road.get<0>().front(), graph);
vertex_type to = find_or_insert(map, road.get<0>().back(), graph);
boost::add_edge(from, to, ggl_edge_property<Line>(road.get<0>()), graph);
}
// Find nearest graph vertex for each city, using the map
typedef typename boost::range_value<CityTupleVector>::type city_type;
BOOST_FOREACH(city_type& city, cities)
{
double min_distance = 1e300;
for(typename map_type::const_iterator it = map.begin(); it != map.end(); ++it)
{
double dist = boost::geometry::distance(it->first, city.get<0>());
if (dist < min_distance)
{
min_distance = dist;
// Set the vertex
city.get<2>() = it->second;
}
}
}
}
template <typename Graph, typename Route>
inline void add_edge_to_route(Graph const& graph,
typename boost::graph_traits<Graph>::vertex_descriptor vertex1,
typename boost::graph_traits<Graph>::vertex_descriptor vertex2,
Route& route)
{
std::pair
<
typename boost::graph_traits<Graph>::edge_descriptor,
bool
> opt_edge = boost::edge(vertex1, vertex2, graph);
if (opt_edge.second)
{
// Get properties of edge and of vertex
ggl_edge_property<Route> const& edge_prop =
boost::get(boost::get(edge_ggl_property, graph), opt_edge.first);
ggl_vertex_property<typename boost::geometry::point_type<Route>::type> const& vertex_prop =
boost::get(boost::get(vertex_ggl_property, graph), vertex2);
// Depending on how edge connects to vertex, copy it forward or backward
if (boost::geometry::equals(edge_prop.line().front(), vertex_prop.location))
{
std::copy(edge_prop.line().begin(), edge_prop.line().end(),
std::back_inserter(route));
}
else
{
std::reverse_copy(edge_prop.line().begin(), edge_prop.line().end(),
std::back_inserter(route));
}
}
}
template <typename Graph, typename Route>
inline void build_route(Graph const& graph,
std::vector<typename boost::graph_traits<Graph>::vertex_descriptor> const& predecessors,
typename boost::graph_traits<Graph>::vertex_descriptor vertex1,
typename boost::graph_traits<Graph>::vertex_descriptor vertex2,
Route& route)
{
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_type;
vertex_type pred = predecessors[vertex2];
add_edge_to_route(graph, vertex2, pred, route);
while (pred != vertex1)
{
add_edge_to_route(graph, predecessors[pred], pred, route);
pred = predecessors[pred];
}
}
int main()
{
// Define a point in the Geographic coordinate system
typedef boost::geometry::point<double, 2, boost::geometry::cs::geographic<boost::geometry::degree> > point_type;
typedef boost::geometry::linestring<point_type> line_type;
// Define the graph, lateron containing the road network
typedef boost::adjacency_list
<
boost::vecS, boost::vecS, boost::undirectedS
, boost::property<vertex_ggl_property_t, ggl_vertex_property<point_type> >
, boost::property<edge_ggl_property_t, ggl_edge_property<line_type> >
> graph_type;
typedef boost::graph_traits<graph_type>::vertex_descriptor vertex_type;
// Init a bounding box, lateron used to define SVG map
boost::geometry::box_2d box;
boost::geometry::assign_inverse(box);
// Read the cities
typedef boost::tuple<point_type, std::string, vertex_type> city_type;
std::vector<city_type> cities;
read_wkt<point_type>("data/cities.wkt", cities, box);
// Read the road network
typedef boost::tuple<line_type, std::string> road_type;
std::vector<road_type> roads;
read_wkt<line_type>("data/roads.wkt", roads, box);
graph_type graph;
// Add roads and connect cities
add_roads_and_connect_cities<line_type>(graph, roads, cities);
double const km = 1000.0;
std::cout << "distances, all in KM" << std::endl
<< std::fixed << std::setprecision(0);
// Main functionality: calculate shortest routes from/to all cities
// For the first one, the complete route is stored as a linestring
bool first = true;
line_type route;
int const n = boost::num_vertices(graph);
BOOST_FOREACH(city_type const& city1, cities)
{
std::vector<vertex_type> predecessors(n);
std::vector<double> costs(n);
// Call Dijkstra (without named-parameter to be compatible with all VC)
boost::dijkstra_shortest_paths(graph, city1.get<2>(),
&predecessors[0], &costs[0],
boost::get(edge_ggl_property, graph),
boost::get(boost::vertex_index, graph),
std::less<double>(), std::plus<double>(),
(std::numeric_limits<double>::max)(), double(),
boost::dijkstra_visitor<boost::null_visitor>());
BOOST_FOREACH(city_type const& city2, cities)
{
if (! boost::equals(city1.get<1>(), city2.get<1>()))
{
double distance = costs[city2.get<2>()] / km;
double acof = boost::geometry::distance(city1.get<0>(), city2.get<0>()) / km;
std::cout
<< std::setiosflags (std::ios_base::left) << std::setw(15)
<< city1.get<1>() << " - "
<< std::setiosflags (std::ios_base::left) << std::setw(15)
<< city2.get<1>()
<< " -> through the air: " << std::setw(4) << acof
<< " , over the road: " << std::setw(4) << distance
<< std::endl;
if (first)
{
build_route(graph, predecessors,
city1.get<2>(), city2.get<2>(),
route);
first = false;
}
}
}
}
// Create the SVG
typedef boost::geometry::point_xy<int> svg_point_type;
std::ofstream stream("routes.svg");
svg_header(stream);
boost::geometry::strategy::transform::map_transformer
<
point_type,
svg_point_type, true, true
> matrix(box, 1000, 800);
// Map roads
BOOST_FOREACH(road_type const& road, roads)
{
boost::geometry::linestring<svg_point_type> line;
boost::geometry::transform(road.get<0>(), line, matrix);
stream << boost::geometry::svg(line, "stroke:rgb(128,128,128);stroke-width:1") << std::endl;
}
// Map the calculated route as thicker green transparent markation
{
boost::geometry::linestring<svg_point_type> line;
boost::geometry::transform(route, line, matrix);
stream << boost::geometry::svg(line, "stroke:rgb(0, 255, 0);stroke-width:6;opacity:0.5") << std::endl;
}
// Map cities
BOOST_FOREACH(city_type const& city, cities)
{
svg_point_type point;
boost::geometry::transform(city.get<0>(), point, matrix);
stream << boost::geometry::svg(point, "fill:rgb(255,255,0);stroke:rgb(0,0,0);stroke-width:1") << std::endl;
}
stream << "</svg>" << std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="07_graph_route_example"
ProjectGUID="{47D30DD8-CBB1-4527-811F-F0193E22B317}"
RootNamespace="07_graph_route_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\07_graph_route_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\07_graph_route_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\07_graph_route_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

33
example/Jamfile.v2 Normal file
View File

@ -0,0 +1,33 @@
# example/Jamfile.v2 controls building of Generic Geometry Library examples
#
# Copyright Barend Gehrels, Geodan Holding B.V. Amsterdam, the Netherlands.
# Copyright (c) 2009 Mateusz Loskot <mateusz@loskot.net>
# 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)
project ggl-example
:
requirements
<include>../../../boost
<toolset>gcc:<cxxflags>-pedantic
;
#
# Build core examples
#
exe 01_point_example : 01_point_example.cpp ;
exe 02_linestring_example : 02_linestring_example.cpp ;
exe 03_polygon_example : 03_polygon_example.cpp ;
exe 06_a_transformation_example : 06_a_transformation_example.cpp ;
exe 06_b_transformation_example : 06_b_transformation_example.cpp ;
exe 07_graph_route_example : 07_graph_route_example.cpp ;
exe c01_custom_point_example : c01_custom_point_example.cpp ;
exe c02_custom_box_example : c02_custom_box_example.cpp ;
exe c03_custom_linestring_example : c03_custom_linestring_example.cpp ;
exe c04_a_custom_triangle_example : c04_a_custom_triangle_example.cpp ;
exe c04_b_custom_triangle_example : c04_b_custom_triangle_example.cpp ;
exe c06_custom_polygon_example : c06_custom_polygon_example.cpp ;
exe c07_custom_ring_pointer_example : c07_custom_ring_pointer_example.cpp ;

20
example/boost.vsprops Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="boost"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(BOOST_ROOT);..\..\.."
WarningLevel="3"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories="$(BOOST_ROOT)\lib"
/>
<UserMacro
Name="BOOST_ROOT"
Value="C:\Program Files\boost\boost_1_41_0"
/>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,136 @@
// 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)
//
// Custom point Example
#include <iostream>
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/algorithms/make.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/util/write_dsv.hpp>
// Sample point, defining three color values
struct my_color_point
{
double red, green, blue;
};
// Sample point, having an int array defined
struct my_array_point
{
int c[3];
};
// Sample point, having x/y
struct my_2d
{
float x,y;
};
// Sample class, protected and construction-time-only x/y,
// Can (of course) only used in algorithms which take const& points
class my_class_ro
{
public:
my_class_ro(double x, double y) : m_x(x), m_y(y) {}
double x() const { return m_x; }
double y() const { return m_y; }
private:
double m_x, m_y;
};
// Sample class using references for read/write
class my_class_rw
{
public:
const double& x() const { return m_x; }
const double& y() const { return m_y; }
double& x() { return m_x; }
double& y() { return m_y; }
private:
double m_x, m_y;
};
// Sample class using getters / setters
class my_class_gs
{
public:
const double get_x() const { return m_x; }
const double get_y() const { return m_y; }
void set_x(double v) { m_x = v; }
void set_y(double v) { m_y = v; }
private:
double m_x, m_y;
};
BOOST_GEOMETRY_REGISTER_POINT_3D(my_color_point, double, cs::cartesian, red, green, blue)
BOOST_GEOMETRY_REGISTER_POINT_3D(my_array_point, int, cs::cartesian, c[0], c[1], c[2])
BOOST_GEOMETRY_REGISTER_POINT_2D(my_2d, float, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(my_class_ro, double, cs::cartesian, x(), y())
BOOST_GEOMETRY_REGISTER_POINT_2D(my_class_rw, double, cs::cartesian, x(), y())
BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(my_class_gs, double, cs::cartesian, get_x, get_y, set_x, set_y)
int main()
{
// Create 2 instances of our custom color point
my_color_point c1 = boost::geometry::make<my_color_point>(255, 3, 233);
my_color_point c2 = boost::geometry::make<my_color_point>(0, 50, 200);
// The distance between them can be calculated using the cartesian method (=pythagoras)
// provided with the library, configured by the coordinate_system type of the point
std::cout << "color distance "
<< boost::geometry::dsv(c1) << " to "
<< boost::geometry::dsv(c2) << " is "
<< boost::geometry::distance(c1,c2) << std::endl;
my_array_point a1 = {{0}};
my_array_point a2 = {{0}};
boost::geometry::assign(a1, 1, 2, 3);
boost::geometry::assign(a2, 3, 2, 1);
std::cout << "color distance "
<< boost::geometry::dsv(a1) << " to "
<< boost::geometry::dsv(a2) << " is "
<< boost::geometry::distance(a1,a2) << std::endl;
my_2d p1 = {1, 5};
my_2d p2 = {3, 4};
std::cout << "float distance "
<< boost::geometry::dsv(p1) << " to "
<< boost::geometry::dsv(p2) << " is "
<< boost::geometry::distance(p1,p2) << std::endl;
my_class_ro cro1(1, 2);
my_class_ro cro2(3, 4);
std::cout << "class ro distance "
<< boost::geometry::dsv(cro1) << " to "
<< boost::geometry::dsv(cro2) << " is "
<< boost::geometry::distance(cro1,cro2) << std::endl;
my_class_rw crw1;
my_class_rw crw2;
boost::geometry::assign(crw1, 1, 2);
boost::geometry::assign(crw2, 3, 4);
std::cout << "class r/w distance "
<< boost::geometry::dsv(crw1) << " to "
<< boost::geometry::dsv(crw2) << " is "
<< boost::geometry::distance(crw1,crw2) << std::endl;
my_class_gs cgs1;
my_class_gs cgs2;
boost::geometry::assign(cgs1, 1, 2);
boost::geometry::assign(cgs2, 3, 4);
std::cout << "class g/s distance "
<< boost::geometry::dsv(crw1) << " to "
<< boost::geometry::dsv(crw2) << " is "
<< boost::geometry::distance(cgs1,cgs2) << std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c01_custom_point_example"
ProjectGUID="{B368C99D-8464-493C-A05B-904F53909046}"
RootNamespace="c01_custom_point_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c01_custom_point_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c01_custom_point_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c01_custom_point_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,76 @@
// 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)
//
// Custom Box Example
#include <iostream>
#include <boost/geometry/algorithms/make.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/box.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/util/write_dsv.hpp>
struct my_point
{
double x, y;
};
struct my_int_point
{
int x, y;
};
struct my_box
{
my_point ll, ur;
};
struct my_box_ltrb
{
int left, top, right, bottom;
};
struct my_box_4
{
double coors[4];
};
template <typename P>
struct my_box_t
{
P ll, ur;
};
BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_POINT_2D(my_int_point, int, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_BOX(my_box, my_point, ll, ur)
BOOST_GEOMETRY_REGISTER_BOX_TEMPLATIZED(my_box_t, ll, ur)
BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(my_box_ltrb, my_int_point, left, top, right, bottom)
BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(my_box_4, my_point, coors[0], coors[1], coors[2], coors[3])
int main()
{
my_point p = boost::geometry::make<my_point>(3.5, 3.5);
my_box b = boost::geometry::make<my_box>(0, 0, 2, 2);
my_box_ltrb b1 = boost::geometry::make<my_box_ltrb>(0, 0, 3, 3);
my_box_4 b4 = boost::geometry::make<my_box_4>(0, 0, 4, 4);
my_box_t<my_point> bt = boost::geometry::make<my_box_t<my_point> >(0, 0, 5, 5);
std::cout << boost::geometry::dsv(p) << " IN " << boost::geometry::dsv(b)
<< " : " << int(boost::geometry::within(p, b)) << std::endl;
std::cout << boost::geometry::dsv(p) << " IN " << boost::geometry::dsv(b1)
<< " : " << int(boost::geometry::within(p, b1)) << std::endl;
std::cout << boost::geometry::dsv(p) << " IN " << boost::geometry::dsv(b4)
<< " : " << int(boost::geometry::within(p, b4)) << std::endl;
std::cout << boost::geometry::dsv(p) << " IN " << boost::geometry::dsv(bt)
<< " : " << int(boost::geometry::within(p, bt)) << std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c02_custom_box_example"
ProjectGUID="{1A68AD9E-7C1A-4340-A8C9-D5362609B0C1}"
RootNamespace="c02_custom_box_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c02_custom_box_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c02_custom_box_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c02_custom_box_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,86 @@
// 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)
//
// Custom Linestring Example
#include <iostream>
#include <string>
#include <vector>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
// To register the 'geographic' distance function to calculate distance over the earth:
#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp>
#include <boost/geometry/algorithms/parse.hpp>
// Define a GPS point with coordinates in latitude/longitude and some additional values
struct gps_point
{
double latitude, longitude, height;
double speed;
// Date/time, heading, etc could be added
// The default constructor is required if being used in a vector
gps_point() {}
// Define a constructor to create the point in one line. Order of latitude/longitude
// does not matter as long as "E", "N", etc are included
gps_point(std::string const& c1, std::string const& c2, double h, double s)
: height(h)
, speed(s)
{
boost::geometry::parse(*this, c1, c2);
}
};
// Declare a custom linestring which will have the GPS points
struct gps_track : std::vector<gps_point>
{
std::string owner;
int route_identifier;
// etc
gps_track(int i, std::string const& o)
: owner(o)
, route_identifier(i)
{}
};
// Register this point as being a recognizable point by the GGL
BOOST_GEOMETRY_REGISTER_POINT_2D(gps_point, double, cs::geographic<degree>, longitude, latitude)
// Register the track as well, as being a "linestring"
BOOST_GEOMETRY_REGISTER_LINESTRING(gps_track)
int main()
{
// Declare a "GPS Track" and add some GPS points
gps_track track(23, "Mister G");
track.push_back(gps_point("52 22 23 N", "4 53 32 E", 50, 180));
track.push_back(gps_point("52 10 00 N", "4 59 59 E", 110, 170));
track.push_back(gps_point("52 5 20 N", "5 6 56 E", 0, 90));
std::cout
<< "track: " << track.route_identifier << std::endl
<< "from: " << track.owner << std::endl
<< "as wkt: " << boost::geometry::dsv(track) << std::endl
<< "length: " << boost::geometry::length(track)/1000.0 << " km" << std::endl;
// Above gives the idea, shows that custom linestrings can be useful.
// We could of course do anything with this track which the library can handle, e.g.:
// - simplify it
// - calculate distance of point-to-line
// - project it to UTM, then transform it to a GIF image (see p03_example)
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c03_custom_linestring_example"
ProjectGUID="{D24F5517-E2B5-4933-B6E7-47A2F8A08911}"
RootNamespace="c03_custom_linestring_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c03_custom_linestring_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c03_custom_linestring_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c03_custom_linestring_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,79 @@
// 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)
//
// Custom Triangle Example
#include <iostream>
#include <boost/array.hpp>
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/util/write_dsv.hpp>
struct triangle : public boost::array<boost::geometry::point_xy<double>, 4>
{
inline void close()
{
(*this)[3] = (*this)[0];
}
};
BOOST_GEOMETRY_REGISTER_RING(triangle)
// Specializations of algorithms, where useful. If not specialized the default ones
// (for linear rings) will be used for triangle. Which is OK as long as the triangle
// is closed, that means, has 4 points (the last one being the first).
namespace boost { namespace geometry {
template<>
inline double area<triangle>(const triangle& t)
{
/* C
/ \
/ \
A-----B
((Bx - Ax) * (Cy - Ay)) - ((Cx - Ax) * (By - Ay))
-------------------------------------------------
2
*/
return 0.5 * ((t[1].x() - t[0].x()) * (t[2].y() - t[0].y())
- (t[2].x() - t[0].x()) * (t[1].y() - t[0].y()));
}
}} // namespace boost::geometry
int main()
{
triangle t;
t[0].x(0);
t[0].y(0);
t[1].x(5);
t[1].y(0);
t[2].x(2.5);
t[2].y(2.5);
t.close();
std::cout << "Triangle: " << boost::geometry::dsv(t) << std::endl;
std::cout << "Area: " << boost::geometry::area(t) << std::endl;
boost::geometry::point_xy<double> c;
boost::geometry::centroid(t, c);
std::cout << "Centroid: " << boost::geometry::dsv(c) << std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c04_a_custom_triangle_example"
ProjectGUID="{5E12A414-E180-4E5F-A575-CC98B449B278}"
RootNamespace="c04_a_custom_triangle_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c04_a_custom_triangle_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c04_a_custom_triangle_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c04_a_custom_triangle_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,68 @@
// 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)
//
// Custom triangle template Example
#include <iostream>
#include <boost/array.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/geometries/adapted/tuple.hpp>
#include <boost/geometry/geometries/adapted/tuple_cartesian.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/util/write_dsv.hpp>
template <typename P>
struct triangle : public boost::array<P, 3>
{
};
// Register triangle<P>
BOOST_GEOMETRY_REGISTER_RING_TEMPLATIZED(triangle)
namespace boost { namespace geometry { namespace dispatch {
// Specializations of area dispatch structure, implement algorithm
template<typename P, typename S>
struct area<ring_tag, triangle<P>, clockwise, S>
{
static inline double apply(triangle<P> const& t, S const&)
{
return 0.5 * ((get<0>(t[1]) - get<0>(t[0])) * (get<1>(t[2]) - get<1>(t[0]))
- (get<0>(t[2]) - get<0>(t[0])) * (get<1>(t[1]) - get<1>(t[0])));
}
};
}}} // namespace boost::geometry::dispatch
int main()
{
//triangle<boost::geometry::point_xy<double> > t;
triangle<boost::tuple<double, double> > t;
t[0] = boost::make_tuple(0, 0);
t[1] = boost::make_tuple(5, 0);
t[2] = boost::make_tuple(2.5, 2.5);
std::cout << "Triangle: " << boost::geometry::dsv(t) << std::endl;
std::cout << "Area: " << boost::geometry::area(t) << std::endl;
//boost::geometry::point_xy<double> c;
boost::tuple<double, double> c;
boost::geometry::centroid(t, c);
std::cout << "Centroid: " << boost::geometry::dsv(c) << std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c04_b_custom_triangle_example"
ProjectGUID="{D005D88D-50BD-4D80-8C3B-72F81B1B9719}"
RootNamespace="c04_b_custom_triangle_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c04_b_custom_triangle_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c04_b_custom_triangle_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c04_b_custom_triangle_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,113 @@
// 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)
//
// Custom pointer-to-point example
#include <iostream>
#include <boost/foreach.hpp>
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/make.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/std_as_linestring.hpp>
#include <boost/geometry/strategies/strategies.hpp>
// Sample point, having x/y
struct my_point
{
double x,y;
};
namespace boost { namespace geometry { namespace traits {
template<> struct tag<my_point*>
{ typedef point_tag type; };
template<> struct coordinate_type<my_point*>
{ typedef double type; };
template<> struct coordinate_system<my_point*>
{ typedef cs::cartesian type; };
template<> struct dimension<my_point*> : boost::mpl::int_<2> {};
template<>
struct access<my_point*, 0>
{
static double get(my_point const* p)
{
return p->x;
}
static void set(my_point* p, double const& value)
{
p->x = value;
}
};
template<>
struct access<my_point*, 1>
{
static double get(my_point const* p)
{
return p->y;
}
static void set(my_point* p, double const& value)
{
p->y = value;
}
};
}}} // namespace boost::geometry::traits
int main()
{
typedef std::vector<my_point*> ln;
ln myline;
for (float i = 0.0; i < 10.0; i++)
{
my_point* p = new my_point;
p->x = i;
p->y = i + 1;
myline.push_back(p);
}
std::cout << boost::geometry::length(myline) << std::endl;
boost::geometry::box_2d cb(boost::geometry::point_2d(1.5, 1.5), boost::geometry::point_2d(4.5, 4.5));
// This will NOT work because would need dynamicly allocating memory for point* in algorithms:
// std::vector<ln> clipped;
//boost::geometry::intersection(cb, myline, std::back_inserter(clipped));
// This works because outputs to a normal struct point, no point*
std::vector<boost::geometry::linestring_2d> clipped;
boost::geometry::strategy::intersection::liang_barsky<boost::geometry::box_2d, boost::geometry::point_2d> strategy;
boost::geometry::detail::intersection::clip_linestring_with_box<boost::geometry::linestring_2d>(cb,
myline, std::back_inserter(clipped), strategy);
std::cout << boost::geometry::length(clipped.front()) << std::endl;
// free
BOOST_FOREACH(my_point* p, myline)
{
delete p;
}
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c05_custom_point_pointer_example"
ProjectGUID="{DAC38456-5241-4DDB-87FF-74A2FF7DE368}"
RootNamespace="c05_custom_point_pointer_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c05_custom_point_pointer_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c05_custom_point_pointer_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c05_custom_point_pointer_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,133 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2007-2009, 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)
//
// Custom Polygon Example
#include <iostream>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
struct my_point
{
my_point(double an_x = 0, double an_y = 0)
: x(an_x)
, y(an_y)
{}
double x, y;
};
struct my_ring : std::deque<my_point>
{};
// Define a struct of a polygon, having always two holes
// (of course this can be implemented differently, usually
// with a vector or deque, but it is just an exampe)
struct my_polygon
{
// required for a polygon: an outer ring...
my_ring boundary;
// ... and a Boost.Range compatible inner ring collection
boost::array<my_ring, 2> holes;
// just for the sample
std::string name;
my_polygon(std::string const& n = "") : name(n) {}
};
// We can conveniently use macro's to register point and ring
BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_RING(my_ring)
// There is currently no registration macro for polygons
// and besides that a boost::array<T,N> in a macro would
// be very specific, so we show it "by hand":
namespace boost { namespace geometry { namespace traits
{
template<> struct tag<my_polygon> { typedef polygon_tag type; };
template<> struct ring_type<my_polygon> { typedef my_ring type; };
template<> struct interior_type<my_polygon>
{
typedef boost::array<my_ring, 2> type;
};
template<> struct exterior_ring<my_polygon>
{
static my_ring& get(my_polygon& p)
{
return p.boundary;
}
static my_ring const& get(my_polygon const& p)
{
return p.boundary;
}
};
template<> struct interior_rings<my_polygon>
{
typedef boost::array<my_ring, 2> holes_type;
static holes_type& get(my_polygon& p)
{
return p.holes;
}
static holes_type const& get(my_polygon const& p)
{
return p.holes;
}
};
}}} // namespace boost::geometry::traits
int main()
{
my_polygon p1("my polygon");
// Fill it the my-way, triangle
p1.boundary.push_back(my_point(2, 0));
p1.boundary.push_back(my_point(1, 5));
p1.boundary.push_back(my_point(5, 5));
p1.boundary.push_back(my_point(2, 0));
// Triangle
p1.holes[0].push_back(my_point(2, 1));
p1.holes[0].push_back(my_point(1.9, 2));
p1.holes[0].push_back(my_point(2.4, 2));
p1.holes[0].push_back(my_point(2, 1));
// Box
p1.holes[1].push_back(my_point(3, 3));
p1.holes[1].push_back(my_point(3, 4));
p1.holes[1].push_back(my_point(4, 4));
p1.holes[1].push_back(my_point(4, 3));
p1.holes[1].push_back(my_point(3, 3));
std::cout << "Representation of " << p1.name << ": "
<< boost::geometry::dsv(p1) << std::endl;
std::cout << "Area of " << p1.name << ": "
<< boost::geometry::area(p1) << std::endl;
std::cout << "Perimeter of " << p1.name << ": "
<< boost::geometry::perimeter(p1) << std::endl;
std::cout << "Centroid of " << p1.name << ": "
<< boost::geometry::dsv(boost::geometry::make_centroid<my_point>(p1)) << std::endl;
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c06_custom_polygon_example"
ProjectGUID="{A8AA1E80-2FC7-42C0-9920-B3E28D2C0665}"
RootNamespace="c06_custom_polygon_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c06_custom_polygon_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c06_custom_polygon_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c06_custom_polygon_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,131 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2007-2009, 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)
//
// Custom pointer-to-point example
#include <iostream>
#include <boost/foreach.hpp>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/std_as_ring.hpp>
// Sample point, having x/y
struct my_point
{
my_point(double a = 0, double b = 0)
: x(a), y(b)
{}
double x,y;
};
namespace boost { namespace geometry { namespace traits {
template<> struct tag<my_point*>
{ typedef point_tag type; };
template<> struct coordinate_type<my_point*>
{ typedef double type; };
template<> struct coordinate_system<my_point*>
{ typedef cs::cartesian type; };
template<> struct dimension<my_point*> : boost::mpl::int_<2> {};
template<>
struct access<my_point*, 0>
{
static double get(my_point const* p)
{
return p->x;
}
static void set(my_point* p, double const& value)
{
p->x = value;
}
};
template<>
struct access<my_point*, 1>
{
static double get(my_point const* p)
{
return p->y;
}
static void set(my_point* p, double const& value)
{
p->y = value;
}
};
}}} // namespace boost::geometry::traits
int main()
{
typedef std::vector<my_point*> ring_type;
ring_type a, b;
a.push_back(new my_point(0, 1));
a.push_back(new my_point(2, 5));
a.push_back(new my_point(5, 3));
a.push_back(new my_point(0, 1));
b.push_back(new my_point(3, 0));
b.push_back(new my_point(0, 3));
b.push_back(new my_point(4, 5));
b.push_back(new my_point(3, 0));
double aa = boost::geometry::area(a);
double ab = boost::geometry::area(b);
// This will NOT work because would need dynamicly allocating memory for point* in algorithms:
//std::vector<ring_type> unioned;
//boost::geometry::union<ring_type>(a, b, std::back_inserter(unioned));
std::vector<boost::geometry::ring_2d> unioned;
std::vector<boost::geometry::ring_2d> intersected;
boost::geometry::intersection_inserter<boost::geometry::ring_2d>(a, b, std::back_inserter(intersected));
boost::geometry::union_inserter<boost::geometry::ring_2d>(a, b, std::back_inserter(unioned));
double ai = 0, au = 0;
BOOST_FOREACH(boost::geometry::ring_2d const& ring, intersected)
{
ai += boost::geometry::area(ring);
}
BOOST_FOREACH(boost::geometry::ring_2d const& ring, unioned)
{
au += boost::geometry::area(ring);
}
std::cout << "a: " << aa << std::endl;
std::cout << "b: " << ab << std::endl;
std::cout << "a & b: " << ai << std::endl;
std::cout << "a | b: " << au << std::endl;
std::cout << "a + b - (a & b): " << (aa + ab - ai) << std::endl;
// free
BOOST_FOREACH(my_point* p, a)
{
delete p;
}
BOOST_FOREACH(my_point* p, b)
{
delete p;
}
return 0;
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c07_custom_ring_pointer_example"
ProjectGUID="{158FBCF6-2FFE-447B-8EB1-07E22B0BE724}"
RootNamespace="c07_custom_ring_pointer_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c07_custom_ring_pointer_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c07_custom_ring_pointer_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c07_custom_ring_pointer_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,326 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2009, 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)
//
// Custom polygon example
#ifndef _MSC_VER
#warning "Currently only works for MSVC"
int main() { return 0; }
#else
#include <iostream>
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/util/add_const_if_c.hpp>
// Sample point, having x/y
struct my_point
{
my_point(double a = 0, double b = 0)
: x(a), y(b)
{}
double x,y;
};
// Sample polygon, having legacy methods
// (similar to e.g. COM objects)
class my_polygon
{
std::vector<my_point> points;
public :
void add_point(my_point const& p) { points.push_back(p); }
my_point const& get_point(std::size_t i) const
{
assert(i < points.size());
return points[i];
}
// Non const access
my_point & get_point(std::size_t i)
{
assert(i < points.size());
return points[i];
}
int point_count() const { return points.size(); }
void erase_all() { points.clear(); }
// Note: it IS possible to have different method names;
// however, there should (probably) be two different
// iterators then or an iterator with a specified policy).
// Note 2: if there is a set_point function, the iterator
// does not have a way to dereference and non-const
// iterators will not work!
};
// ----------------------------------------------------------------------------
// Adaption: implement iterator and range-extension, and register with GGL
// 1) implement iterator (const and non-const versions)
template <bool IsConst>
struct custom_iterator : public boost::iterator_facade
<
custom_iterator<IsConst>,
my_point,
boost::random_access_traversal_tag,
typename boost::geometry::add_const_if_c<IsConst, my_point>::type&
>
{
// Constructor for begin()
explicit custom_iterator(typename boost::geometry::add_const_if_c<IsConst, my_polygon>::type& polygon)
: m_polygon(&polygon)
, m_index(0)
{}
// Constructor for end()
explicit custom_iterator(bool, typename boost::geometry::add_const_if_c<IsConst, my_polygon>::type& polygon)
: m_polygon(&polygon)
, m_index(polygon.point_count())
{}
private:
friend class boost::iterator_core_access;
typedef boost::iterator_facade
<
custom_iterator<IsConst>,
my_point,
boost::random_access_traversal_tag,
typename boost::geometry::add_const_if_c<IsConst, my_point>::type&
> facade;
typename boost::geometry::add_const_if_c<IsConst, my_polygon>::type* m_polygon;
int m_index;
bool equal(custom_iterator const& other) const
{
return this->m_index == other.m_index;
}
typename facade::difference_type distance_to(custom_iterator const& other) const
{
return other.m_index - this->m_index;
}
void advance(typename facade::difference_type n)
{
m_index += n;
if(m_polygon != NULL
&& (m_index >= m_polygon->point_count()
|| m_index < 0)
)
{
m_index = m_polygon->point_count();
}
}
void increment()
{
advance(1);
}
void decrement()
{
advance(-1);
}
// const and non-const dereference of this iterator
typename boost::geometry::add_const_if_c<IsConst, my_point>::type& dereference() const
{
return m_polygon->get_point(m_index);
}
};
// 2) Implement Boost.Range const functionality
// using method 2, "provide free-standing functions and specialize metafunctions"
// 2a) meta-functions
namespace boost
{
template<> struct range_iterator<my_polygon>
{
typedef custom_iterator<false> type;
};
template<> struct range_const_iterator<my_polygon>
{
typedef custom_iterator<true> type;
};
// RangeEx
template<> struct range_size<my_polygon>
{
typedef std::size_t type;
};
} // namespace 'boost'
// 2b) free-standing function for Boost.Range ADP
inline custom_iterator<false> range_begin(my_polygon& polygon)
{
return custom_iterator<false>(polygon);
}
inline custom_iterator<true> range_begin(my_polygon const& polygon)
{
return custom_iterator<true>(polygon);
}
inline custom_iterator<false> range_end(my_polygon& polygon)
{
return custom_iterator<false>(true, polygon);
}
inline custom_iterator<true> range_end(my_polygon const& polygon)
{
return custom_iterator<true>(true, polygon);
}
// RangeEx
inline std::size_t range_size(my_polygon const& polygon)
{
return polygon.point_count();
}
// 3) optional, for writable geometries only, implement back_inserter (=push_back)
class custom_insert_iterator
{
my_polygon* m_polygon;
public:
typedef std::output_iterator_tag iterator_category;
// Not relevant for output iterator
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
typedef void const_reference;
explicit custom_insert_iterator(my_polygon& x)
: m_polygon(&x)
{}
custom_insert_iterator& operator=(my_point const & p)
{
m_polygon->add_point(p);
return *this;
}
custom_insert_iterator& operator*() { return *this; }
custom_insert_iterator& operator++() { return *this; }
custom_insert_iterator& operator++(int) { return *this; }
};
namespace std
{
custom_insert_iterator back_inserter(my_polygon& polygon)
{
return custom_insert_iterator(polygon);
}
}
// 4) register with GGL
BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_RING(my_polygon)
// end adaption
// ----------------------------------------------------------------------------
void walk_using_iterator(my_polygon const& polygon)
{
for (custom_iterator<true> it = custom_iterator<true>(polygon);
it != custom_iterator<true>(true, polygon);
++it)
{
std::cout << boost::geometry::dsv(*it) << std::endl;
}
std::cout << std::endl;
}
void walk_using_range(my_polygon const& polygon)
{
for (boost::range_iterator<const my_polygon>::type it
= boost::begin(polygon);
it != boost::end(polygon);
++it)
{
std::cout << boost::geometry::dsv(*it) << std::endl;
}
std::cout << std::endl;
}
int main()
{
my_polygon container1;
// Create (as an example) a regular polygon
const int n = 5;
const double d = (360 / n) * boost::geometry::math::d2r;
double a = 0;
for (int i = 0; i < n + 1; i++, a += d)
{
container1.add_point(my_point(sin(a), cos(a)));
}
std::cout << "Walk using Boost.Iterator derivative" << std::endl;
walk_using_iterator(container1);
std::cout << "Walk using Boost.Range extension" << std::endl << std::endl;
walk_using_range(container1);
std::cout << "Use it by GGL" << std::endl;
std::cout << "Area: " << boost::geometry::area(container1) << std::endl;
// Container 2 will be modified by GGL. Add all points but the last one.
my_polygon container2;
for (int i = 0; i < n; i++)
{
// Use here the std::/GGL way of inserting (but the my_polygon way of getting)
*(std::back_inserter(container2)++) = container1.get_point(i);
}
std::cout << "Second container is not closed:" << std::endl;
walk_using_range(container2);
// Correct (= close it)
boost::geometry::correct(container2);
std::cout << "Now it is closed:" << std::endl;
walk_using_range(container2);
std::cout << "Area: " << boost::geometry::area(container2) << std::endl;
// Use things from std:: using Boost.Range
std::reverse(boost::begin(container2), boost::end(container2));
std::cout << "Area reversed: " << boost::geometry::area(container2) << std::endl;
return 0;
}
#endif

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="c08_custom_non_std_example"
ProjectGUID="{C215F131-F021-4155-A96E-BB2D91918A17}"
RootNamespace="c08_custom_non_std_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c08_custom_non_std_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="3"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\c08_custom_non_std_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\c08_custom_non_std_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,67 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c01_custom_point_example", "c01_custom_point_example.vcproj", "{B368C99D-8464-493C-A05B-904F53909046}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c04_a_custom_triangle_example", "c04_a_custom_triangle_example.vcproj", "{5E12A414-E180-4E5F-A575-CC98B449B278}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c04_b_custom_triangle_example", "c04_b_custom_triangle_example.vcproj", "{D005D88D-50BD-4D80-8C3B-72F81B1B9719}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c02_custom_box_example", "c02_custom_box_example.vcproj", "{1A68AD9E-7C1A-4340-A8C9-D5362609B0C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c03_custom_linestring_example", "c03_custom_linestring_example.vcproj", "{D24F5517-E2B5-4933-B6E7-47A2F8A08911}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c05_custom_point_pointer_example", "c05_custom_point_pointer_example.vcproj", "{DAC38456-5241-4DDB-87FF-74A2FF7DE368}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c06_custom_polygon_example", "c06_custom_polygon_example.vcproj", "{A8AA1E80-2FC7-42C0-9920-B3E28D2C0665}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c07_custom_ring_pointer_example", "c07_custom_ring_pointer_example.vcproj", "{158FBCF6-2FFE-447B-8EB1-07E22B0BE724}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c08_custom_non_std_example", "c08_custom_non_std_example.vcproj", "{C215F131-F021-4155-A96E-BB2D91918A17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B368C99D-8464-493C-A05B-904F53909046}.Debug|Win32.ActiveCfg = Debug|Win32
{B368C99D-8464-493C-A05B-904F53909046}.Debug|Win32.Build.0 = Debug|Win32
{B368C99D-8464-493C-A05B-904F53909046}.Release|Win32.ActiveCfg = Release|Win32
{B368C99D-8464-493C-A05B-904F53909046}.Release|Win32.Build.0 = Release|Win32
{5E12A414-E180-4E5F-A575-CC98B449B278}.Debug|Win32.ActiveCfg = Debug|Win32
{5E12A414-E180-4E5F-A575-CC98B449B278}.Debug|Win32.Build.0 = Debug|Win32
{5E12A414-E180-4E5F-A575-CC98B449B278}.Release|Win32.ActiveCfg = Release|Win32
{5E12A414-E180-4E5F-A575-CC98B449B278}.Release|Win32.Build.0 = Release|Win32
{D005D88D-50BD-4D80-8C3B-72F81B1B9719}.Debug|Win32.ActiveCfg = Debug|Win32
{D005D88D-50BD-4D80-8C3B-72F81B1B9719}.Debug|Win32.Build.0 = Debug|Win32
{D005D88D-50BD-4D80-8C3B-72F81B1B9719}.Release|Win32.ActiveCfg = Release|Win32
{D005D88D-50BD-4D80-8C3B-72F81B1B9719}.Release|Win32.Build.0 = Release|Win32
{1A68AD9E-7C1A-4340-A8C9-D5362609B0C1}.Debug|Win32.ActiveCfg = Debug|Win32
{1A68AD9E-7C1A-4340-A8C9-D5362609B0C1}.Debug|Win32.Build.0 = Debug|Win32
{1A68AD9E-7C1A-4340-A8C9-D5362609B0C1}.Release|Win32.ActiveCfg = Release|Win32
{1A68AD9E-7C1A-4340-A8C9-D5362609B0C1}.Release|Win32.Build.0 = Release|Win32
{D24F5517-E2B5-4933-B6E7-47A2F8A08911}.Debug|Win32.ActiveCfg = Debug|Win32
{D24F5517-E2B5-4933-B6E7-47A2F8A08911}.Debug|Win32.Build.0 = Debug|Win32
{D24F5517-E2B5-4933-B6E7-47A2F8A08911}.Release|Win32.ActiveCfg = Release|Win32
{D24F5517-E2B5-4933-B6E7-47A2F8A08911}.Release|Win32.Build.0 = Release|Win32
{DAC38456-5241-4DDB-87FF-74A2FF7DE368}.Debug|Win32.ActiveCfg = Debug|Win32
{DAC38456-5241-4DDB-87FF-74A2FF7DE368}.Debug|Win32.Build.0 = Debug|Win32
{DAC38456-5241-4DDB-87FF-74A2FF7DE368}.Release|Win32.ActiveCfg = Release|Win32
{DAC38456-5241-4DDB-87FF-74A2FF7DE368}.Release|Win32.Build.0 = Release|Win32
{A8AA1E80-2FC7-42C0-9920-B3E28D2C0665}.Debug|Win32.ActiveCfg = Debug|Win32
{A8AA1E80-2FC7-42C0-9920-B3E28D2C0665}.Debug|Win32.Build.0 = Debug|Win32
{A8AA1E80-2FC7-42C0-9920-B3E28D2C0665}.Release|Win32.ActiveCfg = Release|Win32
{A8AA1E80-2FC7-42C0-9920-B3E28D2C0665}.Release|Win32.Build.0 = Release|Win32
{158FBCF6-2FFE-447B-8EB1-07E22B0BE724}.Debug|Win32.ActiveCfg = Debug|Win32
{158FBCF6-2FFE-447B-8EB1-07E22B0BE724}.Debug|Win32.Build.0 = Debug|Win32
{158FBCF6-2FFE-447B-8EB1-07E22B0BE724}.Release|Win32.ActiveCfg = Release|Win32
{158FBCF6-2FFE-447B-8EB1-07E22B0BE724}.Release|Win32.Build.0 = Release|Win32
{C215F131-F021-4155-A96E-BB2D91918A17}.Debug|Win32.ActiveCfg = Debug|Win32
{C215F131-F021-4155-A96E-BB2D91918A17}.Debug|Win32.Build.0 = Debug|Win32
{C215F131-F021-4155-A96E-BB2D91918A17}.Release|Win32.ActiveCfg = Release|Win32
{C215F131-F021-4155-A96E-BB2D91918A17}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

21
example/data/cities.sql Normal file
View File

@ -0,0 +1,21 @@
-- script to generate cities table for PostGis
-- used in examples
-- Source: http://www.realestate3d.com/gps/latlong.htm
create user ggl password 'ggl' createdb;
create database ggl owner=ggl template=postgis;
drop table if exists cities;
create table cities(id serial primary key, name varchar(25));
select addgeometrycolumn('','cities','location','4326','POINT',2);
insert into cities(location, name) values(GeometryFromText('POINT( -71.03 42.37)', 4326), 'Boston');
insert into cities(location, name) values(GeometryFromText('POINT( -87.65 41.90)', 4326), 'Chicago');
insert into cities(location, name) values(GeometryFromText('POINT( -95.35 29.97)', 4326), 'Houston');
insert into cities(location, name) values(GeometryFromText('POINT(-118.40 33.93)', 4326), 'Los Angeles');
insert into cities(location, name) values(GeometryFromText('POINT( -80.28 25.82)', 4326), 'Miami');
insert into cities(location, name) values(GeometryFromText('POINT( -73.98 40.77)', 4326), 'New York');
insert into cities(location, name) values(GeometryFromText('POINT(-112.02 33.43)', 4326), 'Phoenix');
insert into cities(location, name) values(GeometryFromText('POINT( -77.04 38.85)', 4326), 'Washington DC');

10
example/data/cities.wkt Normal file
View File

@ -0,0 +1,10 @@
# Source: http://www.realestate3d.com/gps/latlong.htm
# Note: selected and converted manually
POINT( -71.03 42.37) ; Boston
POINT( -87.65 41.90) ; Chicago
POINT( -95.35 29.97) ; Houston
POINT(-118.40 33.93) ; Los Angeles
POINT( -80.28 25.82) ; Miami
POINT( -73.98 40.77) ; New York
POINT(-112.02 33.43) ; Phoenix
POINT( -77.04 38.85) ; Washington DC

1331
example/data/roads.wkt Normal file

File diff suppressed because it is too large Load Diff

49
example/ggl_examples.sln Normal file
View File

@ -0,0 +1,49 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "01_point_example", "01_point_example.vcproj", "{E7BFC111-F0E5-420F-869C-1FC3212270B5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02_linestring_example", "02_linestring_example.vcproj", "{D5CE1A26-1EB7-44A4-84F9-526CFA8C2B74}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03_polygon_example", "03_polygon_example.vcproj", "{1E299DA7-CFD1-4586-B0B0-1ABF2A32ED5B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "06_a_transformation_example", "06_a_transformation_example.vcproj", "{34346EC5-1EE8-49D5-AF24-D915B4D7D144}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "07_graph_route_example", "07_graph_route_example.vcproj", "{47D30DD8-CBB1-4527-811F-F0193E22B317}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "06_b_transformation_example", "06_b_transformation_example.vcproj", "{34346EC5-1EE8-49D5-AC21-D915B4D7D144}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E7BFC111-F0E5-420F-869C-1FC3212270B5}.Debug|Win32.ActiveCfg = Debug|Win32
{E7BFC111-F0E5-420F-869C-1FC3212270B5}.Debug|Win32.Build.0 = Debug|Win32
{E7BFC111-F0E5-420F-869C-1FC3212270B5}.Release|Win32.ActiveCfg = Release|Win32
{E7BFC111-F0E5-420F-869C-1FC3212270B5}.Release|Win32.Build.0 = Release|Win32
{D5CE1A26-1EB7-44A4-84F9-526CFA8C2B74}.Debug|Win32.ActiveCfg = Debug|Win32
{D5CE1A26-1EB7-44A4-84F9-526CFA8C2B74}.Debug|Win32.Build.0 = Debug|Win32
{D5CE1A26-1EB7-44A4-84F9-526CFA8C2B74}.Release|Win32.ActiveCfg = Release|Win32
{D5CE1A26-1EB7-44A4-84F9-526CFA8C2B74}.Release|Win32.Build.0 = Release|Win32
{1E299DA7-CFD1-4586-B0B0-1ABF2A32ED5B}.Debug|Win32.ActiveCfg = Debug|Win32
{1E299DA7-CFD1-4586-B0B0-1ABF2A32ED5B}.Debug|Win32.Build.0 = Debug|Win32
{1E299DA7-CFD1-4586-B0B0-1ABF2A32ED5B}.Release|Win32.ActiveCfg = Release|Win32
{1E299DA7-CFD1-4586-B0B0-1ABF2A32ED5B}.Release|Win32.Build.0 = Release|Win32
{34346EC5-1EE8-49D5-AF24-D915B4D7D144}.Debug|Win32.ActiveCfg = Debug|Win32
{34346EC5-1EE8-49D5-AF24-D915B4D7D144}.Debug|Win32.Build.0 = Debug|Win32
{34346EC5-1EE8-49D5-AF24-D915B4D7D144}.Release|Win32.ActiveCfg = Release|Win32
{34346EC5-1EE8-49D5-AF24-D915B4D7D144}.Release|Win32.Build.0 = Release|Win32
{47D30DD8-CBB1-4527-811F-F0193E22B317}.Debug|Win32.ActiveCfg = Debug|Win32
{47D30DD8-CBB1-4527-811F-F0193E22B317}.Debug|Win32.Build.0 = Debug|Win32
{47D30DD8-CBB1-4527-811F-F0193E22B317}.Release|Win32.ActiveCfg = Release|Win32
{47D30DD8-CBB1-4527-811F-F0193E22B317}.Release|Win32.Build.0 = Release|Win32
{34346EC5-1EE8-49D5-AC21-D915B4D7D144}.Debug|Win32.ActiveCfg = Debug|Win32
{34346EC5-1EE8-49D5-AC21-D915B4D7D144}.Debug|Win32.Build.0 = Debug|Win32
{34346EC5-1EE8-49D5-AC21-D915B4D7D144}.Release|Win32.ActiveCfg = Release|Win32
{34346EC5-1EE8-49D5-AC21-D915B4D7D144}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

37
example/soci_examples.sln Normal file
View File

@ -0,0 +1,37 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_a_soci_example", "x03_a_soci_example.vcproj", "{C3B3143D-F354-4036-9DA1-5975D8A4F166}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_b_soci_example", "x03_b_soci_example.vcproj", "{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_c_soci_example", "x03_c_soci_example.vcproj", "{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_d_soci_example", "x03_d_soci_example.vcproj", "{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C3B3143D-F354-4036-9DA1-5975D8A4F166}.Debug|Win32.ActiveCfg = Debug|Win32
{C3B3143D-F354-4036-9DA1-5975D8A4F166}.Debug|Win32.Build.0 = Debug|Win32
{C3B3143D-F354-4036-9DA1-5975D8A4F166}.Release|Win32.ActiveCfg = Release|Win32
{C3B3143D-F354-4036-9DA1-5975D8A4F166}.Release|Win32.Build.0 = Release|Win32
{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Debug|Win32.ActiveCfg = Debug|Win32
{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Debug|Win32.Build.0 = Debug|Win32
{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Release|Win32.ActiveCfg = Release|Win32
{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Release|Win32.Build.0 = Release|Win32
{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Debug|Win32.ActiveCfg = Debug|Win32
{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Debug|Win32.Build.0 = Debug|Win32
{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Release|Win32.ActiveCfg = Release|Win32
{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Release|Win32.Build.0 = Release|Win32
{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Debug|Win32.ActiveCfg = Debug|Win32
{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Debug|Win32.Build.0 = Debug|Win32
{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Release|Win32.ActiveCfg = Release|Win32
{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,90 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2007-2009, 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)
// Qt Example
// Qt is a well-known and often used platform independent widget library
// To build and run this example:
// 1) download (from http://qt.nokia.com), configure and make QT
// 2) if necessary, adapt Qt clause in include path
#include <sstream>
#include <QtGui>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
// Adapt a QPointF such that it can be handled by GGL
BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(QPointF, double, cs::cartesian, x, y, setX, setY)
// Adapt a QPolygonF as well.
// A QPolygonF has no holes (interiors) so it is similar to a GGL ring
BOOST_GEOMETRY_REGISTER_RING(QPolygonF)
int main(int argc, char *argv[])
{
// This usage QApplication and QLabel is adapted from
// http://en.wikipedia.org/wiki/Qt_(toolkit)#Qt_hello_world
QApplication app(argc, argv);
// Declare a polygon. This is just Qt. The Qt Polygon can be used
// in GGL as well, just by its oneline registration above.
QPolygonF polygon;
// Qt methods can be used, in this case to add points
polygon
<< QPointF(10, 20) << QPointF(20, 30)
<< QPointF(30, 20) << QPointF(20, 10)
<< QPointF(10, 20);
// GGL methods can be used, e.g. to calculate area
std::ostringstream out;
out << "GGL area: " << boost::geometry::area(polygon) << std::endl;
// Some functionality is defined in both Qt and GGL
QPointF p(20,20);
out << "Qt contains: "
<< (polygon.containsPoint(p, Qt::WindingFill) ? "yes" : "no")
<< std::endl
<< "GGL within: "
<< (boost::geometry::within(p, polygon) ? "yes" : "no")
<< std::endl;
// Detail: if point is ON boundary, Qt says yes, GGL says no.
// Qt defines an iterator
// (which is actually required for GGL, it's part of the ring-concept)
// such that GGL can use the points of this polygon
QPolygonF::const_iterator it;
for (it = polygon.begin(); it != polygon.end(); ++it)
{
// Stream Delimiter-Separated, just to show something GGL can do
out << boost::geometry::dsv(*it) << std::endl;
}
// Stream the polygon as well
out << boost::geometry::dsv(polygon) << std::endl;
// Just show what we did in a label
QLabel label(out.str().c_str());
label.show();
return app.exec();
// What else could be useful, functionality that GGL has and Qt not (yet)?
// - simplify a polygon (to get less points and preserve shape)
// - clip a polygon with a box
// - calculate the centroid
// - calculate the perimeter
// - calculate the convex hull
// - transform it using matrix transformations
}

View File

@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x01_qt_example", "x01_qt_example.vcproj", "{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Debug|Win32.ActiveCfg = Debug|Win32
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Debug|Win32.Build.0 = Debug|Win32
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Release|Win32.ActiveCfg = Release|Win32
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="x01_qt_example"
ProjectGUID="{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x01_qt_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="c:\Qt\2009.03\qt\include;c:\Qt\2009.03\qt\include\QtGui"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="qtmain.lib QtGui4.lib QtCore4.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="c:\Qt\2009.03\qt\lib "
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x01_qt_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="c:\Qt\2009.03\qt\include;c:\Qt\2009.03\qt\include\QtGui"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="qtmain.lib QtGui4.lib QtCore4.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="c:\Qt\2009.03\qt\lib "
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\x01_qt_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,139 @@
// 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)
// Numeric Adaptor Example
// The Numeric Adaptor is introduced to the Boost mailing list
// It is a proxy to high precision arithmetic libraries such as gmp
// However, it might be that the same effect can be used using the
// Boost.Math bindings.
// To build and run this example:
// 1) download gmp, it should be somewhere in the include path
// 2) download numeric_adaptor from the Boost.Sandbox
#include <iostream>
#include <iomanip>
#include <typeinfo>
#include <boost/numeric_adaptor/numeric_adaptor.hpp>
#include <boost/numeric_adaptor/gmp_value_type.hpp>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
template <typename Type, typename AssignType>
void calculate(AssignType const& x1,
AssignType const& y1,
AssignType const& x2,
AssignType const& y2,
AssignType const& x3,
AssignType const& y3
)
{
// gmp can be used instead of "double" for any point type
typedef boost::geometry::point_xy<Type> point_type;
point_type a, b, c;
boost::geometry::assign(a, boost::to<Type>(x1), boost::to<Type>(y1));
boost::geometry::assign(b, boost::to<Type>(x2), boost::to<Type>(y2));
boost::geometry::assign(c, boost::to<Type>(x3), boost::to<Type>(y3));
boost::geometry::linear_ring<point_type> r;
r.push_back(a);
r.push_back(b);
r.push_back(c);
r.push_back(a);
// What also is possible is define point coordinates using IEEE double,
// but doing calculations using the gmp type.
// To do that, specify the strategy explicitly
Type ab = boost::geometry::distance(a, b);
Type bc = boost::geometry::distance(b, c);
Type ca = boost::geometry::distance(c, a);
std::cout << std::endl << typeid(Type).name() << std::endl;
std::cout << "a-b: " << ab << std::endl;
std::cout << "b-c: " << bc << std::endl;
std::cout << "c-a: " << ca << std::endl;
std::cout << "area: " << boost::geometry::area(r,
boost::geometry::strategy::area::by_triangles<point_type, Type>())
<< std::endl;
// Heron formula is "famous" for its imprecision. It should give
// same result as area, but is sensible for rounding errors.
Type s = ab + bc + ca;
s /= 2.0;
Type ar = boost::sqrt(s * (s - ab) * (s - bc) * (s - ca));
std::cout << "heron: " << ar << std::endl;
// Area's given:
// float: 740.74078369140625
// double: 740.74073407406990554591
// long double: 740.74073407406991376156
// GMP: 0.74074073407407e3 (right!)
// SQL Server: 740.740724252642
// Postgis: 740.74073407407 (might be rounded from (long) double)
// MySQL: 740.74073407406991000000
}
int main(int argc, char *argv[])
{
typedef boost::numeric_adaptor::gmp_value_type type;
//typedef long double type;
// gmp can be used instead of "double" for any point type
typedef boost::geometry::point_xy<type> point_type;
// Points, polygons or other geometries are gmp now
point_type p;
// They can be used normally
boost::geometry::set<0>(p, 123456.78900001);
std::cout << "x coordinate: " << boost::geometry::get<0>(p) << std::endl;
// But the value above cannot be expressed with that precision in IEEE 64 bits.
// Points can therefore also be assigned by string with boost::geometry::set
// (boost::to is a converser included in the Numeric Adaptor sources)
boost::geometry::set<0>(p, boost::to<type>(std::string("123456.78900001")));
// and streamed (as a string representation)
std::cout << "x coordinate: " << boost::geometry::get<0>(p) << std::endl;
// The boost::geometry::assign function also supports custom numeric types
point_type p1, p2;
boost::geometry::assign(p1,
boost::to<type>(std::string("123456.78900001")),
boost::to<type>(std::string("234567.89100001")));
boost::geometry::assign(p2,
boost::to<type>(std::string("987654.32100001")),
boost::to<type>(std::string("876543.21900001")));
type d = boost::geometry::distance(p1, p2);
std::cout << "Exact distance: " << d << std::endl;
// It gives: 0.1076554 54858339556783e7
// my calculator gives: 1076554.5485833955678294387789057
// CLN gives : 1076554.5485833955
// All algorithms will automatically use the gmp-type
// We show and compare that in the calculate function, with type and
// assigning type as template parameters
std::cout << std::fixed << std::setprecision(20);
calculate<float>(0.0, 0.0, 0.0, 0.0012, 1234567.89012345, 0.0);
calculate<double>(0.0, 0.0, 0.0, 0.0012, 1234567.89012345, 0.0);
calculate<long double>(0.0, 0.0, 0.0, 0.0012, 1234567.89012345, 0.0);
calculate<type, std::string>("0.0", "0.0", "0.0", "0.0012", "1234567.89012345", "0.0");
return 0;
}

View File

@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x02_numeric_adaptor_example", "x02_numeric_adaptor_example.vcproj", "{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Debug|Win32.ActiveCfg = Debug|Win32
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Debug|Win32.Build.0 = Debug|Win32
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Release|Win32.ActiveCfg = Release|Win32
{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="x02_numeric_adaptor_example"
ProjectGUID="{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
RootNamespace="x02_numeric_adaptor_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x02_numeric_adaptor_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;c:\gmp\gmp-dynamic&quot;;c:\svn\numeric_adaptor"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="gmp.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;C:\gmp\gmp-dynamic&quot;"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x02_numeric_adaptor_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;c:\gmp\gmp-dynamic&quot;;c:\svn\numeric_adaptor"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="gmp.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;C:\gmp\gmp-dynamic&quot;"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\x02_numeric_adaptor_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,78 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2007-2009, 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)
// SOCI example
// a: using boost::tuple to retrieve points
// SOCI is a generic C++ template interface to access relational databases
// To build and run this example:
// 1) download SOCI from http://soci.sourceforge.net/
// 2) put it in contrib/soci-3.0.0 (or another version/folder, but then update this VCPROJ)
// 3) adapt your makefile or use this VCPROJ file
// (note that SOCI sources are included directly, building SOCI is not necessary)
// 4) load the demo-data, see script data/cities.sql (for PostgreSQL)
#include <soci.h>
#include <soci-postgresql.h>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <boost/timer.hpp>
#include <boost/random.hpp>
#include <boost/tuple/tuple.hpp>
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>
#include <exception>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/adapted/tuple_cartesian.hpp>
#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
int main()
{
try
{
soci::session sql(soci::postgresql, "dbname=ggl user=ggl password=ggl");
int count;
sql << "select count(*) from cities", soci::into(count);
std::cout << "# Capitals: " << count << std::endl;
typedef std::vector<boost::tuple<double, double> > V;
soci::rowset<boost::tuple<double, double> > rows
= sql.prepare << "select x(location),y(location) from cities";
V vec;
std::copy(rows.begin(), rows.end(), std::back_inserter(vec));
for (V::const_iterator it = vec.begin(); it != vec.end(); ++it)
{
std::cout << it->get<0>() << " " << it->get<1>() << std::endl;
}
// Calculate distances
for (V::const_iterator it1 = vec.begin(); it1 != vec.end(); ++it1)
{
for (V::const_iterator it2 = vec.begin(); it2 != vec.end(); ++it2)
{
std::cout << boost::geometry::dsv(*it1) << " " << boost::geometry::distance(*it1, *it2) << std::endl;
}
}
}
catch (std::exception const &e)
{
std::cerr << "Error: " << e.what() << '\n';
}
return 0;
}

View File

@ -0,0 +1,727 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="x03_a_soci_example"
ProjectGUID="{C3B3143D-F354-4036-9DA1-5975D8A4F166}"
RootNamespace="x03_a_soci_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)/x03_a_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x03_a_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="soci_postgresql"
>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\common.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\factory.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\row-id.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="soci_core"
>
<File
RelativePath="contrib\soci-3.0.0\src\core\backend-loader.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\connection-pool.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\error.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\once-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\prepare-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\procedure.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-prepare-info.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\row.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\rowid.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\transaction.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\values.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath=".\x03_a_soci_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,100 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 2007-2009, 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)
// SOCI example
// b: using WKT to retrieve points
// To build and run this example, see comments in example a
#include <soci.h>
#include <soci-postgresql.h>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <boost/timer.hpp>
#include <boost/random.hpp>
#include <boost/tuple/tuple.hpp>
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>
#include <exception>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
struct city
{
boost::geometry::point<float, 2, boost::geometry::cs::geographic<boost::geometry::degree> > location;
std::string name;
};
namespace soci
{
template <>
struct type_conversion<city>
{
typedef soci::values base_type;
static void from_base(const base_type& v, soci::indicator ind, city& value)
{
try
{
value.name = v.get<std::string>("name");
boost::geometry::read_wkt(v.get<std::string>("wkt"), value.location);
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}
static void to_base(const city& value, base_type& v, soci::indicator& ind)
{
v.set("name", value.name);
std::ostringstream out;
out << boost::geometry::wkt(value.location);
v.set("wkt", out.str());
ind = i_ok;
}
};
}
int main()
{
try
{
soci::session sql(soci::postgresql, "dbname=ggl user=ggl password=ggl");
typedef std::vector<city> V;
soci::rowset<city> rows = sql.prepare << "select name,astext(location) as wkt from cities";
V vec;
std::copy(rows.begin(), rows.end(), std::back_inserter(vec));
for (V::const_iterator it = vec.begin(); it != vec.end(); ++it)
{
static const double sqrkm = 1000.0 * 1000.0;
std::cout << it->name
<< " " << boost::geometry::dsv(it->location)
//<< " " << boost::geometry::area(it->shape) / sqrkm << " km2"
<< std::endl;
}
}
catch (std::exception const &e)
{
std::cerr << "Error: " << e.what() << '\n';
}
return 0;
}

View File

@ -0,0 +1,727 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="x03_b_soci_example"
ProjectGUID="{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}"
RootNamespace="x03_b_soci_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)/x03_b_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x03_b_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="soci_postgresql"
>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\common.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\factory.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\row-id.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="soci_core"
>
<File
RelativePath="contrib\soci-3.0.0\src\core\backend-loader.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\connection-pool.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\error.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\once-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\prepare-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\procedure.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-prepare-info.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\row.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\rowid.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\transaction.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\values.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath=".\x03_b_soci_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,118 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Mateusz Loskot 2009, mateusz@loskot.net
//
// 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)
// Boost.Geometry (aka GGL, Generic Geometry Library)
// SOCI example
// c: using WKB to retrieve geometries
// SOCI is a generic C++ template interface to access relational databases
// To build and run this example, see comments in example a
// Alternatively compile composing and executing compiler command directoy in examples directory,
// for example using GCC compiler:
// g++ -I../../../boost -I/home/mloskot/usr/include/soci \
// -I /home/mloskot/usr/include/soci/postgresql -I/usr/include/postgresql \
// -L/home/mloskot/usr/lib -lsoci_core-gcc-3_0 -lsoci_postgresql-gcc-3_0 x03_c_soci_example.cpp
#include <soci.h>
#include <soci-postgresql.h>
#include <exception>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/extensions/gis/io/wkb/read_wkb.hpp>
#include <boost/geometry/extensions/gis/io/wkb/utility.hpp>
#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
// user-defined type with GGL geometry
struct tree
{
int id;
boost::geometry::point<float, 2, boost::geometry::cs::geographic<boost::geometry::degree> > location;
};
// conversion of row of result to user-defined type - performs WKB parsing
namespace soci
{
template <>
struct type_conversion<tree>
{
typedef soci::values base_type;
static void from_base(base_type const& v, soci::indicator ind, tree& value)
{
try
{
value.id = v.get<int>("id");
// intermediate step: hex-encoded binary string to raw WKB
std::string const& hex = v.get<std::string>("wkb");
std::vector<unsigned char> wkb;
if (!boost::geometry::hex2wkb(hex, std::back_inserter(wkb)))
throw std::runtime_error("hex2wkb translation failed");
// parse WKB and construct point geometry
if (!boost::geometry::read_wkb(wkb.begin(), wkb.end(), value.location))
throw std::runtime_error("read_wkb failed");
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}
static void to_base(tree const& value, base_type& v, soci::indicator& ind)
{
throw std::runtime_error("todo: wkb writer not yet implemented");
}
};
}
int main()
{
try
{
// establish database connection
soci::session sql(soci::postgresql, "dbname=ggl user=ggl password=ggl");
// construct schema of table for trees (point geometries)
sql << "DELETE FROM geometry_columns WHERE f_table_name = 'trees'";
sql << "DROP TABLE IF EXISTS trees CASCADE";
sql << "CREATE TABLE trees (id INTEGER)";
sql << "SELECT AddGeometryColumn('trees', 'geom', -1, 'POINT', 2)";
// insert sample data using plain WKT input
sql << "INSERT INTO trees VALUES(1, ST_GeomFromText('POINT(1.23 2.34)', -1))";
sql << "INSERT INTO trees VALUES(2, ST_GeomFromText('POINT(3.45 4.56)', -1))";
sql << "INSERT INTO trees VALUES(3, ST_GeomFromText('POINT(5.67 6.78)', -1))";
sql << "INSERT INTO trees VALUES(4, ST_GeomFromText('POINT(7.89 9.01)', -1))";
// query data in WKB form and read to geometry object
typedef std::vector<tree> trees_t;
soci::rowset<tree> rows = (sql.prepare << "SELECT id, encode(ST_AsBinary(geom), 'hex') AS wkb FROM trees");
trees_t trees;
std::copy(rows.begin(), rows.end(), std::back_inserter(trees));
// print trees output
for (trees_t::const_iterator it = trees.begin(); it != trees.end(); ++it)
{
std::cout << "Tree #" << it->id << " located at\t" << boost::geometry::wkt(it->location) << std::endl;
}
}
catch (std::exception const &e)
{
std::cerr << "Error: " << e.what() << '\n';
}
return 0;
}

View File

@ -0,0 +1,727 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="x03_c_soci_example"
ProjectGUID="{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}"
RootNamespace="x03_c_soci_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)/x03_c_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x03_c_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="soci_postgresql"
>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\common.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\factory.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\row-id.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="soci_core"
>
<File
RelativePath="contrib\soci-3.0.0\src\core\backend-loader.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\connection-pool.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\error.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\once-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\prepare-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\procedure.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-prepare-info.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\row.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\rowid.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\transaction.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\values.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath=".\x03_c_soci_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,84 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Mateusz Loskot 2009, mateusz@loskot.net
//
// 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)
// Boost.Geometry (aka GGL, Generic Geometry Library)
// SOCI example
// d: using WKB to retrieve geometries
// SOCI is a generic C++ template interface to access relational databases
// To build and run this example, see comments in example a
// Alternatively compile composing and executing compiler command directoy in examples directory,
// for example using GCC compiler:
// g++ -I../../../boost -I/home/mloskot/usr/include/soci \
// -I /home/mloskot/usr/include/soci/postgresql -I/usr/include/postgresql \
// -L/home/mloskot/usr/lib -lsoci_core-gcc-3_0 -lsoci_postgresql-gcc-3_0 x03_c_soci_example.cpp
#include <soci.h>
#include <soci-postgresql.h>
#include <exception>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/extensions/gis/io/wkb/read_wkb.hpp>
#include <boost/geometry/extensions/gis/io/wkb/utility.hpp>
#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
int main()
{
try
{
// establish database connection
soci::session sql(soci::postgresql, "dbname=ggl user=ggl password=ggl");
// construct schema of table for trees (point geometries)
sql << "DELETE FROM geometry_columns WHERE f_table_name = 'parcels'";
sql << "DROP TABLE IF EXISTS parcels CASCADE";
sql << "CREATE TABLE parcels (id INTEGER)";
sql << "SELECT AddGeometryColumn('parcels', 'geom', -1, 'GEOMETRY', 2)";
// insert sample data using plain WKT input
sql << "INSERT INTO parcels VALUES(1, ST_GeomFromText('POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))', -1))";
sql << "INSERT INTO parcels VALUES(2, ST_GeomFromText('POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))', -1))";
sql << "INSERT INTO parcels VALUES(3, ST_GeomFromText('POLYGON((1 1,2 1,2 2,1 2,1 1))', -1))";
// query data in WKB form and read to geometry object
soci::rowset<std::string> rows = (sql.prepare << "SELECT encode(ST_AsBinary(geom), 'hex') AS wkb FROM parcels");
// calculate area of each parcel
for (soci::rowset<std::string>::iterator it = rows.begin(); it != rows.end(); ++it)
{
// parse WKB and construct geometry object
std::string const& hex = *it;
std::vector<unsigned char> wkb;
if (!boost::geometry::hex2wkb(*it, std::back_inserter(wkb)))
throw std::runtime_error("hex2wkb translation failed");
boost::geometry::polygon_2d parcel;
if (!boost::geometry::read_wkb(wkb.begin(), wkb.end(), parcel))
throw std::runtime_error("read_wkb failed");
double a = boost::geometry::area(parcel);
std::cout << "Parcel geometry: " << boost::geometry::wkt(parcel) << std::endl
<< "\thas area is " << a << " in coordinate units" << std::endl;
}
}
catch (std::exception const &e)
{
std::cerr << "Error: " << e.what() << '\n';
}
return 0;
}

View File

@ -0,0 +1,727 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="x03_d_soci_example"
ProjectGUID="{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}"
RootNamespace="x03_d_soci_example"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)/x03_d_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\x03_d_soci_example"
ConfigurationType="1"
InheritedPropertySheets=".\boost.vsprops"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../..;&quot;contrib\soci-3.0.0\src\backends\postgresql&quot;;&quot;contrib\soci-3.0.0\src\core&quot;;&quot;c:\Program Files\PostgreSQL\8.3\include&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\include;&quot;c:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;SOCI_USE_BOOST;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpq.lib"
AdditionalLibraryDirectories="&quot;c:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;;c:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC;&quot;C:\Program Files\PostgreSQL\8.3\lib&quot;"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="soci_postgresql"
>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\common.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\factory.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\row-id.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\standard-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\backends\postgresql\vector-use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\pgsql\"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="soci_core"
>
<File
RelativePath="contrib\soci-3.0.0\src\core\backend-loader.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\blob.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\connection-pool.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\error.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\into-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\once-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\prepare-temp-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\procedure.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-prepare-info.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\ref-counted-statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\row.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\rowid.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\session.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\statement.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\transaction.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\use-type.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
<File
RelativePath="contrib\soci-3.0.0\src\core\values.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\core\"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath=".\x03_d_soci_example.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>