/src/postgis/liblwgeom/lwmpoly.c
Line | Count | Source |
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 | | |
32 | | |
33 | | void |
34 | | lwmpoly_release(LWMPOLY *lwmpoly) |
35 | 0 | { |
36 | 0 | lwgeom_release(lwmpoly_as_lwgeom(lwmpoly)); |
37 | 0 | } |
38 | | |
39 | | LWMPOLY * |
40 | | lwmpoly_construct_empty(int32_t srid, char hasz, char hasm) |
41 | 0 | { |
42 | 0 | LWMPOLY *ret = (LWMPOLY*)lwcollection_construct_empty(MULTIPOLYGONTYPE, srid, hasz, hasm); |
43 | 0 | return ret; |
44 | 0 | } |
45 | | |
46 | | |
47 | | LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj) |
48 | 100k | { |
49 | 100k | return (LWMPOLY*)lwcollection_add_lwgeom((LWCOLLECTION*)mobj, (LWGEOM*)obj); |
50 | 100k | } |
51 | | |
52 | | |
53 | | void lwmpoly_free(LWMPOLY *mpoly) |
54 | 4.73k | { |
55 | 4.73k | uint32_t i; |
56 | 4.73k | if ( ! mpoly ) return; |
57 | 4.73k | if ( mpoly->bbox ) |
58 | 272 | lwfree(mpoly->bbox); |
59 | | |
60 | 200k | for ( i = 0; i < mpoly->ngeoms; i++ ) |
61 | 195k | if ( mpoly->geoms && mpoly->geoms[i] ) |
62 | 195k | lwpoly_free(mpoly->geoms[i]); |
63 | | |
64 | 4.73k | if ( mpoly->geoms ) |
65 | 4.71k | lwfree(mpoly->geoms); |
66 | | |
67 | 4.73k | lwfree(mpoly); |
68 | 4.73k | } |
69 | | |