PostGIS  2.5.7dev-r@@SVN_REVISION@@
lwgeom_export.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright 2009-2011 Olivier Courtin <olivier.courtin@oslandia.com>
22  *
23  **********************************************************************/
24 
25 
26 
31 #include "float.h" /* for DBL_DIG */
32 
33 #include "postgres.h"
34 #include "catalog/pg_type.h" /* for CSTRINGOID */
35 #include "executor/spi.h"
36 #include "utils/builtins.h"
37 
38 #include "../postgis_config.h"
39 #include "lwgeom_pg.h"
40 #include "liblwgeom.h"
41 #include "lwgeom_export.h"
42 
43 Datum LWGEOM_asGML(PG_FUNCTION_ARGS);
44 Datum LWGEOM_asKML(PG_FUNCTION_ARGS);
45 Datum LWGEOM_asGeoJson(PG_FUNCTION_ARGS);
46 Datum LWGEOM_asGeoJson_old(PG_FUNCTION_ARGS);
47 Datum LWGEOM_asSVG(PG_FUNCTION_ARGS);
48 Datum LWGEOM_asX3D(PG_FUNCTION_ARGS);
49 Datum LWGEOM_asEncodedPolyline(PG_FUNCTION_ARGS);
50 
51 /*
52  * Retrieve an SRS from a given SRID
53  * Require valid spatial_ref_sys table entry
54  *
55  * Could return SRS as short one (i.e EPSG:4326)
56  * or as long one: (i.e urn:ogc:def:crs:EPSG::4326)
57  */
58 
59 char *
60 getSRSbySRID(FunctionCallInfo fcinfo, int srid, bool short_crs)
61 {
62  static const uint16_t max_query_size = 512;
63  char query[512];
64  char *srs, *srscopy;
65  int size, err;
66  postgis_initialize_cache(fcinfo);
67 
68  if (SPI_OK_CONNECT != SPI_connect ())
69  {
70  elog(NOTICE, "getSRSbySRID: could not connect to SPI manager");
71  SPI_finish();
72  return NULL;
73  }
74 
75  if (short_crs)
76  snprintf(query,
77  max_query_size,
78  "SELECT auth_name||':'||auth_srid \
79  FROM %s WHERE srid='%d'",
80  postgis_spatial_ref_sys(),
81  srid);
82  else
83  snprintf(query,
84  max_query_size,
85  "SELECT 'urn:ogc:def:crs:'||auth_name||'::'||auth_srid \
86  FROM %s WHERE srid='%d'",
87  postgis_spatial_ref_sys(),
88  srid);
89 
90  err = SPI_exec(query, 1);
91  if ( err < 0 )
92  {
93  elog(NOTICE, "getSRSbySRID: error executing query %d", err);
94  SPI_finish();
95  return NULL;
96  }
97 
98  /* no entry in spatial_ref_sys */
99  if (SPI_processed <= 0)
100  {
101  SPI_finish();
102  return NULL;
103  }
104 
105  /* get result */
106  srs = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
107 
108  /* NULL result */
109  if ( ! srs )
110  {
111  SPI_finish();
112  return NULL;
113  }
114 
115  /* copy result to upper executor context */
116  size = strlen(srs)+1;
117  srscopy = SPI_palloc(size);
118  memcpy(srscopy, srs, size);
119 
120  /* disconnect from SPI */
121  SPI_finish();
122 
123  return srscopy;
124 }
125 
126 
127 /*
128 * Retrieve an SRID from a given SRS
129 * Require valid spatial_ref_sys table entry
130 *
131 */
132 int
133 getSRIDbySRS(FunctionCallInfo fcinfo, const char *srs)
134 {
135  static const int16_t max_query_size = 512;
136  char query[512];
137  Oid argtypes[] = {CSTRINGOID};
138  Datum values[] = {CStringGetDatum(srs)};
139  int32_t srid, err;
140 
141  postgis_initialize_cache(fcinfo);
142  snprintf(query,
143  max_query_size,
144  "SELECT srid "
145  "FROM %s, "
146  "regexp_matches($1::text, E'([a-z]+):([0-9]+)', 'gi') AS re "
147  "WHERE re[1] ILIKE auth_name AND int4(re[2]) = auth_srid",
148  postgis_spatial_ref_sys());
149 
150  if (!srs) return 0;
151 
152  if (SPI_OK_CONNECT != SPI_connect())
153  {
154  elog(NOTICE, "getSRIDbySRS: could not connect to SPI manager");
155  return 0;
156  }
157 
158  err = SPI_execute_with_args(query, 1, argtypes, values, NULL, true, 1);
159  if (err < 0)
160  {
161  elog(NOTICE, "getSRIDbySRS: error executing query %d", err);
162  SPI_finish();
163  return 0;
164  }
165 
166  /* no entry in spatial_ref_sys */
167  if (SPI_processed <= 0)
168  {
169  snprintf(query,
170  max_query_size,
171  "SELECT srid "
172  "FROM %s, "
173  "regexp_matches($1::text, E'urn:ogc:def:crs:([a-z]+):.*:([0-9]+)', 'gi') AS re "
174  "WHERE re[1] ILIKE auth_name AND int4(re[2]) = auth_srid",
175  postgis_spatial_ref_sys());
176 
177  err = SPI_execute_with_args(query, 1, argtypes, values, NULL, true, 1);
178  if (err < 0)
179  {
180  elog(NOTICE, "getSRIDbySRS: error executing query %d", err);
181  SPI_finish();
182  return 0;
183  }
184 
185  if (SPI_processed <= 0)
186  {
187  SPI_finish();
188  return 0;
189  }
190  }
191 
192  srid = atoi(SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1));
193  SPI_finish();
194 
195  return srid;
196 }
197 
198 
203 Datum LWGEOM_asGML(PG_FUNCTION_ARGS)
204 {
205  GSERIALIZED *geom;
206  LWGEOM *lwgeom;
207  char *gml = NULL;
208  text *result;
209  int version;
210  char *srs;
211  int srid;
212  int option = 0;
213  int lwopts = LW_GML_IS_DIMS;
214  int precision = DBL_DIG;
215  static const char* default_prefix = "gml:"; /* default prefix */
216  const char* prefix = default_prefix;
217  const char* gml_id = NULL;
218  size_t len;
219  char *gml_id_buf, *prefix_buf;
220  text *prefix_text, *gml_id_text;
221 
222 
223  /* Get the version */
224  version = PG_GETARG_INT32(0);
225  if ( version != 2 && version != 3 )
226  {
227  elog(ERROR, "Only GML 2 and GML 3 are supported");
228  PG_RETURN_NULL();
229  }
230 
231  /* Get the geometry */
232  if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
233  geom = PG_GETARG_GSERIALIZED_P(1);
234 
235  /* Retrieve precision if any (default is max) */
236  if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
237  {
238  precision = PG_GETARG_INT32(2);
239  /* TODO: leave this to liblwgeom ? */
240  if (precision > DBL_DIG)
241  precision = DBL_DIG;
242  else if (precision < 0)
243  precision = 0;
244  }
245 
246  /* retrieve option */
247  if (PG_NARGS() > 3 && !PG_ARGISNULL(3)) option = PG_GETARG_INT32(3);
248 
249  /* retrieve prefix */
250  if (PG_NARGS() >4 && !PG_ARGISNULL(4))
251  {
252  prefix_text = PG_GETARG_TEXT_P(4);
253  if ( VARSIZE(prefix_text) == VARHDRSZ )
254  {
255  prefix = "";
256  }
257  else
258  {
259  len = VARSIZE(prefix_text)-VARHDRSZ;
260  prefix_buf = palloc(len + 2); /* +2 is one for the ':' and one for term null */
261  memcpy(prefix_buf, VARDATA(prefix_text), len);
262  /* add colon and null terminate */
263  prefix_buf[len] = ':';
264  prefix_buf[len+1] = '\0';
265  prefix = prefix_buf;
266  }
267  }
268 
269  if (PG_NARGS() >5 && !PG_ARGISNULL(5))
270  {
271  gml_id_text = PG_GETARG_TEXT_P(5);
272  if ( VARSIZE(gml_id_text) == VARHDRSZ )
273  {
274  gml_id = "";
275  }
276  else
277  {
278  len = VARSIZE(gml_id_text)-VARHDRSZ;
279  gml_id_buf = palloc(len+1);
280  memcpy(gml_id_buf, VARDATA(gml_id_text), len);
281  gml_id_buf[len] = '\0';
282  gml_id = gml_id_buf;
283  }
284  }
285 
286  srid = gserialized_get_srid(geom);
287  if (srid == SRID_UNKNOWN) srs = NULL;
288  else if (option & 1)
289  srs = getSRSbySRID(fcinfo, srid, false);
290  else
291  srs = getSRSbySRID(fcinfo, srid, true);
292 
293  if (option & 2) lwopts &= ~LW_GML_IS_DIMS;
294  if (option & 4) lwopts |= LW_GML_SHORTLINE;
295  if (option & 8)
296  {
297  elog(ERROR,
298  "Options %d passed to ST_AsGML(geography) sets "
299  "unsupported value 8",
300  option);
301  PG_RETURN_NULL();
302  }
303  if (option & 16) lwopts |= LW_GML_IS_DEGREE;
304  if (option & 32) lwopts |= LW_GML_EXTENT;
305 
306  lwgeom = lwgeom_from_gserialized(geom);
307 
308  if (version == 2)
309  {
310  if (lwopts & LW_GML_EXTENT)
311  gml = lwgeom_extent_to_gml2(
312  lwgeom, srs, precision, prefix);
313  else
314  gml = lwgeom_to_gml2(lwgeom, srs, precision, prefix);
315  }
316  if (version == 3)
317  {
318  if (lwopts & LW_GML_EXTENT)
319  gml = lwgeom_extent_to_gml3(
320  lwgeom, srs, precision, lwopts, prefix);
321  else
322  gml = lwgeom_to_gml3(
323  lwgeom, srs, precision, lwopts, prefix, gml_id);
324  }
325 
326  lwgeom_free(lwgeom);
327  PG_FREE_IF_COPY(geom, 1);
328 
329  /* Return null on null */
330  if ( ! gml )
331  PG_RETURN_NULL();
332 
333  result = cstring_to_text(gml);
334  lwfree(gml);
335  PG_RETURN_TEXT_P(result);
336 }
337 
338 
343 Datum LWGEOM_asKML(PG_FUNCTION_ARGS)
344 {
345  GSERIALIZED *geom;
346  LWGEOM *lwgeom;
347  char *kml;
348  text *result;
349  int version;
350  int precision = DBL_DIG;
351  static const char* default_prefix = ""; /* default prefix */
352  char *prefixbuf;
353  const char* prefix = default_prefix;
354  text *prefix_text;
355 
356 
357  /* Get the version */
358  version = PG_GETARG_INT32(0);
359  if ( version != 2)
360  {
361  elog(ERROR, "Only KML 2 is supported");
362  PG_RETURN_NULL();
363  }
364 
365  /* Get the geometry */
366  if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
367  geom = PG_GETARG_GSERIALIZED_P(1);
368 
369  /* Retrieve precision if any (default is max) */
370  if (PG_NARGS() >2 && !PG_ARGISNULL(2))
371  {
372  /* TODO: leave this to liblwgeom ? */
373  precision = PG_GETARG_INT32(2);
374  if ( precision > DBL_DIG )
375  precision = DBL_DIG;
376  else if ( precision < 0 ) precision = 0;
377  }
378 
379  /* retrieve prefix */
380  if (PG_NARGS() >3 && !PG_ARGISNULL(3))
381  {
382  prefix_text = PG_GETARG_TEXT_P(3);
383  if ( VARSIZE(prefix_text)-VARHDRSZ == 0 )
384  {
385  prefix = "";
386  }
387  else
388  {
389  /* +2 is one for the ':' and one for term null */
390  prefixbuf = palloc(VARSIZE(prefix_text)-VARHDRSZ+2);
391  memcpy(prefixbuf, VARDATA(prefix_text),
392  VARSIZE(prefix_text)-VARHDRSZ);
393  /* add colon and null terminate */
394  prefixbuf[VARSIZE(prefix_text)-VARHDRSZ] = ':';
395  prefixbuf[VARSIZE(prefix_text)-VARHDRSZ+1] = '\0';
396  prefix = prefixbuf;
397  }
398  }
399 
400  lwgeom = lwgeom_from_gserialized(geom);
401  kml = lwgeom_to_kml2(lwgeom, precision, prefix);
402  lwgeom_free(lwgeom);
403  PG_FREE_IF_COPY(geom, 1);
404 
405  if( ! kml )
406  PG_RETURN_NULL();
407 
408  result = cstring_to_text(kml);
409  lwfree(kml);
410 
411  PG_RETURN_POINTER(result);
412 }
413 
414 
422 Datum LWGEOM_asGeoJson_old(PG_FUNCTION_ARGS)
423 {
424  switch( PG_NARGS() )
425  {
426  case 2:
427  return DirectFunctionCall1(LWGEOM_asGeoJson, PG_GETARG_DATUM(1));
428  case 3:
429  return DirectFunctionCall2(LWGEOM_asGeoJson, PG_GETARG_DATUM(1), PG_GETARG_DATUM(2));
430  case 4:
431  return DirectFunctionCall3(LWGEOM_asGeoJson, PG_GETARG_DATUM(1), PG_GETARG_DATUM(2), PG_GETARG_DATUM(3));
432  default:
433  elog(ERROR, "bad call in %s", __func__);
434  }
435  PG_RETURN_NULL();
436 }
437 
442 Datum LWGEOM_asGeoJson(PG_FUNCTION_ARGS)
443 {
444  GSERIALIZED *geom;
445  LWGEOM *lwgeom;
446  char *geojson;
447  text *result;
448  int has_bbox = 0;
449  int precision = DBL_DIG;
450  char *srs = NULL;
451 
452  /* Get the geometry */
453  if ( PG_ARGISNULL(0) )
454  PG_RETURN_NULL();
455 
456  geom = PG_GETARG_GSERIALIZED_P(0);
457 
458  /* Retrieve precision if any (default is max) */
459  if ( PG_NARGS() > 1 && !PG_ARGISNULL(1) )
460  {
461  precision = PG_GETARG_INT32(1);
462  if ( precision > DBL_DIG )
463  precision = DBL_DIG;
464  else if ( precision < 0 )
465  precision = 0;
466  }
467 
468  /* Retrieve output option
469  * 0 = without option (default)
470  * 1 = bbox
471  * 2 = short crs
472  * 4 = long crs
473  */
474  if ( PG_NARGS() > 2 && !PG_ARGISNULL(2) )
475  {
476  int option = PG_GETARG_INT32(2);
477 
478  if ( option & 2 || option & 4 )
479  {
480  int srid = gserialized_get_srid(geom);
481  if ( srid != SRID_UNKNOWN )
482  {
483  if ( option & 2 )
484  srs = getSRSbySRID(fcinfo, srid, true);
485 
486  if ( option & 4 )
487  srs = getSRSbySRID(fcinfo, srid, false);
488 
489  if ( !srs )
490  {
491  elog(ERROR,
492  "SRID %i unknown in spatial_ref_sys table",
493  srid);
494  PG_RETURN_NULL();
495  }
496  }
497  }
498 
499  if (option & 1)
500  has_bbox = 1;
501  }
502 
503  lwgeom = lwgeom_from_gserialized(geom);
504  geojson = lwgeom_to_geojson(lwgeom, srs, precision, has_bbox);
505  lwgeom_free(lwgeom);
506 
507  if (srs) pfree(srs);
508 
509  result = cstring_to_text(geojson);
510  lwfree(geojson);
511 
512  PG_FREE_IF_COPY(geom, 0);
513  PG_RETURN_TEXT_P(result);
514 }
515 
516 
521 Datum LWGEOM_asSVG(PG_FUNCTION_ARGS)
522 {
523  GSERIALIZED *geom;
524  LWGEOM *lwgeom;
525  char *svg;
526  text *result;
527  int relative = 0;
528  int precision=DBL_DIG;
529 
530  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
531 
532  geom = PG_GETARG_GSERIALIZED_P(0);
533 
534  /* check for relative path notation */
535  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
536  relative = PG_GETARG_INT32(1) ? 1:0;
537 
538  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
539  {
540  precision = PG_GETARG_INT32(2);
541  /* TODO: leave this to liblwgeom ? */
542  if ( precision > DBL_DIG )
543  precision = DBL_DIG;
544  else if ( precision < 0 ) precision = 0;
545  }
546 
547  lwgeom = lwgeom_from_gserialized(geom);
548  svg = lwgeom_to_svg(lwgeom, precision, relative);
549  result = cstring_to_text(svg);
550  lwgeom_free(lwgeom);
551  pfree(svg);
552  PG_FREE_IF_COPY(geom, 0);
553 
554  PG_RETURN_TEXT_P(result);
555 }
556 
561 Datum LWGEOM_asX3D(PG_FUNCTION_ARGS)
562 {
563  GSERIALIZED *geom;
564  LWGEOM *lwgeom;
565  char *x3d;
566  text *result;
567  int version;
568  char *srs;
569  int srid;
570  int option = 0;
571  int precision = DBL_DIG;
572  static const char* default_defid = "x3d:"; /* default defid */
573  char *defidbuf;
574  const char* defid = default_defid;
575  text *defid_text;
576 
577  /* Get the version */
578  version = PG_GETARG_INT32(0);
579  if ( version != 3 )
580  {
581  elog(ERROR, "Only X3D version 3 are supported");
582  PG_RETURN_NULL();
583  }
584 
585  /* Get the geometry */
586  if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
587  geom = PG_GETARG_GSERIALIZED_P(1);
588 
589  /* Retrieve precision if any (default is max) */
590  if (PG_NARGS() >2 && !PG_ARGISNULL(2))
591  {
592  precision = PG_GETARG_INT32(2);
593  /* TODO: leave this to liblwgeom ? */
594  if ( precision > DBL_DIG )
595  precision = DBL_DIG;
596  else if ( precision < 0 ) precision = 0;
597  }
598 
599  /* retrieve option */
600  if (PG_NARGS() >3 && !PG_ARGISNULL(3))
601  option = PG_GETARG_INT32(3);
602 
603 
604 
605  /* retrieve defid */
606  if (PG_NARGS() >4 && !PG_ARGISNULL(4))
607  {
608  defid_text = PG_GETARG_TEXT_P(4);
609  if ( VARSIZE(defid_text)-VARHDRSZ == 0 )
610  {
611  defid = "";
612  }
613  else
614  {
615  /* +2 is one for the ':' and one for term null */
616  defidbuf = palloc(VARSIZE(defid_text)-VARHDRSZ+2);
617  memcpy(defidbuf, VARDATA(defid_text),
618  VARSIZE(defid_text)-VARHDRSZ);
619  /* add colon and null terminate */
620  defidbuf[VARSIZE(defid_text)-VARHDRSZ] = ':';
621  defidbuf[VARSIZE(defid_text)-VARHDRSZ+1] = '\0';
622  defid = defidbuf;
623  }
624  }
625 
626  lwgeom = lwgeom_from_gserialized(geom);
627  srid = gserialized_get_srid(geom);
628  if (srid == SRID_UNKNOWN) srs = NULL;
629  else if (option & 1)
630  srs = getSRSbySRID(fcinfo, srid, false);
631  else
632  srs = getSRSbySRID(fcinfo, srid, true);
633 
634  if (option & LW_X3D_USE_GEOCOORDS) {
635  if (srid != 4326) {
636  PG_FREE_IF_COPY(geom, 0);
639  elog(ERROR, "Only SRID 4326 is supported for geocoordinates.");
640  PG_RETURN_NULL();
641  }
642  }
643 
644 
645  x3d = lwgeom_to_x3d3(lwgeom, srs, precision,option, defid);
646 
647  lwgeom_free(lwgeom);
648  PG_FREE_IF_COPY(geom, 1);
649 
650  result = cstring_to_text(x3d);
651  lwfree(x3d);
652 
653  PG_RETURN_TEXT_P(result);
654 }
655 
660 Datum LWGEOM_asEncodedPolyline(PG_FUNCTION_ARGS)
661 {
662  GSERIALIZED *geom;
663  LWGEOM *lwgeom;
664  char *encodedpolyline;
665  int precision = 5;
666  text *result;
667 
668  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
669 
670  geom = PG_GETARG_GSERIALIZED_P(0);
671  if (gserialized_get_srid(geom) != 4326) {
672  PG_FREE_IF_COPY(geom, 0);
673  elog(ERROR, "Only SRID 4326 is supported.");
674  PG_RETURN_NULL();
675  }
676  lwgeom = lwgeom_from_gserialized(geom);
677 
678  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
679  {
680  precision = PG_GETARG_INT32(1);
681  if ( precision < 0 ) precision = 5;
682  }
683 
684  encodedpolyline = lwgeom_to_encoded_polyline(lwgeom, precision);
685  lwgeom_free(lwgeom);
686  PG_FREE_IF_COPY(geom, 0);
687 
688  result = cstring_to_text(encodedpolyline);
689  lwfree(encodedpolyline);
690 
691  PG_RETURN_TEXT_P(result);
692 }
static uint8_t precision
Definition: cu_in_twkb.c:25
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:100
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
char * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
Definition: lwout_svg.c:56
#define LW_GML_IS_DEGREE
For GML3 only, declare that datas are lat/lon.
Definition: liblwgeom.h:1544
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_GML_SHORTLINE
For GML3, use <LineString> rather than <Curve> for lines.
Definition: liblwgeom.h:1546
char * lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:36
char * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
Definition: lwout_kml.c:43
#define LW_GML_EXTENT
For GML2 and GML3, output only extent of geometry.
Definition: liblwgeom.h:1548
char * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
Definition: lwout_gml.c:717
char * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
Definition: lwout_gml.c:213
void lwfree(void *mem)
Definition: lwutil.c:244
#define LW_GML_IS_DIMS
Macros for specifying GML options.
Definition: liblwgeom.h:1542
char * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:198
char * lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
VERSION GML 2 takes a GEOMETRY and returns a GML2 representation.
Definition: lwout_gml.c:231
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
char * lwgeom_to_geojson(const LWGEOM *geo, char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
Definition: lwout_geojson.c:48
#define LW_X3D_USE_GEOCOORDS
Definition: liblwgeom.h:1561
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
This library is the generic geometry handling section of PostGIS.
PG_FUNCTION_INFO_V1(LWGEOM_asGML)
Encode feature in GML.
int getSRIDbySRS(FunctionCallInfo fcinfo, const char *srs)
Datum LWGEOM_asGeoJson_old(PG_FUNCTION_ARGS)
Datum LWGEOM_asEncodedPolyline(PG_FUNCTION_ARGS)
Datum LWGEOM_asGML(PG_FUNCTION_ARGS)
Datum LWGEOM_asSVG(PG_FUNCTION_ARGS)
Datum LWGEOM_asGeoJson(PG_FUNCTION_ARGS)
char * getSRSbySRID(FunctionCallInfo fcinfo, int srid, bool short_crs)
Definition: lwgeom_export.c:60
Datum LWGEOM_asKML(PG_FUNCTION_ARGS)
Datum LWGEOM_asX3D(PG_FUNCTION_ARGS)