PostGIS  2.5.0dev-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 1019 of file mvt.c.

References tile_feature_copy(), and tile_value_copy().

Referenced by vectortile_tile_combine().

1020 {
1021  uint32_t i, j;
1022  int key2_offset, value2_offset;
1023  VectorTile__Tile__Layer *layer = palloc(sizeof(VectorTile__Tile__Layer));
1024  vector_tile__tile__layer__init(layer);
1025 
1026  /* Take globals from layer1 */
1027  layer->version = layer1->version;
1028  layer->name = pstrdup(layer1->name);
1029  layer->has_extent = layer1->has_extent;
1030  layer->extent = layer1->extent;
1031 
1032  /* Copy keys into new layer */
1033  j = 0;
1034  layer->n_keys = layer1->n_keys + layer2->n_keys;
1035  layer->keys = layer->n_keys ? palloc(layer->n_keys * sizeof(void*)) : NULL;
1036  for (i = 0; i < layer1->n_keys; i++)
1037  layer->keys[j++] = pstrdup(layer1->keys[i]);
1038  key2_offset = j;
1039  for (i = 0; i < layer2->n_keys; i++)
1040  layer->keys[j++] = pstrdup(layer2->keys[i]);
1041 
1042  /* Copy values into new layer */
1043  /* TODO, apply hash logic here too, so that merged tiles */
1044  /* retain unique value maps */
1045  layer->n_values = layer1->n_values + layer2->n_values;
1046  layer->values = layer->n_values ? palloc(layer->n_values * sizeof(void*)) : NULL;
1047  j = 0;
1048  for (i = 0; i < layer1->n_values; i++)
1049  layer->values[j++] = tile_value_copy(layer1->values[i]);
1050  value2_offset = j;
1051  for (i = 0; i < layer2->n_values; i++)
1052  layer->values[j++] = tile_value_copy(layer2->values[i]);
1053 
1054 
1055  layer->n_features = layer1->n_features + layer2->n_features;
1056  layer->features = layer->n_features ? palloc(layer->n_features * sizeof(void*)) : NULL;
1057  j = 0;
1058  for (i = 0; i < layer1->n_features; i++)
1059  layer->features[j++] = tile_feature_copy(layer1->features[i], 0, 0);
1060  value2_offset = j;
1061  for (i = 0; i < layer2->n_features; i++)
1062  layer->features[j++] = tile_feature_copy(layer2->features[i], key2_offset, value2_offset);
1063 
1064  return layer;
1065 }
static VectorTile__Tile__Value * tile_value_copy(const VectorTile__Tile__Value *value)
Definition: mvt.c:965
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:975
Here is the call graph for this function:
Here is the caller graph for this function: