I have 2 layers in OpenLayers: first is parcel layer (polygons) and second is railway layer (lines). They are already drawn and all I need to do is when I click on some line, to get intersection of that line and all polygons that are intersected with selected line and get feature info of polygons. How can I do that?
2 Answers
The getFeatureInfo should work, asking for both layers you'll get all the features that intersects the requested pixel. If you receive features from both layers then that's your success condition. It's not perfect because is based on pixel area, not an exact position, but only with WMS that's all you got.
- Yea, i've tried that, didn't got what i needed. Thanks anyway :)Stefan Mihajlovic– Stefan Mihajlovic2015-02-05 12:23:43 +00:00Commented Feb 5, 2015 at 12:23
One option would be to use PHP if your Data is stored in a PostGIS-Database. You could register a click-event, post the click-coordinates to your php and use this coordinate to check for ST_Intersects to get back the feature attributes. would this be an option for you?
- Well, I use Java as back-end, and my data is stored in Geoserver-Database. Tried with geoserver demo requests, couldn't do a thing.Stefan Mihajlovic– Stefan Mihajlovic2015-02-06 09:51:32 +00:00Commented Feb 6, 2015 at 9:51
- out of standards (likely) you can try to write a GeoServer process to do the jobb, then use it directly or through WPSJorge Sanz– Jorge Sanz2015-02-06 13:24:57 +00:00Commented Feb 6, 2015 at 13:24