Beispiel #1
0
vlink duplicateList(vlink head) {
    vlink nhead = NULL, ncurr = NULL, curr = head;
    while (curr != NULL) {
        if (nhead == NULL) {
            nhead = duplicateNode(curr);
            ncurr = nhead;
        } else {
            ncurr->next = duplicateNode(curr);
            ncurr = ncurr->next;
        }
        curr = curr->next;
    }
    return nhead;
}
void PertyDuplicatePoiOp::apply(shared_ptr<OsmMap>& map)
{
  MapProjector::projectToPlanar(map);
  boost::uniform_real<> uni(0.0, 1.0);
  boost::normal_distribution<> nd;
  boost::variate_generator<boost::minstd_rand&, boost::normal_distribution<> > N(*_rng, nd);

  // make a copy since we'll be modifying the map as we go.
  NodeMap nm = map->getNodeMap();
  for (NodeMap::const_iterator it = nm.begin(); it != nm.end(); ++it)
  {
    if (uni(*_rng) < _p)
    {
      const NodePtr& n = it->second;
      int copies = round(fabs(N() * _duplicateSigma)) + 1;

      for (int i = 0; i < copies; i++)
      {
        duplicateNode(n, map);
      }
    }
  }
}