45 lwerror(
"lwgeom_to_encoded_polyline: '%s' geometry type not supported",
64 return encoded_polyline;
73 char* encoded_polyline = NULL;
75 double scale = pow(10, precision);
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;
static char * pointarray_to_encoded_polyline(const POINTARRAY *, int precision)
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
char * stringbuffer_getstringcopy(stringbuffer_t *s)
Returns a newly allocated string large enough to contain the current state of the string...
void lwline_free(LWLINE *line)
static char * lwline_to_encoded_polyline(const LWLINE *, 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...
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
static char * lwmmpoint_to_encoded_polyline(const LWMPOINT *, int precision)
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
void * lwalloc(size_t size)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.