[OpenLayers-Users] How to test if a point is within WMS layer?

Andreas Hocevar ahocevar at opengeo.org
Thu Jan 26 13:45:22 EST 2012


Hi,

you only need the bounding box of the layer, which you can get from
the WMS GetCapabilities response. Use
OpenLayers.Format.WMSCapabilities to parse it, and look for the llbbox
or bbox properties inside the layer object.

Andreas.

On Thu, Jan 26, 2012 at 7:30 PM, maw269 <maw269 at gmail.com> wrote:
> I have a multipolygon layer in GeoServer that I can show as a WMS in
> OpenLayers. I want to geocode a location and place a marker on the map (got
> this working) and determine if that marker is inside or outside the
> multipolygon layer.
>
> I thought I could use WFS to get all the features of the polygon layer then
> use OpenLayers.Format.GML.parseGeometry.multipolygon to turn it into a
> polygon object in OL. Then I could use
> OpenLayers.Geometry.Polygon.containsPoint to test if the point is within the
> polygon. First Question: is this logic sound?
>
> The next issue is that I can't get the WFS for this layer to work. It hangs
> my GeoServer when I request it. I guess the layer is too big? Does anyone
> know how I could use OpenLayers to display the layer as a WMS but query on
> the back end (GeoServer) if my 'point' is within the layer?
> Thanks,
> Matt
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-test-if-a-point-is-within-WMS-layer-tp4341265p4341265.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list