|
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 |
|
> 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? Yes, it is sound and also easy to implement. But you may have an issue if it's more than a few thousand vertices. You may hang the browser simply parsing the GML. The server-side method you are already attempting, sounds like your best bet. I'm sorry I have no help for you on the hanging problem. -- Greg Allensworth, Web GIS Developer BS A+ Network+ Security+ Linux+ Server+ GreenInfo Network - Information and Mapping in the Public Interest 564 Market Street, Suite 510 San Francisco CA 94104 PH: 415-979-0343 x302 FX: 415-979-0371 email: [hidden email] Web: www.GreenInfo.org www.MapsPortal.org Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
In reply to this post by maw269
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 <[hidden email]> 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 > [hidden email] > http://lists.osgeo.org/mailman/listinfo/openlayers-users -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
Thanks Andreas,
Wouldn't the bbox only get me the 'rectangular' extent of the polygon and not each actual polygon face? |
|
In reply to this post by Greg Allensworth
Thanks Greg,
It sounds like using WFS is out of the question. The thing is I wouldn't know how to pass the point-in-polygon client query to the server and utilize the response. Can anyone show me how to do that? --Matt |
|
2012/1/26 maw269 <[hidden email]>:
> Thanks Greg, > It sounds like using WFS is out of the question. The thing is I wouldn't > know how to pass the point-in-polygon client query to the server and utilize > the response. Can anyone show me how to do that? > --Matt > > -- you could use a spatial filter to let the WFS do the work http://dev.openlayers.org/apidocs/files/OpenLayers/Filter/Spatial-js.html eg. Intersect with the point essentially you would send the filter then, on returning from the WFS, test the response for a geometry, if it has one, the point is within a polygon. check out the examples for filter. -- Disclaimer; This message is just a reflection of what I thought at the time of sending. The message may contain information that is not intended for you or that you don't understand. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
In reply to this post by Andreas Hocevar-2
Andreas wrote:"That's right. If that's not what you need, then you probably need
topology rule enforcement. I assume you want to persist the user generated geometries on your GeoServer as well? That can be done as part of WFS transactions, using pre- and post-transaction hooks on the server. The first step would be to see why your GeoServer does not respond to WFS request, but that's a question for the geoserver-users list." I don't have any user generated geometries for this scenario. I simply want to test whether a point is within a polygon geometry sitting on GeoServer. I figured out the GeoServer is actually responding to the WFS request for the polygon but there are LOTS of vertices so it not feasible to use the WFS approach to determine whether the point is within the polygon. |
|
In reply to this post by Mark Prins
So I created a test polygon in GeoServer called test:allPoly and a test geometry point in OL called 'point'. Currently the point is outside the polygon but the wfstest layer still shows up. Shouldn't the wfs polygon be 'filtered out' with the code below?
var wfstest = new OpenLayers.Layer.Vector("Flood Vector Test", { strategies: [new OpenLayers.Strategy.BBOX()], visibility: false, protocol: new OpenLayers.Protocol.WFS({ url: url, featurePrefix: "test", featureType: "allPoly", version: "1.1.0", srsName: "EPSG:900913" }), filters: [new OpenLayers.Filter.Spatial({ type: OpenLayers.Filter.Spatial.INTERSECTS, value: point}) ] }); |
|
That's actually a good approach to proceed. I was about to recommend
WPS and the JTS:interects process that GeoServer ships with, but what you came up with is easier. Having said that, you only have one small typo that keeps this from working: it's "filter" (singular), not "filters". Andreas. On Thu, Jan 26, 2012 at 10:41 PM, maw269 <[hidden email]> wrote: > So I created a test polygon in GeoServer called test:allPoly and a test > geometry point in OL called 'point'. Currently the point is outside the > polygon but the wfstest layer still shows up. Shouldn't the wfs polygon be > 'filtered out' with the code below? > > var wfstest = new OpenLayers.Layer.Vector("Flood Vector Test", { > strategies: [new OpenLayers.Strategy.BBOX()], visibility: false, > protocol: new OpenLayers.Protocol.WFS({ > url: url, > featurePrefix: "test", > featureType: "allPoly", > version: "1.1.0", > srsName: "EPSG:900913" > }), > filters: [new OpenLayers.Filter.Spatial({ > type: OpenLayers.Filter.Spatial.INTERSECTS, > value: point}) > ] > }); > > -- > View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-test-if-a-point-is-within-WMS-layer-tp4341265p4341763.html > Sent from the OpenLayers Users mailing list archive at Nabble.com. > _______________________________________________ > Users mailing list > [hidden email] > http://lists.osgeo.org/mailman/listinfo/openlayers-users -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
In reply to this post by maw269
Instead of wfs you can use a WMS GetFeatureInfo Request.
I use this approach to determine which country the user clicked. Arnd -----Ursprüngliche Nachricht----- Von: [hidden email] [mailto:[hidden email]] Im Auftrag von maw269 Gesendet: Donnerstag, 26. Januar 2012 22:42 An: [hidden email] Betreff: [OpenLayers-Users] Re: How to test if a point is within WMS layer? So I created a test polygon in GeoServer called test:allPoly and a test geometry point in OL called 'point'. Currently the point is outside the polygon but the wfstest layer still shows up. Shouldn't the wfs polygon be 'filtered out' with the code below? var wfstest = new OpenLayers.Layer.Vector("Flood Vector Test", { strategies: [new OpenLayers.Strategy.BBOX()], visibility: false, protocol: new OpenLayers.Protocol.WFS({ url: url, featurePrefix: "test", featureType: "allPoly", version: "1.1.0", srsName: "EPSG:900913" }), filters: [new OpenLayers.Filter.Spatial({ type: OpenLayers.Filter.Spatial.INTERSECTS, value: point}) ] }); -- View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-test-if-a-point-is-within-WMS-lay er-tp4341265p4341763.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
In reply to this post by Andreas Hocevar-2
Hi all, Is there a mean to use user-defined svg symbol for rendering vector point? I've seen a ticket about it here: http://trac.osgeo.org/openlayers/ticket/2403 But I don't know if anything has been implemented yet. Any additional information or ressource would be greatly appreciated. Regards, Rémy _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
Hi,
you can use user-defined symbols. Not defined in SVG though, but easy to create. See http://openlayers.org/dev/examples/graphic-name.html for an example. Andreas. On Thu, Jan 26, 2012 at 10:57 PM, web <[hidden email]> wrote: > Hi all, > > Is there a mean to use user-defined svg symbol for rendering vector point? > I've seen a ticket about it here: > > http://trac.osgeo.org/openlayers/ticket/2403 > > But I don't know if anything has been implemented yet. Any additional > information or ressource would be greatly appreciated. > > Regards, > > Rémy > > > _______________________________________________ > Users mailing list > [hidden email] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
Thanks for your response Andreas. I forget to mention I wanted to use svg to make a basic animated symbol. I know i could achieve an animated symbol with an externalgraphic, but I would rather use svg. Is there any mean to add an animated svg symbol to a vector symbol? regards. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
An externalGraphic *can* be SVG (just reference an svg file), but then
it won't work in IE versions older than 9. Andreas. On Thu, Jan 26, 2012 at 11:42 PM, web <[hidden email]> wrote: > Thanks for your response Andreas. I forget to mention I wanted to use svg to > make a basic animated symbol. I know i could achieve an animated symbol with > an externalgraphic, but I would rather use svg. Is there any mean to add an > animated svg symbol to a vector symbol? > > regards. -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
In reply to this post by maw269
Why not use a GetFeatureInfo request using your x,y inside a small bbox and see if you get attributes returned relating to one of the polygon geometries in the WMS layer? Take your x,y point, create a small bbox round it and then use the width and height parameters to represent your point in the middle of the bbox eg.
http://myserver/cgi-bin/mapserv.exe?service=WMS&version=1.1.1&request=GetFeatureInfo&LAYERS=crs_parcels&QUERY_LAYERS=crs_parcels&INFO_FORMAT=text/plain&SRS=EPSG:2193&BBOX=1754813,5850304,1755013,5850504&WIDTH=20&HEIGHT=20&X=10&Y=10 Robert Sanson >>> maw269 <[hidden email]> 27/01/2012 10:23 a.m. >>> Andreas wrote:"That's right. If that's not what you need, then you probably need topology rule enforcement. I assume you want to persist the user generated geometries on your GeoServer as well? That can be done as part of WFS transactions, using pre- and post-transaction hooks on the server. The first step would be to see why your GeoServer does not respond to WFS request, but that's a question for the geoserver-users list." I don't have any user generated geometries for this scenario. I simply want to test whether a point is within a polygon geometry sitting on GeoServer. I figured out the GeoServer is actually responding to the WFS request for the polygon but there are LOTS of vertices so it not feasible to use the WFS approach to determine whether the point is within the polygon. -- View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-test-if-a-point-is-within-WMS-layer-tp4341265p4341729.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system. This message has been scanned for Malware and Viruses by Websense Hosted Security. www.websense.com _______________________________________________ Users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/openlayers-users |
|
Excellent,
I am late getting back to everyone thanking them for their help. I always want to revisit the thread when I solve the proplem to post the solution. I was able to use the spatial filter on the WFS request to filter only a small part of the multipolygon that my point resided in. This WFS response was then small enough for the client to handle. I want to revisit the getfeatureinfo to see if I can get that to work also. Here is the code that allowed me to pull the the polygon for my test point. wfslayer = new OpenLayers.Layer.Vector("Flood Vector", { strategies: [new OpenLayers.Strategy.BBOX()], visibility: false, protocol: new OpenLayers.Protocol.WFS({ url: url, featurePrefix: "dfirm", featureType: "s_fld_haz_ar2", version: "1.1.0", srsName: "EPSG:900913" }), filter: new OpenLayers.Filter.Spatial({ type: OpenLayers.Filter.Spatial.INTERSECTS, property: 'the_geom', value: point}) }); Where the 'url' is the url to my WFS server and 'point' is an OpenLayers Point Geometry point = new OpenLayers.Geometry.Point(-8911615.2651595,4935047.5500005); |
| Powered by Nabble | Edit this page |
