PostGIS  2.5.7dev-r@@SVN_REVISION@@
mvt.c File Reference
#include "mvt.h"
#include "lwgeom_geos.h"
#include "utils/jsonb.h"
#include "uthash.h"
Include dependency graph for mvt.c:

Go to the source code of this file.

Data Structures

struct  mvt_kv_key
 
struct  mvt_kv_string_value
 
struct  mvt_kv_float_value
 
struct  mvt_kv_double_value
 
struct  mvt_kv_uint_value
 
struct  mvt_kv_sint_value
 
struct  mvt_kv_bool_value
 

Macros

#define DatumGetJsonbP   DatumGetJsonb
 
#define FEATURES_CAPACITY_INITIAL   50
 
#define MVT_CREATE_VALUES(kvtype, hash, hasfield, valuefield)
 
#define MVT_PARSE_VALUE(value, kvtype, hash, valuefield, size)
 
#define MVT_PARSE_INT_VALUE(value)
 
#define MVT_PARSE_DATUM(type, kvtype, hash, valuefield, datumfunc, size)
 
#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 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 (__attribute__((__unused__)) mvt_agg_context *ctx, enum mvt_type type, POINTARRAY *pa, uint32_t *buffer, int32_t *px, int32_t *py)
 
static uint32_t encode_ptarray_initial (mvt_agg_context *ctx, enum mvt_type type, POINTARRAY *pa, uint32_t *buffer)
 
static void encode_point (mvt_agg_context *ctx, LWPOINT *point)
 
static void encode_mpoint (mvt_agg_context *ctx, LWMPOINT *mpoint)
 
static void encode_line (mvt_agg_context *ctx, LWLINE *lwline)
 
static void encode_mline (mvt_agg_context *ctx, LWMLINE *lwmline)
 
static void encode_poly (mvt_agg_context *ctx, LWPOLY *lwpoly)
 
static void encode_mpoly (mvt_agg_context *ctx, LWMPOLY *lwmpoly)
 
static void encode_geometry (mvt_agg_context *ctx, 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 VectorTile__Tile__Value * create_value ()
 
static void encode_values (mvt_agg_context *ctx)
 
static void add_value_as_string_with_size (mvt_agg_context *ctx, char *value, size_t size, uint32_t *tags, uint32_t k)
 
static void add_value_as_string (mvt_agg_context *ctx, char *value, uint32_t *tags, uint32_t k)
 
static void parse_datum_as_string (mvt_agg_context *ctx, Oid typoid, Datum datum, uint32_t *tags, uint32_t k)
 
static uint32_tparse_jsonb (mvt_agg_context *ctx, Jsonb *jb, uint32_t *tags)
 
static void parse_values (mvt_agg_context *ctx)
 
static uint8 lwgeom_get_basic_type (LWGEOM *geom)
 
static LWGEOMlwgeom_to_basic_type (LWGEOM *geom, uint8 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_safe_clip_polygon_by_box (LWGEOM *lwg_in, GBOX *clip_box)
 Clips an input geometry using GEOSIntersection It used to try to use GEOSClipByRect (as mvt_unsafe_clip_by_box) but since that produces invalid output when an invalid geometry is given and detecting it resulted to be impossible, we use intersection instead and, upon error, force validation of the input and retry. More...
 
static LWGEOMmvt_iterate_clip_by_box_geos (LWGEOM *lwgeom, GBOX *clip_gbox, uint8_t basic_type)
 Clips the geometry using GEOSIntersection in a "safe way", cleaning the input if necessary and clipping MULTIPOLYGONs separately to reduce the impact of using invalid input in GEOS Might return NULL. More...
 
static LWGEOMmvt_grid_and_validate_geos (LWGEOM *ng, uint8_t basic_type)
 Given a geometry, it uses GEOS operations to make sure that it's valid according to the MVT spec and that all points are snapped into int coordinates It iterates several times if needed, if it fails, returns NULL. More...
 
static LWGEOMmvt_clip_and_validate_geos (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__Value * tile_value_copy (const VectorTile__Tile__Value *value)
 
static VectorTile__Tile__Feature * tile_feature_copy (const VectorTile__Tile__Feature *feature, int key_offset, int value_offset)
 
static VectorTile__Tile__Layer * vectortile_layer_combine (const VectorTile__Tile__Layer *layer1, const VectorTile__Tile__Layer *layer2)
 
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...