diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2012-10-24 17:40:42 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2012-10-29 09:28:18 -0400 |
commit | 325b42be26c6dda8965f2d6b9b7b64b381f5bd61 (patch) | |
tree | db4db08805b0b1722e10cba723f5ea2dd9e88ca7 /src/third_party/s2/pywraps2_test.py | |
parent | 1bd2fc12ef9de5b705dc1d127d02c397441c77e8 (diff) | |
download | mongo-325b42be26c6dda8965f2d6b9b7b64b381f5bd61.tar.gz |
SERVER-2874 Import S2 the flags library it depends on, add GeoJSON parsing
SERVER-2874 make the S2 stuff compile on mac/windows
Diffstat (limited to 'src/third_party/s2/pywraps2_test.py')
-rwxr-xr-x | src/third_party/s2/pywraps2_test.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/third_party/s2/pywraps2_test.py b/src/third_party/s2/pywraps2_test.py new file mode 100755 index 00000000000..5cd5e2e3f27 --- /dev/null +++ b/src/third_party/s2/pywraps2_test.py @@ -0,0 +1,51 @@ +#!/usr/bin/python2.4 +# Copyright 2006 Google Inc. All Rights Reserved. + + + +from google3.pyglib import app +from google3.testing.pybase import googletest +from google3.util.geometry.pywraps2 import * + +class PyWrapS2TestCase(googletest.TestCase): + + def testContainsIsWrappedCorrectly(self): + london = S2LatLngRect(S2LatLng.FromDegrees(51.3368602, 0.4931979), + S2LatLng.FromDegrees(51.7323965, 0.1495211)) + e14lj = S2LatLngRect(S2LatLng.FromDegrees(51.5213527, -0.0476026), + S2LatLng.FromDegrees(51.5213527, -0.0476026)) + self.failUnless(london.Contains(e14lj)) + + def testS2CellIdEqualsIsWrappedCorrectly(self): + london = S2LatLng.FromDegrees(51.5001525, -0.1262355) + cell = S2CellId.FromLatLng(london) + same_cell = S2CellId.FromLatLng(london) + self.assertEquals(cell, same_cell) + + def testS2CellIdComparsionIsWrappedCorrectly(self): + london = S2LatLng.FromDegrees(51.5001525, -0.1262355) + cell = S2CellId.FromLatLng(london) + self.failUnless(cell < cell.next()) + self.failUnless(cell.next() > cell) + + def testS2HashingIsWrappedCorrectly(self): + london = S2LatLng.FromDegrees(51.5001525, -0.1262355) + cell = S2CellId.FromLatLng(london) + same_cell = S2CellId.FromLatLng(london) + self.assertEquals(hash(cell), hash(same_cell)) + + def testCovererIsWrapperCorrectly(self): + london = S2LatLngRect(S2LatLng.FromDegrees(51.3368602, 0.4931979), + S2LatLng.FromDegrees(51.7323965, 0.1495211)) + e14lj = S2LatLngRect(S2LatLng.FromDegrees(51.5213527, -0.0476026), + S2LatLng.FromDegrees(51.5213527, -0.0476026)) + coverer = S2RegionCoverer() + covering = coverer.GetCovering(e14lj) + for cellid in covering: + self.failUnless(london.Contains(S2Cell(cellid))) + +def main(argv): + googletest.main() + +if __name__ == "__main__": + app.run() |