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