def test_tiny_map_features(self): gm = GeoMap(xml_map.get_osm('package://osm_cartography/tests/tiny.osm', bounding_box.makeGlobal())) self.assertEqual(gm.n_features, 2) # expected feature IDs uuids = ['8e8b355f-f1e8-5d82-827d-91e688e807e4', '199dd143-8309-5401-9728-6ca5e1c6e235'] # test GeoMapFeatures iterator gf = GeoMapFeatures(gm) i = 0 for f in gf: if type(f.id.uuid) == str(): # old-style message? self.assertEqual(f.id.uuid, uuids[i]) else: self.assertEqual(unique_id.toHexString(f.id), uuids[i]) i += 1 self.assertEqual(i, 2) self.assertEqual(len(gf), 2)
def test_tiny_map_features(self): gm = GeoMap( xml_map.get_osm('package://osm_cartography/tests/tiny.osm', bounding_box.makeGlobal())) self.assertEqual(gm.n_features, 2) # expected feature IDs uuids = [ '8e8b355f-f1e8-5d82-827d-91e688e807e4', '199dd143-8309-5401-9728-6ca5e1c6e235' ] # test GeoMapFeatures iterator gf = GeoMapFeatures(gm) i = 0 for f in gf: if type(f.id.uuid) == str(): # old-style message? self.assertEqual(f.id.uuid, uuids[i]) else: self.assertEqual(unique_id.toHexString(f.id), uuids[i]) i += 1 self.assertEqual(i, 2) self.assertEqual(len(gf), 2)
def test_missing_osm_file(self): self.assertRaises(ValueError, xml_map.get_osm, 'package://osm_cartography/tests/missing.osm', bounding_box.makeGlobal())
def test_invalid_url(self): self.assertRaises(ValueError, xml_map.get_osm, 'ftp://osm_cartography/tests/prc.osm', bounding_box.makeGlobal())
def test_prc_osm_file(self): # :todo: deeper results verification m = xml_map.get_osm('package://osm_cartography/tests/prc.osm', bounding_box.makeGlobal()) self.assertEqual(len(m.points), 986) self.assertEqual(len(m.features), 84)
import roslib roslib.load_manifest(PKG_NAME) import cv2 import geodesy.props import geodesy.utm import geodesy.wu_point import rospy import numpy as np import itertools from geodesy import bounding_box from osm_cartography import xml_map import yaml import pickle url = "package://driverless_car/data/map(2).osm" gmap = xml_map.get_osm(url, bounding_box.makeGlobal()) map = gmap map_points = geodesy.wu_point.WuPointSet(gmap.points) bbox = map.bounds min_lat, min_lon, max_lat, max_lon = bounding_box.getLatLong(bbox) p0 = geodesy.utm.fromLatLong(min_lat, min_lon).toPoint() p1 = geodesy.utm.fromLatLong(min_lat, max_lon).toPoint() p2 = geodesy.utm.fromLatLong(max_lat, max_lon).toPoint() p3 = geodesy.utm.fromLatLong(max_lat, min_lon).toPoint() print(p1.x - p0.x) width = (p1.x - p0.x) * 10 height = (p3.y - p0.y) * 10 img = np.ones((height, width)) * 0 index = 0 for feature in itertools.ifilter(