@@ -1165,7 +1165,7 @@ static void add_mean(mvt_feature &feature, mvt_layer &layer, std::string const &
1165
1165
// accumulate :sum:, :min:, :max:, and :count: versions of the specified attribute
1166
1166
static void preserve_numeric (const std::string &key, const mvt_value &val, // numeric attribute being accumulated
1167
1167
std::vector<std::string> &full_keys, // keys of feature being accumulated onto
1168
- std::vector<serial_val > &full_values, // values of features being accumulated onto
1168
+ std::vector<mvt_value > &full_values, // values of features being accumulated onto
1169
1169
const std::string &accumulate_numeric, // prefix of accumulations
1170
1170
std::set<std::string> &keys, // key presence in the source feature
1171
1171
std::map<std::string, size_t > &numeric_out_field, // key index in the output feature
@@ -1218,49 +1218,45 @@ static void preserve_numeric(const std::string &key, const mvt_value &val, /
1218
1218
if (op.second == op_count) {
1219
1219
if (starting_from_accumulation) {
1220
1220
// copy our count
1221
- full_values.push_back (mvt_value_to_serial_val ( val) );
1221
+ full_values.push_back (val);
1222
1222
} else {
1223
1223
// new count of 1
1224
- serial_val sv;
1225
- sv.type = mvt_double;
1226
- sv.s = " 1" ;
1227
- full_values.push_back (sv);
1224
+ full_values.push_back (mvt_value (1 ));
1228
1225
}
1229
1226
} else {
1230
- full_values.push_back (mvt_value_to_serial_val ( val) );
1227
+ full_values.push_back (val);
1231
1228
}
1232
1229
} else {
1233
1230
// exists unprefixed, so copy it, and then accumulate on our value
1234
1231
numeric_out_field.emplace (prefixed, full_keys.size ());
1235
1232
full_keys.push_back (prefixed);
1236
1233
1237
1234
if (op.second == op_count) {
1238
- serial_val sv;
1239
- sv.type = mvt_double;
1235
+ mvt_value v;
1240
1236
if (starting_from_accumulation) {
1241
1237
// sum our count onto the existing 1
1242
- sv. s = std::to_string (1 + mvt_value_to_long_long (val));
1238
+ v = mvt_value (1 + mvt_value_to_long_long (val));
1243
1239
} else {
1244
1240
// sum our 1 onto the existing 1
1245
- sv. s = " 2 " ;
1241
+ v = mvt_value ( 2 ) ;
1246
1242
}
1247
- full_values.push_back (sv );
1243
+ full_values.push_back (v );
1248
1244
} else {
1249
1245
full_values.push_back (full_values[out_attr->second ]);
1250
- preserve_attribute (op.second , prefixed, mvt_value_to_serial_val ( val) , full_keys, full_values, attribute_accum_state);
1246
+ preserve_attribute (op.second , prefixed, val, full_keys, full_values, attribute_accum_state);
1251
1247
}
1252
1248
}
1253
1249
} else {
1254
1250
// exists, so accumulate on our value
1255
1251
if (op.second == op_count) {
1256
1252
if (starting_from_accumulation) {
1257
1253
// sum our count onto the existing count
1258
- full_values[prefixed_attr->second ]. s = std::to_string ( atoll (full_values[prefixed_attr->second ]. s . c_str () ) + mvt_value_to_long_long (val));
1254
+ full_values[prefixed_attr->second ] = mvt_value ( mvt_value_to_long_long (full_values[prefixed_attr->second ]) + mvt_value_to_long_long (val));
1259
1255
} else {
1260
- full_values[prefixed_attr->second ]. s = std::to_string ( atoll (full_values[prefixed_attr->second ]. s . c_str () ) + 1 );
1256
+ full_values[prefixed_attr->second ] = mvt_value ( mvt_value_to_long_long (full_values[prefixed_attr->second ]) + 1 );
1261
1257
}
1262
1258
} else {
1263
- preserve_attribute (op.second , prefixed, mvt_value_to_serial_val ( val) , full_keys, full_values, attribute_accum_state);
1259
+ preserve_attribute (op.second , prefixed, val, full_keys, full_values, attribute_accum_state);
1264
1260
}
1265
1261
}
1266
1262
}
@@ -1293,7 +1289,6 @@ static void feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
1293
1289
std::set<std::string> const &exclude,
1294
1290
std::vector<std::string> const &exclude_prefix,
1295
1291
std::unordered_map<std::string, attribute_op> const &attribute_accum,
1296
- std::shared_ptr<std::string> const &tile_stringpool,
1297
1292
std::string const &accumulate_numeric) {
1298
1293
// Add geometry to output feature
1299
1294
@@ -1315,13 +1310,13 @@ static void feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
1315
1310
1316
1311
if (attribute_accum.size () > 0 || accumulate_numeric.size () > 0 ) {
1317
1312
// convert the attributes of the output feature
1318
- // from mvt_value to serial_val so they can have
1313
+ // from layer references to a vector so they can have
1319
1314
// attributes from the other features of the
1320
1315
// multiplier cluster accumulated onto them
1321
1316
1322
1317
std::unordered_map<std::string, accum_state> attribute_accum_state;
1323
1318
std::vector<std::string> full_keys;
1324
- std::vector<serial_val > full_values;
1319
+ std::vector<mvt_value > full_values;
1325
1320
std::map<std::string, size_t > numeric_out_field;
1326
1321
1327
1322
for (size_t i = 0 ; i + 1 < features[0 ].tags .size (); i += 2 ) {
@@ -1330,12 +1325,12 @@ static void feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
1330
1325
if (f != attribute_accum.end ()) {
1331
1326
// this attribute has an accumulator, so convert it
1332
1327
full_keys.push_back (features[0 ].layer ->keys [features[0 ].tags [i]]);
1333
- full_values.push_back (mvt_value_to_serial_val ( features[0 ].layer ->values [features[0 ].tags [i + 1 ]]) );
1328
+ full_values.push_back (features[0 ].layer ->values [features[0 ].tags [i + 1 ]]);
1334
1329
} else if (accumulate_numeric.size () > 0 && features[0 ].layer ->values [features[0 ].tags [i + 1 ]].is_numeric ()) {
1335
1330
// convert numeric for accumulation
1336
1331
numeric_out_field.emplace (key, full_keys.size ());
1337
1332
full_keys.push_back (key);
1338
- full_values.push_back (mvt_value_to_serial_val ( features[0 ].layer ->values [features[0 ].tags [i + 1 ]]) );
1333
+ full_values.push_back (features[0 ].layer ->values [features[0 ].tags [i + 1 ]]);
1339
1334
} else {
1340
1335
// otherwise just tag it directly onto the output feature
1341
1336
if (should_keep (features[0 ].layer ->keys [features[0 ].tags [i]], keep, exclude, exclude_prefix)) {
@@ -1361,7 +1356,7 @@ static void feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
1361
1356
1362
1357
auto f = attribute_accum.find (key);
1363
1358
if (f != attribute_accum.end ()) {
1364
- serial_val val = mvt_value_to_serial_val ( features[i].layer ->values [features[i].tags [j + 1 ]]) ;
1359
+ mvt_value val = features[i].layer ->values [features[i].tags [j + 1 ]];
1365
1360
preserve_attribute (f->second , key, val, full_keys, full_values, attribute_accum_state);
1366
1361
} else if (accumulate_numeric.size () > 0 ) {
1367
1362
const mvt_value &val = features[i].layer ->values [features[i].tags [j + 1 ]];
@@ -1379,7 +1374,7 @@ static void feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
1379
1374
1380
1375
for (size_t i = 0 ; i < full_keys.size (); i++) {
1381
1376
if (should_keep (full_keys[i], keep, exclude, exclude_prefix)) {
1382
- outlayer.tag (outfeature, full_keys[i], stringified_to_mvt_value ( full_values[i]. type , full_values[i]. s . c_str (), tile_stringpool) );
1377
+ outlayer.tag (outfeature, full_keys[i], full_values[i]);
1383
1378
}
1384
1379
}
1385
1380
@@ -1570,7 +1565,6 @@ mvt_tile assign_to_bins(mvt_tile &features,
1570
1565
outlayer.name = features.layers [0 ].name ;
1571
1566
1572
1567
std::vector<std::vector<tile_feature>> outfeatures;
1573
- std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
1574
1568
1575
1569
for (auto &e : events) {
1576
1570
if (e.kind == index_event::ENTER) {
@@ -1680,7 +1674,7 @@ mvt_tile assign_to_bins(mvt_tile &features,
1680
1674
if (outfeatures[i].size () > 1 ) {
1681
1675
feature_out (outfeatures[i], outlayer,
1682
1676
keep, exclude, exclude_prefix, attribute_accum,
1683
- tile_stringpool, accumulate_numeric);
1677
+ accumulate_numeric);
1684
1678
mvt_feature &nfeature = outlayer.features .back ();
1685
1679
mvt_value val;
1686
1680
val.type = mvt_uint;
@@ -1715,7 +1709,6 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
1715
1709
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
1716
1710
std::string const &accumulate_numeric) {
1717
1711
mvt_tile outtile;
1718
- std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
1719
1712
1720
1713
for (auto const &tile : tiles) {
1721
1714
for (auto const &layer : tile.tile .layers ) {
@@ -1840,7 +1833,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
1840
1833
1841
1834
if (flush_multiplier_cluster) {
1842
1835
if (pending_tile_features.size () > 0 ) {
1843
- feature_out (pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, tile_stringpool, accumulate_numeric);
1836
+ feature_out (pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, accumulate_numeric);
1844
1837
pending_tile_features.clear ();
1845
1838
}
1846
1839
}
@@ -1897,7 +1890,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
1897
1890
}
1898
1891
1899
1892
if (pending_tile_features.size () > 0 ) {
1900
- feature_out (pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, tile_stringpool, accumulate_numeric);
1893
+ feature_out (pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, accumulate_numeric);
1901
1894
pending_tile_features.clear ();
1902
1895
}
1903
1896
0 commit comments