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;
void * lwalloc(size_t size)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
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.