PostGIS  3.4.0dev-r@@SVN_REVISION@@
mvt.c File Reference
#include <stdbool.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include "mvt.h"
#include "lwgeom_geos.h"
#include "pgsql_compat.h"
#include "utils/jsonb.h"
#include "lwgeom_wagyu.h"
#include "uthash.h"
#include "vector_tile.pb-c.h"
Include dependency graph for mvt.c:

Go to the source code of this file.

Data Structures

struct  mvt_kv_key
 
struct  mvt_kv_value
 
struct  feature_builder
 

Macros

#define uthash_fatal(msg)   lwerror("uthash: fatal error (out of memory)")
 
#define uthash_malloc(sz)   palloc(sz)
 
#define uthash_free(ptr, sz)   pfree(ptr)
 
#define FEATURES_CAPACITY_INITIAL   50
 
#define TAGS_INITIAL_CAPACITY   20
 
#define MVT_CREATE_VALUES(hash)
 
#define MVT_PARSE_VALUE(hash, newvalue, size, pfvaluefield, pftype)
 
#define MVT_PARSE_INT_VALUE(value)
 
#define MVT_PARSE_DATUM(type, datumfunc, hash, size, pfvaluefield, pftype)
 
#define MVT_PARSE_INT_DATUM(type, datumfunc)
 

Enumerations

enum  mvt_cmd_id { CMD_MOVE_TO = 1 , CMD_LINE_TO = 2 , CMD_CLOSE_PATH = 7 }
 
enum  mvt_type { MVT_POINT = 1 , MVT_LINE = 2 , MVT_RING = 3 }
 

Functions

static void feature_init (struct feature_builder *builder)
 
static VectorTile__Tile__Feature * feature_build (struct feature_builder *builder)
 
static void feature_add_property (struct feature_builder *builder, uint32_t key_id, uint32_t value_id)
 
static uint32_t c_int (enum mvt_cmd_id id, uint32_t count)
 
static uint32_t p_int (int32_t value)
 
static uint32_t encode_ptarray (enum mvt_type type, POINTARRAY *pa, uint32_t *buffer, int32_t *px, int32_t *py)
 
static uint32_t encode_ptarray_initial (enum mvt_type type, POINTARRAY *pa, uint32_t *buffer)
 
static void encode_point (struct feature_builder *feature, LWPOINT *point)
 
static void encode_mpoint (struct feature_builder *feature, LWMPOINT *mpoint)
 
static void encode_line (struct feature_builder *feature, LWLINE *lwline)
 
static void encode_mline (struct feature_builder *feature, LWMLINE *lwmline)
 
static void encode_poly (struct feature_builder *feature, LWPOLY *lwpoly)
 
static void encode_mpoly (struct feature_builder *feature, LWMPOLY *lwmpoly)
 
static void encode_feature_geometry (struct feature_builder *feature, LWGEOM *lwgeom)
 
static TupleDesc get_tuple_desc (mvt_agg_context *ctx)
 
static uint32_t get_key_index_with_size (mvt_agg_context *ctx, const char *name, size_t size)
 
static uint32_t add_key (mvt_agg_context *ctx, char *name)
 
static void parse_column_keys (mvt_agg_context *ctx)
 
static void encode_keys (mvt_agg_context *ctx)
 
static void encode_values (mvt_agg_context *ctx)
 
static bool add_value_as_string_with_size (mvt_agg_context *ctx, struct feature_builder *feature, char *value, size_t size, uint32_t k)
 
static void add_value_as_string (mvt_agg_context *ctx, struct feature_builder *feature, char *value, uint32_t k)
 
static void parse_datum_as_string (mvt_agg_context *ctx, struct feature_builder *feature, Oid typoid, Datum datum, uint32_t k)
 
static void parse_jsonb (mvt_agg_context *ctx, struct feature_builder *feature, Jsonb *jb)
 
static void set_feature_id (mvt_agg_context *ctx, struct feature_builder *feature, Datum datum, bool isNull)
 Sets the feature id. More...
 
static void parse_values (mvt_agg_context *ctx, struct feature_builder *feature)
 
static uint8_t lwgeom_get_basic_type (LWGEOM *geom)
 
static LWGEOMlwgeom_to_basic_type (LWGEOM *geom, uint8_t original_type)
 In place process a collection to find a concrete geometry object and expose that as the actual object. More...
 
static LWGEOMmvt_unsafe_clip_by_box (LWGEOM *lwg_in, GBOX *clip_box)
 
static LWGEOMmvt_clip_and_validate_geos (LWGEOM *lwgeom, uint8_t basic_type, uint32_t extent, uint32_t buffer, bool clip_geom)
 
static LWGEOMmvt_clip_and_validate (LWGEOM *lwgeom, uint8_t basic_type, uint32_t extent, uint32_t buffer, bool clip_geom)
 
LWGEOMmvt_geom (LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32_t buffer, bool clip_geom)
 Transform a geometry into vector tile coordinate space. More...
 
void mvt_agg_init_context (mvt_agg_context *ctx)
 Initialize aggregation context. More...
 
void mvt_agg_transfn (mvt_agg_context *ctx)
 Aggregation step. More...
 
static VectorTile__Tile * mvt_ctx_to_tile (mvt_agg_context *ctx)
 
static bytea * mvt_ctx_to_bytea (mvt_agg_context *ctx)
 
bytea * mvt_ctx_serialize (mvt_agg_context *ctx)
 
static void * mvt_allocator (__attribute__((__unused__)) void *data, size_t size)
 
static void mvt_deallocator (__attribute__((__unused__)) void *data, void *ptr)
 
mvt_agg_contextmvt_ctx_deserialize (const bytea *ba)
 
static VectorTile__Tile__Layer * vectortile_layer_combine (VectorTile__Tile__Layer *layer, VectorTile__Tile__Layer *layer2)
 Combine 2 layers. More...
 
static VectorTile__Tile * vectortile_tile_combine (VectorTile__Tile *tile1, VectorTile__Tile *tile2)
 
mvt_agg_contextmvt_ctx_combine (mvt_agg_context *ctx1, mvt_agg_context *ctx2)
 
bytea * mvt_agg_finalfn (mvt_agg_context *ctx)
 Finalize aggregation. More...