/Src/Dependencies/Boost/libs/geometry/test/domains/gis/io/wkt/multi_wkt.cpp

http://hadesmem.googlecode.com/ · C++ · 88 lines · 34 code · 22 blank · 32 comment · 0 complexity · 8e41a6c6c20a2c187b7980fbd6e6e998 MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. //#include <iostream>
  12. #include <sstream>
  13. #include <string>
  14. #include <boost/algorithm/string.hpp>
  15. #include <boost/concept/requires.hpp>
  16. #include <boost/test/floating_point_comparison.hpp>
  17. #include <boost/test/included/test_exec_monitor.hpp>
  18. #include <boost/geometry/geometries/geometries.hpp>
  19. #include <boost/geometry/multi/algorithms/area.hpp>
  20. #include <boost/geometry/multi/algorithms/length.hpp>
  21. #include <boost/geometry/multi/algorithms/num_points.hpp>
  22. #include <boost/geometry/multi/algorithms/perimeter.hpp>
  23. #include <boost/geometry/multi/core/point_type.hpp>
  24. #include <boost/geometry/multi/core/topological_dimension.hpp>
  25. #include <boost/geometry/multi/geometries/multi_point.hpp>
  26. #include <boost/geometry/multi/geometries/multi_linestring.hpp>
  27. #include <boost/geometry/multi/geometries/multi_polygon.hpp>
  28. #include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>
  29. #include <boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp>
  30. template <typename T>
  31. void test_all();
  32. // Include the single test
  33. #define GEOMETRY_TEST_MULTI
  34. #include "domains/gis/io/wkt/wkt.cpp"
  35. template <typename T>
  36. void test_all()
  37. {
  38. using namespace boost::geometry;
  39. typedef bg::model::point<T, 2, bg::cs::cartesian> P;
  40. test_wkt<bg::model::multi_point<P> >("multipoint((1 2),(3 4))", 2);
  41. test_wkt<bg::model::multi_linestring<bg::model::linestring<P> > >("multilinestring((1 1,2 2,3 3),(4 4,5 5,6 6))", 6, 4 * sqrt(2.0));
  42. test_wkt<bg::model::multi_polygon<bg::model::polygon<P> > >("multipolygon(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))", 15, 0, 21, 28);
  43. test_wrong_wkt<bg::model::multi_polygon<bg::model::polygon<P> > >(
  44. "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),(0 0,0 4,4 4,4 0,0 0)))",
  45. "expected '('");
  46. }
  47. /*
  48. ... see comments in "wkt.cpp"
  49. union select 13,'# mpoint',npoints(geomfromtext('MULTIPOINT((1 2),(3 4))'))
  50. union select 14,'length mpoint',length(geomfromtext('MULTIPOINT((1 2),(3 4))'))
  51. union select 15,'peri mpoint',perimeter(geomfromtext('MULTIPOINT((1 2),(3 4))'))
  52. union select 16,'area mpoint',area(geomfromtext('MULTIPOINT((1 2),(3 4))'))
  53. union select 17,'# mls',npoints(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
  54. union select 18,'length mls',length(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
  55. union select 19,'peri mls',perimeter(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
  56. union select 20,'area mls',area(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
  57. union select 21,'# mpoly',npoints(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
  58. union select 22,'length mpoly',length(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
  59. union select 23,'peri mpoly',perimeter(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
  60. union select 24,'area mpoly',area(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
  61. */