Transform a geometry into vector tile coordinate space.
Makes best effort to keep validity. Might collapse geometry into lower dimension.
715 LWGEOM *lwgeom_out = NULL;
716 double width = gbox->
xmax - gbox->
xmin;
717 double height = gbox->
ymax - gbox->
ymin;
718 double fx = extent / width;
719 double fy = -(extent / height);
721 POSTGIS_DEBUG(2,
"mvt_geom called");
727 if (width == 0 || height == 0)
728 elog(ERROR,
"mvt_geom: bounds width or height cannot be 0");
731 elog(ERROR,
"mvt_geom: extent cannot be 0");
737 memset(&affine, 0,
sizeof(affine));
758 GBOX bgbox, lwgeom_gbox;
769 POSTGIS_DEBUG(3,
"mvt_geom: geometry outside clip box");
776 #if POSTGIS_GEOS_VERSION < 35 785 POSTGIS_DEBUG(3,
"mvt_geom: no geometry after clip");
799 POSTGIS_DEBUG(3,
"mvt_geom: Invalid geometry after clipping");
804 lwgeom_out = clipped_geom;
827 POSTGIS_DEBUG(3,
"mvt_geom: Dropping geometry after type change");
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
int gbox_contains_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the first GBOX contains the second on the 2d plane, LW_FALSE otherwise.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
#define FLAGS_SET_GEODETIC(flags, value)
static LWGEOM * lwgeom_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...
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
LWPOLY * lwpoly_construct_envelope(int srid, double x1, double y1, double x2, double y2)
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
Datum buffer(PG_FUNCTION_ARGS)
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
void lwpoly_free(LWPOLY *poly)
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
void lwgeom_reverse(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise.
static uint8 lwgeom_get_basic_type(LWGEOM *geom)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)