PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ pointArray_to_geojson()

static size_t pointArray_to_geojson ( POINTARRAY pa,
char *  buf,
int  precision 
)
static

Definition at line 723 of file lwout_geojson.c.

724{
725 uint32_t i;
726 char *ptr;
730
732 ptr = output;
733
734 /* TODO: rewrite this loop to be simpler and possibly quicker */
735 if (!FLAGS_GET_Z(pa->flags))
736 {
737 for (i=0; i<pa->npoints; i++)
738 {
739 const POINT2D *pt;
740 pt = getPoint2d_cp(pa, i);
741
746
747 if ( i ) ptr += sprintf(ptr, ",");
748 ptr += sprintf(ptr, "[%s,%s]", x, y);
749 }
750 }
751 else
752 {
753 for (i=0; i<pa->npoints; i++)
754 {
755 const POINT3D *pt = getPoint3d_cp(pa, i);
756
763
764 if ( i ) ptr += sprintf(ptr, ",");
765 ptr += sprintf(ptr, "[%s,%s,%s]", x, y, z);
766 }
767 }
768
769 return (ptr-output);
770}
static uint8_t precision
Definition cu_in_twkb.c:25
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
#define OUT_DOUBLE_BUFFER_SIZE
#define OUT_MAX_DOUBLE_PRECISION
int lwprint_double(double d, int maxdd, char *buf, size_t bufsize)
Definition lwprint.c:492
static const POINT3D * getPoint3d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition lwinline.h:103
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition lwinline.h:91
double y
Definition liblwgeom.h:376
double x
Definition liblwgeom.h:376
double z
Definition liblwgeom.h:388
double x
Definition liblwgeom.h:388
double y
Definition liblwgeom.h:388
lwflags_t flags
Definition liblwgeom.h:417
uint32_t npoints
Definition liblwgeom.h:413

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_cp(), getPoint3d_cp(), lwprint_double(), POINTARRAY::npoints, OUT_DOUBLE_BUFFER_SIZE, OUT_MAX_DOUBLE_PRECISION, precision, POINT2D::x, POINT3D::x, POINT2D::y, POINT3D::y, and POINT3D::z.

Referenced by asgeojson_line_buf(), asgeojson_multiline_buf(), asgeojson_multipoint_buf(), asgeojson_multipolygon_buf(), asgeojson_point_buf(), asgeojson_poly_buf(), and asgeojson_triangle_buf().

Here is the call graph for this function:
Here is the caller graph for this function: