我想指定一个方框(即2个点)并选择所有在该方框内或与方框相交的线串。
SELECT * FROM pub_trail_segment WHERE st_force_2d(pub_trail_segment.geometry) && ST_SetSRID(ST_MakeBox2D(ST_GeomFromEWKT('SRID=4326;POINT(48.25077560316286 -124.46710205078124)'), ST_GeomFromEWKT('SRID=4326;POINT(50.4743709029765 -120.73239135742186)')), 4326);
然而它返回0行。我已经尝试扩展盒子的大小并将几何列强制为2D但我看不到我错过的东西。
测试数据如下 - (DBTestCase格式,但你明白了):
<pub_trail_segment id="1" pub_trail_id="1" geometry="SRID=4326;LINESTRING(-123.258275 7 49.3607281 123.666748, -123.2583172 49.3607195 120.302124)"/>
<pub_trail_segment id="2" pub_trail_id="3" geometry="SRID=4326;LINESTRING(-123.2582757 49.3607281 123.666748, -123.2583172 49.3607195 120.302124, -123.3583172 49.3607195 120.402124)"/>
<pub_trail_segment id="3" pub_trail_id="1" geometry="SRID=4326;LINESTRING(-123.3582757 49.4607281 123.666748, -123.3583172 49.4607195 120.302124)"/>
<pub_trail_segment id="4" pub_trail_id="4" geometry="SRID=4326;LINESTRING(-123.3582757 50.4607281 123.666748, -123.3583172 50.4607195 120.302124)"/>
感谢您的帮助!
答案 0 :(得分:0)
我解决了这个问题。我的经纬度是错误的。