From ee97e6c3078ffae350706942d21ab8027685a83f Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 27 Apr 2016 15:09:06 -0700 Subject: [PATCH] Whittle down tile.hpp to the things that actually related to tile.cpp --- decode.cpp | 16 +++++++------- geojson.cpp | 3 ++- geometry.cpp | 2 +- geometry.hpp | 13 ++++++++++++ main.hpp | 6 ++++++ mbtiles.cpp | 3 ++- options.hpp | 37 ++++++++++++++++++++++++++++++++ tile-join.cpp | 2 +- tile.cpp | 2 ++ tile.hpp | 59 --------------------------------------------------- 10 files changed, 72 insertions(+), 71 deletions(-) create mode 100644 options.hpp diff --git a/decode.cpp b/decode.cpp index f52d3d6..8b58319 100644 --- a/decode.cpp +++ b/decode.cpp @@ -12,8 +12,8 @@ #include #include #include "mvt.hpp" -#include "tile.hpp" #include "projection.hpp" +#include "geometry.hpp" void printq(const char *s) { putchar('"'); @@ -29,12 +29,12 @@ void printq(const char *s) { putchar('"'); } -struct draw { +struct lonlat { int op; double lon; double lat; - draw(int op, double lon, double lat) { + lonlat(int op, double lon, double lat) { this->op = op; this->lon = lon; this->lat = lat; @@ -141,7 +141,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { printf(" }, \"geometry\": { "); - std::vector ops; + std::vector ops; for (size_t g = 0; g < feat.geometry.size(); g++) { int op = feat.geometry[g].op; @@ -156,9 +156,9 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { double lat, lon; tile2latlon(wx, wy, 32, &lat, &lon); - ops.push_back(draw(op, lon, lat)); + ops.push_back(lonlat(op, lon, lat)); } else { - ops.push_back(draw(op, 0, 0)); + ops.push_back(lonlat(op, 0, 0)); } } @@ -212,12 +212,12 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { printf(" ] ]"); } } else if (feat.type == VT_POLYGON) { - std::vector > rings; + std::vector > rings; std::vector areas; for (size_t i = 0; i < ops.size(); i++) { if (ops[i].op == VT_MOVETO) { - rings.push_back(std::vector()); + rings.push_back(std::vector()); areas.push_back(0); } diff --git a/geojson.cpp b/geojson.cpp index 741b8ee..f8f0c75 100644 --- a/geojson.cpp +++ b/geojson.cpp @@ -19,12 +19,12 @@ #include #include #include +#include extern "C" { #include "jsonpull.h" } -#include "tile.hpp" #include "pool.hpp" #include "mbtiles.hpp" #include "projection.hpp" @@ -33,6 +33,7 @@ extern "C" { #include "serial.hpp" #include "main.hpp" #include "geojson.hpp" +#include "geometry.hpp" #define GEOM_POINT 0 /* array of positions */ #define GEOM_MULTIPOINT 1 /* array of arrays of positions */ diff --git a/geometry.cpp b/geometry.cpp index e932fb2..1cefe65 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -11,9 +11,9 @@ #include #include "geometry.hpp" #include "clipper/clipper.hpp" -#include "tile.hpp" #include "projection.hpp" #include "serial.hpp" +#include "main.hpp" static int pnpoly(drawvec &vert, size_t start, size_t nvert, long long testx, long long testy); static int clip(double *x0, double *y0, double *x1, double *y1, double xmin, double ymin, double xmax, double ymax); diff --git a/geometry.hpp b/geometry.hpp index 77fdc6c..760a383 100644 --- a/geometry.hpp +++ b/geometry.hpp @@ -1,3 +1,16 @@ +#define VT_POINT 1 +#define VT_LINE 2 +#define VT_POLYGON 3 + +#define VT_END 0 +#define VT_MOVETO 1 +#define VT_LINETO 2 +#define VT_CLOSEPATH 7 + +#define VT_STRING 1 +#define VT_NUMBER 2 +#define VT_BOOLEAN 7 + struct draw { signed char op; long long x; diff --git a/main.hpp b/main.hpp index 105397e..ff0338d 100644 --- a/main.hpp +++ b/main.hpp @@ -7,3 +7,9 @@ struct index { }; void checkdisk(struct reader *r, int nreader); + +extern int geometry_scale; +extern int quiet; + +extern int CPUS; +extern int TEMP_FILES; diff --git a/mbtiles.cpp b/mbtiles.cpp index 216bdbb..697630c 100644 --- a/mbtiles.cpp +++ b/mbtiles.cpp @@ -5,9 +5,10 @@ #include #include #include +#include #include "pool.hpp" -#include "tile.hpp" #include "mbtiles.hpp" +#include "geometry.hpp" sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable) { sqlite3 *outdb; diff --git a/options.hpp b/options.hpp new file mode 100644 index 0000000..8e7d130 --- /dev/null +++ b/options.hpp @@ -0,0 +1,37 @@ +static int additional_options[] = { +#define A_COALESCE ((int) 'c') + A_COALESCE, +#define A_REVERSE ((int) 'r') + A_REVERSE, +#define A_REORDER ((int) 'o') + A_REORDER, +#define A_LINE_DROP ((int) 'l') + A_LINE_DROP, +#define A_DEBUG_POLYGON ((int) 'd') + A_DEBUG_POLYGON, +#define A_POLYGON_DROP ((int) 'p') + A_POLYGON_DROP, +#define A_PREFER_RADIX_SORT ((int) 'R') + A_PREFER_RADIX_SORT, +}; + +static int prevent_options[] = { +#define P_SIMPLIFY ((int) 's') + P_SIMPLIFY, +#define P_SIMPLIFY_LOW ((int) 'S') + P_SIMPLIFY_LOW, +#define P_FEATURE_LIMIT ((int) 'f') + P_FEATURE_LIMIT, +#define P_KILOBYTE_LIMIT ((int) 'k') + P_KILOBYTE_LIMIT, +#define P_DYNAMIC_DROP ((int) 'd') + P_DYNAMIC_DROP, +#define P_INPUT_ORDER ((int) 'i') + P_INPUT_ORDER, +#define P_POLYGON_SPLIT ((int) 'p') + P_POLYGON_SPLIT, +#define P_CLIPPING ((int) 'c') + P_CLIPPING, +#define P_DUPLICATION ((int) 'D') + P_DUPLICATION, +}; diff --git a/tile-join.cpp b/tile-join.cpp index b265264..acccbb3 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -10,10 +10,10 @@ #include #include #include "mvt.hpp" -#include "tile.hpp" #include "projection.hpp" #include "pool.hpp" #include "mbtiles.hpp" +#include "geometry.hpp" std::string dequote(std::string s); diff --git a/tile.cpp b/tile.cpp index 99370f0..9a235f4 100644 --- a/tile.cpp +++ b/tile.cpp @@ -26,6 +26,8 @@ #include "mbtiles.hpp" #include "projection.hpp" #include "serial.hpp" +#include "options.hpp" +#include "main.hpp" #define CMD_BITS 3 diff --git a/tile.hpp b/tile.hpp index b16a142..e37a02a 100644 --- a/tile.hpp +++ b/tile.hpp @@ -1,64 +1,5 @@ -#define VT_POINT 1 -#define VT_LINE 2 -#define VT_POLYGON 3 - -#define VT_END 0 -#define VT_MOVETO 1 -#define VT_LINETO 2 -#define VT_CLOSEPATH 7 - -#define VT_STRING 1 -#define VT_NUMBER 2 -#define VT_BOOLEAN 7 - -struct pool; - 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, struct pool **file_keys, char **layernames, sqlite3 *outdb, 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 *prevent, int *additional); int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpool, struct pool **file_keys, unsigned *midx, unsigned *midy, char **layernames, int maxzoom, int minzoom, int basezoom, sqlite3 *outdb, double droprate, int buffer, const char *fname, const char *tmpdir, double gamma, int nlayers, int *prevent, int *additional, int full_detail, int low_detail, int min_detail, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y); int manage_gap(unsigned long long index, unsigned long long *previndex, double scale, double gamma, double *gap); - -extern int geometry_scale; -extern int quiet; - -extern int CPUS; -extern int TEMP_FILES; - -static int additional_options[] = { -#define A_COALESCE ((int) 'c') - A_COALESCE, -#define A_REVERSE ((int) 'r') - A_REVERSE, -#define A_REORDER ((int) 'o') - A_REORDER, -#define A_LINE_DROP ((int) 'l') - A_LINE_DROP, -#define A_DEBUG_POLYGON ((int) 'd') - A_DEBUG_POLYGON, -#define A_POLYGON_DROP ((int) 'p') - A_POLYGON_DROP, -#define A_PREFER_RADIX_SORT ((int) 'R') - A_PREFER_RADIX_SORT, -}; - -static int prevent_options[] = { -#define P_SIMPLIFY ((int) 's') - P_SIMPLIFY, -#define P_SIMPLIFY_LOW ((int) 'S') - P_SIMPLIFY_LOW, -#define P_FEATURE_LIMIT ((int) 'f') - P_FEATURE_LIMIT, -#define P_KILOBYTE_LIMIT ((int) 'k') - P_KILOBYTE_LIMIT, -#define P_DYNAMIC_DROP ((int) 'd') - P_DYNAMIC_DROP, -#define P_INPUT_ORDER ((int) 'i') - P_INPUT_ORDER, -#define P_POLYGON_SPLIT ((int) 'p') - P_POLYGON_SPLIT, -#define P_CLIPPING ((int) 'c') - P_CLIPPING, -#define P_DUPLICATION ((int) 'D') - P_DUPLICATION, -};