Clean up #includes and add fields for counting attributes

This commit is contained in:
Eric Fischer 2017-07-14 16:56:23 -07:00
parent 24a182772f
commit 65c095cc2b
18 changed files with 123 additions and 10 deletions

View File

@ -1,3 +1,10 @@
#include <string>
#ifndef DIRTILES_HPP
#define DIRTILES_HPP
std::string dir_read_tile(std::string pbfPath);
void dir_write_tile(const char *outdir, int z, int tx, int ty, std::string const &pbf);
#endif

View File

@ -24,11 +24,7 @@
#include <set>
#include <map>
#include <string>
extern "C" {
#include "jsonpull/jsonpull.h"
}
#include "pool.hpp"
#include "projection.hpp"
#include "memfile.hpp"

View File

@ -1,3 +1,13 @@
#ifndef GEOJSON_HPP
#define GEOJSON_HPP
#include <stdio.h>
#include <set>
#include <map>
#include <string>
#include "mbtiles.hpp"
#include "jsonpull/jsonpull.h"
struct parse_json_args {
json_pull *jp;
const char *reading;
@ -39,3 +49,5 @@ void json_end_map(struct json_pull *jp);
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, int maxzoom, std::map<std::string, layermap_entry> *layermap, std::string layername, bool uses_gamma, std::map<std::string, int> const *attribute_types, double *dist_sum, size_t *dist_count, bool want_dist);
void *run_parse_json(void *v);
#endif

View File

@ -1,3 +1,9 @@
#ifndef GEOMETRY_HPP
#define GEOMETRY_HPP
#include <vector>
#include <sqlite3.h>
#define VT_POINT 1
#define VT_LINE 2
#define VT_POLYGON 3
@ -68,3 +74,5 @@ std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms);
void check_polygon(drawvec &geom, drawvec &before);
double get_area(drawvec &geom, size_t i, size_t j);
double get_mp_area(drawvec &geom);
#endif

View File

@ -1,3 +1,10 @@
#ifndef JSONPULL_H
#define JSONPULL_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum json_type {
// These types can be returned by json_read()
JSON_HASH,
@ -65,3 +72,9 @@ void json_disconnect(json_object *j);
json_object *json_hash_get(json_object *o, const char *s);
char *json_stringify(json_object *o);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -36,10 +36,7 @@
#include <sys/statfs.h>
#endif
extern "C" {
#include "jsonpull/jsonpull.h"
}
#include "mbtiles.hpp"
#include "tile.hpp"
#include "pool.hpp"

View File

@ -1,3 +1,8 @@
#ifndef MAIN_HPP
#define MAIN_HPP
#include <stddef.h>
struct index {
long long start;
long long end;
@ -18,3 +23,5 @@ extern size_t TEMP_FILES;
extern size_t max_tile_size;
#define MAX_ZOOM 24
#endif

View File

@ -1,7 +1,18 @@
#ifndef MBTILES_HPP
#define MBTILES_HPP
#include <math.h>
#include "mvt.hpp"
struct type_and_string {
int type;
std::string string;
size_t attribute_count = 0;
std::vector<mvt_value> sample_values;
double min = INFINITY;
double max = -INFINITY;
bool operator<(const type_and_string &o) const;
};
@ -10,6 +21,7 @@ struct layermap_entry {
std::set<type_and_string> file_keys;
int minzoom;
int maxzoom;
size_t feature_count = 0;
layermap_entry(size_t _id) {
id = _id;
@ -27,3 +39,5 @@ void mbtiles_close(sqlite3 *outdb, char **argv);
void aprintf(std::string *buf, const char *format, ...);
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps);
#endif

View File

@ -1,3 +1,6 @@
#ifndef MEMFILE_HPP
#define MEMFILE_HPP
struct memfile {
int fd;
char *map;
@ -9,3 +12,5 @@ struct memfile {
struct memfile *memfile_open(int fd);
int memfile_close(struct memfile *file);
int memfile_write(struct memfile *file, void *s, long long len);
#endif

11
mvt.hpp
View File

@ -1,3 +1,12 @@
#ifndef MVT_HPP
#define MVT_HPP
#include <sqlite3.h>
#include <string>
#include <map>
#include <set>
#include <vector>
struct mvt_value;
struct mvt_layer;
@ -98,3 +107,5 @@ bool is_compressed(std::string const &data);
int decompress(std::string const &input, std::string &output);
int compress(std::string const &input, std::string &output);
int dezig(unsigned n);
#endif

View File

@ -1,3 +1,6 @@
#ifndef OPTIONS_HPP
#define OPTIONS_HPP
#define A_COALESCE ((int) 'c')
#define A_REVERSE ((int) 'r')
#define A_REORDER ((int) 'o')
@ -30,3 +33,5 @@
extern int prevent[256];
extern int additional[256];
#endif

View File

@ -1,3 +1,6 @@
#ifndef POOL_HPP
#define POOL_HPP
struct stringpool {
long long left;
long long right;
@ -5,3 +8,5 @@ struct stringpool {
};
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type);
#endif

View File

@ -1,3 +1,6 @@
#ifndef PROJECTION_HPP
#define PROJECTION_HPP
void lonlat2tile(double lon, double lat, int zoom, long long *x, long long *y);
void epsg3857totile(double ix, double iy, int zoom, long long *x, long long *y);
void tile2lonlat(long long x, long long y, int zoom, double *lon, double *lat);
@ -15,3 +18,5 @@ struct projection {
extern struct projection *projection;
extern struct projection projections[];
#endif

View File

@ -1,3 +1,11 @@
#ifndef SERIAL_HPP
#define SERIAL_HPP
#include <stddef.h>
#include <stdio.h>
#include <vector>
#include "geometry.hpp"
size_t fwrite_check(const void *ptr, size_t size, size_t nitems, FILE *stream, const char *fname);
void serialize_int(FILE *out, int n, long long *fpos, const char *fname);
@ -47,3 +55,5 @@ struct serial_feature {
};
void serialize_feature(FILE *geomfile, serial_feature *sf, long long *geompos, const char *fname, long long wx, long long wy, bool include_minzoom);
#endif

View File

@ -1,3 +1,8 @@
#ifndef TEXT_HPP
#define TEXT_HPP
#include <string>
std::string check_utf8(std::string text);
#endif

View File

@ -26,10 +26,7 @@
#include <sstream>
#include <algorithm>
#include <functional>
extern "C" {
#include "jsonpull/jsonpull.h"
}
std::string dequote(std::string s);

View File

@ -1,5 +1,16 @@
#ifndef TILE_HPP
#define TILE_HPP
#include <stdio.h>
#include <sqlite3.h>
#include <vector>
#include <map>
#include "mbtiles.hpp"
long long write_tile(char **geom, char *metabase, char *stringpool, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int min_detail, int basezoom, sqlite3 *outdb, const char *outdir, double droprate, int buffer, const char *fname, FILE **geomfile, int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along, double gamma, int nlayers);
int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpool, unsigned *midx, unsigned *midy, int &maxzoom, int minzoom, int basezoom, sqlite3 *outdb, const char *outdir, double droprate, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, std::vector<std::map<std::string, layermap_entry> > &layermap);
int manage_gap(unsigned long long index, unsigned long long *previndex, double scale, double gamma, double *gap);
#endif

View File

@ -1 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "tippecanoe v1.20.0\n"
#endif