diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-06-25 22:59:01 +0000 |
---|---|---|
committer | <> | 2013-09-27 11:49:28 +0000 |
commit | 8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch) | |
tree | c09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/geometry/example/with_external_libs | |
download | boost-tarball-8c4528713d907ee2cfd3bfcbbad272c749867f84.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/geometry/example/with_external_libs')
35 files changed, 5627 insertions, 0 deletions
diff --git a/libs/geometry/example/with_external_libs/contrib/gd-2.0.35/boost_geometry_readme.txt b/libs/geometry/example/with_external_libs/contrib/gd-2.0.35/boost_geometry_readme.txt new file mode 100644 index 000000000..93d331a30 --- /dev/null +++ b/libs/geometry/example/with_external_libs/contrib/gd-2.0.35/boost_geometry_readme.txt @@ -0,0 +1,20 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2010, 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) + + + +Download gd from +http://www.libgd.org/ +(currently from: https://bitbucket.org/pierrejoye/gd-libgd/downloads) + +and extract to this folder. +(currently: extract from ../src/ into this folder) + +Nothing has to be installed. + +This is used in x02_gd_example.cpp + diff --git a/libs/geometry/example/with_external_libs/contrib/shapelib-1.3.0b2/boost_geometry_readme.txt b/libs/geometry/example/with_external_libs/contrib/shapelib-1.3.0b2/boost_geometry_readme.txt new file mode 100644 index 000000000..19426e75f --- /dev/null +++ b/libs/geometry/example/with_external_libs/contrib/shapelib-1.3.0b2/boost_geometry_readme.txt @@ -0,0 +1,24 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) test file +// +// Copyright Barend Gehrels 2010, 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) + + + +Download shapelib from +http://shapelib.maptools.org/ +or http://download.osgeo.org/shapelib/ + +and extract to this folder. + + +Install at least the following files: +- shpopen.c +- shapefil.h +- dbfopen.c + +For new shapelibs: +- safileio.c + diff --git a/libs/geometry/example/with_external_libs/contrib/soci-3.1.0/boost_geometry_readme.txt b/libs/geometry/example/with_external_libs/contrib/soci-3.1.0/boost_geometry_readme.txt new file mode 100644 index 000000000..39470eb9d --- /dev/null +++ b/libs/geometry/example/with_external_libs/contrib/soci-3.1.0/boost_geometry_readme.txt @@ -0,0 +1,18 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2010, 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) + + + +Download soci from +http://soci.sourceforge.net +and extract to this folder. + +Nothing has to be installed. + +This is used in the examples x03_*_soci_example.cpp + + diff --git a/libs/geometry/example/with_external_libs/gd.vsprops b/libs/geometry/example/with_external_libs/gd.vsprops new file mode 100644 index 000000000..209165c2e --- /dev/null +++ b/libs/geometry/example/with_external_libs/gd.vsprops @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioPropertySheet + ProjectType="Visual C++" + Version="8.00" + Name="gd" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories=""$(GD)"" + PreprocessorDefinitions="NONDLL" + /> + <UserMacro + Name="GD" + Value="contrib/gd-2.0.35" + /> +</VisualStudioPropertySheet> diff --git a/libs/geometry/example/with_external_libs/postgresql.vsprops b/libs/geometry/example/with_external_libs/postgresql.vsprops new file mode 100644 index 000000000..6a95d3e1c --- /dev/null +++ b/libs/geometry/example/with_external_libs/postgresql.vsprops @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioPropertySheet + ProjectType="Visual C++" + Version="8.00" + Name="postgresql" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="$(POSTGRESQL_ROOT)/include" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="libpq.lib" + AdditionalLibraryDirectories="$(POSTGRESQL_ROOT)/lib" + /> + <UserMacro + Name="POSTGRESQL_ROOT" + Value="c:\software\PostgreSQL\8.4" + /> +</VisualStudioPropertySheet> diff --git a/libs/geometry/example/with_external_libs/qt.vsprops b/libs/geometry/example/with_external_libs/qt.vsprops new file mode 100644 index 000000000..8de8e56ac --- /dev/null +++ b/libs/geometry/example/with_external_libs/qt.vsprops @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioPropertySheet + ProjectType="Visual C++" + Version="8.00" + Name="qt" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="$(QT)\include;$(QT)\include\QtGui;$(QT)\include\QtCore" + PreprocessorDefinitions="QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="qtmain.lib QtGui4.lib QtCore4.lib" + AdditionalLibraryDirectories="$(QT)\lib" + IgnoreDefaultLibraryNames="msvcrt.lib" + /> + <UserMacro + Name="QT" + Value="c:\software\libraries\Qt\4.7.1" + /> +</VisualStudioPropertySheet> diff --git a/libs/geometry/example/with_external_libs/shapelib.vsprops b/libs/geometry/example/with_external_libs/shapelib.vsprops new file mode 100644 index 000000000..fcd579559 --- /dev/null +++ b/libs/geometry/example/with_external_libs/shapelib.vsprops @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioPropertySheet + ProjectType="Visual C++" + Version="8.00" + Name="shapelib" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="$(SHAPELIB)" + /> + <UserMacro + Name="SHAPELIB" + Value=".\contrib\shapelib-1.3.0b2" + /> +</VisualStudioPropertySheet> diff --git a/libs/geometry/example/with_external_libs/soci.vsprops b/libs/geometry/example/with_external_libs/soci.vsprops new file mode 100644 index 000000000..c397b1241 --- /dev/null +++ b/libs/geometry/example/with_external_libs/soci.vsprops @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioPropertySheet + ProjectType="Visual C++" + Version="8.00" + Name="soci" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories=""$(SOCI_ROOT)/src/core";"$(SOCI_ROOT)/src/backends/postgresql"" + PreprocessorDefinitions="SOCI_USE_BOOST;SOCI_LIB_PREFIX=\"libsoci_\";SOCI_LIB_SUFFIX=\".so\"" + /> + <UserMacro + Name="SOCI_ROOT" + Value="contrib/soci-3.1.0" + /> +</VisualStudioPropertySheet> diff --git a/libs/geometry/example/with_external_libs/wxwidgets.vsprops b/libs/geometry/example/with_external_libs/wxwidgets.vsprops new file mode 100644 index 000000000..a5a0836fc --- /dev/null +++ b/libs/geometry/example/with_external_libs/wxwidgets.vsprops @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioPropertySheet + ProjectType="Visual C++" + Version="8.00" + Name="wxwidgets" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="$(WXWIDGETS)\lib\vc_lib\mswd;$(WXWIDGETS)\include;$(WXWIDGETS)\include\msvc;" + PreprocessorDefinitions="NOPCH;__WXMSW__" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="$(WXWIDGETS)\lib\vc_lib" + /> + <UserMacro + Name="WXWIDGETS" + Value="c:\software\libraries\wxWidgets-2.8.10" + /> +</VisualStudioPropertySheet> diff --git a/libs/geometry/example/with_external_libs/x01_qt_example.cpp b/libs/geometry/example/with_external_libs/x01_qt_example.cpp new file mode 100644 index 000000000..4ccade27a --- /dev/null +++ b/libs/geometry/example/with_external_libs/x01_qt_example.cpp @@ -0,0 +1,81 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, 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 windows 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 (note there is a Qt property sheet) + +#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 Boost.Geometry +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 Boost.Geometry 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 Qt polygon. The Qt Polygon can be used + // in Boost.Geometry, just by its oneline registration above. + QPolygonF polygon; + + // Use Qt to add points to polygon + polygon + << QPointF(10, 20) << QPointF(20, 30) + << QPointF(30, 20) << QPointF(20, 10) + << QPointF(10, 20); + + // Use Boost.Geometry e.g. to calculate area + std::ostringstream out; + out << "Boost.Geometry area: " << boost::geometry::area(polygon) << std::endl; + + // Some functionality is defined in both Qt and Boost.Geometry + QPointF p(20,20); + out << "Qt contains: " + << (polygon.containsPoint(p, Qt::WindingFill) ? "yes" : "no") + << std::endl + << "Boost.Geometry within: " + << (boost::geometry::within(p, polygon) ? "yes" : "no") + << std::endl; + // Detail: if point is ON boundary, Qt says yes, Boost.Geometry says no. + + // Qt defines an iterator + // (which is required for of the Boost.Geometry ring-concept) + // such that Boost.Geometry 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 Boost.Geometry 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(); +} + diff --git a/libs/geometry/example/with_external_libs/x01_qt_example.sln b/libs/geometry/example/with_external_libs/x01_qt_example.sln new file mode 100644 index 000000000..6af3e9304 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x01_qt_example.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +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 diff --git a/libs/geometry/example/with_external_libs/x01_qt_example.vcproj b/libs/geometry/example/with_external_libs/x01_qt_example.vcproj new file mode 100644 index 000000000..eba736e3f --- /dev/null +++ b/libs/geometry/example/with_external_libs/x01_qt_example.vcproj @@ -0,0 +1,176 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="x01_qt_example" + ProjectGUID="{242C6ADC-3A10-4B69-81F7-5669E0582A8B}" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <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;.\qt.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="1" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\x01_qt_example" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\qt.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + UsePrecompiledHeader="0" + WarningLevel="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\x01_qt_example.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/example/with_external_libs/x02_gd_example.cpp b/libs/geometry/example/with_external_libs/x02_gd_example.cpp new file mode 100644 index 000000000..f5441d589 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x02_gd_example.cpp @@ -0,0 +1,144 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, 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) +// +// GD example + +// GD is a well-known and often used graphic library to write GIF (and other formats) + +// To build and run this example: +// 1) download GD from http://www.libgd.org (currently gd-2.0.35 is assumed) +// 2) add 11 files +// gd.c, gd_gd.c, gd_gif_out.c, gd_io*.c, gd_security.c, gd_topal.c, gdhelpers.c, gdtables.c +// to the project or makefile or jamfile +// 3) for windows, add define NONDLL to indicate GD is not used as a DLL +// (Note that steps 2 and 3 are done in the MSVC gd_example project file and property sheets) + +#include <cmath> +#include <cstdio> +#include <vector> + +#include <fstream> +#include <sstream> + + +#include <boost/foreach.hpp> + +#include <boost/geometry.hpp> +#include <boost/geometry/multi/geometries/multi_polygon.hpp> + +#include <boost/geometry/extensions/gis/latlong/latlong.hpp> +#include <boost/geometry/extensions/gis/geographic/strategies/area_huiller_earth.hpp> + + +#include <gd.h> + +namespace bg = boost::geometry; + + +// ---------------------------------------------------------------------------- +// Read an ASCII file containing WKT's +// (note this function is shared by various examples) +// ---------------------------------------------------------------------------- +template <typename Geometry> +inline void read_wkt(std::string const& filename, std::vector<Geometry>& geometries) +{ + std::ifstream cpp_file(filename.c_str()); + if (cpp_file.is_open()) + { + while (! cpp_file.eof() ) + { + std::string line; + std::getline(cpp_file, line); + if (! line.empty()) + { + Geometry geometry; + bg::read_wkt(line, geometry); + geometries.push_back(geometry); + } + } + } +} + + +int main() +{ + // Adapt if necessary + std::string filename = "../data/world.wkt"; + + + // The world is measured in latlong (degrees), so latlong is appropriate. + // We ignore holes in this sample (below) + typedef bg::model::ll::point<bg::degree> point_type; + typedef bg::model::polygon<point_type> polygon_type; + typedef bg::model::multi_polygon<polygon_type> country_type; + + std::vector<country_type> countries; + + // Read (for example) world countries + read_wkt(filename, countries); + + + // Create a GD image. + // A world map, as world.shp, is usually mapped in latitude-longitude (-180..180 and -90..90) + // For this example we use a very simple "transformation" + // mapping to 0..720 and 0..360 + const double factor = 2.0; + gdImagePtr im = gdImageCreateTrueColor(int(360 * factor), int(180 * factor)); + + // Allocate three colors + int blue = gdImageColorResolve(im, 0, 52, 255); + int green = gdImageColorResolve(im, 0, 255, 0); + int black = gdImageColorResolve(im, 0, 0, 0); + + // Paint background in blue + gdImageFilledRectangle(im, 0, 0, im->sx, im->sy, blue); + + // Paint all countries in green + BOOST_FOREACH(country_type const& country, countries) + { + BOOST_FOREACH(polygon_type const& polygon, country) + { + // Ignore holes, so take only exterior ring + bg::model::ring<point_type> const& ring = bg::exterior_ring(polygon); + + // If wished, suppress too small polygons. + // (Note that even in latlong, area is calculated in square meters) + double const a = bg::area(ring); + if (std::fabs(a) > 5000.0e6) + { + int const n = ring.size(); + gdPoint* points = new gdPoint[n]; + + for (int i = 0; i < n; i++) + { + // Translate lon/lat or x/y to GD x/y points + points[i].x = int(factor * (bg::get<0>(ring[i]) + 180.0)); + points[i].y = im->sy - int(factor * (bg::get<1>(ring[i]) + 90.0)); + } + + // Draw the polygon... + gdImageFilledPolygon(im, points, n, green); + // .. and the outline in black... + gdImagePolygon(im, points, n, black); + + delete[] points; + } + } + } + + // Use GD to create a GIF file + std::FILE* out = std::fopen("world.gif", "wb"); + if (out != NULL) + { + gdImageGif(im, out); + std::fclose(out); + } + + gdImageDestroy(im); + + return 0; +} diff --git a/libs/geometry/example/with_external_libs/x02_gd_example.sln b/libs/geometry/example/with_external_libs/x02_gd_example.sln new file mode 100644 index 000000000..1ab96a86f --- /dev/null +++ b/libs/geometry/example/with_external_libs/x02_gd_example.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x02_gd_example", "x02_gd_example.vcproj", "{A73F21AC-6F32-41A9-A86C-53BD4DC84B05}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A73F21AC-6F32-41A9-A86C-53BD4DC84B05}.Debug|Win32.ActiveCfg = Debug|Win32 + {A73F21AC-6F32-41A9-A86C-53BD4DC84B05}.Debug|Win32.Build.0 = Debug|Win32 + {A73F21AC-6F32-41A9-A86C-53BD4DC84B05}.Release|Win32.ActiveCfg = Release|Win32 + {A73F21AC-6F32-41A9-A86C-53BD4DC84B05}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/geometry/example/with_external_libs/x02_gd_example.vcproj b/libs/geometry/example/with_external_libs/x02_gd_example.vcproj new file mode 100644 index 000000000..20471a0a6 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x02_gd_example.vcproj @@ -0,0 +1,236 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="x02_gd_example" + ProjectGUID="{A73F21AC-6F32-41A9-A86C-53BD4DC84B05}" + RootNamespace="x02_gd_example" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\x02_gd_example" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\gd.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="../../../.." + MinimalRebuild="true" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="kernel32.lib" + 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)\x02_gd_example" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\gd.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="2" + EnableIntrinsicFunctions="true" + FavorSizeOrSpeed="1" + WholeProgramOptimization="false" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="../../../.." + RuntimeLibrary="2" + UsePrecompiledHeader="0" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="kernel32.lib" + 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> + <Filter + Name="GD" + > + <File + RelativePath="$(GD)\gd.c" + > + </File> + <File + RelativePath="$(GD)\gd_color.c" + > + </File> + <File + RelativePath="$(GD)\gd_gd.c" + > + </File> + <File + RelativePath="$(GD)\gd_gif_out.c" + > + </File> + <File + RelativePath="$(GD)\gd_io.c" + > + </File> + <File + RelativePath="$(GD)\gd_io_dp.c" + > + </File> + <File + RelativePath="$(GD)\gd_io_file.c" + > + </File> + <File + RelativePath="$(GD)\gd_io_ss.c" + > + </File> + <File + RelativePath="$(GD)\gd_security.c" + > + </File> + <File + RelativePath="$(GD)\gd_topal.c" + > + </File> + <File + RelativePath="$(GD)\gdhelpers.c" + > + </File> + <File + RelativePath="$(GD)\gdtables.c" + > + </File> + </Filter> + <File + RelativePath=".\x02_gd_example.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/example/with_external_libs/x03_a_soci_example.cpp b/libs/geometry/example/with_external_libs/x03_a_soci_example.cpp new file mode 100644 index 000000000..5b509057f --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_a_soci_example.cpp @@ -0,0 +1,78 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, 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/boost_tuple.hpp> + +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian); + + +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; +} diff --git a/libs/geometry/example/with_external_libs/x03_a_soci_example.vcproj b/libs/geometry/example/with_external_libs/x03_a_soci_example.vcproj new file mode 100644 index 000000000..2f6665a51 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_a_soci_example.vcproj @@ -0,0 +1,744 @@ +<?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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + DebugInformationFormat="1" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\src\backends\postgresql\error.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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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> diff --git a/libs/geometry/example/with_external_libs/x03_b_soci_example.cpp b/libs/geometry/example/with_external_libs/x03_b_soci_example.cpp new file mode 100644 index 000000000..59eaf6d2f --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_b_soci_example.cpp @@ -0,0 +1,100 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, 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/io/wkt/wkt.hpp> + + +struct city +{ + boost::geometry::model::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; +} diff --git a/libs/geometry/example/with_external_libs/x03_b_soci_example.vcproj b/libs/geometry/example/with_external_libs/x03_b_soci_example.vcproj new file mode 100644 index 000000000..35781e542 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_b_soci_example.vcproj @@ -0,0 +1,744 @@ +<?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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + DebugInformationFormat="1" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\src\backends\postgresql\error.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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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> diff --git a/libs/geometry/example/with_external_libs/x03_c_soci_example.cpp b/libs/geometry/example/with_external_libs/x03_c_soci_example.cpp new file mode 100644 index 000000000..d9739763f --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_c_soci_example.cpp @@ -0,0 +1,118 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2009-2012 Mateusz Loskot, 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) +// 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/io/wkt/wkt.hpp> + +// user-defined type with GGL geometry +struct tree +{ + int id; + boost::geometry::model::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; +} + diff --git a/libs/geometry/example/with_external_libs/x03_c_soci_example.vcproj b/libs/geometry/example/with_external_libs/x03_c_soci_example.vcproj new file mode 100644 index 000000000..05a4ae022 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_c_soci_example.vcproj @@ -0,0 +1,744 @@ +<?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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + DebugInformationFormat="1" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\src\backends\postgresql\error.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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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> diff --git a/libs/geometry/example/with_external_libs/x03_d_soci_example.cpp b/libs/geometry/example/with_external_libs/x03_d_soci_example.cpp new file mode 100644 index 000000000..26b59a72b --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_d_soci_example.cpp @@ -0,0 +1,84 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2009-2012 Mateusz Loskot, 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) +// 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.hpp> + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +#include <boost/geometry/extensions/gis/io/wkb/read_wkb.hpp> +#include <boost/geometry/extensions/gis/io/wkb/utility.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::model::polygon<boost::geometry::model::d2::point_xy<double> > 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; +} + diff --git a/libs/geometry/example/with_external_libs/x03_d_soci_example.vcproj b/libs/geometry/example/with_external_libs/x03_d_soci_example.vcproj new file mode 100644 index 000000000..d699d5186 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_d_soci_example.vcproj @@ -0,0 +1,744 @@ +<?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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + DebugInformationFormat="1" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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;.\soci.vsprops;.\postgresql.vsprops" + CharacterSet="0" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_ALL_NO_LIB" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + 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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\src\backends\postgresql\error.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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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="$(SOCI_ROOT)\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> diff --git a/libs/geometry/example/with_external_libs/x03_soci_examples.sln b/libs/geometry/example/with_external_libs/x03_soci_examples.sln new file mode 100644 index 000000000..49ea1a3be --- /dev/null +++ b/libs/geometry/example/with_external_libs/x03_soci_examples.sln @@ -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 diff --git a/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.cpp b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.cpp new file mode 100644 index 000000000..1a8bde389 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.cpp @@ -0,0 +1,389 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2010-2012 Barend Gehrels, 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) +// +// wxWidgets World Mapper example + + +// #define EXAMPLE_WX_USE_GRAPHICS_CONTEXT 1 + +#include <fstream> +#include <sstream> + +#include <boost/foreach.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/scoped_array.hpp> + +#include <boost/geometry/geometry.hpp> +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> +#include <boost/geometry/multi/geometries/multi_geometries.hpp> + +#include <boost/geometry/geometries/register/point.hpp> +#include <boost/geometry/geometries/register/ring.hpp> +#include <boost/geometry/extensions/algorithms/selected.hpp> + + +// wxWidgets, if these headers are NOT found, adapt include path (and lib path) + +#include "wx/wx.h" +#include "wx/math.h" +#include "wx/stockitem.h" + + +#ifdef EXAMPLE_WX_USE_GRAPHICS_CONTEXT +#include "wx/graphics.h" +#include "wx/dcgraph.h" +#endif + +typedef boost::geometry::model::d2::point_xy<double> point_2d; +typedef boost::geometry::model::multi_polygon + < + boost::geometry::model::polygon<point_2d> + > country_type; + +// Adapt wxWidgets points to Boost.Geometry points such that they can be used +// in e.g. transformations (see below) +BOOST_GEOMETRY_REGISTER_POINT_2D(wxPoint, int, cs::cartesian, x, y) +BOOST_GEOMETRY_REGISTER_POINT_2D(wxRealPoint, double, cs::cartesian, x, y) + + +// wxWidgets draws using wxPoint*, so we HAVE to use that. +// Therefore have to make a wxPoint* array +// 1) compatible with Boost.Geometry +// 2) compatible with Boost.Range (required by Boost.Geometry) +// 3) compatible with std::back_inserter (required by Boost.Geometry) + +// For compatible 2): +typedef std::pair<wxPoint*,wxPoint*> wxPointPointerPair; + +// For compatible 1): +BOOST_GEOMETRY_REGISTER_RING(wxPointPointerPair); + + +// For compatible 3): +// Specialize back_insert_iterator for the wxPointPointerPair +// (has to be done within "namespace std") +namespace std +{ + +template <> +class back_insert_iterator<wxPointPointerPair> + : public std::iterator<std::output_iterator_tag, void, void, void, void> +{ +public: + + typedef wxPointPointerPair container_type; + + explicit back_insert_iterator(wxPointPointerPair& x) + : current(boost::begin(x)) + , end(boost::end(x)) + {} + + inline back_insert_iterator<wxPointPointerPair>& + operator=(wxPoint const& value) + { + // Check if not passed beyond + if (current != end) + { + *current++ = value; + } + return *this; + } + + // Boiler-plate + inline back_insert_iterator<wxPointPointerPair>& operator*() { return *this; } + inline back_insert_iterator<wxPointPointerPair>& operator++() { return *this; } + inline back_insert_iterator<wxPointPointerPair>& operator++(int) { return *this; } + +private: + boost::range_iterator<wxPointPointerPair>::type current, end; +}; + +} // namespace std + + +// ---------------------------------------------------------------------------- +// Read an ASCII file containing WKT's +// ---------------------------------------------------------------------------- +template <typename Geometry, typename Box> +inline void read_wkt(std::string const& filename, std::vector<Geometry>& geometries, 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); + if (! line.empty()) + { + Geometry geometry; + boost::geometry::read_wkt(line, geometry); + geometries.push_back(geometry); + boost::geometry::expand(box, boost::geometry::return_envelope<Box>(geometry)); + } + } + } +} + + +// ---------------------------------------------------------------------------- +class HelloWorldFrame: public wxFrame +{ +public: + HelloWorldFrame(wxFrame *frame, wxString const& title, wxPoint const& pos, wxSize const& size); + + void OnCloseWindow(wxCloseEvent& ); + void OnExit(wxCommandEvent& ); + + DECLARE_EVENT_TABLE() +}; + + +// ---------------------------------------------------------------------------- +class HelloWorldCanvas: public wxWindow +{ +public: + HelloWorldCanvas(wxFrame *frame); + +private: + void DrawCountries(wxDC& dc); + void DrawCountry(wxDC& dc, country_type const& country); + + void OnPaint(wxPaintEvent& ); + void OnMouseMove(wxMouseEvent&); + + typedef boost::geometry::strategy::transform::map_transformer + < + point_2d, wxPoint, + true, true + > map_transformer_type; + + typedef boost::geometry::strategy::transform::inverse_transformer + < + wxPoint, point_2d + > inverse_transformer_type; + + boost::shared_ptr<map_transformer_type> m_map_transformer; + boost::shared_ptr<inverse_transformer_type> m_inverse_transformer; + + boost::geometry::model::box<point_2d> m_box; + std::vector<country_type> m_countries; + int m_focus; + + wxBrush m_orange; + wxFrame* m_owner; + +DECLARE_EVENT_TABLE() +}; + + + +// ---------------------------------------------------------------------------- +class HelloWorldApp: public wxApp +{ +public: + bool OnInit() + { + // Create the main frame window + HelloWorldFrame *frame = new HelloWorldFrame(NULL, _T("Boost.Geometry for wxWidgets - Hello World!"), wxDefaultPosition, wxSize(640, 480)); + + wxMenu *file_menu = new wxMenu; + file_menu->Append(wxID_EXIT, wxGetStockLabel(wxID_EXIT)); + wxMenuBar* menuBar = new wxMenuBar; + menuBar->Append(file_menu, _T("&File")); + frame->SetMenuBar(menuBar); + + int width, height; + frame->GetClientSize(&width, &height); + + (void) new HelloWorldCanvas(frame); + + // Show the frame + frame->Show(true); + + return true; + } +}; + + + +// ---------------------------------------------------------------------------- +HelloWorldFrame::HelloWorldFrame(wxFrame *frame, wxString const& title, wxPoint const& pos, wxSize const& size) + : wxFrame(frame, wxID_ANY, title, pos, size, wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE ) +{ + CreateStatusBar(2); +} + + +void HelloWorldFrame::OnExit(wxCommandEvent& ) +{ + this->Destroy(); +} + +void HelloWorldFrame::OnCloseWindow(wxCloseEvent& ) +{ + static bool destroyed = false; + if (! destroyed) + { + this->Destroy(); + destroyed = true; + } +} + + +// ---------------------------------------------------------------------------- +HelloWorldCanvas::HelloWorldCanvas(wxFrame *frame) + : wxWindow(frame, wxID_ANY) + , m_owner(frame) + , m_focus(-1) +{ + boost::geometry::assign_inverse(m_box); + read_wkt("../data/world.wkt", m_countries, m_box); + m_orange = wxBrush(wxColour(255, 128, 0), wxSOLID); +} + + + +void HelloWorldCanvas::OnMouseMove(wxMouseEvent &event) +{ + namespace bg = boost::geometry; + + if (m_inverse_transformer) + { + // Boiler-plate wxWidgets code + wxClientDC dc(this); + PrepareDC(dc); + m_owner->PrepareDC(dc); + + // Transform the point to Lon/Lat + point_2d point; + bg::transform(event.GetPosition(), point, *m_inverse_transformer); + + // Determine selected object + int i = 0; + int previous_focus = m_focus; + m_focus = -1; + BOOST_FOREACH(country_type const& country, m_countries) + { + if (bg::selected(country, point, 0)) + { + m_focus = i; + } + i++; + } + + // On change: + if (m_focus != previous_focus) + { + // Undraw old focus + if (previous_focus >= 0) + { + dc.SetBrush(*wxWHITE_BRUSH); + DrawCountry(dc, m_countries[previous_focus]); + } + // Draw new focus + if (m_focus >= 0) + { + dc.SetBrush(m_orange); + DrawCountry(dc, m_countries[m_focus]); + } + } + + // Create a string and set it in the status text + std::ostringstream out; + out << "Position: " << point.x() << ", " << point.y(); + m_owner->SetStatusText(wxString(out.str().c_str(), wxConvUTF8)); + } +} + + + +void HelloWorldCanvas::OnPaint(wxPaintEvent& ) +{ +#if defined(EXAMPLE_WX_USE_GRAPHICS_CONTEXT) + wxPaintDC pdc(this); + wxGCDC gdc(pdc); + wxDC& dc = (wxDC&) gdc; +#else + wxPaintDC dc(this); +#endif + + PrepareDC(dc); + + static bool running = false; + if (! running) + { + running = true; + + // Update the transformers + wxSize sz = dc.GetSize(); + m_map_transformer.reset(new map_transformer_type(m_box, sz.x, sz.y)); + m_inverse_transformer.reset(new inverse_transformer_type(*m_map_transformer)); + + DrawCountries(dc); + + running = false; + } +} + + +void HelloWorldCanvas::DrawCountries(wxDC& dc) +{ + namespace bg = boost::geometry; + + dc.SetBackground(*wxLIGHT_GREY_BRUSH); + dc.Clear(); + + BOOST_FOREACH(country_type const& country, m_countries) + { + DrawCountry(dc, country); + } + if (m_focus != -1) + { + dc.SetBrush(m_orange); + DrawCountry(dc, m_countries[m_focus]); + } +} + + +void HelloWorldCanvas::DrawCountry(wxDC& dc, country_type const& country) +{ + namespace bg = boost::geometry; + + BOOST_FOREACH(bg::model::polygon<point_2d> const& poly, country) + { + // Use only exterior ring, holes are (for the moment) ignored. This would need + // a holey-polygon compatible wx object + + std::size_t n = boost::size(bg::exterior_ring(poly)); + + boost::scoped_array<wxPoint> points(new wxPoint[n]); + + wxPointPointerPair pair = std::make_pair(points.get(), points.get() + n); + bg::transform(bg::exterior_ring(poly), pair, *m_map_transformer); + + dc.DrawPolygon(n, points.get()); + } +} + +// ---------------------------------------------------------------------------- + + +BEGIN_EVENT_TABLE(HelloWorldFrame, wxFrame) + EVT_CLOSE(HelloWorldFrame::OnCloseWindow) + EVT_MENU(wxID_EXIT, HelloWorldFrame::OnExit) +END_EVENT_TABLE() + + +BEGIN_EVENT_TABLE(HelloWorldCanvas, wxWindow) + EVT_PAINT(HelloWorldCanvas::OnPaint) + EVT_MOTION(HelloWorldCanvas::OnMouseMove) +END_EVENT_TABLE() + + +IMPLEMENT_APP(HelloWorldApp) diff --git a/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.sln b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.sln new file mode 100644 index 000000000..9761bba39 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x04_wxwidgets_world_mapper", "x04_wxwidgets_world_mapper.vcproj", "{DD1D469B-29A8-4873-A596-9CCCB24F54FA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Debug|Win32.ActiveCfg = Debug|Win32 + {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Debug|Win32.Build.0 = Debug|Win32 + {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Release|Win32.ActiveCfg = Release|Win32 + {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.vcproj b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.vcproj new file mode 100644 index 000000000..3d4ed9ab1 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper.vcproj @@ -0,0 +1,217 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="x04_wxwidgets_world_mapper" + ProjectGUID="{DD1D469B-29A8-4873-A596-9CCCB24F54FA}" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\x04_wxwidgets_world_mapper" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\wxwidgets.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/EHsc " + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__WXDEBUG__" + RuntimeLibrary="3" + RuntimeTypeInfo="true" + WarningLevel="3" + SuppressStartupBanner="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG,__WXMSW__,__WXDEBUG__,_WINDOWS,NOPCH" + Culture="1033" + AdditionalIncludeDirectories=".\..\..\lib\vc_lib\mswd;.\..\..\include;.;.\..\..\samples" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wxmsw28d_core.lib wxbase28d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib gdiplus.lib" + SuppressStartupBanner="true" + IgnoreDefaultLibraryNames="" + GenerateDebugInformation="true" + SubSystem="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\x04_wxwidgets_world_mapper" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\wxwidgets.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/EHsc " + Optimization="2" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_WINDOWS" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + RuntimeTypeInfo="true" + PrecompiledHeaderFile="" + WarningLevel="3" + SuppressStartupBanner="true" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="__WXMSW__,_WINDOWS,NOPCH" + Culture="1033" + AdditionalIncludeDirectories=".\..\..\lib\vc_lib\msw;.\..\..\include;.;.\..\..\samples" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib gdiplus.lib" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="" + ProgramDatabaseFile="" + SubSystem="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="x04_wxwidgets_world_mapper.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\x04_wxwidgets_world_mapper_readme.txt" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt new file mode 100644 index 000000000..ed3df6cb0 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt @@ -0,0 +1,31 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2010, 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) + + + +wxWidgets World Mapper example + +It will show a basic wxWidgets window, displaying world countries, highlighting the country under +the mouse, and indicating position of the mouse in latitude/longitude and in pixels. + + +To compile this program: + +Install wxWidgets (if not done before) +Install Boost (if not done before) + +Using MSVC: + - edit the file wxwidgets.vsprops + - set the UserMacro WXWIDGETS to point to your wxWidgets distribution + - edit the file boost.vsprops + - set the UserMacro BOOST_ROOT to point to your Boost distribution + - alternatively you can include Boost and/or wxWidgets in your standard include path + +Using Linux/gcc + - check if installation is OK, http://wiki.wxwidgets.org/Installing_and_configuring_under_Ubuntu + - compile using e.g. gcc -o x04_wxwidgets -I../../../.. x04_wxwidgets_world_mapper.cpp `wx-config --cxxflags` `wx-config --libs` + diff --git a/libs/geometry/example/with_external_libs/x05_shapelib_example.cpp b/libs/geometry/example/with_external_libs/x05_shapelib_example.cpp new file mode 100644 index 000000000..d9fd73115 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x05_shapelib_example.cpp @@ -0,0 +1,118 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// 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) +// +// SHAPELIB example + +// Shapelib is a well-known and often used library to read (and write) shapefiles by Frank Warmerdam + +// To build and run this example: +// 1) download shapelib from http://shapelib.maptools.org/ +// 2) extract and put the source "shpopen.cpp" in project or makefile +// 3) download a shapefile, for example world countries from http://aprsworld.net/gisdata/world +// Alternativelly, install Shapelib using OSGeo4W installer from http://trac.osgeo.org/osgeo4w/ +// that provides Windows binary packages + +#include "shapefil.h" + +#include <boost/geometry/geometry.hpp> +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +using namespace boost::geometry; + +template <typename T, typename F> +void read_shapefile(const std::string& filename, std::vector<T>& polygons, F functor) +{ + try + { + SHPHandle handle = SHPOpen(filename.c_str(), "rb"); + if (handle <= 0) + { + throw std::string("File " + filename + " not found"); + } + + int nShapeType, nEntities; + double adfMinBound[4], adfMaxBound[4]; + SHPGetInfo(handle, &nEntities, &nShapeType, adfMinBound, adfMaxBound ); + + for (int i = 0; i < nEntities; i++) + { + SHPObject* psShape = SHPReadObject(handle, i ); + + // Read only polygons, and only those without holes + if (psShape->nSHPType == SHPT_POLYGON && psShape->nParts == 1) + { + T polygon; + functor(psShape, polygon); + polygons.push_back(polygon); + } + SHPDestroyObject( psShape ); + } + SHPClose(handle); + } + catch(const std::string& s) + { + throw s; + } + catch(...) + { + throw std::string("Other exception"); + } +} + + +template <typename T> +void convert(SHPObject* psShape, T& polygon) +{ + double* x = psShape->padfX; + double* y = psShape->padfY; + for (int v = 0; v < psShape->nVertices; v++) + { + typename point_type<T>::type point; + assign_values(point, x[v], y[v]); + append(polygon, point); + } +} + + +int main() +{ + std::string filename = "c:/data/spatial/shape/world_free/world.shp"; + + typedef model::polygon<model::d2::point_xy<double> > polygon_2d; + std::vector<polygon_2d> polygons; + + try + { + read_shapefile(filename, polygons, convert<polygon_2d>); + } + catch(const std::string& s) + { + std::cout << s << std::endl; + return 1; + } + + // Do something with the polygons, for example simplify them + for (std::vector<polygon_2d>::iterator it = polygons.begin(); it != polygons.end(); it++) + { + polygon_2d p; + simplify(*it, p, 0.01); + std::cout << it->outer().size() << "," << p.outer().size() << std::endl; + *it = p; + } + std::cout << "Simplified " << polygons.size() << std::endl; + + double sum = 0; + for (std::vector<polygon_2d>::const_iterator it = polygons.begin(); it != polygons.end(); it++) + { + sum += area(*it); + } + std::cout << "Total area of " << polygons.size() << " polygons, total: " << sum << std::endl; + + return 0; +} diff --git a/libs/geometry/example/with_external_libs/x05_shapelib_example.sln b/libs/geometry/example/with_external_libs/x05_shapelib_example.sln new file mode 100644 index 000000000..48693bb6a --- /dev/null +++ b/libs/geometry/example/with_external_libs/x05_shapelib_example.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x05_shapelib_example", "x05_shapelib_example.vcproj", "{92ECE1AC-1A5D-4554-A8AD-690AC266210D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92ECE1AC-1A5D-4554-A8AD-690AC266210D}.Debug|Win32.ActiveCfg = Debug|Win32 + {92ECE1AC-1A5D-4554-A8AD-690AC266210D}.Debug|Win32.Build.0 = Debug|Win32 + {92ECE1AC-1A5D-4554-A8AD-690AC266210D}.Release|Win32.ActiveCfg = Release|Win32 + {92ECE1AC-1A5D-4554-A8AD-690AC266210D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/geometry/example/with_external_libs/x05_shapelib_example.vcproj b/libs/geometry/example/with_external_libs/x05_shapelib_example.vcproj new file mode 100644 index 000000000..d9c6a1d3f --- /dev/null +++ b/libs/geometry/example/with_external_libs/x05_shapelib_example.vcproj @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="x05_shapelib_example" + ProjectGUID="{92ECE1AC-1A5D-4554-A8AD-690AC266210D}" + RootNamespace="shapelib" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\shapelib" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\shapelib.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="kernel32.lib" + LinkIncremental="2" + AdditionalLibraryDirectories="$(OSGEO4W_HOME)/lib" + 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)\shapelib" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\shapelib.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="2" + EnableIntrinsicFunctions="true" + FavorSizeOrSpeed="1" + WholeProgramOptimization="false" + AdditionalIncludeDirectories="../../../.." + 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" + LinkIncremental="1" + AdditionalLibraryDirectories="$(OSGEO4W_HOME)/lib" + 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="SHAPELIB" + > + <File + RelativePath="$(SHAPELIB)\dbfopen.c" + > + </File> + <File + RelativePath="$(SHAPELIB)\safileio.c" + > + </File> + <File + RelativePath="$(SHAPELIB)\shpopen.c" + > + </File> + </Filter> + <File + RelativePath=".\x05_shapelib_example.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/example/with_external_libs/x06_qt_world_mapper.cpp b/libs/geometry/example/with_external_libs/x06_qt_world_mapper.cpp new file mode 100644 index 000000000..8f0cf3477 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x06_qt_world_mapper.cpp @@ -0,0 +1,162 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, 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 World Mapper Example + +// Qt is a well-known and often used platform independent windows 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 (note there is a Qt property sheet) + +#include <fstream> + +#include <QtGui> +#include <QWidget> +#include <QObject> +#include <QPainter> + +#include <boost/foreach.hpp> + +#include <boost/geometry/geometry.hpp> + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/multi/geometries/multi_geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +#include <boost/geometry/geometries/register/point.hpp> +#include <boost/geometry/geometries/register/ring.hpp> + +#include <boost/geometry/extensions/algorithms/selected.hpp> + + + +// Adapt a QPointF such that it can be handled by Boost.Geometry +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 Boost.Geometry ring +BOOST_GEOMETRY_REGISTER_RING(QPolygonF) + + +typedef boost::geometry::model::d2::point_xy<double> point_2d; +typedef boost::geometry::model::multi_polygon + < + boost::geometry::model::polygon<point_2d> + > country_type; + + +class WorldMapper : public QWidget +{ + public: + WorldMapper(std::vector<country_type> const& countries, boost::geometry::model::box<point_2d> const& box) + : m_countries(countries) + , m_box(box) + { + setPalette(QPalette(QColor(200, 250, 250))); + setAutoFillBackground(true); + } + + protected: + void paintEvent(QPaintEvent*) + { + map_transformer_type transformer(m_box, this->width(), this->height()); + + QPainter painter(this); + painter.setBrush(Qt::green); + painter.setRenderHint(QPainter::Antialiasing); + + BOOST_FOREACH(country_type const& country, m_countries) + { + typedef boost::range_value<country_type>::type polygon_type; + BOOST_FOREACH(polygon_type const& polygon, country) + { + typedef boost::geometry::ring_type<polygon_type>::type ring_type; + ring_type const& ring = boost::geometry::exterior_ring(polygon); + + // This is the essention: + // Directly transform from a multi_polygon (ring-type) to a QPolygonF + QPolygonF qring; + boost::geometry::transform(ring, qring, transformer); + + painter.drawPolygon(qring); + } + } + } + + private: + typedef boost::geometry::strategy::transform::map_transformer + < + point_2d, QPointF, + true, true + > map_transformer_type; + + std::vector<country_type> const& m_countries; + boost::geometry::model::box<point_2d> const& m_box; + }; + + +class MapperWidget : public QWidget +{ + public: + MapperWidget(std::vector<country_type> const& countries, boost::geometry::model::box<point_2d> const& box, QWidget *parent = 0) + : QWidget(parent) + { + WorldMapper* mapper = new WorldMapper(countries, box); + + QPushButton *quit = new QPushButton(tr("Quit")); + quit->setFont(QFont("Times", 18, QFont::Bold)); + connect(quit, SIGNAL(clicked()), qApp, SLOT(quit())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(mapper); + layout->addWidget(quit); + setLayout(layout); + } + +}; + + +// ---------------------------------------------------------------------------- +// Read an ASCII file containing WKT's +// ---------------------------------------------------------------------------- +template <typename Geometry, typename Box> +inline void read_wkt(std::string const& filename, std::vector<Geometry>& geometries, 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); + if (! line.empty()) + { + Geometry geometry; + boost::geometry::read_wkt(line, geometry); + geometries.push_back(geometry); + boost::geometry::expand(box, boost::geometry::return_envelope<Box>(geometry)); + } + } + } +} + + +int main(int argc, char *argv[]) +{ + std::vector<country_type> countries; + boost::geometry::model::box<point_2d> box; + boost::geometry::assign_inverse(box); + read_wkt("../data/world.wkt", countries, box); + + QApplication app(argc, argv); + MapperWidget widget(countries, box); + widget.setWindowTitle("Boost.Geometry for Qt - Hello World!"); + widget.setGeometry(50, 50, 800, 500); + widget.show(); + return app.exec(); +} diff --git a/libs/geometry/example/with_external_libs/x06_qt_world_mapper.sln b/libs/geometry/example/with_external_libs/x06_qt_world_mapper.sln new file mode 100644 index 000000000..32cfaf4ad --- /dev/null +++ b/libs/geometry/example/with_external_libs/x06_qt_world_mapper.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x06_qt_world_mapper", "x06_qt_world_mapper.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 diff --git a/libs/geometry/example/with_external_libs/x06_qt_world_mapper.vcproj b/libs/geometry/example/with_external_libs/x06_qt_world_mapper.vcproj new file mode 100644 index 000000000..efee2124e --- /dev/null +++ b/libs/geometry/example/with_external_libs/x06_qt_world_mapper.vcproj @@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="x06_qt_world_mapper" + ProjectGUID="{242C6ADC-3A10-4B69-81F7-5669E0582A8B}" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\x06_qt_world_mapper" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\qt.vsprops" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="1" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\x06_qt_world_mapper" + ConfigurationType="1" + InheritedPropertySheets="..\boost.vsprops;.\qt.vsprops" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../.." + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + UsePrecompiledHeader="0" + WarningLevel="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalLibraryDirectories="" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\x06_qt_world_mapper.cpp" + > + </File> + <File + RelativePath=".\x06_qt_world_mapper_readme.txt" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/example/with_external_libs/x06_qt_world_mapper_readme.txt b/libs/geometry/example/with_external_libs/x06_qt_world_mapper_readme.txt new file mode 100644 index 000000000..8c67025e2 --- /dev/null +++ b/libs/geometry/example/with_external_libs/x06_qt_world_mapper_readme.txt @@ -0,0 +1,31 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, Amsterdam, the Netherlands +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +Qt World Mapper example + +It will show a basic Qt Widget, displaying world countries + +To compile this program: + +Install Qt (if not done before) +Install Boost (if not done before) + +Using MSVC: + - edit the file qt.vsprops + - set the UserMacro QT to point to your Qt distribution + - edit the file boost.vsprops + - set the UserMacro BOOST_ROOT to point to your Boost distribution + - alternatively you can include Boost and/or Qt in your standard include path + +Using Linux/gcc + - install Qt with sudo apt-get install libqt4-dev + - run qmake -project + - edit the generated file "with_external_libs.pro" and delete all lines but the x06_qt_world_mapper.cpp + - run qmake + - edit the generated Makefile, if necessary, and add -I../../../.. to include Boost and Boost.Geometry + - run make + |