// // Copyright (C) 2007 Refractions Research, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of version 2.1 of the GNU Lesser // General Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // #include "Pch.h" #include "PgGeometryTest.h" // EWKB<->FGF // NOTE: The PgGeometry stuff is built-in directly into UnitTest program // (see UnitTest project, Folder Misc), but not called from PostGisProvider.dll // library, because the PgGeomery operations are not publicly exported. #include //std #include // boost #include CPPUNIT_TEST_SUITE_REGISTRATION(PgGeometryTest); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(PgGeometryTest, "PgGeometryTest"); // Namespace defining EWKB geometry parser using namespace fdo::postgis::ewkb; PgGeometryTest::PgGeometryTest() { } PgGeometryTest::~PgGeometryTest() { } void PgGeometryTest::setUp() { } void PgGeometryTest::tearDown() { } void PgGeometryTest::testPoint() { // POINT(1.234 5.678) ewkb_t ewkb; std::string original("POINT (1.234 5.678)"); std::string ewkbhex("01010000005839B4C876BEF33F83C0CAA145B61640"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointSRID() { // SRID=32632;POINT(1.234 5.678) ewkb_t ewkb; std::string original("POINT (1.234 5.678)"); std::string ewkbhex("0101000020787F00005839B4C876BEF33F83C0CAA145B61640"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointZ() { // POINT(1.234 5.678 99) ewkb_t ewkb; std::string original("POINT XYZ (1.234 5.678 99)"); std::string ewkbhex("01010000805839b4c876bef33f83c0caa145b616400000000000c05840"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointSRIDZ() { // SRID=4326;POINT(1.234 5.678 99) ewkb_t ewkb; std::string original("POINT XYZ (1.234 5.678 99)"); std::string ewkbhex("01010000a0e61000005839b4c876bef33f83c0caa145b616400000000000c05840"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointM() { // POINTM(1.234 5.678 99) ewkb_t ewkb; std::string original("POINT XYM (1.234 5.678 99)"); std::string ewkbhex("01010000405839B4C876BEF33F83C0CAA145B616400000000000C05840"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointSRIDM() { // SRID=32632;POINTM(1.234 5.678 99) ewkb_t ewkb; std::string original("POINT XYM (1.234 5.678 99)"); std::string ewkbhex("0101000060787f00005839b4c876bef33f83c0caa145b616400000000000c05840"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointZM() { // POINT(1.234 5.678 15 79) ewkb_t ewkb; std::string original("POINT XYZM (1.234 5.678 15 79)"); std::string ewkbhex("01010000C05839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPointSRIDZM() { // SRID=4326;POINT(1.234 5.678 15 79) std::string original("POINT XYZM (1.234 5.678 15 79)"); std::string ewkbhex("01010000e0e61000005839b4c876bef33f83c0caa145b616400000000000002e400000000000c05340"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineString() { // LINESTRING(1.123 1.456, 2.123 2.456, 3.123 3.456) std::string original("LINESTRING (1.123 1.456, 2.123 2.456, 3.123 3.456)"); std::string ewkbhex("0102000000030000002b8716d9cef7f13fb29defa7c64bf73f96438b6ce7fb0040d9cef753e3a5034096438b6ce7fb0840d9cef753e3a50b40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringSRID() { // SRID=32632;LINESTRING(1.123 1.456, 2.123 2.456, 3.123 3.456) std::string original("LINESTRING (1.123 1.456, 2.123 2.456, 3.123 3.456)"); std::string ewkbhex("0102000020787f0000030000002b8716d9cef7f13fb29defa7c64bf73f96438b6ce7fb0040d9cef753e3a5034096438b6ce7fb0840d9cef753e3a50b40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringZ() { // LINESTRING(1.123 1.456 100, 2.123 2.456 105, 3.123 3.456 110) std::string original("LINESTRING XYZ (1.123 1.456 100, 2.123 2.456 105, 3.123 3.456 110)"); std::string ewkbhex("0102000080030000002b8716d9cef7f13fb29defa7c64bf73f000000000000594096438b6ce7fb0040d9cef753e3a503400000000000405a4096438b6ce7fb0840d9cef753e3a50b400000000000805b40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringSRIDZ() { // SRID=32632;LINESTRING(1.123 1.456 100, 2.123 2.456 105, 3.123 3.456 110) std::string original("LINESTRING XYZ (1.123 1.456 100, 2.123 2.456 105, 3.123 3.456 110)"); std::string ewkbhex("01020000a0787f0000030000002b8716d9cef7f13fb29defa7c64bf73f000000000000594096438b6ce7fb0040d9cef753e3a503400000000000405a4096438b6ce7fb0840d9cef753e3a50b400000000000805b40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringM() { // LINESTRINGM(2 3 4,3 4 5) std::string original("LINESTRING XYM (2 3 4, 3 4 5)"); std::string ewkbhex("010200004002000000000000000000004000000000000008400000000000001040000000000000084000000000000010400000000000001440"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringSRIDM() { // SRID=32632;LINESTRINGM(2 3 4,3 4 5) std::string original("LINESTRING XYM (2 3 4, 3 4 5)"); std::string ewkbhex("0102000060787f000002000000000000000000004000000000000008400000000000001040000000000000084000000000000010400000000000001440"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringZM() { // LINESTRING(1.123 1.456 100 1, 2.123 2.456 105 1, 3.123 3.456 110 1) std::string original("LINESTRING XYZM (1.123 1.456 100 1, 2.123 2.456 105 1, 3.123 3.456 110 1)"); std::string ewkbhex("01020000c0030000002b8716d9cef7f13fb29defa7c64bf73f0000000000005940000000000000f03f96438b6ce7fb0040d9cef753e3a503400000000000405a40000000000000f03f96438b6ce7fb0840d9cef753e3a50b400000000000805b40000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testLineStringSRIDZM() { // SRID=32632;LINESTRING(1.123 1.456 100 1, 2.123 2.456 105 1, 3.123 3.456 110 1) std::string original("LINESTRING XYZM (1.123 1.456 100 1, 2.123 2.456 105 1, 3.123 3.456 110 1)"); std::string ewkbhex("01020000e0787f0000030000002b8716d9cef7f13fb29defa7c64bf73f0000000000005940000000000000f03f96438b6ce7fb0040d9cef753e3a503400000000000405a40000000000000f03f96438b6ce7fb0840d9cef753e3a50b400000000000805b40000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygon() { // POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)) std::string original("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))"); std::string ewkbhex("01030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000f03f000000000000f03f0000000000000040000000000000f03f00000000000000400000000000000040000000000000f03f0000000000000040000000000000f03f000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonSRID() { // SRID=32632;POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)) std::string original("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))"); std::string ewkbhex("0103000020787f00000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000f03f000000000000f03f0000000000000040000000000000f03f00000000000000400000000000000040000000000000f03f0000000000000040000000000000f03f000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonZ() { // POLYGON((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)) std::string original("POLYGON XYZ ((0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0), (1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0))"); std::string ewkbhex("0103000080020000000500000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000010400000000000001040000000000000000000000000000000000000000000001040000000000000000000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f00000000000000000000000000000040000000000000f03f0000000000000000000000000000004000000000000000400000000000000000000000000000f03f00000000000000400000000000000000000000000000f03f000000000000f03f0000000000000000"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonSRIDZ() { // SRID=32632;POLYGON((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)) std::string original("POLYGON XYZ ((0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0), (1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0))"); std::string ewkbhex("01030000a0787f0000020000000500000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000010400000000000001040000000000000000000000000000000000000000000001040000000000000000000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f00000000000000000000000000000040000000000000f03f0000000000000000000000000000004000000000000000400000000000000000000000000000f03f00000000000000400000000000000000000000000000f03f000000000000f03f0000000000000000"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonM() { // POLYGONM((0 0 7,4 0 7,4 4 7,0 4 7,0 0 7),(1 1 7,2 1 7,2 2 7,1 2 7,1 1 7)) std::string original("POLYGON XYM ((0 0 7, 4 0 7, 4 4 7, 0 4 7, 0 0 7), (1 1 7, 2 1 7, 2 2 7, 1 2 7, 1 1 7))"); std::string ewkbhex("01030000400200000005000000000000000000000000000000000000000000000000001c40000000000000104000000000000000000000000000001c40000000000000104000000000000010400000000000001c40000000000000000000000000000010400000000000001c40000000000000000000000000000000000000000000001c4005000000000000000000f03f000000000000f03f0000000000001c400000000000000040000000000000f03f0000000000001c40000000000000004000000000000000400000000000001c40000000000000f03f00000000000000400000000000001c40000000000000f03f000000000000f03f0000000000001c40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonSRIDM() { // SRID=4326;POLYGONM((0 0 7,4 0 7,4 4 7,0 4 7,0 0 7),(1 1 7,2 1 7,2 2 7,1 2 7,1 1 7)) std::string original("POLYGON XYM ((0 0 7, 4 0 7, 4 4 7, 0 4 7, 0 0 7), (1 1 7, 2 1 7, 2 2 7, 1 2 7, 1 1 7))"); std::string ewkbhex("0103000060e61000000200000005000000000000000000000000000000000000000000000000001c40000000000000104000000000000000000000000000001c40000000000000104000000000000010400000000000001c40000000000000000000000000000010400000000000001c40000000000000000000000000000000000000000000001c4005000000000000000000f03f000000000000f03f0000000000001c400000000000000040000000000000f03f0000000000001c40000000000000004000000000000000400000000000001c40000000000000f03f00000000000000400000000000001c40000000000000f03f000000000000f03f0000000000001c40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonZM() { // POLYGON((0 0 0 99,4 0 0 99,4 4 0 99,0 4 0 99,0 0 0 99),(1 1 0 99,2 1 0 99,2 2 0 99,1 2 0 99,1 1 0 99)) std::string original("POLYGON XYZM ((0 0 0 99, 4 0 0 99, 4 4 0 99, 0 4 0 99, 0 0 0 99), (1 1 0 99, 2 1 0 99, 2 2 0 99, 1 2 0 99, 1 1 0 99))"); std::string ewkbhex("01030000c002000000050000000000000000000000000000000000000000000000000000000000000000c058400000000000001040000000000000000000000000000000000000000000c058400000000000001040000000000000104000000000000000000000000000c058400000000000000000000000000000104000000000000000000000000000c058400000000000000000000000000000000000000000000000000000000000c0584005000000000000000000f03f000000000000f03f00000000000000000000000000c058400000000000000040000000000000f03f00000000000000000000000000c058400000000000000040000000000000004000000000000000000000000000c05840000000000000f03f000000000000004000000000000000000000000000c05840000000000000f03f000000000000f03f00000000000000000000000000c05840"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testPolygonSRIDZM() { // SRID=4326;POLYGON((0 0 0 99,4 0 0 99,4 4 0 99,0 4 0 99,0 0 0 99),(1 1 0 99,2 1 0 99,2 2 0 99,1 2 0 99,1 1 0 99)) std::string original("POLYGON XYZM ((0 0 0 99, 4 0 0 99, 4 4 0 99, 0 4 0 99, 0 0 0 99), (1 1 0 99, 2 1 0 99, 2 2 0 99, 1 2 0 99, 1 1 0 99))"); std::string ewkbhex("01030000e0e610000002000000050000000000000000000000000000000000000000000000000000000000000000c058400000000000001040000000000000000000000000000000000000000000c058400000000000001040000000000000104000000000000000000000000000c058400000000000000000000000000000104000000000000000000000000000c058400000000000000000000000000000000000000000000000000000000000c0584005000000000000000000f03f000000000000f03f00000000000000000000000000c058400000000000000040000000000000f03f00000000000000000000000000c058400000000000000040000000000000004000000000000000000000000000c05840000000000000f03f000000000000004000000000000000000000000000c05840000000000000f03f000000000000f03f00000000000000000000000000c05840"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPoint() { // MULTIPOINT(1.123 1.456, 2.123 2.456, 3.123 3.456) ewkb_t ewkb; std::string original("MULTIPOINT (1.123 1.456, 2.123 2.456, 3.123 3.456)"); std::string ewkbhex("01040000000300000001010000002b8716d9cef7f13fb29defa7c64bf73f010100000096438b6ce7fb0040d9cef753e3a50340010100000096438b6ce7fb0840d9cef753e3a50b40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointSRID() { // SRID=4326;MULTIPOINT(1.123 1.456, 2.123 2.456, 3.123 3.456) ewkb_t ewkb; std::string original("MULTIPOINT (1.123 1.456, 2.123 2.456, 3.123 3.456)"); std::string ewkbhex("0104000020e61000000300000001010000002b8716d9cef7f13fb29defa7c64bf73f010100000096438b6ce7fb0040d9cef753e3a50340010100000096438b6ce7fb0840d9cef753e3a50b40"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointZ() { // MULTIPOINT(1.123 1.456 101, 2.123 2.456 102, 3.123 3.456 103) ewkb_t ewkb; std::string original("MULTIPOINT XYZ (1.123 1.456 101, 2.123 2.456 102, 3.123 3.456 103)"); std::string ewkbhex("01040000800300000001010000802b8716d9cef7f13fb29defa7c64bf73f0000000000405940010100008096438b6ce7fb0040d9cef753e3a503400000000000805940010100008096438b6ce7fb0840d9cef753e3a50b400000000000c05940"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointSRIDZ() { // SRID=4326;MULTIPOINT(1.123 1.456 101, 2.123 2.456 102, 3.123 3.456 103) ewkb_t ewkb; std::string original("MULTIPOINT XYZ (1.123 1.456 101, 2.123 2.456 102, 3.123 3.456 103)"); std::string ewkbhex("01040000a0e61000000300000001010000802b8716d9cef7f13fb29defa7c64bf73f0000000000405940010100008096438b6ce7fb0040d9cef753e3a503400000000000805940010100008096438b6ce7fb0840d9cef753e3a50b400000000000c05940"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointM() { // MULTIPOINTM(0 0 0,1 2 1) ewkb_t ewkb; std::string original("MULTIPOINT XYM (0 0 0, 1 2 1)"); std::string ewkbhex("01040000400200000001010000400000000000000000000000000000000000000000000000000101000040000000000000f03f0000000000000040000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointSRIDM() { // SRID=4326;MULTIPOINTM(0 0 0,1 2 1) ewkb_t ewkb; std::string original("MULTIPOINT XYM (0 0 0, 1 2 1)"); std::string ewkbhex("0104000060E61000000200000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F0000000000000040000000000000F03F"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointZM() { // MULTIPOINT(1.123 1.456 101 7, 2.123 2.456 102 8, 3.123 3.456 103 9) ewkb_t ewkb; std::string original("MULTIPOINT XYZM (1.123 1.456 101 7, 2.123 2.456 102 8, 3.123 3.456 103 9)"); std::string ewkbhex("01040000c00300000001010000c02b8716d9cef7f13fb29defa7c64bf73f00000000004059400000000000001c4001010000c096438b6ce7fb0040d9cef753e3a503400000000000805940000000000000204001010000c096438b6ce7fb0840d9cef753e3a50b400000000000c059400000000000002240"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPointSRIDZM() { // SRID=4326;MULTIPOINT(1.123 1.456 101 7, 2.123 2.456 102 8, 3.123 3.456 103 9) ewkb_t ewkb; std::string original("MULTIPOINT XYZM (1.123 1.456 101 7, 2.123 2.456 102 8, 3.123 3.456 103 9)"); std::string ewkbhex("01040000e0e61000000300000001010000c02b8716d9cef7f13fb29defa7c64bf73f00000000004059400000000000001c4001010000c096438b6ce7fb0040d9cef753e3a503400000000000805940000000000000204001010000c096438b6ce7fb0840d9cef753e3a50b400000000000c059400000000000002240"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineString() { // MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)) ewkb_t ewkb; std::string original("MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))"); std::string ewkbhex("01050000000200000001020000000300000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f0000000000000040010200000003000000000000000000004000000000000008400000000000000840000000000000004000000000000014400000000000001040"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringSRID() { // SRID=4326;MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)) ewkb_t ewkb; std::string original("MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))"); std::string ewkbhex("0105000020e61000000200000001020000000300000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f0000000000000040010200000003000000000000000000004000000000000008400000000000000840000000000000004000000000000014400000000000001040"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringZ() { // MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4 1)) ewkb_t ewkb; std::string original("MULTILINESTRING XYZ ((0 0 0, 1 1 0, 1 2 1), (2 3 1, 3 2 1, 5 4 1))"); std::string ewkbhex("010500008002000000010200008003000000000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000000000000000000F03F0000000000000040000000000000F03F01020000800300000000000000000000400000000000000840000000000000F03F00000000000008400000000000000040000000000000F03F00000000000014400000000000001040000000000000F03F"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringSRIDZ() { // SRID=4326MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4 1)) ewkb_t ewkb; std::string original("MULTILINESTRING XYZ ((0 0 0, 1 1 0, 1 2 1), (2 3 1, 3 2 1, 5 4 1))"); std::string ewkbhex("01050000a0e610000002000000010200008003000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f0000000000000040000000000000f03f01020000800300000000000000000000400000000000000840000000000000f03f00000000000008400000000000000040000000000000f03f00000000000014400000000000001040000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringM() { // MULTILINESTRINGM((0 0 0,1 1 0,1 2 0),(2 3 1,3 2 1,5 4 1)) ewkb_t ewkb; std::string original("MULTILINESTRING XYM ((0 0 0, 1 1 0, 1 2 0), (2 3 1, 3 2 1, 5 4 1))"); std::string ewkbhex("010500004002000000010200004003000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f0000000000000040000000000000000001020000400300000000000000000000400000000000000840000000000000f03f00000000000008400000000000000040000000000000f03f00000000000014400000000000001040000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringSRIDM() { // SRID=4326;MULTILINESTRINGM((0 0 0,1 1 0,1 2 0),(2 3 1,3 2 1,5 4 1)) ewkb_t ewkb; std::string original("MULTILINESTRING XYM ((0 0 0, 1 1 0, 1 2 0), (2 3 1, 3 2 1, 5 4 1))"); std::string ewkbhex("0105000060e610000002000000010200004003000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f0000000000000040000000000000000001020000400300000000000000000000400000000000000840000000000000f03f00000000000008400000000000000040000000000000f03f00000000000014400000000000001040000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringZM() { // MULTILINESTRING((0 0 99 0,1 1 99 0,1 2 99 0),(2 3 101 1,3 2 101 1,5 4 101 1)) ewkb_t ewkb; std::string original("MULTILINESTRING XYZM ((0 0 99 0, 1 1 99 0, 1 2 99 0), (2 3 101 1, 3 2 101 1, 5 4 101 1))"); std::string ewkbhex("01050000c00200000001020000c003000000000000000000000000000000000000000000000000c058400000000000000000000000000000f03f000000000000f03f0000000000c058400000000000000000000000000000f03f00000000000000400000000000c05840000000000000000001020000c003000000000000000000004000000000000008400000000000405940000000000000f03f000000000000084000000000000000400000000000405940000000000000f03f000000000000144000000000000010400000000000405940000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiLineStringSRIDZM() { // SRID=4326;MULTILINESTRING((0 0 99 0,1 1 99 0,1 2 99 0),(2 3 101 1,3 2 101 1,5 4 101 1)) ewkb_t ewkb; std::string original("MULTILINESTRING XYZM ((0 0 99 0, 1 1 99 0, 1 2 99 0), (2 3 101 1, 3 2 101 1, 5 4 101 1))"); std::string ewkbhex("01050000e0e61000000200000001020000c003000000000000000000000000000000000000000000000000c058400000000000000000000000000000f03f000000000000f03f0000000000c058400000000000000000000000000000f03f00000000000000400000000000c05840000000000000000001020000c003000000000000000000004000000000000008400000000000405940000000000000f03f000000000000084000000000000000400000000000405940000000000000f03f000000000000144000000000000010400000000000405940000000000000f03f"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygon() { // MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)),((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))) ewkb_t ewkb; std::string original("MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))"); std::string ewkbhex("01060000000200000001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000f03f000000000000f03f0000000000000040000000000000f03f00000000000000400000000000000040000000000000f03f0000000000000040000000000000f03f000000000000f03f01030000000100000005000000000000000000f0bf000000000000f0bf000000000000f0bf00000000000000c000000000000000c000000000000000c000000000000000c0000000000000f0bf000000000000f0bf000000000000f0bf"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonSRID() { // SRID=32632;MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)),((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))) ewkb_t ewkb; std::string original("MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))"); std::string ewkbhex("0106000020787f00000200000001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000f03f000000000000f03f0000000000000040000000000000f03f00000000000000400000000000000040000000000000f03f0000000000000040000000000000f03f000000000000f03f01030000000100000005000000000000000000f0bf000000000000f0bf000000000000f0bf00000000000000c000000000000000c000000000000000c000000000000000c0000000000000f0bf000000000000f0bf000000000000f0bf"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonZ() { // MULTIPOLYGON(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0))) ewkb_t ewkb; std::string original("MULTIPOLYGON XYZ (((0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0), (1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0)), ((-1 -1 0, -1 -2 0, -2 -2 0, -2 -1 0, -1 -1 0)))"); std::string ewkbhex("0106000080020000000103000080020000000500000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000010400000000000001040000000000000000000000000000000000000000000001040000000000000000000000000000000000000000000000000000000000000000005000000000000000000F03F000000000000F03F00000000000000000000000000000040000000000000F03F0000000000000000000000000000004000000000000000400000000000000000000000000000F03F00000000000000400000000000000000000000000000F03F000000000000F03F000000000000000001030000800100000005000000000000000000F0BF000000000000F0BF0000000000000000000000000000F0BF00000000000000C0000000000000000000000000000000C000000000000000C0000000000000000000000000000000C0000000000000F0BF0000000000000000000000000000F0BF000000000000F0BF0000000000000000"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonSRIDZ() { // SRID=32632;MULTIPOLYGON(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0))) ewkb_t ewkb; std::string original("MULTIPOLYGON XYZ (((0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0), (1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0)), ((-1 -1 0, -1 -2 0, -2 -2 0, -2 -1 0, -1 -1 0)))"); std::string ewkbhex("01060000a0787f0000020000000103000080020000000500000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000010400000000000001040000000000000000000000000000000000000000000001040000000000000000000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f00000000000000000000000000000040000000000000f03f0000000000000000000000000000004000000000000000400000000000000000000000000000f03f00000000000000400000000000000000000000000000f03f000000000000f03f000000000000000001030000800100000005000000000000000000f0bf000000000000f0bf0000000000000000000000000000f0bf00000000000000c0000000000000000000000000000000c000000000000000c0000000000000000000000000000000c0000000000000f0bf0000000000000000000000000000f0bf000000000000f0bf0000000000000000"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonM() { // MULTIPOLYGONM(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0))) ewkb_t ewkb; std::string original("MULTIPOLYGON XYM (((0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0), (1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0)), ((-1 -1 0, -1 -2 0, -2 -2 0, -2 -1 0, -1 -1 0)))"); std::string ewkbhex("0106000040020000000103000040020000000500000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000010400000000000001040000000000000000000000000000000000000000000001040000000000000000000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f00000000000000000000000000000040000000000000f03f0000000000000000000000000000004000000000000000400000000000000000000000000000f03f00000000000000400000000000000000000000000000f03f000000000000f03f000000000000000001030000400100000005000000000000000000f0bf000000000000f0bf0000000000000000000000000000f0bf00000000000000c0000000000000000000000000000000c000000000000000c0000000000000000000000000000000c0000000000000f0bf0000000000000000000000000000f0bf000000000000f0bf0000000000000000"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonSRIDM() { // SRID=32632;MULTIPOLYGONM(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0))) ewkb_t ewkb; std::string original("MULTIPOLYGON XYM (((0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0), (1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0)), ((-1 -1 0, -1 -2 0, -2 -2 0, -2 -1 0, -1 -1 0)))"); std::string ewkbhex("0106000060787f0000020000000103000040020000000500000000000000000000000000000000000000000000000000000000000000000010400000000000000000000000000000000000000000000010400000000000001040000000000000000000000000000000000000000000001040000000000000000000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f00000000000000000000000000000040000000000000f03f0000000000000000000000000000004000000000000000400000000000000000000000000000f03f00000000000000400000000000000000000000000000f03f000000000000f03f000000000000000001030000400100000005000000000000000000f0bf000000000000f0bf0000000000000000000000000000f0bf00000000000000c0000000000000000000000000000000c000000000000000c0000000000000000000000000000000c0000000000000f0bf0000000000000000000000000000f0bf000000000000f0bf0000000000000000"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonZM() { // MULTIPOLYGON(((0 0 0 1,4 0 0 1,4 4 0 1,0 4 0 1,0 0 0 1),(1 1 0 5,2 1 0 5,2 2 0 5,1 2 0 5,1 1 0 5)),((-1 -1 0 10,-1 -2 0 10,-2 -2 0 10,-2 -1 0 10,-1 -1 0 10))) ewkb_t ewkb; std::string original("MULTIPOLYGON XYZM (((0 0 0 1, 4 0 0 1, 4 4 0 1, 0 4 0 1, 0 0 0 1), (1 1 0 5, 2 1 0 5, 2 2 0 5, 1 2 0 5, 1 1 0 5)), ((-1 -1 0 10, -1 -2 0 10, -2 -2 0 10, -2 -1 0 10, -1 -1 0 10)))"); std::string ewkbhex("01060000c00200000001030000c00200000005000000000000000000000000000000000000000000000000000000000000000000f03f000000000000104000000000000000000000000000000000000000000000f03f000000000000104000000000000010400000000000000000000000000000f03f000000000000000000000000000010400000000000000000000000000000f03f000000000000000000000000000000000000000000000000000000000000f03f05000000000000000000f03f000000000000f03f000000000000000000000000000014400000000000000040000000000000f03f000000000000000000000000000014400000000000000040000000000000004000000000000000000000000000001440000000000000f03f000000000000004000000000000000000000000000001440000000000000f03f000000000000f03f0000000000000000000000000000144001030000c00100000005000000000000000000f0bf000000000000f0bf00000000000000000000000000002440000000000000f0bf00000000000000c00000000000000000000000000000244000000000000000c000000000000000c00000000000000000000000000000244000000000000000c0000000000000f0bf00000000000000000000000000002440000000000000f0bf000000000000f0bf00000000000000000000000000002440"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testMultiPolygonSRIDZM() { // SRID=32632;MULTIPOLYGON(((0 0 0 1,4 0 0 1,4 4 0 1,0 4 0 1,0 0 0 1),(1 1 0 5,2 1 0 5,2 2 0 5,1 2 0 5,1 1 0 5)),((-1 -1 0 10,-1 -2 0 10,-2 -2 0 10,-2 -1 0 10,-1 -1 0 10))) ewkb_t ewkb; std::string original("MULTIPOLYGON XYZM (((0 0 0 1, 4 0 0 1, 4 4 0 1, 0 4 0 1, 0 0 0 1), (1 1 0 5, 2 1 0 5, 2 2 0 5, 1 2 0 5, 1 1 0 5)), ((-1 -1 0 10, -1 -2 0 10, -2 -2 0 10, -2 -1 0 10, -1 -1 0 10)))"); std::string ewkbhex("01060000e0787f00000200000001030000c00200000005000000000000000000000000000000000000000000000000000000000000000000f03f000000000000104000000000000000000000000000000000000000000000f03f000000000000104000000000000010400000000000000000000000000000f03f000000000000000000000000000010400000000000000000000000000000f03f000000000000000000000000000000000000000000000000000000000000f03f05000000000000000000f03f000000000000f03f000000000000000000000000000014400000000000000040000000000000f03f000000000000000000000000000014400000000000000040000000000000004000000000000000000000000000001440000000000000f03f000000000000004000000000000000000000000000001440000000000000f03f000000000000f03f0000000000000000000000000000144001030000c00100000005000000000000000000f0bf000000000000f0bf00000000000000000000000000002440000000000000f0bf00000000000000c00000000000000000000000000000244000000000000000c000000000000000c00000000000000000000000000000244000000000000000c0000000000000f0bf00000000000000000000000000002440000000000000f0bf000000000000f0bf00000000000000000000000000002440"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollection() { // GEOMETRYCOLLECTION(POINT(2 3),LINESTRING(2 3,3 4)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT (2 3), LINESTRING (2 3, 3 4))"); std::string ewkbhex("0107000000020000000101000000000000000000004000000000000008400102000000020000000000000000000040000000000000084000000000000008400000000000001040"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionSRID() { // SRID=32632;GEOMETRYCOLLECTION(POINT(2 3),LINESTRING(2 3,3 4)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT (2 3), LINESTRING (2 3, 3 4))"); std::string ewkbhex("0107000020787f0000020000000101000000000000000000004000000000000008400102000000020000000000000000000040000000000000084000000000000008400000000000001040"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionZ() { // GEOMETRYCOLLECTION(POINT(2 3 101),LINESTRING(2 3 102,3 4 103)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT XYZ (2 3 101), LINESTRING XYZ (2 3 102, 3 4 103))"); std::string ewkbhex("0107000080020000000101000080000000000000004000000000000008400000000000405940010200008002000000000000000000004000000000000008400000000000805940000000000000084000000000000010400000000000c05940"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionSRIDZ() { // SRID=32632;GEOMETRYCOLLECTION(POINT(2 3 101),LINESTRING(2 3 102,3 4 103)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT XYZ (2 3 101), LINESTRING XYZ (2 3 102, 3 4 103))"); std::string ewkbhex("01070000a0787f0000020000000101000080000000000000004000000000000008400000000000405940010200008002000000000000000000004000000000000008400000000000805940000000000000084000000000000010400000000000c05940"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionM() { // GEOMETRYCOLLECTIONM(POINTM(2 3 9),LINESTRINGM(2 3 4,3 4 5)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT XYM (2 3 9), LINESTRING XYM (2 3 4, 3 4 5))"); std::string ewkbhex("0107000040020000000101000040000000000000004000000000000008400000000000002240010200004002000000000000000000004000000000000008400000000000001040000000000000084000000000000010400000000000001440"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionSRIDM() { // SRID=32632;GEOMETRYCOLLECTIONM(POINTM(2 3 9),LINESTRINGM(2 3 4,3 4 5)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT XYM (2 3 9), LINESTRING XYM (2 3 4, 3 4 5))"); std::string ewkbhex("0107000060787f0000020000000101000040000000000000004000000000000008400000000000002240010200004002000000000000000000004000000000000008400000000000001040000000000000084000000000000010400000000000001440"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionZM() { // GEOMETRYCOLLECTION(POINT(2 3 11 101),LINESTRING(2 3 12 102,3 4 13 103)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT XYZM (2 3 11 101), LINESTRING XYZM (2 3 12 102, 3 4 13 103))"); std::string ewkbhex("01070000c00200000001010000c0000000000000004000000000000008400000000000002640000000000040594001020000c0020000000000000000000040000000000000084000000000000028400000000000805940000000000000084000000000000010400000000000002a400000000000c05940"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } void PgGeometryTest::testGeometryCollectionSRIDZM() { // SRID=32632;GEOMETRYCOLLECTION(POINT(2 3 11 101),LINESTRING(2 3 12 102,3 4 13 103)) ewkb_t ewkb; std::string original("GEOMETRYCOLLECTION (POINT XYZM (2 3 11 101), LINESTRING XYZM (2 3 12 102, 3 4 13 103))"); std::string ewkbhex("01070000e0787f00000200000001010000c0000000000000004000000000000008400000000000002640000000000040594001020000c0020000000000000000000040000000000000084000000000000028400000000000805940000000000000084000000000000010400000000000002a400000000000c05940"); std::string output = BuildTestGeometry(ewkbhex); CPPUNIT_ASSERT_EQUAL(original, output); } /////////////////////////////////////////////////////////////////////////////// // Private operations /////////////////////////////////////////////////////////////////////////////// std::string PgGeometryTest::BuildTestGeometry(std::string const& ewkbhex) const { ewkb_t ewkb; // Convert EWKB hex-string to raw binary data hex_to_bytes(ewkbhex, ewkb); CPPUNIT_ASSERT(!ewkb.empty()); // Build FDO geometry FdoPtr g = CreateGeometryFromExtendedWkb(ewkb); CPPUNIT_ASSERT(NULL != g); // Get WKT form of FDO geometry FdoStringP tmp(g->GetText()); CPPUNIT_ASSERT(tmp.GetLength() > 0); // Convert to narrow string std::string output(static_cast(tmp)); return output; }