def test_duplicated_ids_positive(self): nodes = [ Node.create_node(2, 48.16256981067, 11.5868239213).to_xml(), Node.create_node(3, 48.16254537153, 11.58697933476).to_xml(), Node.create_node(3, 48.16255438099, 11.58692204178).to_xml(), ] lookup = OsmLookup(strict=True) lookup.load(nodes) self.assertEqual(len(lookup.latlon_to_node_errors), 0)
def test_load(self): nodes = [ Node.create_node(2, 48.16256981067, 11.5868239213).to_xml(), Node.create_node(1, 48.16254537153, 11.58697933476).to_xml(), Node.create_node(-3, 48.16255438099, 11.58692204178).to_xml(), ] lookup = OsmLookup() lookup.load(nodes) self.assertDictEqual(lookup.latlon_to_node_errors, {}) self.assertEqual(len(lookup.zone_map), 1) self.assertTupleEqual(list(lookup.zone_map.keys())[0], (32, "U")) self.assertEqual(len(lookup.latlon_to_node), 3) self.assertEqual(len(lookup.node_to_utm), 3) self.assertEqual(len(lookup.node_to_latlon), 3)
def test_multiple_utm_zones(self): nodes = [ Node.create_node(2, 48.16256981067, 11.5868239213).to_xml(), Node.create_node(1, 48.16254537153, 11.58697933476).to_xml(), Node.create_node(-3, 48.16255438099, 33.58692204178).to_xml(), ] # wrong zone lookup = OsmLookup() self.assertRaises(RuntimeError, lookup.load, nodes)
def test_duplicated_latlon(self): nodes = [ Node.create_node(2, 48.16256981067, 11.5868239213).to_xml(), Node.create_node(1, 48.16254537153, 11.58697933476).to_xml(), Node.create_node(-3, 48.16254537153, 11.58697933476).to_xml(), ] lookup = OsmLookup(strict=True) self.assertRaises(OsmLookupError, lookup.load, nodes) self.assertEqual(len(lookup.latlon_to_node_errors), 1)
def test_add(self): node1 = Node.create_node(2, 48.16256981067, 11.5868239213) node2 = Node.create_node(1, 48.16254537153, 11.58697933476) lookup = OsmLookup() lookup.add(2, (node1.lat, node1.lon), (3, 5)) self.assertEqual(len(lookup.node_to_latlon), 1) self.assertEqual(len(lookup.node_to_utm), 1) self.assertEqual(len(lookup.latlon_to_node), 1) lookup.add(2, (node1.lat, node1.lon), (3, 5)) self.assertEqual(len(lookup.node_to_latlon), 1) self.assertEqual(len(lookup.node_to_utm), 1) self.assertEqual(len(lookup.latlon_to_node), 1) lookup.add(1, (node2.lat, node2.lon), (3, 7)) self.assertEqual(len(lookup.node_to_latlon), 2) self.assertEqual(len(lookup.node_to_utm), 2) self.assertEqual(len(lookup.latlon_to_node), 2)
def test_remove(self): nodes = [ Node.create_node(2, 48.16256981067, 11.5868239213).to_xml(), Node.create_node(1, 48.16254537153, 11.58697933476).to_xml(), Node.create_node(-3, 48.16255438099, 11.58692204178).to_xml(), ] lookup = OsmLookup() lookup.load(nodes) self.assertEqual(len(lookup.latlon_to_node), 3) self.assertEqual(len(lookup.node_to_utm), 3) self.assertEqual(len(lookup.node_to_latlon), 3) lookup.remove(2) self.assertEqual(len(lookup.latlon_to_node), 2) self.assertEqual(len(lookup.node_to_utm), 2) self.assertEqual(len(lookup.node_to_latlon), 2)