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?
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.