]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Added the KMLTest module containing the LineString tests.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 25 Oct 2009 22:12:34 +0000 (18:12 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 25 Oct 2009 22:12:34 +0000 (18:12 -0400)
src/Tests/Fixtures/KML/linestring1.kml [new file with mode: 0644]
src/Tests/Unit/KMLTest.py [new file with mode: 0644]

diff --git a/src/Tests/Fixtures/KML/linestring1.kml b/src/Tests/Fixtures/KML/linestring1.kml
new file mode 100644 (file)
index 0000000..3002aae
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
+  <Placemark>
+    <name>Test LineString #1</name>
+    <LineString>
+      <tessellate>1</tessellate>
+      <coordinates>
+       -76.62861599999999,39.315609,0 -76.62606,39.312859,0 -76.62496899999999,39.311951,0 -76.624062,39.31134,0 -76.620209,39.30901,0 -76.61734,39.307499,0 -76.616272,39.306782,0 -76.61550099999999,39.30632,0 -76.614952,39.306091,0 -76.614441,39.305962,0 -76.613983,39.305908,0 -76.613152,39.305939,0 -76.612534,39.305889,0 -76.612038,39.30571,0
+      </coordinates>
+    </LineString>
+  </Placemark>
+</kml>
diff --git a/src/Tests/Unit/KMLTest.py b/src/Tests/Unit/KMLTest.py
new file mode 100644 (file)
index 0000000..579ba22
--- /dev/null
@@ -0,0 +1,42 @@
+import unittest
+
+import Tests.Fixtures
+from KML import *
+
+
+class LineStringTest(unittest.TestCase):
+
+    def testTuplesFromKml(self):
+        """
+        Make sure we parse KML LineStrings into tuples properly.
+        """
+
+        fixture_path = Tests.Fixtures.Path() + '/KML/linestring1.kml'
+        f = open(fixture_path, 'r')
+        kml = f.read()
+        f.close()
+        
+        actual_tuples = LineString.tuples_from_kml(kml)
+        
+        expected_tuples = [ (-76.62861599999999, 39.315609),
+                            (-76.62606, 39.312859),
+                            (-76.62496899999999, 39.311951),
+                            (-76.624062, 39.31134),
+                            (-76.620209, 39.30901),
+                            (-76.61734, 39.307499),
+                            (-76.616272, 39.306782),
+                            (-76.61550099999999, 39.30632),
+                            (-76.614952, 39.306091),
+                            (-76.614441, 39.305962),
+                            (-76.613983, 39.305908),
+                            (-76.613152, 39.305939),
+                            (-76.612534, 39.305889),
+                            (-76.612038, 39.30571) ]
+        
+        self.assertEqual(expected_tuples, actual_tuples)
+
+
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(LineStringTest))
+    return suite