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"
|
|
|
|
|
2016-04-28 14:43:04 -07:00
|
|
|
struct type_and_string {
|
2016-04-28 15:11:57 -07:00
|
|
|
int type;
|
|
|
|
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-07-19 16:53:53 -07:00
|
|
|
std::vector<type_and_string> sample_values; // 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 {
|
|
|
|
size_t id;
|
2017-07-17 17:31:46 -07:00
|
|
|
std::map<std::string, type_and_string_stats> file_keys;
|
2016-09-19 17:53:31 -07:00
|
|
|
int minzoom;
|
|
|
|
int maxzoom;
|
2017-07-14 17:23:41 -07:00
|
|
|
|
|
|
|
size_t points = 0;
|
|
|
|
size_t lines = 0;
|
|
|
|
size_t polygons = 0;
|
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);
|
|
|
|
|
2017-08-15 10:35:41 -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);
|
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
|
|
|
|
|
|
|
void aprintf(std::string *buf, const char *format, ...);
|
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
|