2
在下面的MySQL存儲函數調用中,我不想手動輸入緯度座標,我想從另一個要測試的表中選擇一個多邊形。我有問題得到正確的語法。在MySQL函數調用中使用Select語句
SELECT IS_POINT_IN_POLYGON(
POINTFROMTEXT(CONCAT('POINT(', latitude, ' ', longitude, ')')) , POLYFROMTEXT('POLYGON((43.40930419213147, -72.5537109375
43.40884544242924, -72.53695249557495
43.38754804789373, -72.5437331199646
43.378580946950244, -72.58398771286011
43.40930419213147, -72.5537109375))')
)AS result, latitude, longitude
FROM sport
WHERE sport_type = 'lacrosse' AND IS_POINT_IN_POLYGON(
POINTFROMTEXT(CONCAT('POINT(', latitude, ' ', longitude, ')')) , POLYFROMTEXT('POLYGON((43.40930419213147, -72.5537109375
43.40884544242924, -72.53695249557495
43.38754804789373, -72.5437331199646
43.378580946950244, -72.58398771286011
43.40930419213147, -72.5537109375))')
) = 1;
所以,我想刪除 43.40930419213147,-72.5537109375 43.40884544242924,-72.53695249557495 43.38754804789373,-72.5437331199646 43.378580946950244,-72.58398771286011 43.40930419213147,-72.5537109375
,而是,我會喜歡使用此選擇語句:
SELECT neighborhood_polygon FROM `neighborhood_shapes` WHERE neighborhood="XYZ neighborhood"
我有多邊形存儲在nei ghborhood_shapes。其結構如下:
- neighborhood_index SMALLINT(3)
- 附近VARCHAR(50)
- neighborhood_polygon(幾何)
附加信息:
的IS_POINT_IN_POLYGON被稱爲如下:IS_POINT_IN_POLYGON(p POINT,poly polygon)
任何s uggestions?
嗨Tony318,謝謝你的留言。我嘗試了你的建議。不幸的是,我得到了「#1583 - 調用本地函數'POLYFROMTEXT'」時出現錯誤的參數。如果您有任何其他想法,請告訴我。我試過了我能想到的一切。謝謝。 – Laxmidi
@OMG小馬,幫助 - 我需要你的MySQL輝煌! – Laxmidi
可能保留多邊形部分? POLYFROMTEXT('POLYGON('+(SELECT neighborhood_polygon FROM neighborhood_shapes WHERE neighborhood =「XYZ neighborhood」)as coords +')') 玩了一下。我不確定 – Tony318