Example #1
0
    def test_decode(self):
        with open('test_data/encode_and_decode.csv', mode='r') as csvfile:
            reader = csv.DictReader(csvfile)

            for row in reader:
                code = str(row['code.v1'])

                child = openlocationcode.CodeArea(float(row['child.latitudeLo']), float(row['child.longitudeLo']), float(row['child.latitudeHi']), float(row['child.longitudeHi']), int(row['child.codeLength']))

                code_area = buildingid.CodeArea(child, float(row['latitudeLo']), float(row['longitudeLo']), float(row['latitudeHi']), float(row['longitudeHi']), int(row['codeLength']))

                self.assertEqualCodeArea(buildingid.v1.decode(code), code_area, tolerance=float(row['tolerance']), precision=int(row['precision']))
Example #2
0
    def test_encodeCodeArea(self):
        with open('test_data/encode_and_decode.csv', mode='r') as csvfile:
            reader = csv.DictReader(csvfile)

            for row in reader:
                code = str(row['code.v1'])

                child = openlocationcode.CodeArea(float(row['child.latitudeLo']), float(row['child.longitudeLo']), float(row['child.latitudeHi']), float(row['child.longitudeHi']), int(row['child.codeLength']))

                code_area = buildingid.CodeArea(child, float(row['latitudeLo']), float(row['longitudeLo']), float(row['latitudeHi']), float(row['longitudeHi']), int(row['codeLength']))
                code_area = code_area.resize()

                self.assertEqual(buildingid.v1.encodeCodeArea(code_area), code)