File: osm_mem_tiles.h

package info (click to toggle)
tilemaker 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 83,488 kB
  • sloc: cpp: 29,461; ansic: 12,510; makefile: 229; ruby: 77; sh: 43
file content (62 lines) | stat: -rw-r--r-- 1,781 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*! \file */ 
#ifndef _OSM_MEM_TILES
#define _OSM_MEM_TILES

#include "tile_data.h"
#include "osm_store.h"
#include "geometry_cache.h"

// NB: Currently, USE_NODE_STORE and USE_WAY_STORE are equivalent.
// If we permit LayerAsCentroid to be generated from the OSM stores,
// this will have to change.
#define OSM_THRESHOLD (1ull << TILE_DATA_ID_SIZE)
#define USE_NODE_STORE (2ull << TILE_DATA_ID_SIZE)
#define IS_NODE(x) (((x) >> TILE_DATA_ID_SIZE) == (USE_NODE_STORE >> TILE_DATA_ID_SIZE))
#define USE_WAY_STORE (1ull << TILE_DATA_ID_SIZE)
#define IS_WAY(x) (((x) >> TILE_DATA_ID_SIZE) == (USE_WAY_STORE >> TILE_DATA_ID_SIZE))
#define OSM_ID(x) ((x) & 0b1111111111111111111111111111111111)

class NodeStore;
class WayStore;

/**
	\brief OsmMemTiles stores OSM objects in memory and provides a vector of OutputObjectf for specified tiles
	
	The input objects are generated by PbfReader. The output objects are sent to OsmMemTiles for storage.

	This class provides a consistent interface for Lua scripts to access.
*/
class OsmMemTiles : public TileDataSource {

public:
	OsmMemTiles(
		size_t threadNum,
		uint indexZoom,
		bool includeID,
		const NodeStore& nodeStore,
		const WayStore& wayStore
	);

	std::string name() const override { return "osm"; }

	Geometry buildWayGeometry(
		const OutputGeometryType geomType, 
		const NodeID objectID,
		const TileBbox &bbox
	) override;
	LatpLon buildNodeGeometry(NodeID const objectID, const TileBbox &bbox) const override;


	void Clear();

private:
	void populateLinestring(Linestring& ls, NodeID objectID) const;
	Linestring& getOrBuildLinestring(NodeID objectID) const;
	void populateMultiPolygon(MultiPolygon& dst, NodeID objectID) override;

	const NodeStore& nodeStore;
	const WayStore& wayStore;
};

#endif //_OSM_MEM_TILES