2017-07-14 23:56:23 +00:00
|
|
|
#ifndef MBTILES_HPP
|
|
|
|
#define MBTILES_HPP
|
|
|
|
|
|
|
|
#include <math.h>
|
2017-07-17 18:58:37 +00:00
|
|
|
#include <map>
|
2017-07-14 23:56:23 +00:00
|
|
|
#include "mvt.hpp"
|
|
|
|
|
2018-08-31 22:11:05 +00:00
|
|
|
extern size_t max_tilestats_attributes;
|
|
|
|
extern size_t max_tilestats_sample_values;
|
|
|
|
extern size_t max_tilestats_values;
|
|
|
|
|
2016-04-28 21:43:04 +00:00
|
|
|
struct type_and_string {
|
2017-11-07 23:20:17 +00:00
|
|
|
int type = 0;
|
|
|
|
std::string string = "";
|
2016-04-28 21:43:04 +00:00
|
|
|
|
2017-07-15 00:59:24 +00:00
|
|
|
bool operator<(const type_and_string &o) const;
|
2017-07-19 23:40:06 +00:00
|
|
|
bool operator!=(const type_and_string &o) const;
|
2017-07-15 00:59:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct type_and_string_stats {
|
2017-11-07 23:20:17 +00:00
|
|
|
std::vector<type_and_string> sample_values = std::vector<type_and_string>(); // sorted
|
2017-07-14 23:56:23 +00:00
|
|
|
double min = INFINITY;
|
|
|
|
double max = -INFINITY;
|
2017-07-17 20:28:46 +00:00
|
|
|
int type = 0;
|
2016-04-28 21:43:04 +00:00
|
|
|
};
|
|
|
|
|
2016-08-29 21:59:28 +00:00
|
|
|
struct layermap_entry {
|
2017-11-07 23:20:17 +00:00
|
|
|
size_t id = 0;
|
2017-11-07 23:25:54 +00:00
|
|
|
std::map<std::string, type_and_string_stats> file_keys{};
|
2017-11-07 23:20:17 +00:00
|
|
|
int minzoom = 0;
|
|
|
|
int maxzoom = 0;
|
2018-05-24 17:27:43 +00:00
|
|
|
std::string description = "";
|
2017-07-15 00:23:41 +00:00
|
|
|
|
|
|
|
size_t points = 0;
|
|
|
|
size_t lines = 0;
|
|
|
|
size_t polygons = 0;
|
2017-12-14 22:30:08 +00:00
|
|
|
size_t retain = 0; // keep for tilestats, even if no features directly here
|
2016-08-29 21:59:28 +00:00
|
|
|
|
|
|
|
layermap_entry(size_t _id) {
|
|
|
|
id = _id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-28 22:18:31 +00:00
|
|
|
sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable);
|
2014-09-29 19:48:58 +00:00
|
|
|
|
|
|
|
void mbtiles_write_tile(sqlite3 *outdb, int z, int tx, int ty, const char *data, int size);
|
|
|
|
|
2018-06-08 04:37:25 +00:00
|
|
|
void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, int forcetable, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program);
|
2014-09-29 19:48:58 +00:00
|
|
|
|
2017-07-18 16:54:59 +00:00
|
|
|
void mbtiles_close(sqlite3 *outdb, const char *pgm);
|
2016-05-03 18:14:09 +00:00
|
|
|
|
2016-09-20 18:04:24 +00:00
|
|
|
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps);
|
2017-07-21 19:56:30 +00:00
|
|
|
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps, bool trunc);
|
2017-07-14 23:56:23 +00:00
|
|
|
|
2017-07-19 21:45:15 +00:00
|
|
|
void add_to_file_keys(std::map<std::string, type_and_string_stats> &file_keys, std::string const &layername, type_and_string const &val);
|
|
|
|
|
2017-07-14 23:56:23 +00:00
|
|
|
#endif
|