[postgis-devel] point_in_multipolygon implementation
Mose Andre
mose.andre at gmail.com
Thu Sep 11 12:35:06 PDT 2008
In trunk, lwgeom_functions_analytic.c:1397 and thereabouts is a
commented out point_in_multipolygon function.
We have noticed a performance gain by convincing contains
(lwgeom_geos_c:1388) to use the point_in_polygon shortcut, but our
application uses a lot of multipolygons. Rather than switch the
client code to decompose multipolygons (most of them are a single
polygon anyway) it would be nice to just implement this other
shortcut.
Does anyone know why it's not functional? Or have any recommendations
on how to fix it up? I cannot find any discussion on the lists.
Thanks,
Mose
>From lwgeom_functions_analytic.c:
/*
* return 0 iff point is outside every polygon
*/
/* Not yet functional.
int point_in_multipolygon(LWMPOLY *mpolygon, LWPOINT *point)
{
int i;
#ifdef PGIS_DEBUG_CALLS
lwnotice("point_in_multipolygon called.");
#endif
for(i=1; i<mpolygon->ngeoms; i++)
{
if(point_in_polygon((LWPOLY *)mpolygon->geoms[i],
point)!=0) return 1;
}
return 0;
}
*/
>From lwgeom_geos_c.c:
/* Not yet functional
else if(type1 == MULTIPOLYGONTYPE && type2 == POINTTYPE)
{
POSTGIS_DEBUG(3, "Point in MultiPolygon test
requested...short-circuiting.");
mpoly = lwmpoly_deserialize(SERIALIZED_FORM(geom1));
point = lwpoint_deserialize(SERIALIZED_FORM(geom2));
if(point_in_multipolygon(mpoly, point) == 0)
{
PG_FREE_IF_COPY(geom1, 0);
PG_FREE_IF_COPY(geom2, 1);
lwgeom_release((LWGEOM *)mpoly);
lwgeom_release((LWGEOM *)point);
PG_RETURN_BOOL(FALSE);
}
else
{
PG_FREE_IF_COPY(geom1, 0);
PG_FREE_IF_COPY(geom2, 1);
lwgeom_release((LWGEOM *)mpoly);
lwgeom_release((LWGEOM *)point);
PG_RETURN_BOOL(TRUE);
}
}
*/
More information about the postgis-devel
mailing list