PostGIS  2.2.8dev-r@@SVN_REVISION@@
lwline.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * Copyright (C) 2012 Sandro Santilli <strk@keybit.net>
7  * Copyright (C) 2001-2006 Refractions Research Inc.
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 /* basic LWLINE functions */
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include "liblwgeom_internal.h"
20 #include "lwgeom_log.h"
21 
22 
23 
24 /*
25  * Construct a new LWLINE. points will *NOT* be copied
26  * use SRID=SRID_UNKNOWN for unknown SRID (will have 8bit type's S = 0)
27  */
28 LWLINE *
29 lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
30 {
31  LWLINE *result;
32  result = (LWLINE*) lwalloc(sizeof(LWLINE));
33 
34  LWDEBUG(2, "lwline_construct called.");
35 
36  result->type = LINETYPE;
37 
38  result->flags = points->flags;
39  FLAGS_SET_BBOX(result->flags, bbox?1:0);
40 
41  LWDEBUGF(3, "lwline_construct type=%d", result->type);
42 
43  result->srid = srid;
44  result->points = points;
45  result->bbox = bbox;
46 
47  return result;
48 }
49 
50 LWLINE *
51 lwline_construct_empty(int srid, char hasz, char hasm)
52 {
53  LWLINE *result = lwalloc(sizeof(LWLINE));
54  result->type = LINETYPE;
55  result->flags = gflags(hasz,hasm,0);
56  result->srid = srid;
57  result->points = ptarray_construct_empty(hasz, hasm, 1);
58  result->bbox = NULL;
59  return result;
60 }
61 
62 
63 void lwline_free (LWLINE *line)
64 {
65  if ( ! line ) return;
66 
67  if ( line->bbox )
68  lwfree(line->bbox);
69  if ( line->points )
70  ptarray_free(line->points);
71  lwfree(line);
72 }
73 
74 
75 void printLWLINE(LWLINE *line)
76 {
77  lwnotice("LWLINE {");
78  lwnotice(" ndims = %i", (int)FLAGS_NDIMS(line->flags));
79  lwnotice(" srid = %i", (int)line->srid);
80  printPA(line->points);
81  lwnotice("}");
82 }
83 
84 /* @brief Clone LWLINE object. Serialized point lists are not copied.
85  *
86  * @see ptarray_clone
87  */
88 LWLINE *
90 {
91  LWLINE *ret = lwalloc(sizeof(LWLINE));
92 
93  LWDEBUGF(2, "lwline_clone called with %p", g);
94 
95  memcpy(ret, g, sizeof(LWLINE));
96 
97  ret->points = ptarray_clone(g->points);
98 
99  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
100  return ret;
101 }
102 
103 /* Deep clone LWLINE object. POINTARRAY *is* copied. */
104 LWLINE *
106 {
107  LWLINE *ret = lwalloc(sizeof(LWLINE));
108 
109  LWDEBUGF(2, "lwline_clone_deep called with %p", g);
110  memcpy(ret, g, sizeof(LWLINE));
111 
112  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
113  if ( g->points ) ret->points = ptarray_clone_deep(g->points);
114  FLAGS_SET_READONLY(ret->flags,0);
115 
116  return ret;
117 }
118 
119 
120 void
122 {
124 }
125 
126 void
128 {
129  if ( lwline_is_empty(line) ) return;
130  ptarray_reverse(line->points);
131 }
132 
133 LWLINE *
134 lwline_segmentize2d(LWLINE *line, double dist)
135 {
136  POINTARRAY *segmentized = ptarray_segmentize2d(line->points, dist);
137  if ( ! segmentized ) return NULL;
138  return lwline_construct(line->srid, NULL, segmentized);
139 }
140 
141 /* check coordinate equality */
142 char
143 lwline_same(const LWLINE *l1, const LWLINE *l2)
144 {
145  return ptarray_same(l1->points, l2->points);
146 }
147 
148 /*
149  * Construct a LWLINE from an array of point and line geometries
150  * LWLINE dimensions are large enough to host all input dimensions.
151  */
152 LWLINE *
153 lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
154 {
155  int i;
156  int hasz = LW_FALSE;
157  int hasm = LW_FALSE;
158  POINTARRAY *pa;
159  LWLINE *line;
160  POINT4D pt;
161 
162  /*
163  * Find output dimensions, check integrity
164  */
165  for (i=0; i<ngeoms; i++)
166  {
167  if ( FLAGS_GET_Z(geoms[i]->flags) ) hasz = LW_TRUE;
168  if ( FLAGS_GET_M(geoms[i]->flags) ) hasm = LW_TRUE;
169  if ( hasz && hasm ) break; /* Nothing more to learn! */
170  }
171 
172  /* ngeoms should be a guess about how many points we have in input */
173  pa = ptarray_construct_empty(hasz, hasm, ngeoms);
174 
175  for ( i=0; i < ngeoms; i++ )
176  {
177  LWGEOM *g = geoms[i];
178 
179  if ( lwgeom_is_empty(g) ) continue;
180 
181  if ( g->type == POINTTYPE )
182  {
183  lwpoint_getPoint4d_p((LWPOINT*)g, &pt);
184  ptarray_append_point(pa, &pt, LW_TRUE);
185  }
186  else if ( g->type == LINETYPE )
187  {
188  ptarray_append_ptarray(pa, ((LWLINE*)g)->points, -1);
189  }
190  else
191  {
192  ptarray_free(pa);
193  lwerror("lwline_from_ptarray: invalid input type: %s", lwtype_name(g->type));
194  return NULL;
195  }
196  }
197 
198  if ( pa->npoints > 0 )
199  line = lwline_construct(srid, NULL, pa);
200  else {
201  /* Is this really any different from the above ? */
202  ptarray_free(pa);
203  line = lwline_construct_empty(srid, hasz, hasm);
204  }
205 
206  return line;
207 }
208 
209 /*
210  * Construct a LWLINE from an array of LWPOINTs
211  * LWLINE dimensions are large enough to host all input dimensions.
212  */
213 LWLINE *
214 lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
215 {
216  int i;
217  int hasz = LW_FALSE;
218  int hasm = LW_FALSE;
219  POINTARRAY *pa;
220  LWLINE *line;
221  POINT4D pt;
222 
223  /*
224  * Find output dimensions, check integrity
225  */
226  for (i=0; i<npoints; i++)
227  {
228  if ( points[i]->type != POINTTYPE )
229  {
230  lwerror("lwline_from_ptarray: invalid input type: %s", lwtype_name(points[i]->type));
231  return NULL;
232  }
233  if ( FLAGS_GET_Z(points[i]->flags) ) hasz = LW_TRUE;
234  if ( FLAGS_GET_M(points[i]->flags) ) hasm = LW_TRUE;
235  if ( hasz && hasm ) break; /* Nothing more to learn! */
236  }
237 
238  pa = ptarray_construct_empty(hasz, hasm, npoints);
239 
240  for ( i=0; i < npoints; i++ )
241  {
242  if ( ! lwpoint_is_empty(points[i]) )
243  {
244  lwpoint_getPoint4d_p(points[i], &pt);
245  ptarray_append_point(pa, &pt, LW_TRUE);
246  }
247  }
248 
249  if ( pa->npoints > 0 )
250  line = lwline_construct(srid, NULL, pa);
251  else
252  line = lwline_construct_empty(srid, hasz, hasm);
253 
254  return line;
255 }
256 
257 /*
258  * Construct a LWLINE from a LWMPOINT
259  */
260 LWLINE *
261 lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
262 {
263  uint32_t i;
264  POINTARRAY *pa = NULL;
265  LWGEOM *lwgeom = (LWGEOM*)mpoint;
266  POINT4D pt;
267 
268  char hasz = lwgeom_has_z(lwgeom);
269  char hasm = lwgeom_has_m(lwgeom);
270  uint32_t npoints = mpoint->ngeoms;
271 
272  if ( lwgeom_is_empty(lwgeom) )
273  {
274  return lwline_construct_empty(srid, hasz, hasm);
275  }
276 
277  pa = ptarray_construct(hasz, hasm, npoints);
278 
279  for (i=0; i < npoints; i++)
280  {
281  getPoint4d_p(mpoint->geoms[i]->point, 0, &pt);
282  ptarray_set_point4d(pa, i, &pt);
283  }
284 
285  LWDEBUGF(3, "lwline_from_lwmpoint: constructed pointarray for %d points", mpoint->ngeoms);
286 
287  return lwline_construct(srid, NULL, pa);
288 }
289 
294 LWPOINT*
295 lwline_get_lwpoint(const LWLINE *line, int where)
296 {
297  POINT4D pt;
298  LWPOINT *lwpoint;
299  POINTARRAY *pa;
300 
301  if ( lwline_is_empty(line) || where < 0 || where >= line->points->npoints )
302  return NULL;
303 
305  pt = getPoint4d(line->points, where);
306  ptarray_append_point(pa, &pt, LW_TRUE);
307  lwpoint = lwpoint_construct(line->srid, NULL, pa);
308  return lwpoint;
309 }
310 
311 
312 int
313 lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
314 {
315  POINT4D pt;
316  getPoint4d_p(point->point, 0, &pt);
317 
318  if ( ptarray_insert_point(line->points, &pt, where) != LW_SUCCESS )
319  return LW_FAILURE;
320 
321  /* Update the bounding box */
322  if ( line->bbox )
323  {
326  }
327 
328  return LW_SUCCESS;
329 }
330 
331 
332 
333 LWLINE *
334 lwline_removepoint(LWLINE *line, uint32_t index)
335 {
336  POINTARRAY *newpa;
337  LWLINE *ret;
338 
339  newpa = ptarray_removePoint(line->points, index);
340 
341  ret = lwline_construct(line->srid, NULL, newpa);
342  lwgeom_add_bbox((LWGEOM *) ret);
343 
344  return ret;
345 }
346 
347 /*
348  * Note: input will be changed, make sure you have permissions for this.
349  */
350 void
351 lwline_setPoint4d(LWLINE *line, uint32_t index, POINT4D *newpoint)
352 {
353  ptarray_set_point4d(line->points, index, newpoint);
354  /* Update the box, if there is one to update */
355  if ( line->bbox )
356  {
357  lwgeom_drop_bbox((LWGEOM*)line);
358  lwgeom_add_bbox((LWGEOM*)line);
359  }
360 }
361 
366 LWLINE*
367 lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end)
368 {
369  int i = 0;
370  int hasm = 0, hasz = 0;
371  int npoints = 0;
372  double length = 0.0;
373  double length_so_far = 0.0;
374  double m_range = m_end - m_start;
375  double m;
376  POINTARRAY *pa = NULL;
377  POINT3DZ p1, p2;
378 
379  if ( lwline->type != LINETYPE )
380  {
381  lwerror("lwline_construct_from_lwline: only line types supported");
382  return NULL;
383  }
384 
385  hasz = FLAGS_GET_Z(lwline->flags);
386  hasm = 1;
387 
388  /* Null points or npoints == 0 will result in empty return geometry */
389  if ( lwline->points )
390  {
391  npoints = lwline->points->npoints;
392  length = ptarray_length_2d(lwline->points);
393  getPoint3dz_p(lwline->points, 0, &p1);
394  }
395 
396  pa = ptarray_construct(hasz, hasm, npoints);
397 
398  for ( i = 0; i < npoints; i++ )
399  {
400  POINT4D q;
401  POINT2D a, b;
402  getPoint3dz_p(lwline->points, i, &p2);
403  a.x = p1.x;
404  a.y = p1.y;
405  b.x = p2.x;
406  b.y = p2.y;
407  length_so_far += distance2d_pt_pt(&a, &b);
408  if ( length > 0.0 )
409  m = m_start + m_range * length_so_far / length;
410  /* #3172, support (valid) zero-length inputs */
411  else if ( length == 0.0 && npoints > 1 )
412  m = m_start + m_range * i / (npoints-1);
413  else
414  m = 0.0;
415  q.x = p2.x;
416  q.y = p2.y;
417  q.z = p2.z;
418  q.m = m;
419  ptarray_set_point4d(pa, i, &q);
420  p1 = p2;
421  }
422 
423  return lwline_construct(lwline->srid, NULL, pa);
424 }
425 
426 LWGEOM*
427 lwline_remove_repeated_points(LWLINE *lwline, double tolerance)
428 {
429  POINTARRAY* npts = ptarray_remove_repeated_points_minpoints(lwline->points, tolerance, 2);
430 
431  LWDEBUGF(3, "%s: npts %p", __func__, npts);
432 
433  return (LWGEOM*)lwline_construct(lwline->srid,
434  lwline->bbox ? gbox_copy(lwline->bbox) : 0,
435  npts);
436 }
437 
438 int
440 {
441  if (FLAGS_GET_Z(line->flags))
442  return ptarray_is_closed_3d(line->points);
443 
444  return ptarray_is_closed_2d(line->points);
445 }
446 
447 int
449 {
450  POINT3DM p;
451  int i, n;
452  double m = -1 * FLT_MAX;
453 
454  if ( ! FLAGS_GET_M(line->flags) ) {
455  lwnotice("Line does not have M dimension");
456  return LW_FALSE;
457  }
458 
459  n = line->points->npoints;
460  if ( n < 2 ) return LW_TRUE; /* empty or single-point are "good" */
461 
462  for (i=0; i<n; ++i) {
463  getPoint3dm_p(line->points, i, &p);
464  if ( p.m <= m ) {
465  lwnotice("Measure of vertex %d (%g) not bigger than measure of vertex %d (%g)",
466  i, p.m, i-1, m);
467  return LW_FALSE;
468  }
469  m = p.m;
470  }
471 
472  return LW_TRUE;
473 }
474 
475 
476 LWLINE*
477 lwline_force_dims(const LWLINE *line, int hasz, int hasm)
478 {
479  POINTARRAY *pdims = NULL;
480  LWLINE *lineout;
481 
482  /* Return 2D empty */
483  if( lwline_is_empty(line) )
484  {
485  lineout = lwline_construct_empty(line->srid, hasz, hasm);
486  }
487  else
488  {
489  pdims = ptarray_force_dims(line->points, hasz, hasm);
490  lineout = lwline_construct(line->srid, NULL, pdims);
491  }
492  lineout->type = line->type;
493  return lineout;
494 }
495 
496 int lwline_is_empty(const LWLINE *line)
497 {
498  if ( !line->points || line->points->npoints < 1 )
499  return LW_TRUE;
500  return LW_FALSE;
501 }
502 
503 
505 {
506  assert(line);
507  if ( ! line->points )
508  return 0;
509  return line->points->npoints;
510 }
511 
512 LWLINE* lwline_simplify(const LWLINE *iline, double dist, int preserve_collapsed)
513 {
514  static const int minvertices = 2; /* TODO: allow setting this */
515  LWLINE *oline;
516  POINTARRAY *pa;
517 
518  LWDEBUG(2, "function called");
519 
520  /* Skip empty case */
521  if( lwline_is_empty(iline) )
522  return NULL;
523 
524  pa = ptarray_simplify(iline->points, dist, minvertices);
525  if ( ! pa ) return NULL;
526 
527  /* Make sure single-point collapses have two points */
528  if ( pa->npoints == 1 )
529  {
530  /* Make sure single-point collapses have two points */
531  if ( preserve_collapsed )
532  {
533  POINT4D pt;
534  getPoint4d_p(pa, 0, &pt);
535  ptarray_append_point(pa, &pt, LW_TRUE);
536  }
537  /* Return null for collapse */
538  else
539  {
540  ptarray_free(pa);
541  return NULL;
542  }
543  }
544 
545  oline = lwline_construct(iline->srid, NULL, pa);
546  oline->type = iline->type;
547  return oline;
548 }
549 
550 double lwline_length(const LWLINE *line)
551 {
552  if ( lwline_is_empty(line) )
553  return 0.0;
554  return ptarray_length(line->points);
555 }
556 
557 double lwline_length_2d(const LWLINE *line)
558 {
559  if ( lwline_is_empty(line) )
560  return 0.0;
561  return ptarray_length_2d(line->points);
562 }
563 
564 
565 
566 LWLINE* lwline_grid(const LWLINE *line, const gridspec *grid)
567 {
568  LWLINE *oline;
569  POINTARRAY *opa;
570 
571  opa = ptarray_grid(line->points, grid);
572 
573  /* Skip line3d with less then 2 points */
574  if ( opa->npoints < 2 ) return NULL;
575 
576  /* TODO: grid bounding box... */
577  oline = lwline_construct(line->srid, NULL, opa);
578 
579  return oline;
580 }
581 
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
Definition: lwgeom_api.c:536
int lwline_is_trajectory(const LWLINE *line)
Definition: lwline.c:448
double x
Definition: liblwgeom.h:336
#define LINETYPE
Definition: liblwgeom.h:71
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:403
uint8_t type
Definition: liblwgeom.h:402
double z
Definition: liblwgeom.h:318
double y
Definition: liblwgeom.h:318
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:62
double m
Definition: liblwgeom.h:336
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:153
GBOX * bbox
Definition: liblwgeom.h:404
POINTARRAY * ptarray_clone(const POINTARRAY *ptarray)
Clone a POINTARRAY object.
Definition: ptarray.c:658
double x
Definition: liblwgeom.h:318
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:61
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:439
void printLWLINE(LWLINE *line)
Definition: lwline.c:75
void lwfree(void *mem)
Definition: lwutil.c:214
int npoints
Definition: liblwgeom.h:355
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:707
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it&#39;s 3d)
Definition: ptarray.c:1645
#define LW_SUCCESS
Definition: liblwgeom.h:65
POINTARRAY * ptarray_segmentize2d(const POINTARRAY *ipa, double dist)
Returns a modified POINTARRAY so that no segment is longer than the given distance (computed using 2d...
Definition: ptarray.c:420
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:51
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
Definition: lwline.c:214
int lwline_is_empty(const LWLINE *line)
Definition: lwline.c:496
void lwline_setPoint4d(LWLINE *line, uint32_t index, POINT4D *newpoint)
Definition: lwline.c:351
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point)
Definition: lwgeom_api.c:369
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
Definition: measures.c:2302
POINTARRAY * ptarray_remove_repeated_points_minpoints(POINTARRAY *in, double tolerance, int minpoints)
Definition: ptarray.c:1437
int32_t srid
Definition: liblwgeom.h:405
LWLINE * lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end)
Re-write the measure ordinate (or add one, if it isn&#39;t already there) interpolating the measure betwe...
Definition: lwline.c:367
POINTARRAY * point
Definition: liblwgeom.h:395
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:694
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:836
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:586
#define LW_FAILURE
Definition: liblwgeom.h:64
double x
Definition: liblwgeom.h:312
void lwline_release(LWLINE *lwline)
Definition: lwline.c:121
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:216
double lwline_length(const LWLINE *line)
Definition: lwline.c:550
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:319
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
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.
Definition: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:62
double m
Definition: liblwgeom.h:330
uint8_t flags
Definition: liblwgeom.h:353
LWLINE * lwline_grid(const LWLINE *line, const gridspec *grid)
Definition: lwline.c:566
char lwline_same(const LWLINE *l1, const LWLINE *l2)
Definition: lwline.c:143
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
Definition: lwline.c:261
LWLINE * lwline_clone(const LWLINE *g)
Definition: lwline.c:89
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:295
void lwline_reverse(LWLINE *line)
Definition: lwline.c:127
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
Definition: ptarray.c:187
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:44
LWPOINT ** geoms
Definition: liblwgeom.h:454
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
POINTARRAY * ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm)
Definition: ptarray.c:1035
LWLINE * lwline_clone_deep(const LWLINE *g)
Definition: lwline.c:105
double y
Definition: liblwgeom.h:312
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:96
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
Add a LWPOINT to an LWLINE.
Definition: lwline.c:313
double z
Definition: liblwgeom.h:336
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:130
double ptarray_length(const POINTARRAY *pts)
Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality)
Definition: ptarray.c:1673
POINTARRAY * ptarray_simplify(POINTARRAY *inpts, double epsilon, unsigned int minpts)
Definition: ptarray.c:1554
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:132
LWLINE * lwline_removepoint(LWLINE *line, uint32_t index)
Definition: lwline.c:334
void printPA(POINTARRAY *pa)
Definition: lwgeom_api.c:598
char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
Definition: ptarray.c:484
int lwline_count_vertices(LWLINE *line)
Definition: lwline.c:504
POINTARRAY * ptarray_grid(const POINTARRAY *pa, const gridspec *grid)
Definition: ptarray.c:1843
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
int lwpoint_is_empty(const LWPOINT *point)
Definition: lwpoint.c:260
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:599
void ptarray_reverse(POINTARRAY *pa)
Definition: ptarray.c:343
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
LWLINE * lwline_segmentize2d(LWLINE *line, double dist)
Definition: lwline.c:134
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
Definition: lwgeom.c:372
LWLINE * lwline_force_dims(const LWLINE *line, int hasz, int hasm)
Definition: lwline.c:477
uint8_t type
Definition: liblwgeom.h:380
void lwline_free(LWLINE *line)
Definition: lwline.c:63
type
Definition: ovdump.py:41
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:557
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
Definition: ptarray.c:562
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:98
void * lwalloc(size_t size)
Definition: lwutil.c:199
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1297
double y
Definition: liblwgeom.h:336
int ngeoms
Definition: liblwgeom.h:452
uint8_t flags
Definition: liblwgeom.h:403
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
LWLINE * lwline_simplify(const LWLINE *iline, double dist, int preserve_collapsed)
Definition: lwline.c:512
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:843
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231
#define FLAGS_SET_READONLY(flags, value)
Definition: liblwgeom.h:134
LWGEOM * lwline_remove_repeated_points(LWLINE *lwline, double tolerance)
Definition: lwline.c:427
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
POINTARRAY * points
Definition: liblwgeom.h:406
Snap to grid.