void _identifySuccessors(struct grid *gd, struct node *activeNode, struct open_list *current, struct node *endNode) { int endX = endNode->x; int endY = endNode->y; int *jumpPoint; struct neighbor_xy_list *neighbors_head = _findNeighbors(gd, activeNode); struct neighbor_xy_list *neighbors_current = neighbors_head; while (neighbors_head != (neighbors_current = neighbors_current->right)) { if (DEBUG) { if (isWalkableAt(gd, neighbors_current->x, neighbors_current->y)) printf("Neighbor x:%d/y:%d is walkable!\n", neighbors_current->x, neighbors_current->y); else printf("Neighbor x:%d/y:%d is NOT walkable!\n", neighbors_current->x, neighbors_current->y); } jumpPoint = _jump(gd, neighbors_current->x, neighbors_current->y, activeNode->x, activeNode->y, endNode); if (DEBUG) printf("Jump point not set!\n\n"); if (jumpPoint != NULL) { int jx, jy, d, ng; struct node *jumpNode; if (DEBUG) printf("Jump point set!\n\n"); jx = jumpPoint[0]; jy = jumpPoint[1]; free(jumpPoint); malloc_count--; /* [ Malloc Count ] */ jumpNode = getNodeAt(gd, jx, jy); if (jumpNode->closed) { continue; } d = euclidean(abs(jx - activeNode->x), abs(jy - activeNode->y)); ng = activeNode->g + d; if (!jumpNode->opened || ng < jumpNode->g) { jumpNode->g = ng; if (!jumpNode->h) jumpNode->h = manhattan(abs(jx - endX), abs(jy - endY)); /* jumpNode->h = jumpNode->h || manhattan(abs(jx - endX), abs(jy - endY)); // ASK FIDELIS !! */ jumpNode->f = jumpNode->g + jumpNode->h; if (DEBUG) printf("Node g:%d h:%d f:%d\n", jumpNode->g, jumpNode->h, jumpNode->f); jumpNode->parent = activeNode; if (!jumpNode->opened) { current = ol_insert_right(current, jumpNode); jumpNode->opened = true; } else { ol_listsort(current->right); } } } } neighbor_xy_clean(neighbors_head); }
void checkForMatch(const shared_ptr<const Node>& n) { // find other nearby candidates set<long> neighbors = _findNeighbors(n); ElementId from(n->getElementId()); _elementsEvaluated++; int neighborCount = 0; vector<double> classes; for (set<long>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++it) { ElementId eid(ElementType::Node, *it); const shared_ptr<const Node>& neighbor = _map->getNode(*it); // make sure we only create one match per pair. Use the node with the larger circular error // to make sure we do the larger of the two queries. If the CE is equal then use the eid // with the lower id. Arbitrary, but it will prevent duplicates. if ((neighbor->getCircularError() < n->getCircularError()) || (neighbor->getCircularError() == n->getCircularError() && from.getId() < eid.getId())) { if (OsmSchema::getInstance().isPoi(*n)) { // score each candidate and push it on the result vector PlacesPoiMatch* m = new PlacesPoiMatch(_map, from, eid, _threshold); // if we're confident this is a miss if (m->getClassification().getMissP() >= _rejectScore) { delete m; } else { _result.push_back(m); neighborCount++; } } } } _neighborCountSum += neighborCount; _neighborCountMax = std::max(_neighborCountMax, neighborCount); }