diff --git a/test/multi/io/Jamfile.v2 b/test/multi/io/Jamfile.v2 index cf1cf59c9..6985a7ab9 100644 --- a/test/multi/io/Jamfile.v2 +++ b/test/multi/io/Jamfile.v2 @@ -8,4 +8,5 @@ # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -build-project wkt ; \ No newline at end of file +build-project wkt ; +build-project dsv ; diff --git a/test/multi/io/dsv/Jamfile.v2 b/test/multi/io/dsv/Jamfile.v2 new file mode 100644 index 000000000..1434d754e --- /dev/null +++ b/test/multi/io/dsv/Jamfile.v2 @@ -0,0 +1,15 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +# 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) + +test-suite boost-geometry-multi-io-dsv + : + [ run dsv.cpp ] + ; + diff --git a/test/multi/io/dsv/dsv.cpp b/test/multi/io/dsv/dsv.cpp new file mode 100644 index 000000000..7f565906f --- /dev/null +++ b/test/multi/io/dsv/dsv.cpp @@ -0,0 +1,100 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// 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) + + +#include + +#include + +#include +#include +#include +#include + +template +void test_dsv(std::string const& wkt, std::string const& expected, bool json = false) +{ + Geometry geometry; + bg::read_wkt(wkt, geometry); + std::ostringstream out; + if (json) + { + out << bg::dsv(geometry, ", ", "[", "]", ", ", "[ ", " ]", ", "); + } + else + { + out << bg::dsv(geometry); + } + BOOST_CHECK_EQUAL(out.str(), expected); +} + + +template +void test_all() +{ + using namespace boost::geometry; + typedef model::point point_type; + typedef model::multi_point mpoint; + typedef model::multi_linestring > mline; + typedef model::multi_polygon > mpoly; + + test_dsv + ( + "multipoint((1 2),(3 4))", + "((1, 2), (3, 4))" + ); + test_dsv + ( + "multilinestring((1 1,2 2,3 3),(4 4,5 5,6 6))", + "(((1, 1), (2, 2), (3, 3)), ((4, 4), (5, 5), (6, 6)))" + ); + test_dsv + ( + // Multi with 2 poly's, first has hole, second is triangle + "multipolygon(((0 0,0 4,4 4,4 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((5 5,6 5,5 6,5 5)))", + "((((0, 0), (0, 4), (4, 4), (4, 0), (0, 0)), ((1, 1), (1, 2), (2, 2), (2, 1), (1, 1))), (((5, 5), (6, 5), (5, 6), (5, 5))))" + ); + + // http://geojson.org/geojson-spec.html#id5 + test_dsv + ( + "multipoint((1 2),(3 4))", + "[ [1, 2], [3, 4] ]", + true + ); + + // http://geojson.org/geojson-spec.html#id6 + test_dsv + ( + "multilinestring((1 1,2 2,3 3),(4 4,5 5,6 6))", + "[ [ [1, 1], [2, 2], [3, 3] ], [ [4, 4], [5, 5], [6, 6] ] ]", + true + ); + + // http://geojson.org/geojson-spec.html#id7 + test_dsv + ( + "multipolygon(((0 0,0 4,4 4,4 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((5 5,6 5,5 6,5 5)))", + "[ [ [ [0, 0], [0, 4], [4, 4], [4, 0], [0, 0] ], [ [1, 1], [1, 2], [2, 2], [2, 1], [1, 1] ] ], [ [ [5, 5], [6, 5], [5, 6], [5, 5] ] ] ]", + true + ); + +} + + +int test_main(int, char* []) +{ + test_all(); + test_all(); + + return 0; +} + diff --git a/test/multi/io/dsv/dsv.sln b/test/multi/io/dsv/dsv.sln new file mode 100644 index 000000000..ecea59719 --- /dev/null +++ b/test/multi/io/dsv/dsv.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{6CD4A68C-3EA1-11E1-B9E4-BF144924019B}") = "dsv", "dsv.vcproj", "{7463ED40-3EA1-11E1-9FC7-D0144924019B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7463ED40-3EA1-11E1-9FC7-D0144924019B}.Debug|Win32.ActiveCfg = Debug|Win32 + {7463ED40-3EA1-11E1-9FC7-D0144924019B}.Debug|Win32.Build.0 = Debug|Win32 + {7463ED40-3EA1-11E1-9FC7-D0144924019B}.Release|Win32.ActiveCfg = Release|Win32 + {7463ED40-3EA1-11E1-9FC7-D0144924019B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/test/multi/io/dsv/dsv.vcproj b/test/multi/io/dsv/dsv.vcproj new file mode 100644 index 000000000..494551daa --- /dev/null +++ b/test/multi/io/dsv/dsv.vcproj @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +