mirror of
https://github.com/systemed/tilemaker.git
synced 2026-05-08 01:10:22 -04:00
a9a54f97ee
* Pack OutputObject bitfields more efficiently * Move to plain enum to keep GCC happy * Convert int40 to string * Cast bitfield as a full int for logging * Make enum names unique, because Windows * Fake relation id shouldn't overtop the bitfield * Pack into 36 bytes * Improved simplify performance (#279) * Remove reference counted outputobject * Use OsmID to lookup generated geometry * Remove temporary when assigning multipolygon * Make attribute store ref an intrusive pointer Co-authored-by: systemed <richard@systemeD.net>
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
/*! \file */
|
|
#ifndef _TILE_DATA_H
|
|
#define _TILE_DATA_H
|
|
|
|
#include <map>
|
|
#include <set>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "output_object.h"
|
|
|
|
typedef std::vector<OutputObjectRef>::const_iterator OutputObjectsConstIt;
|
|
typedef std::pair<OutputObjectsConstIt, OutputObjectsConstIt> OutputObjectsConstItPair;
|
|
typedef std::map<TileCoordinates, std::vector<OutputObjectRef>, TileCoordinatesCompare> TileIndex;
|
|
typedef std::set<TileCoordinates, TileCoordinatesCompare> TileCoordinatesSet;
|
|
|
|
class TileDataSource {
|
|
|
|
protected:
|
|
std::mutex mutex;
|
|
TileIndex tileIndex;
|
|
std::deque<OutputObject> objects;
|
|
|
|
unsigned int baseZoom;
|
|
|
|
public:
|
|
TileDataSource(unsigned int baseZoom)
|
|
: baseZoom(baseZoom)
|
|
{ }
|
|
|
|
///This must be thread safe!
|
|
void MergeTileCoordsAtZoom(uint zoom, TileCoordinatesSet &dstCoords) {
|
|
MergeTileCoordsAtZoom(zoom, baseZoom, tileIndex, dstCoords);
|
|
}
|
|
|
|
///This must be thread safe!
|
|
void MergeSingleTileDataAtZoom(TileCoordinates dstIndex, uint zoom, std::vector<OutputObjectRef> &dstTile) {
|
|
MergeSingleTileDataAtZoom(dstIndex, zoom, baseZoom, tileIndex, dstTile);
|
|
}
|
|
|
|
OutputObjectRef CreateObject(OutputObject const &oo) {
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
objects.push_back(oo);
|
|
return &objects.back();
|
|
}
|
|
|
|
void AddObject(TileCoordinates const &index, OutputObjectRef const &oo) {
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
tileIndex[index].push_back(oo);
|
|
}
|
|
|
|
private:
|
|
static void MergeTileCoordsAtZoom(uint zoom, uint baseZoom, const TileIndex &srcTiles, TileCoordinatesSet &dstCoords);
|
|
static void MergeSingleTileDataAtZoom(TileCoordinates dstIndex, uint zoom, uint baseZoom, const TileIndex &srcTiles, std::vector<OutputObjectRef> &dstTile);
|
|
};
|
|
|
|
TileCoordinatesSet GetTileCoordinates(std::vector<class TileDataSource *> const &sources, unsigned int zoom);
|
|
|
|
std::vector<OutputObjectRef> GetTileData(std::vector<class TileDataSource *> const &sources, TileCoordinates coordinates, unsigned int zoom);
|
|
|
|
OutputObjectsConstItPair GetObjectsAtSubLayer(std::vector<OutputObjectRef> const &data, uint_least8_t layerNum);
|
|
|
|
#endif //_TILE_DATA_H
|