示例#1
0
void testAtomic()
{
	Atomic<int> i(0);
	i += 1;
	LOG_VAR((i++).value());
	LOG_VAR((++i).value());
}
示例#2
0
double NodeMatcher::scorePair(long nid1, long nid2)
{
  shared_ptr<const Node> n1 = _map->getNode(nid1);
  shared_ptr<const Node> n2 = _map->getNode(nid2);

  const set<long>& wids1 = _map->getIndex().getNodeToWayMap()->at(nid1);
  const set<long>& wids2 = _map->getIndex().getNodeToWayMap()->at(nid2);

  double acc = 0;
  for (set<long>::const_iterator it = wids1.begin(); it != wids1.end(); ++it)
  {
    acc = max(acc, _map->getWay(*it)->getCircularError());
  }
  for (set<long>::const_iterator it = wids2.begin(); it != wids2.end(); ++it)
  {
    acc = max(acc, _map->getWay(*it)->getCircularError());
  }

  vector<Radians> theta1 = calculateAngles(_map.get(), nid1, wids1);
  vector<Radians> theta2 = calculateAngles(_map.get(), nid2, wids2);

  int s1 = theta1.size();
  int s2 = theta2.size();

  if (s1 < 3 || s2 < 3)
  {
    return 0.0;
  }

  double d = n1->toCoordinate().distance(n2->toCoordinate());

  /// @todo this isnt right Talk to mike
  double distanceScore = 1 - (Normal::phi(d, acc * 1.5) - 0.5) * 2.0;

  if (theta1.size() < theta2.size())
  {
    swap(theta1, theta2);
  }

  double thetaScore;
  // this is very unsual and will slow things down.
  if (theta1.size() > 6 && theta2.size() > 6)
  {
    LOG_WARN("7 intersections at one spot? Odd. Giving it a high angleScore.");
    LOG_VAR(nid1);
    LOG_VAR(nid2);
    LOG_VAR(wids1);
    LOG_VAR(wids2);
    thetaScore = 1.0;
  }
  else
  {
    vector<bool> exclude(theta1.size(), false);
    thetaScore = _calculateAngleScore(theta1, theta2, exclude, 0);
  }

  // simple stupid heuristic. Replace w/ some cosine fanciness later.
  int diff = abs((int)s1 - (int)s2);
  return (min(s1, s2) - diff) * thetaScore * distanceScore;
}
示例#3
0
void SqlBulkInsert::insert(const QList<QVariant> l)
{
  if (l.size() != _columns.size())
  {
    LOG_VAR(l);
    LOG_VAR(_columns);
    throw IllegalArgumentException("Expected l to have the same size as _columns.");
  }
  _pending.append(l);
}
示例#4
0
static int __init imgrement_init(void)
{
    char* err;
    struct imgrement_device *dev;

    imgrement_device = kzalloc(sizeof(struct imgrement_device), GFP_KERNEL);
    _astgo(imgrement_device != NULL, "Error allocating", err, init_error);
    dev = imgrement_device;

    dev->major = register_blkdev(0, DRIVER_NAME);
    _astgo(dev->major > 0, "Error register block device", err, init_error);

    dev->base_dev = blkdev_get_by_path("/dev/sdb", FMODE_READ, NULL);
    _astgo(dev->base_dev != NULL, "Error getting base block device", err, init_error);

    dev->base_queue = bdev_get_queue(dev->base_dev);
    _astgo(dev->base_queue != NULL, "Error getting queue", err, init_error);
    dev->orig_req_fn = dev->base_queue->make_request_fn;
    dev->base_queue->make_request_fn = trace_request_fn;

    LOG("%s trace initialization succeeded", dev->base_dev->bd_disk->disk_name);
    return 0;

init_error:
    LOG_VAR(err);
    imgrement_exit();
    return -1;
}
示例#5
0
void testThread()
{
	char arg1[] = "th1";
	char arg2[] = "th2";

	Thread th1((Thread::Routine)foo, arg1);
	Thread th2((Thread::Routine)foo, arg2);

	th1.setBackground(true);
	th1.start();
	th2.start();

#ifdef _WIN32
	Thread::sleep(500);
	th1.suspend();
	LOGT("th1 was suspended.");

	Thread::sleep(500);
	th2.suspend();
	LOGT("th2 was suspended.");

	Thread::sleep(500);
	th1.resume();
	LOGT("th1 was resumed.");

	Thread::sleep(500);
	th2.resume();
	LOGT("th2 was resumed.");
#endif

	int ret2 = th2.join();

	LOG_VAR(ret2);
}
示例#6
0
void XScrollArea::layoutVScrollBar(int hValue)
{
    QPoint movePoint(width() - verticalScrollBar()->height(),0);
    LOG_VAR(movePoint);

    verticalScrollBar()->move(QPoint(0,0));
}
  /**
   * Creates two matches with overlap and should create a MarkForReviewMerger
   */
  void reviewTest()
  {
    OsmMap::resetCounters();
    OsmMapPtr map(new OsmMap());

    Coordinate c1[] = { Coordinate(0.0, 0.0), Coordinate(20.0, 0.0),
                        Coordinate(20.0, 20.0), Coordinate(0.0, 20.0),
                        Coordinate(0.0, 0.0),
                        Coordinate::getNull() };
    WayPtr w1 = TestUtils::createWay(map, Status::Unknown1, c1, 5, "w1");
    w1->getTags().set("building", true);
    w1->getTags()["name"] = "foo";
    w1->getTags()["amenity"] = "bar";

    Coordinate c2[] = { Coordinate(0.0, 0.0), Coordinate(5.0, 0.0),
                        Coordinate(5.0, 5.0), Coordinate(0.0, 5.0),
                        Coordinate(0.0, 0.0),
                        Coordinate::getNull() };
    WayPtr w2 = TestUtils::createWay(map, Status::Unknown2, c2, 5, "w2");
    w2->getTags().set("building", true);
    w2->getTags()["name"] = "goofie";

    NodePtr n1(new Node(Status::Unknown2, 1, 19, 19, 5));
    n1->getTags()["name"] = "foo";
    n1->getTags()["amenity"] = "cafe";
    map->addNode(n1);

    vector<const Match*> matchesV;
    PoiPolygonMatch match1(map, w1->getElementId(), n1->getElementId(), shared_ptr<MatchThreshold>());
    matchesV.push_back(&match1);
    shared_ptr<const MatchThreshold> threshold(new MatchThreshold(0.5, 0.5, 0.5));
    BuildingMatchCreator().createMatches(map, matchesV, threshold);

    PoiPolygonMatch match2(map, w2->getElementId(), n1->getElementId(), shared_ptr<MatchThreshold>());
    LOG_VAR(match2);

    MatchSet matches;
    matches.insert(matchesV.begin(), matchesV.end());
    vector<Merger*> mergers;
    PoiPolygonMergerCreator uut;
    uut.setOsmMap(map.get());
    HOOT_STR_EQUALS(1, uut.createMergers(matches, mergers));
    HOOT_STR_EQUALS(1, mergers.size());
    LOG_VAR(*mergers[0]);
    HOOT_STR_EQUALS(1, (dynamic_cast<MarkForReviewMerger*>(mergers[0]) != 0));
  }
WaySublineMatchString::WaySublineMatchString(const MatchCollection& m)
{
  for (size_t i = 0; i < m.size(); i++)
  {
    for (size_t j = 0; j < m.size(); j++)
    {
      if (i != j && m[i].overlaps(m[j]))
      {
        LOG_VAR(m);
        throw OverlappingMatchesException("The match collection must not contain overlapping "
                                          "matches.");
      }
    }
  }
  _matches = m;
}
示例#9
0
  void runCircularVisitRw1Test()
  {
    DisableLog dl;

    shared_ptr<OsmMap> map(new OsmMap());
    shared_ptr<Relation> r1(new Relation(Status::Unknown1, 1, 15));
    shared_ptr<Relation> r2(new Relation(Status::Unknown1, 2, 15));
    map->addElement(r1);
    map->addElement(r2);

    r1->addElement("", r2->getElementId());
    r2->addElement("", r1->getElementId());

    CountVisitor v;
    r1->visitRw(*map, v);

    LOG_VAR(v.getCount());
  }
示例#10
0
struct io_activity *create_ioa(struct bio *bio)
{
    char *err;
    struct io_activity *ioa = vmalloc(sizeof(struct io_activity));
    _astgo(ioa != NULL, "Error allocating io_activity", err, create_ioa_error);

    ioa->rw = bio_data_dir(bio);
    ioa->data_size = bio_size(bio);
    ioa->delta_count = bio_cnt(bio);

    if (ioa->delta_count != 0) {
        ioa->deltas = vmalloc(ioa->delta_count * sizeof(struct block_delta));
        _astgo(ioa->deltas != NULL, "Error allocating deltas", err, create_ioa_error);
    } else ioa->deltas = NULL;

    return ioa;

create_ioa_error:
    LOG_VAR(err);
    LOG("Error creating ioa from bio with: %lu sector, %d size", bio_sector(bio), bio_size(bio));
    ast_vfree(ioa->deltas);
    ast_vfree(ioa);
    return NULL;
}