Re: [問題] 抓取字串
※ 引述《sask (sask)》之銘言:
: 請問各位
: 我有一個變數$xy存了一筆WKT格式的字串 如下:
: polygon((121.1234567 23.2345678, 121.7654321 23.8765432,
: 121.3456789 23.9876543, 121.5678901 23.1098765 .........
: 我想取出這個字串裡的第二筆座標並且存在兩個變數中
: 也就是$x=121.7654321 $y=23.8765432
: 請問要怎麼處理呢??
: 我翻書翻了很久 還是不太知道怎麼做
: 感謝大家~~
您可以 google 搜尋一下關鍵字:wkt、well-known text
Well-Known Text format
* http://en.wikipedia.org/wiki/Well-known_text
* http://geoapi.sourceforge.net/2.0/javadoc/org/opengis/referencing/
doc-files/WKT.html
這對於您要 parse 這個格式的資料應該有幫助。
另外 cpan 中有個 Geo::WKT 的模組可以使用,您可以參考當中
parse_wkt_polygon 的程式碼。
* http://cpansearch.perl.org/src/MARKOV/Geo-WKT-0.03/lib/Geo/WKT.pm
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.74.246.253
※ 編輯: liyih 來自: 211.74.246.253 (07/23 01:02)
推
07/23 10:13, , 1F
07/23 10:13, 1F
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章