<div dir="ltr">Hi,<div><br></div><div>Yes, you can use st_dumppoints to extract way's points and use these points in a query with <span style="font-size:12.8px">seg_wp_intersection and </span><span style="font-size:12.8px">zone_wp_intersection to find intersections.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Nicolas</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 1 October 2015 at 20:27, Trang Nguyen <span dir="ltr"><<a href="mailto:Trang.Nguyen@inrix.com" target="_blank">Trang.Nguyen@inrix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"><span style="color:#44546a">I realize I didn’t clearly phrase my question:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#44546a"><u></u> <u></u></span></p>
<p><u></u><span style="color:#44546a"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span style="color:#44546a">Is there a way to retrieve the points in the waypoints linestring that intersects a polygon or another linestring without having to write a function to traverse each point in waypoints to check whether
 the conditions st_intersects(point, </span>seg_wp_intersection<span style="color:#44546a">) and st_intersects(point,
</span>zone_wp_intersection<span style="color:#44546a">)  are met? <u></u><u></u></span></p>
<p><span style="color:#44546a"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#44546a">Any help on this would be greatly appreciated!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#44546a"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#44546a">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#44546a">Trang<u></u><u></u></span></p>
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a> [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a>]
<b>On Behalf Of </b>Trang Nguyen<br>
<b>Sent:</b> Wednesday, September 30, 2015 10:28 PM<br>
<b>To:</b> <a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<b>Subject:</b> [postgis-users] Finding points of intersection of a linestring with another multiolygon and linestring<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi forum,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have a LINESTRING represent the waypoints of a trip through road segments (LINESTRING) and zones (MULTIPOLYGON).<u></u><u></u></p>
<p class="MsoNormal">For each segment and zone, I would like to find out the points in the waypoints  which intersected the targeted zone/segment geometries. First and last intersection point into and exiting the zone or segment  would the sufficient as well.<u></u><u></u></p>
<p class="MsoNormal">I can use st_intersection to find the intersection each of waypoints to segment and zone geometries, but this returns a geometry that doesn’t necessarily contain the subset of intersecting points in the linestring. The query will be run
 on large datasets, so performance is an important consideration. GIST indexes exist on all the geometries joined (zone_geom, segment_geom and waypoints).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">---------------------------<u></u><u></u></p>
<p class="MsoNormal">Query<u></u><u></u></p>
<p class="MsoNormal">---------------------------<u></u><u></u></p>
<p class="MsoNormal">select<u></u><u></u></p>
<p class="MsoNormal">st_transform(st_intersection(segment_geom, waypoints),4326) seg_wp_intersection, -- need subset of points in waypoints that intersected with segment_geom<u></u><u></u></p>
<p class="MsoNormal">st_transform(st_intersection(zone_geom, waypoints),4326)  zone_wp_intersection,  -- need subset of  points in waypoints that intersected with zone_geom<u></u><u></u></p>
<p class="MsoNormal">trip_id, waypoints, zone_id, segment_id <u></u><u></u></p>
<p class="MsoNormal">from od1.v_trip_zone_segment <u></u><u></u></p>
<p class="MsoNormal">where <u></u><u></u></p>
<p class="MsoNormal">startts>=TIMESTAMP '2015-01-16T12:20:29.000Z' and startts<TIMESTAMP '2015-01-16T17:20:30.000Z' and endts<TIMESTAMP '2015-01-16T17:20:30.000Z' and zone_id in ('kansas_303','kansas_601','kansas_603','kansas_604','kansas_10','kansas_11','kansas_9','kansas_310','kansas_311','kansas_315','kansas_301','kansas_302','kansas_307','kansas_306','kansas_305','kansas_204','kansas_201','kansas_3','kansas_2','kansas_1')
 and segment_id in ('5062926','5062931','5062932','4062933','5055496','5063065','5062826','5062825','5062824','5062643','5062644','5062645','5062646','5055551','5062839','5062849','5062895','5063081') and segment_mapversion='1501'<u></u><u></u></p>
<p class="MsoNormal">and st_intersects(segment_geom, waypoints)<u></u><u></u></p>
<p class="MsoNormal">and st_intersects(szone_geom, waypoints)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Trang<u></u><u></u></p>
</div></div></div>
</div>

<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>