2006-05-30 08:38:58 +00:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* PostGIS - Spatial Types for PostgreSQL
|
2014-01-29 17:49:35 +00:00
|
|
|
* http://postgis.net
|
2011-09-28 10:05:36 +00:00
|
|
|
*
|
2015-12-14 10:11:21 +00:00
|
|
|
* PostGIS is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PostGIS is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
|
2006-05-30 08:38:58 +00:00
|
|
|
*
|
2015-12-14 10:11:21 +00:00
|
|
|
**********************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-2006 Refractions Research Inc.
|
2009-06-11 16:44:03 +00:00
|
|
|
*
|
2006-05-30 08:38:58 +00:00
|
|
|
**********************************************************************/
|
|
|
|
|
2015-12-14 10:11:21 +00:00
|
|
|
|
2004-09-29 10:50:30 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2004-09-29 15:25:21 +00:00
|
|
|
#include <string.h>
|
2010-11-01 01:28:12 +00:00
|
|
|
#include "liblwgeom_internal.h"
|
2011-09-28 10:05:36 +00:00
|
|
|
#include "lwgeom_log.h"
|
2004-09-29 10:50:30 +00:00
|
|
|
|
2004-09-30 08:18:06 +00:00
|
|
|
|
2009-01-08 17:04:00 +00:00
|
|
|
void
|
|
|
|
lwmpoly_release(LWMPOLY *lwmpoly)
|
|
|
|
{
|
2009-06-11 16:44:03 +00:00
|
|
|
lwgeom_release(lwmpoly_as_lwgeom(lwmpoly));
|
2009-01-08 17:04:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 03:13:33 +00:00
|
|
|
LWMPOLY *
|
|
|
|
lwmpoly_construct_empty(int srid, char hasz, char hasm)
|
|
|
|
{
|
2010-10-23 23:48:37 +00:00
|
|
|
LWMPOLY *ret = (LWMPOLY*)lwcollection_construct_empty(MULTIPOLYGONTYPE, srid, hasz, hasm);
|
2010-03-16 03:13:33 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2009-01-08 17:04:00 +00:00
|
|
|
|
2004-09-29 10:50:30 +00:00
|
|
|
|
2010-03-16 03:13:33 +00:00
|
|
|
LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
|
2004-10-01 14:49:34 +00:00
|
|
|
{
|
2010-03-16 03:13:33 +00:00
|
|
|
return (LWMPOLY*)lwcollection_add_lwgeom((LWCOLLECTION*)mobj, (LWGEOM*)obj);
|
2004-10-01 14:49:34 +00:00
|
|
|
}
|
2008-12-19 19:20:34 +00:00
|
|
|
|
2010-03-16 03:13:33 +00:00
|
|
|
|
2009-06-11 16:44:03 +00:00
|
|
|
void lwmpoly_free(LWMPOLY *mpoly)
|
2008-12-19 19:20:34 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-02-07 19:42:49 +00:00
|
|
|
if ( ! mpoly ) return;
|
2009-06-11 16:44:03 +00:00
|
|
|
if ( mpoly->bbox )
|
2008-12-19 19:20:34 +00:00
|
|
|
lwfree(mpoly->bbox);
|
2010-12-11 00:28:57 +00:00
|
|
|
|
2009-06-11 16:44:03 +00:00
|
|
|
for ( i = 0; i < mpoly->ngeoms; i++ )
|
2010-12-11 00:28:57 +00:00
|
|
|
if ( mpoly->geoms && mpoly->geoms[i] )
|
2009-01-09 17:41:23 +00:00
|
|
|
lwpoly_free(mpoly->geoms[i]);
|
2010-12-11 00:28:57 +00:00
|
|
|
|
2009-06-11 16:44:03 +00:00
|
|
|
if ( mpoly->geoms )
|
2008-12-19 19:20:34 +00:00
|
|
|
lwfree(mpoly->geoms);
|
2009-06-11 16:44:03 +00:00
|
|
|
|
2010-12-11 00:28:57 +00:00
|
|
|
lwfree(mpoly);
|
2009-12-20 17:42:44 +00:00
|
|
|
}
|
2009-01-12 19:29:57 +00:00
|
|
|
|