File: shared_data.h

package info (click to toggle)
tilemaker 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 78,284 kB
  • sloc: cpp: 28,715; ansic: 4,052; makefile: 180; ruby: 77; sh: 6
file content (114 lines) | stat: -rw-r--r-- 3,202 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*! \file */ 
#ifndef _SHARED_DATA_H
#define _SHARED_DATA_H

#include <vector>
#include <map>

#include "rapidjson/document.h"

#include "options_parser.h"
#include "osm_store.h"
#include "output_object.h"
#include "mbtiles.h"
#include "pmtiles.h"
#include "tile_data.h"

///\brief Defines map single layer appearance
struct LayerDef {
	std::string name;
	uint minzoom;
	uint maxzoom;
	uint simplifyBelow;
	double simplifyLevel;
	double simplifyLength;
	double simplifyRatio;
	uint filterBelow;
	double filterArea;
	uint combinePolygonsBelow;
	bool sortZOrderAscending;
	uint featureLimit;
	uint featureLimitBelow;
	std::string source;
	std::vector<std::string> sourceColumns;
	bool allSourceColumns;
	bool indexed;
	std::string indexName;
	std::map<std::string, uint> attributeMap;
	bool writeTo;
	
	const bool useColumn(std::string &col) {
		return allSourceColumns || (std::find(sourceColumns.begin(), sourceColumns.end(), col) != sourceColumns.end());
	}
};

///\brief Defines layers used in map rendering
class LayerDefinition {

public:	
	std::vector<LayerDef> layers;				// List of layers
	std::map<std::string,uint> layerMap;				// Layer->position map
	std::vector<std::vector<uint> > layerOrder;		// Order of (grouped) layers, e.g. [ [0], [1,2,3], [4] ]

	// Define a layer (as read from the .json file)
	uint addLayer(std::string name, uint minzoom, uint maxzoom,
			uint simplifyBelow, double simplifyLevel, double simplifyLength, double simplifyRatio, 
			uint filterBelow, double filterArea, uint combinePolygonsBelow, bool sortZOrderAscending,
			uint featureLimit, uint featureLimitBelow,
			const std::string &source,
			const std::vector<std::string> &sourceColumns,
			bool allSourceColumns,
			bool indexed,
			const std::string &indexName,
			const std::string &writeTo);
	std::vector<bool> getSortOrders();
	rapidjson::Value serialiseToJSONValue(rapidjson::Document::AllocatorType &allocator) const;
	std::string serialiseToJSON() const;
};

///\brief Config read from JSON to control behavior of program
class Config {
	
public:
	class LayerDefinition layers;
	uint baseZoom, startZoom, endZoom;
	uint mvtVersion, combineBelow;
	bool includeID, compress, gzip, highResolution;
	std::string compressOpt;
	bool clippingBoxFromJSON;
	double minLon, minLat, maxLon, maxLat;
	std::string projectName, projectVersion, projectDesc;
	std::string defaultView;

	Config();
	virtual ~Config();

	void readConfig(rapidjson::Document &jsonConfig, bool &hasClippingBox, Box &clippingBox);
	void enlargeBbox(double cMinLon, double cMaxLon, double cMinLat, double cMaxLat);
};

///\brief Data used by worker threads ::outputProc to write output
class SharedData {

public:
	const class LayerDefinition &layers;
	OptionsParser::OutputMode outputMode;
	bool mergeSqlite;
	MBTiles mbtiles;
	PMTiles pmtiles;
	std::string outputFile;

	Config &config;

	SharedData(Config &configIn, const class LayerDefinition &layers);
	virtual ~SharedData();

	void writeMBTilesProjectData();
	void writeMBTilesMetadata(rapidjson::Document const &jsonConfig);
	void writeFileMetadata(rapidjson::Document const &jsonConfig);	
	std::string pmTilesMetadata();
	void writePMTilesBounds();
};

#endif //_SHARED_DATA_H