29 #include "../postgis_config.h" 36 int length = strlen(encodedpolyline);
38 double scale = pow(10,precision);
40 float latitude = 0.0f;
41 float longitude = 0.0f;
45 while (idx < length) {
52 byte = encodedpolyline[idx++] - 63;
53 res |= (byte & 0x1F) << shift;
55 }
while (byte >= 0x20);
56 float deltaLat = ((res & 1) ? ~(res >> 1) : (res >> 1));
62 byte = encodedpolyline[idx++] - 63;
63 res |= (byte & 0x1F) << shift;
65 }
while (byte >= 0x20);
66 float deltaLon = ((res & 1) ? ~(res >> 1) : (res >> 1));
67 longitude += deltaLon;
69 pt.
x = longitude/scale;
70 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_FALSE, 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.