mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Pull the writing of the serialized feature out to the callers
This commit is contained in:
+6
-5
@@ -383,7 +383,7 @@ static void write_geometry(drawvec const &dv, std::string &out, long long wx, lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// called from generating the next zoom level
|
// called from generating the next zoom level
|
||||||
void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long> *geompos, const char *fname, long long wx, long long wy) {
|
std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
serialize_byte(s, sf->t);
|
serialize_byte(s, sf->t);
|
||||||
@@ -445,9 +445,7 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long
|
|||||||
|
|
||||||
// MAGIC: This knows that the feature minzoom is the last byte of the feature,
|
// MAGIC: This knows that the feature minzoom is the last byte of the feature,
|
||||||
serialize_byte(s, sf->feature_minzoom);
|
serialize_byte(s, sf->feature_minzoom);
|
||||||
|
return s;
|
||||||
serialize_long_long(geomfile, s.size(), geompos, fname);
|
|
||||||
fwrite_check(s.c_str(), sizeof(char), s.size(), geomfile, geompos, fname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_in, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y) {
|
serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_in, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y) {
|
||||||
@@ -917,7 +915,10 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
|||||||
|
|
||||||
long long geomstart = r->geompos;
|
long long geomstart = r->geompos;
|
||||||
sf.geometry = scaled_geometry;
|
sf.geometry = scaled_geometry;
|
||||||
serialize_feature(r->geomfile, &sf, &r->geompos, sst->fname, SHIFT_RIGHT(*(sst->initial_x)), SHIFT_RIGHT(*(sst->initial_y)));
|
|
||||||
|
std::string feature = serialize_feature(&sf, SHIFT_RIGHT(*(sst->initial_x)), SHIFT_RIGHT(*(sst->initial_y)));
|
||||||
|
serialize_long_long(r->geomfile, feature.size(), &r->geompos, sst->fname);
|
||||||
|
fwrite_check(feature.c_str(), sizeof(char), feature.size(), r->geomfile, &r->geompos, sst->fname);
|
||||||
|
|
||||||
struct index index;
|
struct index index;
|
||||||
index.start = geomstart;
|
index.start = geomstart;
|
||||||
|
|||||||
+1
-1
@@ -75,7 +75,7 @@ struct serial_feature {
|
|||||||
bool dropped = false;
|
bool dropped = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long> *geompos, const char *fname, long long wx, long long wy);
|
std::string serialize_feature(serial_feature *sf, long long wx, long long wy);
|
||||||
serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_in, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y);
|
serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_in, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y);
|
||||||
|
|
||||||
struct reader {
|
struct reader {
|
||||||
|
|||||||
@@ -422,7 +422,9 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u
|
|||||||
sf.values.push_back(metavals[i]);
|
sf.values.push_back(metavals[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
serialize_feature(geomfile[j], &sf, &geompos[j], fname, SHIFT_RIGHT(initial_x[segment]), SHIFT_RIGHT(initial_y[segment]));
|
std::string feature = serialize_feature(&sf, SHIFT_RIGHT(initial_x[segment]), SHIFT_RIGHT(initial_y[segment]));
|
||||||
|
serialize_long_long(geomfile[j], feature.size(), &geompos[j], fname);
|
||||||
|
fwrite_check(feature.c_str(), sizeof(char), feature.size(), geomfile[j], &geompos[j], fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user