def __init__(self, edges, nodes, **kwargs): self.edges = edges edge_costs = dict(osm2graph.euclidean_edge_costs(nodes, edges)) self.matcher = slowmapmatch.MapMatcher2d(edge_costs, nodes, transition_logpdf=angle_diff_logpdf, measurement_logpdf=slowmapmatch.gaussian_logpdf(5), **kwargs) self.nodes = nodes self.edge_costs = edge_costs
def __init__(self, edges, nodes, **kwargs): self.edges = edges edge_costs = dict(osm2graph.euclidean_edge_costs(nodes, edges)) self.matcher = slowmapmatch.MapMatcher2d( edge_costs, nodes, transition_logpdf=angle_diff_logpdf, measurement_logpdf=slowmapmatch.gaussian_logpdf(5), **kwargs) self.nodes = nodes self.edge_costs = edge_costs
float(row.shape_pt_lat), float(row.shape_pt_lon))) for shape_id, coords in shapes.iteritems(): # Could use a heap if this causes # performance problems (probably wont) coords.sort() lat, lon = zip(*coords)[1:] latlon = zip(lat, lon) yield (shape_id, latlon) def vectangle(a, b): cosa = np.dot(a, b)/(np.linalg.norm(a)*np.linalg.norm(b)) return np.arccos(cosa) _ad_logpdf = slowmapmatch.gaussian_logpdf(0.1) _lendiff_logpdf = slowmapmatch.gaussian_logpdf(0.1) def angle_diff_logpdf(distance, straight_dist, points, path_coords): #reldiff = (distance - straight_dist)/straight_dist #return _lendiff_logpdf((distance - straight_dist)/straight_dist) anglediff = 0.0 ospan = np.subtract(points[1], points[0]) spans = np.diff(path_coords, axis=0) n = 0 for span in spans: angle = vectangle(ospan, span) if np.isnan(angle): continue anglediff += np.abs(angle)
for shape_id, coords in shapes.iteritems(): # Could use a heap if this causes # performance problems (probably wont) coords.sort() lat, lon = zip(*coords)[1:] latlon = zip(lat, lon) yield (shape_id, latlon) def vectangle(a, b): cosa = np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)) return np.arccos(cosa) _ad_logpdf = slowmapmatch.gaussian_logpdf(0.1) _lendiff_logpdf = slowmapmatch.gaussian_logpdf(0.1) def angle_diff_logpdf(distance, straight_dist, points, path_coords): #reldiff = (distance - straight_dist)/straight_dist #return _lendiff_logpdf((distance - straight_dist)/straight_dist) anglediff = 0.0 ospan = np.subtract(points[1], points[0]) spans = np.diff(path_coords, axis=0) n = 0 for span in spans: angle = vectangle(ospan, span) if np.isnan(angle): continue