Ejemplo n.º 1
0
inline void lru_cache_cab::insert(const bucket* pbuck, const double & time)
{
    assert(cache.size() + flow_table.size() <=_capacity);
    buffer_check.insert(std::make_pair(pbuck, time)); // insert bucket as rec

    cache.insert(container_T::value_type(pbuck, time)); // insert bucket
    for (auto iter = pbuck->related_rules.begin(); iter != pbuck->related_rules.end(); iter++)
    {
        // rule_down_count += 1;  // controller does not know which rules are kept in OFswtich
        auto ins_rule_result = flow_table.insert(std::make_pair(*iter, 1));
        if (!ins_rule_result.second)
            ++ins_rule_result.first->second;
        else
            ++rule_down_count; // controller knows which rules are kept in OFswitch
    }

    while(cache.size() + flow_table.size() > _capacity)   // kick out
    {
        const bucket * to_kick_buck = cache.right.begin()->second;
        cache.right.erase(cache.right.begin());
        buffer_check.erase(to_kick_buck);

        for (auto iter = to_kick_buck->related_rules.begin(); iter != to_kick_buck->related_rules.end(); ++iter)   // dec flow occupy no.
        {
            --flow_table[*iter];
            if (flow_table[*iter] == 0)
                flow_table.erase(*iter);
        }
    }
}
Ejemplo n.º 2
0
Archivo: var.cpp Proyecto: hyln9/nV
Key* key(uint x) {
    std::pair<boost::unordered_map<uint, var>::iterator, bool>
    r = keys.insert(std::make_pair((x << 1) + 1, null));
    if (r.second)
        r.first->second = new Key((x << 1) + 1);
    return static_cast<Key*>(r.first->second.ptr);
}
Ejemplo n.º 3
0
Archivo: var.cpp Proyecto: hyln9/nV
Key* key(wcs x) {
    std::pair<boost::unordered_map<uint, var>::iterator, bool>
    r =	keys.insert(std::make_pair(reinterpret_cast<uint>(x), null));
    if (r.second)
        r.first->second = new Key(reinterpret_cast<uint>(x));
    return static_cast<Key*>(r.first->second.ptr);
}
Ejemplo n.º 4
0
 template <typename T> void insert_visitor(boost::function<void(T)> f) {
     try {
         fs.insert(std::make_pair(boost::ref(typeid(T)), boost::bind(f, boost::bind(any_cast_f<T>, boost::lambda::_1))));
     } catch (boost::bad_any_cast& e) {
         std::cout << e.what() << std::endl;
     }
 }
void Streamer::processPickups(Player &player, const std::vector<SharedCell> &cells)
{
	static boost::unordered_map<int, Item::SharedPickup> discoveredPickups;
	for (std::vector<SharedCell>::const_iterator c = cells.begin(); c != cells.end(); ++c)
	{
		for (boost::unordered_map<int, Item::SharedPickup>::const_iterator p = (*c)->pickups.begin(); p != (*c)->pickups.end(); ++p)
		{
			boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.find(p->first);
			if (d == discoveredPickups.end())
			{
				if (checkPlayer(p->second->players, player.playerID, p->second->interiors, player.interiorID, p->second->worlds, player.worldID))
				{
					if (boost::geometry::comparable_distance(player.position, p->second->position) <= p->second->streamDistance)
					{
						boost::unordered_map<int, int>::iterator i = internalPickups.find(p->first);
						if (i == internalPickups.end())
						{
							p->second->worldID = !p->second->worlds.empty() ? player.worldID : -1;
						}
						discoveredPickups.insert(*p);
					}
				}
			}
		}
	}
	if (processingFinalPlayer)
	{
		boost::unordered_map<int, int>::iterator i = internalPickups.begin();
		while (i != internalPickups.end())
		{
			boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.find(i->first);
			if (d == discoveredPickups.end())
			{
				DestroyPickup(i->second);
				i = internalPickups.erase(i);
			}
			else
			{
				discoveredPickups.erase(d);
				++i;
			}
		}
		for (boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.begin(); d != discoveredPickups.end(); ++d)
		{
			if (internalPickups.size() == visiblePickups)
			{
				break;
			}
			int internalID = CreatePickup(d->second->modelID, d->second->type, d->second->position[0], d->second->position[1], d->second->position[2], d->second->worldID);
			if (internalID == INVALID_ALTERNATE_ID)
			{
				break;
			}
			internalPickups.insert(std::make_pair(d->second->pickupID, internalID));
		}
		discoveredPickups.clear();
	}
}
Ejemplo n.º 6
0
	cairo_surface_t* getImage(string path)
	{
		auto it = images.find(path);
		if (it != images.end())
			return (*it).second;

		cairo_surface_t* image = cairo_image_surface_create_from_png(path.c_str());
		images.insert(std::make_pair(path, image));
		return image;
	}
Ejemplo n.º 7
0
inline boost::unordered_map<K, V> operator>> (object o, boost::unordered_map<K, V>& v)
{
    if(o.type != type::MAP) { throw type_error(); }
    object_kv* p(o.via.map.ptr);
    object_kv* const pend(o.via.map.ptr + o.via.map.size);
    for(; p != pend; ++p) {
        K key;
        p->key.convert(&key);
        V val;
        p->val.convert(&val);
        v.insert(std::pair<K,V>(key, val));
    }
    return v;
}
void load(Archive & ar, boost::unordered_map<T,U> & t, unsigned int version)
{
    // clear the map
    t.clear();
    // read the size
    typedef typename boost::unordered_map<T,U>::size_type size_type;
    size_type size;
    ar & BOOST_SERIALIZATION_NVP(size);
    for (size_type i = 0; i < size; i++) {
        // read a pair
        std::pair<T, U> pair;
        ar & boost::serialization::make_nvp("pair"+i, pair);
        // insert it into the map
        t.insert(pair);
    }
}
Ejemplo n.º 9
0
static CStrInternInternals* GetString(const char* str, size_t len)
{
	// g_Strings is not thread-safe, so complain if anyone is using this
	// type in non-main threads. (If that's desired, g_Strings should be changed
	// to be thread-safe, preferably without sacrificing performance.)
	ENSURE(ThreadUtil::IsMainThread());

#if BOOST_VERSION >= 104200
	StringsKeyProxy proxy = { str, len };
	boost::unordered_map<StringsKey, shared_ptr<CStrInternInternals> >::iterator it =
		g_Strings.find(proxy, StringsKeyProxyHash(), StringsKeyProxyEq());
#else
	// Boost <= 1.41 doesn't support the new find(), so do a slightly less efficient lookup
	boost::unordered_map<StringsKey, shared_ptr<CStrInternInternals> >::iterator it =
		g_Strings.find(str);
#endif

	if (it != g_Strings.end())
		return it->second.get();

	shared_ptr<CStrInternInternals> internals(new CStrInternInternals(str, len));
	g_Strings.insert(std::make_pair(internals->data, internals));
	return internals.get();
}
Ejemplo n.º 10
0
void Voxelize::generateUmap(pcl::PointCloud<pcl::PointXYZ> &cloud,double resolution,boost::unordered_map<unordered_map_voxel,un_key> &m)//遍历每个点,生成栅格。然后计算每个栅格的参数
{
    double t0 = ros::Time::now().toSec();

    un_key tempp;  //key键不允许修改,全存在value中

    for(int i=0;i<cloud.size();i++)
    {
        unordered_map_voxel tempv(cloud[i].x,cloud[i].y,cloud[i].z,resolution);

        pair<umap::iterator,bool> pair_insert = m.insert(umap::value_type(tempv,tempp));//这个pair就是用来存储插入返回值的,看是否这个栅格已经存在

        pair_insert.first->second.vec_index_point.push_back(i);
        /*
           if(!pair_insert.second)//如果栅格已经存在,那么把value++
           {
           (pair_insert.first)->second.cout++;
           pair_insert.first->second.vec_index_point.push_back(i);
           }
           else{
           pair_insert.first->second.vec_index_point.push_back(i);
           }
           */
    }

    double t2 = ros::Time::now().toSec();
    //cout <<"划栅格的时间为"<<(t2-t0)<<endl;
    Matrix3d tempmat;
    tempmat.setZero();

    pcl::PointXYZ temppoint(0,0,0);
    for(umap::iterator iter=m.begin();iter!=m.end();)
    {
        temppoint.x=temppoint.y=temppoint.z=0;
        if(iter->second.vec_index_point.size()<10)
        {
            m.erase(iter++);
            continue;
        }

        for(int j = 0;j<iter->second.vec_index_point.size();j++)
        {
            double x_ = cloud[iter->second.vec_index_point[j]].x;
            double y_ = cloud[iter->second.vec_index_point[j]].y;
            double z_ = cloud[iter->second.vec_index_point[j]].z;

            tempmat += (Vector3d(x_,y_,z_) * RowVector3d(x_,y_,z_));//存储pipiT的和
            temppoint.x += x_;
            temppoint.y += y_;
            temppoint.z += z_;
        }

        int n = iter->second.vec_index_point.size();
        //cout <<"栅格大小为"<<n<<endl;
        Vector3d v(temppoint.x/n,temppoint.y/n,temppoint.z/n);//存储栅格重心
        RowVector3d vT(temppoint.x/n,temppoint.y/n,temppoint.z/n);

        tempmat /= n;
        tempmat -= v*vT;//S
        iter->second.matS = tempmat;
        //cout <<"S 矩阵= "<< tempmat <<endl;

        vector<eigen_sort> vector1(3);//用于排序

        //cout <<"tempmat="<<endl<<tempmat<<endl;
        EigenSolver<MatrixXd> es(tempmat);
        VectorXcd eivals = es.eigenvalues();
        MatrixXcd eigenvectors = es.eigenvectors();
        //cout << "特征值="<<eivals<<endl;
        vector1[0]=eigen_sort(eivals(0).real(),es.eigenvectors().col(0));
        vector1[1]=eigen_sort(eivals(1).real(),es.eigenvectors().col(1));
        vector1[2]=eigen_sort(eivals(2).real(),es.eigenvectors().col(2));
        sort(vector1.begin(),vector1.end());
        double lamada1 = vector1[0].eigen_value;
        double lamada2 = vector1[1].eigen_value;
        double lamada3 = vector1[2].eigen_value;
        //cout <<"lamada="<<lamada1<<" "<<lamada2<<" "<<lamada3<<endl;
        //
        if(vector1[0].eigen_vector(2).real()<0)
        {
            vector1[0].eigen_vector(2).real() = -vector1[0].eigen_vector(2).real();
        }
        if(vector1[2].eigen_vector(2).real()<0)
        {
            vector1[2].eigen_vector(2).real() = -vector1[2].eigen_vector(2).real();
        }


        iter->second.c = (lamada3-lamada2)/(lamada1+lamada2+lamada3);
        iter->second.p = 2*(lamada2-lamada1)/(lamada1+lamada2+lamada3);
        iter->second.u = v;
        iter->second.v1 = vector1[0].eigen_vector;
        iter->second.v3 = vector1[2].eigen_vector;

        double c = iter->second.c;
        double p = iter->second.p;


        iter->second.vector_9D << v(0),v(1),v(2),p*vector1[0].eigen_vector(0).real(),p*vector1[0].eigen_vector(1).real(),
            p*vector1[0].eigen_vector(2).real(),c*vector1[2].eigen_vector(0).real(),c*vector1[2].eigen_vector(1).real(),
            p*vector1[2].eigen_vector(2).real();

        //cout << "9D向量="<<iter->second.vector_9D<<endl;
        //ArrayXd ad = iter->second.vector_9D;
        //cout <<"ad = "<<ad<<endl;
        //cout <<"ad square="<<ad.square()<<endl;
        tempmat.setZero();

        iter++;

    }

    double tn = ros::Time::now().toSec();
    //cout << "对栅格计算处理的时间"<<(tn - t2)<<endl;
    //cout <<"栅格数量为" <<m.size()<<endl;

}
Ejemplo n.º 11
0
	void insert( operators const& val, const std::string& name ){
		enum_to_name.insert( std::make_pair( val, name ) );
		name_to_enum.insert( std::make_pair( name, val ) );
	}
Ejemplo n.º 12
0
void IfcPPReaderSTEP::readStreamData(	std::string& read_in, const IfcPPModel::IfcPPSchemaVersion& ifc_version, boost::unordered_map<int,shared_ptr<IfcPPEntity> >& target_map )
{
	std::string current_numeric_locale(setlocale(LC_NUMERIC, nullptr));
	setlocale(LC_NUMERIC,"C");

	if( ifc_version.m_ifc_file_schema_enum  == IfcPPModel::IFC_VERSION_UNDEFINED || ifc_version.m_ifc_file_schema_enum == IfcPPModel::IFC_VERSION_UNKNOWN )
	{
		std::wstring error_message;
		error_message.append( L"Unsupported IFC version: " );
		error_message.append( ifc_version.m_IFC_FILE_SCHEMA );
		messageCallback( error_message, StatusCallback::MESSAGE_TYPE_ERROR, __FUNC__ );
		progressValueCallback(0.0, "parse");
		return;
	}
	
	if( read_in.size() == 0 )
	{
		return;
	}
	messageCallback( std::wstring( L"Detected IFC version: ") + ifc_version.m_IFC_FILE_SCHEMA, StatusCallback::MESSAGE_TYPE_GENERAL_MESSAGE, "" );

	std::stringstream err;
	std::vector<std::string> step_lines;

	std::vector<std::pair<std::string, shared_ptr<IfcPPEntity> > > vec_entities;
	try
	{
		splitIntoStepLines( read_in, step_lines );
		read_in.clear(); // the input string is not needed any more
		const size_t num_lines = step_lines.size();
		vec_entities.resize( num_lines );
		readStepLines( step_lines, vec_entities );
	}
	catch( UnknownEntityException& e )
	{
		std::string unknown_keyword = e.m_keyword;
		err << __FUNC__ << ": unknown entity: " << unknown_keyword.c_str() << std::endl;
	}
	catch( IfcPPOutOfMemoryException& e)
	{
		throw e;
	}
	catch( IfcPPException& e )
	{
		err << e.what();
	}
	catch(std::exception& e)
	{
		err << e.what();
	}
	catch(...)
	{
		err << __FUNC__ << ": error occurred" << std::endl;
	}
	step_lines.clear();

	// copy entities into map so that they can be found during entity attribute initialization
	for( size_t ii_entity = 0; ii_entity < vec_entities.size(); ++ii_entity )
	{
		std::pair<std::string, shared_ptr<IfcPPEntity> >& entity_read_object = vec_entities[ii_entity];
		shared_ptr<IfcPPEntity> entity = entity_read_object.second;

		if( entity ) // skip aborted entities
		{
			target_map.insert( std::make_pair( entity->m_id, entity ) );
		}
	}

	try
	{
		readEntityArguments( ifc_version, vec_entities, target_map );
	}
	catch( IfcPPOutOfMemoryException& e)
	{
		throw e;
	}
	catch( IfcPPException& e )
	{
		err << e.what();
	}
	catch(std::exception& e)
	{
		err << e.what();
	}
	catch(...)
	{
		err << __FUNC__ << ": error occurred" << std::endl;
	}

	setlocale(LC_NUMERIC,current_numeric_locale.c_str());
	if( err.tellp() > 0 )
	{
		messageCallback( err.str().c_str(), StatusCallback::MESSAGE_TYPE_ERROR, __FUNC__ );
	}
}
Ejemplo n.º 13
0
bool buildTable(Kompex::SQLiteStatement * stmt,
                int32_t &name_id,
                boost::unordered_map<std::string,int32_t> &table_names,
                std::string const &sql_table_name,
                std::vector<Tile*> list_tiles,
                osmscout::Database &map,
                osmscout::TypeSet const &typeSet,
                bool allow_duplicate_nodes,
                bool allow_duplicate_ways,
                bool allow_duplicate_areas)
{
    // spec area search parameter
    osmscout::AreaSearchParameter area_search_param;
    area_search_param.SetUseLowZoomOptimization(false);

    // create the sql statement
    std::string stmt_insert = "INSERT INTO "+sql_table_name;
    stmt_insert +=
            "(id,node_offsets,way_offsets,area_offsets) VALUES("
            "@id,@node_offsets,@way_offsets,@area_offsets);";

    try   {
        stmt->BeginTransaction();
        stmt->Sql(stmt_insert);
    }
    catch(Kompex::SQLiteException &exception)   {
        qDebug() << "ERROR: SQLite exception with insert statement:"
                 << QString::fromStdString(exception.GetString());
        return false;
    }

    // osmscout may return nearby results again so we make
    // sure offsets are only included once if requested
    std::set<osmscout::FileOffset> set_node_offsets;
    std::set<osmscout::FileOffset> set_way_offsets;
    std::set<osmscout::FileOffset> set_area_offsets;

    // container for blob memory we delete after
    // committing the sql transaction
    std::vector<char*> list_blobs;

    // keep track of the number of transactions and
    // commit after a certain limit
    size_t transaction_limit=5000;
    size_t transaction_count=0;

    for(size_t i=0; i < list_tiles.size(); i++)   {
        // for each tile

        // get objects from osmscout
        GeoBoundingBox const &bbox = list_tiles[i]->bbox;
        std::vector<osmscout::NodeRef> listNodes;
        std::vector<osmscout::WayRef>  listWays;
        std::vector<osmscout::AreaRef> listAreas;
        map.GetObjects(bbox.minLon,bbox.minLat,
                       bbox.maxLon,bbox.maxLat,
                       typeSet,
                       listNodes,
                       listWays,
                       listAreas);

        // merge all of the object refs into one list
        // of MapObjects so its easier to manage
        std::vector<MapObject> list_map_objects;
        list_map_objects.reserve(listNodes.size()+listWays.size()+listAreas.size());

        for(size_t j=0; j < listNodes.size(); j++)   {
            osmscout::NodeRef &nodeRef = listNodes[j];

            if(nodeRef->GetName().empty())   {
                continue;
            }
            if(!allow_duplicate_nodes)   {
                if(set_node_offsets.count(nodeRef->GetFileOffset()) != 0)   {
                    continue;
                }
                set_node_offsets.insert(nodeRef->GetFileOffset());
            }
            MapObject map_object;
            map_object.name     = nodeRef->GetName();
            map_object.offset   = nodeRef->GetFileOffset();
            map_object.type     = osmscout::refNode;
            list_map_objects.push_back(map_object);
        }
        for(size_t j=0; j < listWays.size(); j++)   {
            osmscout::WayRef &wayRef = listWays[j];

            if(wayRef->GetName().empty())   {
                continue;
            }
            if(!allow_duplicate_ways)   {
                if(set_way_offsets.count(wayRef->GetFileOffset()) != 0)   {
                    continue;
                }
                set_way_offsets.insert(wayRef->GetFileOffset());
            }
            MapObject map_object;
            map_object.name     = wayRef->GetName();
            map_object.offset   = wayRef->GetFileOffset();
            map_object.type     = osmscout::refWay;
            list_map_objects.push_back(map_object);
        }
        for(size_t j=0; j < listAreas.size(); j++)   {
            osmscout::AreaRef &areaRef = listAreas[j];

            if(areaRef->rings.front().GetName().empty())   {
                continue;
            }
            if(!allow_duplicate_areas)   {
                if(set_area_offsets.count(areaRef->GetFileOffset()) != 0)   {
                    continue;
                }
                set_area_offsets.insert(areaRef->GetFileOffset());
            }
            MapObject map_object;
            map_object.name     = areaRef->rings.front().GetName();
            map_object.offset   = areaRef->GetFileOffset();
            map_object.type     = osmscout::refArea;
            list_map_objects.push_back(map_object);
        }

        // create structs to sort file offsets by name lookup
        // [name_lookup_id] [list_offsets]
        boost::unordered_map<int32_t,OffsetGroup> entry_admin_regions;

        for(size_t j=0; j < list_map_objects.size(); j++)   {

            MapObject &map_object = list_map_objects[j];

            // add name_lookup up to table_names
            std::string name_lookup = convNameToLookup(map_object.name);
            int32_t name_lookup_id;

            // check if this lookup string already exists
            if(table_names.count(name_lookup) == 0)   {
                // insert lookup string
                std::pair<std::string,int32_t> data;
                data.first  = name_lookup;
                data.second = name_id;
                table_names.insert(data);

                name_lookup_id = name_id;
                name_id++;
            }
            else   {
                name_lookup_id = table_names.find(name_lookup)->second;
            }

            // check if this lookup string already exists
            if(entry_admin_regions.count(name_lookup_id) == 0)   {
                // insert new list of offsets
                std::pair<int32_t,OffsetGroup> data;
                data.first = name_lookup_id;
                entry_admin_regions.insert(data);
            }

            // add offset to list
            boost::unordered_map<int32_t,OffsetGroup>::iterator it;
            it = entry_admin_regions.find(name_lookup_id);
            if(map_object.type == osmscout::refNode)   {
                it->second.node_offsets.push_back(map_object.offset);
            }
            else if(map_object.type == osmscout::refWay)   {
                it->second.way_offsets.push_back(map_object.offset);
            }
            else if(map_object.type == osmscout::refArea)   {
                it->second.area_offsets.push_back(map_object.offset);
            }
        }

        //qDebug() << list_tiles[i]->id << ":" << entry_admin_regions.size();

        // write information for this tile to the database
        boost::unordered_map<int32_t,OffsetGroup>::iterator it;
        for(it  = entry_admin_regions.begin();
            it != entry_admin_regions.end(); ++it)   {
            // convert offsets to byte arrays
            char * data_node_offsets = NULL; size_t sz_node_offsets=0;
            char * data_way_offsets  = NULL; size_t sz_way_offsets=0;
            char * data_area_offsets = NULL; size_t sz_area_offsets=0;

            OffsetGroup &g = it->second;

//            // ### debug start
//            if(g_table_nameid_count.count(it->first) == 0)   {
//                std::pair<int64_t,int64_t> debugdata;
//                debugdata.first = it->first;
//                debugdata.second =
//                        g.node_offsets.size()+
//                        g.way_offsets.size()+
//                        g.area_offsets.size();
//                g_table_nameid_count.insert(debugdata);
//            }
//            else   {
//                std::map<int64_t,int64_t>::iterator d_it;
//                d_it = g_table_nameid_count.find(it->first);
//                d_it->second +=
//                        g.node_offsets.size()+
//                        g.way_offsets.size()+
//                        g.area_offsets.size();
//            }
//            // ### debug end

            if(!(g.node_offsets.empty()))   {
                sz_node_offsets = sizeof(osmscout::FileOffset)*g.node_offsets.size();
                data_node_offsets = new char[sz_node_offsets];
                memcpy(data_node_offsets,&(g.node_offsets[0]),sz_node_offsets);
                list_blobs.push_back(data_node_offsets);
            }
            if(!(g.way_offsets.empty()))   {
                sz_way_offsets = sizeof(osmscout::FileOffset)*g.way_offsets.size();
                data_way_offsets = new char[sz_way_offsets];
                memcpy(data_way_offsets,&(g.way_offsets[0]),sz_way_offsets);
                list_blobs.push_back(data_way_offsets);
            }
            if(!(g.area_offsets.empty()))   {
                sz_area_offsets = sizeof(osmscout::FileOffset)*g.area_offsets.size();
                data_area_offsets = new char[sz_area_offsets];
                memcpy(data_area_offsets,&(g.area_offsets[0]),sz_area_offsets);
                list_blobs.push_back(data_area_offsets);
            }

            if(data_node_offsets == NULL &&
               data_way_offsets  == NULL &&
               data_area_offsets == NULL)   {
                continue;
            }

            // prepare sql
            try   {

                // cat name_id and tile_id into one id
                // get mask for bitlength
                int32_t mask = pow(2,g_sz_bits_tile_id)-1;

                int64_t id = it->first;             // name_id
                id = id << g_sz_bits_tile_id;       // bitshift
                id |= (list_tiles[i]->id & mask);   // 24 most sig bits of tile_id

                stmt->BindInt64(1,id);

                if(data_node_offsets)   {
                    stmt->BindBlob(2,data_node_offsets,sz_node_offsets);
                }
                else   {
                    stmt->BindNull(2);
                }
                if(data_way_offsets)   {
                    stmt->BindBlob(3,data_way_offsets,sz_way_offsets);
                }
                else   {
                    stmt->BindNull(3);
                }
                if(data_area_offsets)   {
                    stmt->BindBlob(4,data_area_offsets,sz_area_offsets);
                }
                else   {
                    stmt->BindNull(4);
                }

                stmt->Execute();
                stmt->Reset();

                if(transaction_count > transaction_limit)   {
                    stmt->FreeQuery();
                    stmt->CommitTransaction();

                    stmt->BeginTransaction();
                    stmt->Sql(stmt_insert);
                    transaction_count=0;
                }
                transaction_count++;
            }
            catch(Kompex::SQLiteException &exception)   {
                qDebug() << "ERROR: SQLite exception writing tile data:"
                         << QString::fromStdString(exception.GetString());
                qDebug() << "ERROR: id:" << list_tiles[i]->id;
                qDebug() << "ERROR: name_lookup_id:" << it->first;
                qDebug() << "ERROR:" << sz_node_offsets << sz_way_offsets << sz_area_offsets;
                return false;
            }
        }
        // debug
//        qDebug() << i << "/" << list_tiles.size();
    }

    stmt->FreeQuery();
    stmt->CommitTransaction();

    // free up blob memory
    for(size_t i=0; i < list_blobs.size(); i++)   {
        delete[] list_blobs[i];
    }

    return true;
}