Beispiel #1
0
bool _split(node_t * root, node_t * p,
        node_t * & t1, node_t * & t2)
{
    if (!root) {
        return false;
    }

    node_t *L = NULL, *R = NULL;

    if (_split(root->lc, p, L, R)) {
        root->lc = R;
        t1 = L;
        t2 = root;
        return true;
    }

    if (root == p) {
        t1 = root->lc;
        t2 = root;
        root->lc = NULL;
        return true;
    }

    if (_split(root->rc, p, L, R)) {
        root->rc = L;
        t1 = root;
        t2 = R;
        return true;
    }

    return false;
}
Beispiel #2
0
void _split(T A[], T temp[], int begin, int end)
{
	if ((end - begin) < 2)
		return;
	
	
	// recursively split into halves until size is 1,
	// then merge and go back up.
	int mid = (end + begin) / 2;

	// I chose 16 because it's a power of 2 and precedence.
	if ((end - mid) <= 16)
	{
		insertion_sort(A, end, mid);	// mid included.
		insertion_sort(A, mid, begin);	// mid excluded.
	}
	// Split if large enough.
	else
	{
		_split(A, temp, begin, mid);	// mid will be excluded.
		_split(A, temp, mid, end);		// mid will be included.
	}
	_merge(A, temp, begin, mid, end);	// merge them back again.
	_copy (A, temp, begin, end);		// Copy sorted array to original array.
}
Beispiel #3
0
void MeshTextureGraphicsItem::_drawQuad(const Texture& texture, const Quad& inputQuad, const Quad& outputQuad, float outputArea, float inputThreshod, float outputThreshold)
{
  QPointF oa = mapFromScene(outputQuad.getVertex(0));
  QPointF ob = mapFromScene(outputQuad.getVertex(1));
  QPointF oc = mapFromScene(outputQuad.getVertex(2));
  QPointF od = mapFromScene(outputQuad.getVertex(3));

  QPointF ia = inputQuad.getVertex(0);
  QPointF ib = inputQuad.getVertex(1);
  QPointF ic = inputQuad.getVertex(2);
  QPointF id = inputQuad.getVertex(3);

  // compute the dot products for the polygon
  float outputV1dotV2 = QPointF::dotProduct(oa-ob, oc-ob);
  float outputV3dotV4 = QPointF::dotProduct(oc-od, oa-od);
  float outputV1dotV4 = QPointF::dotProduct(oa-ob, oa-od);
  float outputV2dotV3 = QPointF::dotProduct(oc-ob, oc-od);

  // compute the dot products for the texture
  float inputV1dotV2  = QPointF::dotProduct(ia-ib, ic-ib);
  float inputV3dotV4  = QPointF::dotProduct(ic-id, ia-id);
  float inputV1dotV4  = QPointF::dotProduct(ia-ib, ia-id);
  float inputV2dotV3  = QPointF::dotProduct(ic-ib, ic-id);

  // Stopping criterion.
  if (outputArea < 200 ||
      (fabs(outputV1dotV2 - outputV3dotV4) < outputThreshold &&
       fabs(outputV1dotV4 - outputV2dotV3) < outputThreshold &&
       fabs(inputV1dotV2  - inputV3dotV4)  < inputThreshod &&
       fabs(inputV1dotV4  - inputV2dotV3)  < inputThreshod))
  {
    glBegin(GL_QUADS);
    for (int i = 0; i < outputQuad.nVertices(); i++)
    {
      Util::setGlTexPoint(texture, inputQuad.getVertex(i), mapFromScene(outputQuad.getVertex(i)));
    }
    glEnd();
  }
  else // subdivide
  {
    QList<Quad> inputSubQuads  = _split(inputQuad);
    QList<Quad> outputSubQuads = _split(outputQuad);
    for (int i = 0; i < inputSubQuads.size(); i++)
    {
      _drawQuad(texture, inputSubQuads[i], outputSubQuads[i], outputArea*0.25, inputThreshod, outputThreshold);
    }
  }
}
Beispiel #4
0
int line_processor (struct line_read_state * state, char * line, int len, int counter, int err_code){
    if(err_code != _GETLINE_NONE && err_code != _GETLINE_EOF) return -1;
    if(len > 0){
        state->line_counter++;
        if(state->line_counter == 1){
            return init_complex_pipe(&state->pipe, create_exec_args(line));
        }else{
            struct str_splited_pair pointers [3];
            int cnt = _split(line, " ", pointers, 2);
            if(cnt < 2){
                _print(STDERR_FILENO, "Wrong format!\n");
                return 0;
            }
            *pointers[0].end = '\0';
            *pointers[1].end = '\0';
            if(strcmp(pointers[0].start, "->") == 0){
                return bind_left(&state->pipe, create_exec_args(pointers[1].start));
            }else if(strcmp(pointers[0].start, "<-") == 0){
                return bind_right(&state->pipe, create_exec_args(pointers[1].start));
            }else{
                _print(STDERR_FILENO, "Wrong format!\n");
                return 0;
            }
        }
    }else{
        return 1;
    }
    return 0;
}
Beispiel #5
0
void fbuf_connect(FBUF* b, FBUF* x, uint8_t pos)
{
    register uint8_t islot = x->head;  
    register uint8_t p = pos;
    while (p >= FBUF_SLOTSIZE) {
        p -= _fbuf_length[islot]; 
        if (p > 0) 
            islot = _fbuf_next[islot];
    }

    /* Find last slot of b and connect it to rest of x */
    register uint8_t xlast = b->head;
    while (_fbuf_next[xlast] != NILPTR) 
        xlast = _fbuf_next[xlast];

    _fbuf_next[xlast] = _split(islot, p);

    /* Increment reference count of rest of x */
    while (_fbuf_next[xlast] != NILPTR) {
        xlast = _fbuf_next[xlast];
        _fbuf_refcnt[xlast]++;
    }

    b->wslot = x->wslot = NILPTR; // Disallow writing
    b->length = b->length + x->length - pos;
}
Beispiel #6
0
int main (int argc, char *argv[]) {

  dsr_t    hdr;
  uint8_t *img;
  uint8_t  pref;

  pref = 1;

  img = NULL;

  startup("cutimg", argc, argv, NULL, NULL);

  if (argc != 3 && argc != 4) {
    printf("usage: cutimg input outdir [prefix]\n");
    goto fail;
  }

  if (argc == 4) pref = atoi(argv[3]);

  if (analyze_load(argv[1], &hdr, &img)) goto fail;

  if (_split(&hdr, img, argv[2], pref)) goto fail;

  free(img);
  return 0;

fail:
  printf("Cut failed\n");
  if (img != NULL) free(img);
  return 1;
}
Beispiel #7
0
void _insert(bp_tree * tree, int k)
{
    if (!tree->root) {
        bp_node * r = new bp_node;
        r->n = 1;
        r->key[0] = k;
        tree->root = tree->sqt = r;
        return;
    }

    bp_node * p = NULL;
    int i = -1;

    if (_find(tree->root, k, p, i)) {
        return;
    }

    _insert_key(p, i, k);

    while (p->n == 4) {
        bp_node *n1 = NULL, *n2 = NULL;
        bp_node * parent = p->parent;
        _split(p, n1, n2);

        if (!parent) {
            tree->root = parent = new bp_node;
        }

        _insert_child(parent, n1, n2);

        p = parent;
    }
}
QStringList zuluMountTask::hiddenVolumeList()
{
	QFile f( _excludeVolumePath() ) ;

	if( f.open( QIODevice::ReadOnly ) ){

		QVector< deviceList > l = _getDevices() ;

		QStringList e ;

		QStringList g = _split( f ) ;

		for( const auto& it : l ){

			if( g.contains( it.uniqueName ) ){

				e.append( it.device ) ;
			}
		}

		return  e ;
	}else{
		return QStringList() ;
	}
}
Beispiel #9
0
            bool run(const string& , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
                ShardConnection::sync();

                string ns = cmdObj.firstElement().valuestrsafe();
                if ( ns.size() == 0 ){
                    errmsg = "no ns";
                    return false;
                }

                DBConfigPtr config = grid.getDBConfig( ns );
                if ( ! config->isSharded( ns ) ){
                    errmsg = "ns not sharded.  have to shard before can split";
                    return false;
                }

                BSONObj find = cmdObj.getObjectField( "find" );
                if ( find.isEmpty() ){
                    find = cmdObj.getObjectField( "middle" );

                    if ( find.isEmpty() ){
                        errmsg = "need to specify find or middle";
                        return false;
                    }
                }
                
                ChunkManagerPtr info = config->getChunkManager( ns );
                ChunkPtr old = info->findChunk( find );

                return _split( result , errmsg , ns , info , old , cmdObj.getObjectField( "middle" ) );
            }
	bool ShaderFile::addShader(const std::string& fname, const std::string& define)
	{
		// Clear last stuff if there is any
		mFileName.clear();
		mDirectory.clear();
		
		Log::message("Parsing shader file '%s'", fname.c_str());

		// Split the string into dir/filename/extension
		std::string ext, dir, filen;
		Utilities::splitPath(fname, &dir, &filen, &ext);

		mFileName = filen + ext;
		mDirectory = dir;
		mDefineString = define;

		std::string source;
		if (!Utilities::fileToString(mDirectory + mFileName, source))
		{
			Log::error("Unable to open file '%s'", fname.c_str());
			return false;
		}
		
		_split(source);
		
		return true;
	}
void PertyWaySplitVisitor::visit(const shared_ptr<Element>& e)
{
  //LOG_DEBUG(e->getElementType());
  if (OsmSchema::getInstance().isLinearHighway(e->getTags(), e->getElementType()))
  {
    _split(e);
  }
}
Beispiel #12
0
void merge_sort(T A[], const int size)
{
	// No point in sorting if array doesn't point to anything or has but 1 element.
	if ((A == nullptr) || (size <= 1))
		return;
	T temp[size];
	_split(A, temp, 0, size);
	// Will automatically delete temp when loses scope.
}
Beispiel #13
0
void TreeEqualizer::_split( Node* node )
{
    if( node->compound )
        return;
    LBASSERT( node->left && node->right );

    Node* left = node->left;
    Node* right = node->right;
    // easy outs
    if( left->resources == 0.f )
    {
        node->split = 0.f;
        return;
    }
    if( right->resources == 0.f )
    {
        node->split = 1.f;
        return;
    }

    // new split
    const float target = node->time * left->resources / node->resources;
    const float leftTime = float(left->time);
    float split = 0.f;
    const float rightTime = float(right->time);

    if( leftTime >= target )
        split = target / leftTime * node->split;
    else
    {
        const float timeLeft = target - leftTime;
        split = node->split + timeLeft / rightTime * ( 1.f - node->split );
    }

    LBLOG( LOG_LB2 )
        << "Should split at " << split << " (" << target << ": " << leftTime
        << " by " << left->resources << "/" << rightTime << " by "
        << right->resources << ")" << std::endl;
    node->split = (1.f - _damping) * split + _damping * node->split;
    LBLOG( LOG_LB2 ) << "Dampened split at " << node->split << std::endl;

    _split( left );
    _split( right );
}
Beispiel #14
0
void split(node_t * root, int x, node_t * & t1, node_t * & t2)
{
    if (!root) {
        return;
    }

    node_t * p = _find_x(root, x);
    if (!p) {
        if (root->data > x) {
            t2 = root;
        }
        else {
            t1 = root;
        }
        return;
    }

    _split(root, p, t1, t2);
}
void SplayTree::insert(int key, int position) {
    size_t treeSize = (_root ? _root->sizeOfSubtree : 0);

    if(position > treeSize) {
        return;
        // throw std::out_of_range("out of range in SplayTree::insert\n");
    }

    SplayTree* rightTree = _split(position);
    Node* newRoot = new Node(key);
    newRoot->leftChild = _root;
    newRoot->rightChild = rightTree->_root;
    _root = newRoot;
    _keepParent(_root);

    Node::updateNodeParams(_root);

    rightTree->_root = NULL;

    rightTree->~SplayTree();
}
Beispiel #16
0
            void * allocate(std::size_t size, std::size_t alignment = alignof(std::max_align_t))
            {
                if (size < platform::min_chunk_size)
                {
                    assert("TODO");
                }

                else
                {
                    for (auto bin = _get_bin(size); bin != _bins.end(); ++bin)
                    {
                        std::unique_lock<platform::lock> lock{ bin->lock };
                        
                        if (bin == _bins.end() - 1 && !bin->first)
                        {
                            bin->first = _allocate_chunk();
                        }

                        if (bin->first)
                        {
                            auto chunk = bin->first;
                            bin->first = chunk->next;
    
                            while (chunk->chunk_size >= 2 * size && bin != _bins.begin())
                            {
                                chunk = _split(chunk);
                            }
    
                            chunk->next = nullptr;
                            chunk->prev = nullptr;
                            chunk->bin = nullptr;
                            chunk->allocation_size = size;
                            chunk->state = _chunk_state::allocated;
    
                            return reinterpret_cast<void *>(chunk->address);
                        }
                    }
                }
            }
void zuluMountTask::removeVolumeFromHiddenVolumeList( const QString& e )
{
	QFile f( _excludeVolumePath() ) ;

	if( f.open( QIODevice::ReadOnly ) ){

		QStringList l = _split( f ) ;

		l.removeAll( _getUniqueName( e ) ) ;

		f.close() ;

		if( f.open( QIODevice::WriteOnly | QIODevice::Truncate ) ){

			if( !l.isEmpty() ){

				for( const auto& it : l ){

					f.write( it.toLatin1() + "\n" ) ;
				}
			}
		}
	}
}
Beispiel #18
0
void fbuf_insert(FBUF* b, FBUF* x, uint8_t pos)
{
    register uint8_t islot = b->head;    
    while (pos >= FBUF_SLOTSIZE) {
        pos -= _fbuf_length[islot]; 
        if (pos > 0) 
            islot = _fbuf_next[islot];
    }
    
    /* Find last slot in x chain and increment reference count*/
    register uint8_t xlast = x->head;
    _fbuf_refcnt[xlast]++;
    while (_fbuf_next[xlast] != NILPTR) {
        xlast = _fbuf_next[xlast];
        _fbuf_refcnt[xlast]++;
    }
    
    /* Insert x chain after islot */  
    _fbuf_next[xlast] = _split(islot, pos); 
    _fbuf_next[islot] = x->head;
    
    b->wslot = x->wslot = NILPTR; // Disallow writing
    b->length += x->length;
}
Beispiel #19
0
std::vector<std::string>
BaseParser::_split( const std::string & input, const std::string & str ) {
	std::regex regex(str);
	return _split( input, regex );
}
Beispiel #20
0
NeuronDatareader::NeuronDatareader(char * file, char * labels)
{
    try
    {
        _file = _split(file, '.', _file);
        _label = _split(labels, '.', _label);

        if(!std::strcmp(_file.at(1).c_str(),"idx3-ubyte"))
        {
            if(!std::strcmp(_label.at(1).c_str(),"idx1-ubyte"))
            {
                _filetype = Fileformat::idx;
            }
        }
        _dimensions = 0;
        _size[0]=_size[1]=_size[2] = 1;
        _lsize[0]=_lsize[1]=_lsize[2] = 1;
        std::fstream filestream;
        std::fstream labelstream;
        filestream.open(file, std::ios::in|std::ios::binary);
        labelstream.open(labels, std::ios::in|std::ios::binary);
        bool open = filestream.is_open()&&labelstream.is_open();
        std::cout <<"IsOpen? "<< open<<" " <<file <<" " << labels<<std::endl;
        std::cout <<"Stream Read!"<<std::endl;
        std::cout <<"Get Header Information!"<< std::endl;
        _magicnumber =  (filestream.get()<<24)|(filestream.get()<<16)|(filestream.get()<<8)|filestream.get();
        _nmb_items = (filestream.get()<<24)|(filestream.get()<<16)|(filestream.get()<<8)|filestream.get();
        _dimensions = _magicnumber&(0x000000ff);
        _item_type = (_magicnumber&(0x0000ff00))>>8;

        _lmagicnumber = (labelstream.get()<<24)|(labelstream.get()<<16)|(labelstream.get()<<8)|labelstream.get();
        _lnmb_items = (labelstream.get()<<24)|(labelstream.get()<<16)|(labelstream.get()<<8)|labelstream.get();
        _ldimensions = _lmagicnumber&(0x000000ff);
        _litem_type = (_lmagicnumber&(0x0000ff00))>>8;

        switch(_dimensions)
        {
            case 0: //scalar
            _dimensions = 0;
            break;
            case 1: //1D
            _dimensions = 1;
            break;
            case 2: //2D
            _dimensions = 2;
            break;
            case 3: //3D
            _dimensions = 2;
            break;
        }

        switch(_ldimensions)
        {
            case 0: //scalar
            _ldimensions = 0;
            break;
            case 1: //1D
            _ldimensions = 0;
            break;
            case 2: //2D
            _ldimensions = 2;
            break;
            case 3: //3D
            _ldimensions = 2;
            break;
        }

        switch(_item_type)
        {
            case 0x08:
                //unsigned byte
                _item_size = 8;
                break;
            case 0x09:
                //signed byte
                _item_size = 8;
                break;
            case 0x0b:
                //short
                _item_size = 16;
                break;
            case 0x0c:
                //int
                _item_size = 32;
                break;
            case 0x0d:
                //float
                _item_size = 32;
                break;
            case 0x0e:
                //double
                _item_size = 64;
                break;
        }

        switch(_litem_type)
        {
            case 0x08:
                //unsigned byte
                _litem_size = 8;
                break;
            case 0x09:
                //signed byte
                _litem_size = 8;
                break;
            case 0x0b:
                //short
                _litem_size = 16;
                break;
            case 0x0c:
                //int
                _litem_size = 32;
                break;
            case 0x0d:
                //float
                _litem_size = 32;
                break;
            case 0x0e:
                //double
                _litem_size = 64;
                break;
        }


        for(int c=0; c <_dimensions; c++)
        {
            _size[c] = (filestream.get()<<24)|(filestream.get()<<16)|(filestream.get()<<8)|filestream.get();
        }

        for(int c=0; c <_ldimensions; c++)
        {
            _lsize[c] = (filestream.get()<<24)|(filestream.get()<<16)|(filestream.get()<<8)|filestream.get();
        }

        _inputsize = _size[0]*_size[1]*_size[2];
        Filetype value;
        Imagetype img;
        int cnt=0;
        int img_index = 0;
        for(int dataset_cnt = 0; dataset_cnt < _nmb_items; dataset_cnt++,cnt++)
        {
            img.val = new Filetype[_inputsize];
            memset(img.val, 0, _inputsize*sizeof(Filetype));//Set Image to 0

            for(int dep_c=0; dep_c < _size[2]; dep_c++) //Z
            {
                for(int col_c=0; col_c < _size[1]; col_c++) //Y
                {
                    for(int row_c = 0; row_c <_size[0]; row_c++) //X
                    {
                        memset(&value, 0, sizeof(Filetype)); //SetPixel to 0
                        int shift = 0;
                        unsigned char bla = 0;
                        for(int val_c = 0; val_c < _item_size/8 ; val_c++)//Read Byte-wise
                        {
                            shift = (_item_size-8-(val_c*8));
                            bla = filestream.get();
                            value.ulong |= ((unsigned long)bla)<< shift;  //SetPixel
                        }
                        img_index = row_c+col_c*_size[0]+dep_c*_size[0]*_size[1];
                        value.sfloat = value.ulong/(std::pow(2, _item_size)-1.0f);//norm
                        img.val[img_index] = value; //Save Pixel in image
                    }
                }
            }
            img.img_size = _size[0]*_size[1]*_size[2];
            _data.push_back(img);//Pushback in data-array
        }
        /*
        for(int c2 = 0; c2 < _size[1]; c2++)
        {
            for(int c1=0; c1 < _size[0]; c1++)
            {
                int val = (_data.at(0).val[c1+c2*_size[0]].uchar);
                std::cout << std::setw(2) << std::setfill('0') << std::hex << (val);
            }
            std::cout << std::endl;
        }
        */
        _linputsize = 10;
        unsigned char label_data = 0;
        Imagetype label_img;
        for(int dataset_cnt = 0; dataset_cnt < _lnmb_items; dataset_cnt++)
        {
            label_img.val =  new Filetype[_linputsize];
            label_img.img_size = _linputsize;
            label_data=labelstream.get();
            _ldata.push_back(label_data);
            //label_vec
            for(int index = 0; index < _linputsize; index++)
            {

                value.sfloat = (label_data == index)?(1.0f):(0.0f);
                label_img.val[index] = value;
            }

            _ldata_vec.push_back(label_img);
        }

        _indexes.resize(_ldata.size());
        for (unsigned int i = 0; i < _indexes.size(); ++i)
            _indexes.at(i) = i;

        std::random_shuffle(_indexes.begin(), _indexes.end());

        std::cout << "Feddich!" << std::endl;
    }
    catch(std::exception & exp)
    {
        std::cout << exp.what() << std::endl;
        throw _EXP_FLAG_READ;
    }
    //ctor
}
vector<ElementPtr> PertyWaySplitVisitor::_split(ElementPtr element)
{
  //randomly select elements and split them into two parts
  boost::uniform_real<> randomSplitDistribution(0.0, 1.0);
  const double randomSplitNum = randomSplitDistribution(*_rng);
  if (randomSplitNum <= _waySplitProbability)
  {
    LOG_DEBUG("element " << element->getElementId() << " *will* be split based on a split " <<
      "probability of: " <<  _waySplitProbability << " and a randomly generated number: " <<
      randomSplitNum << "\n");

    _splitRecursionLevel++;
    LOG_VARD(_splitRecursionLevel);

    const int numNodesBeforeSplit = _map->getNodeMap().size();
    LOG_VARD(numNodesBeforeSplit);
    const int numWaysBeforeSplit = _map->getWays().size();
    LOG_VARD(numWaysBeforeSplit);

    WayLocation waySplitPoint;
    MultiLineStringLocation multiLineSplitPoint;
    QList<long> nodeIdsBeforeSplit;
    int segmentIndex = -1;
    ElementId wayId;
    //determine where to split the element
    if (element->getElementType() == ElementType::Way)
    {
      WayPtr way = dynamic_pointer_cast<Way>(element);
      LOG_VARD(way->getNodeCount());
      nodeIdsBeforeSplit = QVector<long>::fromStdVector(way->getNodeIds()).toList();
      LOG_VARD(nodeIdsBeforeSplit);
      waySplitPoint = _calcSplitPoint(way);
    }
    else
    {
      multiLineSplitPoint = _calcSplitPoint(dynamic_pointer_cast<Relation>(element), wayId);
      waySplitPoint = multiLineSplitPoint.getWayLocation();
    }

    const QString distanceMsgStrEnd =
      QString("a minimum node spacing of ")
        .append(QString::number(_minNodeSpacing))
        .append(" meters");
    if (!waySplitPoint.isValid())
    {
      _splitRecursionLevel--;
      LOG_VARD(_splitRecursionLevel);

      LOG_DEBUG("split point *will not* be used because *it violates* " << distanceMsgStrEnd);
      //if it violates the min node spacing, return an empty element collection, which will end the
      //recursive splitting on the current way
      return vector<ElementPtr>();
    }
    else
    {
      LOG_DEBUG("split point *will* be used because it *does not* violate " << distanceMsgStrEnd);
      segmentIndex = waySplitPoint.getSegmentIndex();
      LOG_VARD(segmentIndex);
    }

    //split the element
    vector<ElementPtr> newElementsAfterSplit;
    if (element->getElementType() == ElementType::Way)
    {
      vector<WayPtr> newWaysAfterSplit =
        WaySplitter::split(_map->shared_from_this(), dynamic_pointer_cast<Way>(element), waySplitPoint);
      for (size_t i = 0; i < newWaysAfterSplit.size(); i++)
      {
        newElementsAfterSplit.push_back(newWaysAfterSplit.at(i));
      }
    }
    else
    {
      ElementPtr match;
      MultiLineStringSplitter().split(_map->shared_from_this(), multiLineSplitPoint, match);
      newElementsAfterSplit.push_back(match);
    }

    const int numNodesAfterSplit = _map->getNodeMap().size();
    LOG_VARD(numNodesAfterSplit);
    const int numNewNodesCreatedBySplit = numNodesAfterSplit - numNodesBeforeSplit;
    LOG_VARD(numNewNodesCreatedBySplit);
    LOG_VARD(_map->getWays().size());

    if (numNewNodesCreatedBySplit > 0)
    {
      WayPtr way = dynamic_pointer_cast<Way>(element);
      //Its possible that the splitting of a relation could generate a new node.  In that case,
      //_updateNewNodeProperties does not need to be called b/c the MultiLineStringSplitter has
      //already properly updated the new node's properties.  when a way is split, however, the
      //new node's properties must be updated by the call to _updateNewNodeProperties.
      if (way != 0)
      {
        assert(nodeIdsBeforeSplit.size() > 0);
        //update properties on any nodes added as a result of the way splitting (new ways created as a
        //result of the splitting will already have had their parent's tags added by WaySplitter)
        _updateNewNodeProperties(
          _getNodeAddedBySplit(nodeIdsBeforeSplit, newElementsAfterSplit),
          _map->getNode(way->getNodeId(segmentIndex)),
          _map->getNode(way->getNodeId(segmentIndex + 1)));
      }
    }

    //recursive call
    for (vector<ElementPtr>::const_iterator it = newElementsAfterSplit.begin();
         it != newElementsAfterSplit.end(); it++)
    {
      _split(*it);
    }

    return newElementsAfterSplit;
  }
  else
  {
    LOG_DEBUG("element " << element->getElementId() << " *will not* be split based on a split " <<
      "probability of: " << _waySplitProbability << " and a randomly generated number: " <<
      randomSplitNum << "\n");
  }

  //end the recursive splitting on the current way
  return vector<ElementPtr>();
}
Beispiel #22
0
void
split(const StaticString &str, char sep, vector<StaticString> &output) {
	_split(str, sep, output);
}