17 #include "../postgis_config.h" 24 int length = strlen(encodedpolyline);
26 double scale = pow(10,precision);
28 float latitude = 0.0f;
29 float longitude = 0.0f;
33 while (idx < length) {
40 byte = encodedpolyline[idx++] - 63;
41 res |= (byte & 0x1F) << shift;
43 }
while (byte >= 0x20);
44 float deltaLat = ((res & 1) ? ~(res >> 1) : (res >> 1));
50 byte = encodedpolyline[idx++] - 63;
51 res |= (byte & 0x1F) << shift;
53 }
while (byte >= 0x20);
54 float deltaLon = ((res & 1) ? ~(res >> 1) : (res >> 1));
55 longitude += deltaLon;
57 pt.
x = longitude/scale;
58 pt.
y = latitude/scale;
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_TRUE, then a duplicate point will not be added.
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
This library is the generic geometry handling section of PostGIS.