45 lwerror(
"lwgeom_to_encoded_polyline: '%s' geometry type not supported",
64 return encoded_polyline;
73 char* encoded_polyline = NULL;
79 encoded_polyline =
lwalloc(1 *
sizeof(
char));
80 encoded_polyline[0] = 0;
81 return encoded_polyline;
89 delta[0] = round(prevPoint->
y * scale);
90 delta[1] = round(prevPoint->
x * scale);
93 for (i = 1; i < pa->
npoints; i++)
96 delta[2 * i] = round(point->
y * scale) - round(prevPoint->
y * scale);
98 round(point->
x * scale) - round(prevPoint->
x * scale);
104 for (i = 0; i < pa->
npoints * 2; i++)
110 delta[i] = ~(delta[i]);
115 for (i = 0; i < pa->
npoints * 2; i++)
117 int numberToEncode = delta[i];
119 while (numberToEncode >= 0x20)
123 int nextValue = (0x20 | (numberToEncode & 0x1f)) + 63;
127 numberToEncode >>= 5;
130 numberToEncode += 63;
138 return encoded_polyline;
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
void * lwalloc(size_t size)
void lwline_free(LWLINE *line)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static char * pointarray_to_encoded_polyline(const POINTARRAY *, int precision)
static char * lwmmpoint_to_encoded_polyline(const LWMPOINT *, int precision)
static char * lwline_to_encoded_polyline(const LWLINE *, int precision)
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided.
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
char * stringbuffer_getstringcopy(stringbuffer_t *s)
Returns a newly allocated string large enough to contain the current state of the string.