Put the pieces back together

This commit is contained in:
Eric Fischer
2017-08-23 11:43:48 -07:00
parent 6cea2d5db6
commit 6caf20b9c8
4 changed files with 78 additions and 102 deletions
+26 -14
View File
@@ -4,6 +4,7 @@
#include <stddef.h>
#include <stdio.h>
#include <vector>
#include <sys/stat.h>
#include "geometry.hpp"
size_t fwrite_check(const void *ptr, size_t size, size_t nitems, FILE *stream, const char *fname);
@@ -67,6 +68,31 @@ 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);
serial_feature deserialize_feature(FILE *geoms, long long *geompos_in, char *metabase, long long *meta_off, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y);
struct reader {
int metafd;
int poolfd;
int treefd;
int geomfd;
int indexfd;
FILE *metafile;
struct memfile *poolfile;
struct memfile *treefile;
FILE *geomfile;
FILE *indexfile;
long long metapos;
long long geompos;
long long indexpos;
long long file_bbox[4];
struct stat geomst;
struct stat metast;
char *geom_map;
};
struct serialization_state {
const char *fname; // source file name
int line; // user-oriented location within source for error reports
@@ -77,20 +103,6 @@ struct serialization_state {
struct reader *readers; // array of data for each input thread
int segment; // the current input thread
FILE *geomfile; // main feature serialization; references metafile or poolfile
long long *geompos;
FILE *metafile; // feature metadata; references poolfile
long long *metapos;
FILE *indexfile; // quadkey index into geomfile
long long *indexpos;
struct memfile *poolfile; // string pool for keys and values
struct memfile *treefile; // index into poolfile
long long file_bbox[4]; // global bounding box
unsigned *initial_x; // relative offset of all geometries
unsigned *initial_y;
int *initialized;