[OpenLayers-Users] Contains polygon function

Tim Schaub tschaub at opengeo.org
Mon Aug 4 08:00:28 EDT 2008


Hey-

Bas Couwenberg wrote:
> Hello,
>  
> is there an function in OpenLayers that checks if a polygon contains 
> another polygon? I saw there is one for points and I also found a mail 
> about this matter: 
> http://www.nabble.com/OpenLayers.Geometry.Polygon---to16179019.html#a16179019.

The geometry intersection code includes most of the logic you need to do 
this.

http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Geometry/Polygon.js#L144

This could be separated out as a contains method for polygons.

In addition, you'd want to check that interior rings do not intersect 
the passed in geometry.

poly1.contains(poly2)

Interior rings in poly1 should not intersect poly2.

Tim

>  
> Greetings,
>  
> Bas
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list