Find all polygons containing points specific criteria

المشرف العام

Administrator
طاقم الإدارة
I have searched for a bit, but couldn't find an answer for my question.

So I have two tables (PostGIS), one containing points, and the other containing polygons.

Right now i have this query for finding polygons (Laravel framework):

$polygon = DB::connection('pgsql') ->select(DB::raw("SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM (SELECT 'Feature' As type , ST_AsGeoJSON(ST_Transform(geom,4326))::json As geometry , row_to_json((SELECT l FROM (SELECT areal) As l )) As properties FROM jbb2013 As lg WHERE gid = 1208749 OR gid = 692891 OR gid = 993224 OR gid = 1171857 OR gid = 1176873) As f ) As fc;") ); With some work i get the results as GeoJSON, i then send that to Leaflet.

But now for the main question, as you can see i specify the the polygons by id. That's not what i want to do. I'd like to use the other table containing points and find the points by a specific customer_id.

So something like this: Find all points that belong to a specific customer_id Use those points in a ST_Contains query to find the polygons that contain the points. The resulting GeoJSON should then only contain the polygons found by the query.

Thank you all for you're help!

/Simon



أكثر...
 
أعلى