summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2024-01-19 20:15:29 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-01-22 10:40:32 +0100
commit1c3a9b9f968295848baa56670797fb424096efaf (patch)
tree5089fb28c617e698095692dcc3e24f9fd1e9e6d0
parenta5622f84ab0ba0ebb30c2b85f2b85d8aef75f337 (diff)
Added more WKT and WKB tests.
-rw-r--r--tests/gis_tests/gdal_tests/test_geom.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/gis_tests/gdal_tests/test_geom.py b/tests/gis_tests/gdal_tests/test_geom.py
index eba90504b2..9d62bcd07b 100644
--- a/tests/gis_tests/gdal_tests/test_geom.py
+++ b/tests/gis_tests/gdal_tests/test_geom.py
@@ -727,3 +727,86 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
msg = "Input to 'set_3d' must be a boolean, got 'None'"
with self.assertRaisesMessage(ValueError, msg):
geom.set_3d(None)
+
+ def test_wkt_and_wkb_output(self):
+ tests = [
+ # 2D
+ ("POINT (1 2)", "0101000000000000000000f03f0000000000000040"),
+ (
+ "LINESTRING (30 10,10 30)",
+ "0102000000020000000000000000003e400000000000002"
+ "44000000000000024400000000000003e40",
+ ),
+ (
+ "POLYGON ((30 10,40 40,20 40,30 10))",
+ "010300000001000000040000000000000000003e400000000000002440000000000000"
+ "44400000000000004440000000000000344000000000000044400000000000003e4000"
+ "00000000002440",
+ ),
+ (
+ "MULTIPOINT (10 40,40 30)",
+ "0104000000020000000101000000000000000000244000000000000044400101000000"
+ "00000000000044400000000000003e40",
+ ),
+ (
+ "MULTILINESTRING ((10 10,20 20),(40 40,30 30,40 20))",
+ "0105000000020000000102000000020000000000000000002440000000000000244000"
+ "0000000000344000000000000034400102000000030000000000000000004440000000"
+ "00000044400000000000003e400000000000003e400000000000004440000000000000"
+ "3440",
+ ),
+ (
+ "MULTIPOLYGON (((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,15 5)))",
+ "010600000002000000010300000001000000040000000000000000003e400000000000"
+ "0034400000000000804640000000000000444000000000000024400000000000004440"
+ "0000000000003e40000000000000344001030000000100000004000000000000000000"
+ "2e40000000000000144000000000000044400000000000002440000000000000244000"
+ "000000000034400000000000002e400000000000001440",
+ ),
+ (
+ "GEOMETRYCOLLECTION (POINT (40 10))",
+ "010700000001000000010100000000000000000044400000000000002440",
+ ),
+ # 3D
+ (
+ "POINT (1 2 3)",
+ "0101000080000000000000f03f00000000000000400000000000000840",
+ ),
+ (
+ "LINESTRING (30 10 3,10 30 3)",
+ "0102000080020000000000000000003e40000000000000244000000000000008400000"
+ "0000000024400000000000003e400000000000000840",
+ ),
+ (
+ "POLYGON ((30 10 3,40 40 3,30 10 3))",
+ "010300008001000000030000000000000000003e400000000000002440000000000000"
+ "08400000000000004440000000000000444000000000000008400000000000003e4000"
+ "000000000024400000000000000840",
+ ),
+ (
+ "MULTIPOINT (10 40 3,40 30 3)",
+ "0104000080020000000101000080000000000000244000000000000044400000000000"
+ "000840010100008000000000000044400000000000003e400000000000000840",
+ ),
+ (
+ "MULTILINESTRING ((10 10 3,20 20 3))",
+ "0105000080010000000102000080020000000000000000002440000000000000244000"
+ "00000000000840000000000000344000000000000034400000000000000840",
+ ),
+ (
+ "MULTIPOLYGON (((30 20 3,45 40 3,30 20 3)))",
+ "010600008001000000010300008001000000030000000000000000003e400000000000"
+ "0034400000000000000840000000000080464000000000000044400000000000000840"
+ "0000000000003e4000000000000034400000000000000840",
+ ),
+ (
+ "GEOMETRYCOLLECTION (POINT (40 10 3))",
+ "0107000080010000000101000080000000000000444000000000000024400000000000"
+ "000840",
+ ),
+ ]
+ for geom, wkb in tests:
+ with self.subTest(geom=geom):
+ g = OGRGeometry(geom)
+ self.assertEqual(g.wkt, geom)
+ self.assertEqual(g.wkb.hex(), wkb)