First stages of geobuf support

This commit is contained in:
Eric Fischer 2017-08-08 10:31:26 -07:00
parent e982b2f6a7
commit fa0e38da2b
3 changed files with 21 additions and 2 deletions

View File

@ -46,7 +46,7 @@ C = $(wildcard *.c) $(wildcard *.cpp)
INCLUDES = -I/usr/local/include -I.
LIBS = -L/usr/local/lib
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o text.o dirtiles.o
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o text.o dirtiles.o geobuf.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-enumerate: enumerate.o

13
geobuf.hpp Normal file
View File

@ -0,0 +1,13 @@
#ifndef GEOBUF_HPP
#define GEOBUF_HPP
#include <stdio.h>
#include <set>
#include <map>
#include <string>
#include "mbtiles.hpp"
void parse_geobuf(FILE *fp, 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

@ -45,6 +45,7 @@
#include "memfile.hpp"
#include "main.hpp"
#include "geojson.hpp"
#include "geobuf.hpp"
#include "geometry.hpp"
#include "serial.hpp"
#include "options.hpp"
@ -1376,7 +1377,7 @@ int read_input(std::vector<source> &sources, char *fname, int &maxzoom, int minz
overall_offset += ahead;
checkdisk(reader, CPUS);
}
} else {
} else if (c == '{') {
// Plain serial reading
long long layer_seq = overall_offset;
@ -1385,6 +1386,11 @@ int read_input(std::vector<source> &sources, char *fname, int &maxzoom, int minz
json_end(jp);
overall_offset = layer_seq;
checkdisk(reader, CPUS);
} else {
long long layer_seq = overall_offset;
parse_geobuf(fp, reading.c_str(), &layer_seq, &progress_seq, &reader[0].metapos, &reader[0].geompos, &reader[0].indexpos, exclude, include, exclude_all, reader[0].metafile, reader[0].geomfile, reader[0].indexfile, reader[0].poolfile, reader[0].treefile, fname, basezoom, layer, droprate, reader[0].file_bbox, 0, &initialized[0], &initial_x[0], &initial_y[0], reader, maxzoom, &layermaps[0], sources[layer].layer, uses_gamma, attribute_types, &dist_sum, &dist_count, guess_maxzoom);
overall_offset = layer_seq;
checkdisk(reader, CPUS);
}
if (fclose(fp) != 0) {