PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ vectortile_layer_combine()

static VectorTile__Tile__Layer* vectortile_layer_combine ( const VectorTile__Tile__Layer *  layer1,
const VectorTile__Tile__Layer *  layer2 
)
static

Definition at line 1158 of file mvt.c.

References tile_feature_copy(), and tile_value_copy().

Referenced by vectortile_tile_combine().

1159 {
1160  uint32_t i, j;
1161  int key2_offset, value2_offset;
1162  VectorTile__Tile__Layer *layer = palloc(sizeof(VectorTile__Tile__Layer));
1163  vector_tile__tile__layer__init(layer);
1164 
1165  /* Take globals from layer1 */
1166  layer->version = layer1->version;
1167  layer->name = pstrdup(layer1->name);
1168  layer->has_extent = layer1->has_extent;
1169  layer->extent = layer1->extent;
1170 
1171  /* Copy keys into new layer */
1172  j = 0;
1173  layer->n_keys = layer1->n_keys + layer2->n_keys;
1174  layer->keys = layer->n_keys ? palloc(layer->n_keys * sizeof(void*)) : NULL;
1175  for (i = 0; i < layer1->n_keys; i++)
1176  layer->keys[j++] = pstrdup(layer1->keys[i]);
1177  key2_offset = j;
1178  for (i = 0; i < layer2->n_keys; i++)
1179  layer->keys[j++] = pstrdup(layer2->keys[i]);
1180 
1181  /* Copy values into new layer */
1182  /* TODO, apply hash logic here too, so that merged tiles */
1183  /* retain unique value maps */
1184  layer->n_values = layer1->n_values + layer2->n_values;
1185  layer->values = layer->n_values ? palloc(layer->n_values * sizeof(void*)) : NULL;
1186  j = 0;
1187  for (i = 0; i < layer1->n_values; i++)
1188  layer->values[j++] = tile_value_copy(layer1->values[i]);
1189  value2_offset = j;
1190  for (i = 0; i < layer2->n_values; i++)
1191  layer->values[j++] = tile_value_copy(layer2->values[i]);
1192 
1193 
1194  layer->n_features = layer1->n_features + layer2->n_features;
1195  layer->features = layer->n_features ? palloc(layer->n_features * sizeof(void*)) : NULL;
1196  j = 0;
1197  for (i = 0; i < layer1->n_features; i++)
1198  layer->features[j++] = tile_feature_copy(layer1->features[i], 0, 0);
1199  for (i = 0; i < layer2->n_features; i++)
1200  layer->features[j++] = tile_feature_copy(layer2->features[i], key2_offset, value2_offset);
1201 
1202  return layer;
1203 }
static VectorTile__Tile__Value * tile_value_copy(const VectorTile__Tile__Value *value)
Definition: mvt.c:1104
unsigned int uint32_t
Definition: uthash.h:78
static VectorTile__Tile__Feature * tile_feature_copy(const VectorTile__Tile__Feature *feature, int key_offset, int value_offset)
Definition: mvt.c:1114
Here is the call graph for this function:
Here is the caller graph for this function: