PostGIS  2.5.1dev-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 1146 of file mvt.c.

References tile_feature_copy(), and tile_value_copy().

Referenced by vectortile_tile_combine().

1147 {
1148  uint32_t i, j;
1149  int key2_offset, value2_offset;
1150  VectorTile__Tile__Layer *layer = palloc(sizeof(VectorTile__Tile__Layer));
1151  vector_tile__tile__layer__init(layer);
1152 
1153  /* Take globals from layer1 */
1154  layer->version = layer1->version;
1155  layer->name = pstrdup(layer1->name);
1156  layer->has_extent = layer1->has_extent;
1157  layer->extent = layer1->extent;
1158 
1159  /* Copy keys into new layer */
1160  j = 0;
1161  layer->n_keys = layer1->n_keys + layer2->n_keys;
1162  layer->keys = layer->n_keys ? palloc(layer->n_keys * sizeof(void*)) : NULL;
1163  for (i = 0; i < layer1->n_keys; i++)
1164  layer->keys[j++] = pstrdup(layer1->keys[i]);
1165  key2_offset = j;
1166  for (i = 0; i < layer2->n_keys; i++)
1167  layer->keys[j++] = pstrdup(layer2->keys[i]);
1168 
1169  /* Copy values into new layer */
1170  /* TODO, apply hash logic here too, so that merged tiles */
1171  /* retain unique value maps */
1172  layer->n_values = layer1->n_values + layer2->n_values;
1173  layer->values = layer->n_values ? palloc(layer->n_values * sizeof(void*)) : NULL;
1174  j = 0;
1175  for (i = 0; i < layer1->n_values; i++)
1176  layer->values[j++] = tile_value_copy(layer1->values[i]);
1177  value2_offset = j;
1178  for (i = 0; i < layer2->n_values; i++)
1179  layer->values[j++] = tile_value_copy(layer2->values[i]);
1180 
1181 
1182  layer->n_features = layer1->n_features + layer2->n_features;
1183  layer->features = layer->n_features ? palloc(layer->n_features * sizeof(void*)) : NULL;
1184  j = 0;
1185  for (i = 0; i < layer1->n_features; i++)
1186  layer->features[j++] = tile_feature_copy(layer1->features[i], 0, 0);
1187  for (i = 0; i < layer2->n_features; i++)
1188  layer->features[j++] = tile_feature_copy(layer2->features[i], key2_offset, value2_offset);
1189 
1190  return layer;
1191 }
static VectorTile__Tile__Value * tile_value_copy(const VectorTile__Tile__Value *value)
Definition: mvt.c:1092
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:1102
Here is the call graph for this function:
Here is the caller graph for this function: