[postgis-devel] point_in_multipolygon implementation
Mark Leslie
mrk.leslie at gmail.com
Thu Sep 11 16:58:02 PDT 2008
Mose Andre wrote:
> 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);
> }
> }
> */
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>
The short story is that I wrote that when I did the point_in_polygon
implementation, figuring it was a trivial extension, but had enough bugs
in point_in_polygon that I ran out of time to test the
point_in_multipolygon. There's no fundamental reason that I recall that
it doesn't work, I just couldn't say that it did, so it's left out. If
you have time to run some tests with it uncommented and let me know the
results/report any bugs, we can get it working.
--
Mark Leslie
Geospatial Software Architect
LISAsoft
-------------------------------------------------------------
Ph: +61 2 8570 5000 Fax: +61 2 8570 5099 Mob: +61
Suite 112, Jones Bay Wharf 19-21 Pirrama Rd Pyrmont NSW 2009
-------------------------------------------------------------
LISAsoft is part of the A2end Group of Companies
http://www.ardec.com.au
http://www.lisasoft.com
http://www.terrapages.com
More information about the postgis-devel
mailing list