PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches
lwmpoint.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 (C) 2001-2006 Refractions Research Inc.
22 *
23 **********************************************************************/
24
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include "liblwgeom_internal.h"
30#include "lwgeom_log.h"
31
32void
37
39lwmpoint_construct_empty(int32_t srid, char hasz, char hasm)
40{
42 return ret;
43}
44
46{
47 LWDEBUG(4, "Called");
49}
50
52lwmpoint_construct(int32_t srid, const POINTARRAY *pa)
53{
54 uint32_t i;
55 int hasz = ptarray_has_z(pa);
56 int hasm = ptarray_has_m(pa);
58
59 for ( i = 0; i < pa->npoints; i++ )
60 {
61 LWPOINT *lwp;
62 POINT4D p;
63 getPoint4d_p(pa, i, &p);
64 lwp = lwpoint_make(srid, hasz, hasm, &p);
65 lwmpoint_add_lwpoint(ret, lwp);
66 }
67
68 return ret;
69}
70
71
73{
74 uint32_t i;
75
76 if ( ! mpt ) return;
77
78 if ( mpt->bbox )
79 lwfree(mpt->bbox);
80
81 for ( i = 0; i < mpt->ngeoms; i++ )
82 if ( mpt->geoms && mpt->geoms[i] )
83 lwpoint_free(mpt->geoms[i]);
84
85 if ( mpt->geoms )
86 lwfree(mpt->geoms);
87
88 lwfree(mpt);
89}
90
91
94{
96 int has_z = lwgeom_has_z(g);
97 int has_m = lwgeom_has_m(g);
98 LWMPOINT* result = lwmpoint_construct_empty(g->srid, has_z, has_m);
99 POINT4D p;
100
101 while(lwpointiterator_next(it, &p)) {
102 LWPOINT* lwp = lwpoint_make(g->srid, has_z, has_m, &p);
104 }
105
107 return result;
108}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
Definition lwgeom.c:332
void lwpoint_free(LWPOINT *pt)
Definition lwpoint.c:213
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
Definition lwiterator.c:243
int lwpointiterator_next(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assign the next point in the iterator to p, and advances the iterator to the next point.
Definition lwiterator.c:210
#define MULTIPOINTTYPE
Definition liblwgeom.h:105
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition lwiterator.c:268
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition lwgeom.c:962
void lwfree(void *mem)
Definition lwutil.c:248
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
LWPOINT * lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p)
Definition lwpoint.c:206
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
Definition lwgeom.c:496
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition lwgeom.c:969
int ptarray_has_z(const POINTARRAY *pa)
Definition ptarray.c:37
int ptarray_has_m(const POINTARRAY *pa)
Definition ptarray.c:44
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
LWMPOINT * lwmpoint_construct(int32_t srid, const POINTARRAY *pa)
Definition lwmpoint.c:52
void lwmpoint_free(LWMPOINT *mpt)
Definition lwmpoint.c:72
void lwmpoint_release(LWMPOINT *lwmpoint)
Definition lwmpoint.c:33
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
Definition lwmpoint.c:45
LWMPOINT * lwmpoint_construct_empty(int32_t srid, char hasz, char hasm)
Definition lwmpoint.c:39
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
Definition lwmpoint.c:93
int32_t srid
Definition liblwgeom.h:460
GBOX * bbox
Definition liblwgeom.h:532
uint32_t ngeoms
Definition liblwgeom.h:538
LWPOINT ** geoms
Definition liblwgeom.h:533
uint32_t npoints
Definition liblwgeom.h:427