PostGIS  2.5.0dev-r@@SVN_REVISION@@
static VectorTile__Tile__Layer* vectortile_layer_combine ( const VectorTile__Tile__Layer *  layer1,
const VectorTile__Tile__Layer *  layer2 
)
static

Definition at line 1004 of file mvt.c.

References tile_feature_copy(), and tile_value_copy().

Referenced by vectortile_tile_combine().

1005 {
1006  uint32_t i, j;
1007  int key2_offset, value2_offset;
1008  VectorTile__Tile__Layer *layer = palloc(sizeof(VectorTile__Tile__Layer));
1009  vector_tile__tile__layer__init(layer);
1010 
1011  /* Take globals from layer1 */
1012  layer->version = layer1->version;
1013  layer->name = pstrdup(layer1->name);
1014  layer->has_extent = layer1->has_extent;
1015  layer->extent = layer1->extent;
1016 
1017  /* Copy keys into new layer */
1018  j = 0;
1019  layer->n_keys = layer1->n_keys + layer2->n_keys;
1020  layer->keys = layer->n_keys ? palloc(layer->n_keys * sizeof(void*)) : NULL;
1021  for (i = 0; i < layer1->n_keys; i++)
1022  layer->keys[j++] = pstrdup(layer1->keys[i]);
1023  key2_offset = j;
1024  for (i = 0; i < layer2->n_keys; i++)
1025  layer->keys[j++] = pstrdup(layer2->keys[i]);
1026 
1027  /* Copy values into new layer */
1028  /* TODO, apply hash logic here too, so that merged tiles */
1029  /* retain unique value maps */
1030  layer->n_values = layer1->n_values + layer2->n_values;
1031  layer->values = layer->n_values ? palloc(layer->n_values * sizeof(void*)) : NULL;
1032  j = 0;
1033  for (i = 0; i < layer1->n_values; i++)
1034  layer->values[j++] = tile_value_copy(layer1->values[i]);
1035  value2_offset = j;
1036  for (i = 0; i < layer2->n_values; i++)
1037  layer->values[j++] = tile_value_copy(layer2->values[i]);
1038 
1039 
1040  layer->n_features = layer1->n_features + layer2->n_features;
1041  layer->features = layer->n_features ? palloc(layer->n_features * sizeof(void*)) : NULL;
1042  j = 0;
1043  for (i = 0; i < layer1->n_features; i++)
1044  layer->features[j++] = tile_feature_copy(layer1->features[i], 0, 0);
1045  value2_offset = j;
1046  for (i = 0; i < layer2->n_features; i++)
1047  layer->features[j++] = tile_feature_copy(layer2->features[i], key2_offset, value2_offset);
1048 
1049  return layer;
1050 }
static VectorTile__Tile__Value * tile_value_copy(const VectorTile__Tile__Value *value)
Definition: mvt.c:951
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:961

Here is the call graph for this function:

Here is the caller graph for this function: