PostGIS  2.3.7dev-r@@SVN_REVISION@@
cu_in_encoded_polyline.c
Go to the documentation of this file.
1 /**********************************************************************
2 *
3 * PostGIS - Spatial Types for PostgreSQL
4 * http://postgis.net
5 *
6 * Copyright 2014 Kashif Rasul <kashif.rasul@gmail.com> and
7 * Shoaib Burq <saburq@gmail.com>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU General Public Licence. See the COPYING file.
11 *
12 **********************************************************************/
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include "CUnit/Basic.h"
18 
19 #include "liblwgeom_internal.h"
20 #include "cu_tester.h"
21 
22 static void do_encoded_polyline_test(char * in, int precision, char * out)
23 {
24  LWGEOM *g;
25  char * h;
26  size_t size;
27 
28  g = lwgeom_from_encoded_polyline(in, precision);
29  h = lwgeom_to_wkt(g, WKT_EXTENDED, 15, &size);
30 
31  if (strcmp(h, out))
32  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
33 
34  CU_ASSERT_STRING_EQUAL(h, out);
35 
36  lwgeom_free(g);
37  if ( h ) lwfree(h);
38 }
39 
41 {
43  "_p~iF~ps|U_ulLnnqC_mqNvxq`@",
44  5,
45  "SRID=4326;LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)");
46 }
47 
49 {
51  "o}~~|AdshNoSsBgd@eGoBlm@wKhj@~@?",
52  6,
53  "SRID=4326;LINESTRING(-0.250691 49.283048,-0.250633 49.283376,-0.250502 49.283972,-0.251245 49.284028,-0.251938 49.284232,-0.251938 49.2842)");
54 }
55 
56 /*
57 ** Used by test harness to register the tests in this file.
58 */
61 {
62  CU_pSuite suite = CU_add_suite("encoded_polyline_input", NULL, NULL);
65 }
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:669
static void in_encoded_polyline_test_geoms(void)
void lwfree(void *mem)
Definition: lwutil.c:242
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
void in_encoded_polyline_suite_setup(void)
static void do_encoded_polyline_test(char *in, int precision, char *out)
static void in_encoded_polyline_test_precision(void)
#define PG_ADD_TEST(suite, testfunc)
uint8_t precision
Definition: cu_in_twkb.c:25
#define WKT_EXTENDED
Definition: liblwgeom.h:2057