2014-06-05 50 views
0

遷移的Postgres 8.4至9.1和移動我的項目到新的服務器我得到這個錯誤功能makepoint的PostgreSQL 9.1錯誤的PostGIS

ERROR: function makepoint(unknown, unknown) does not exist LINE 4: distance_sphere(makepoint('14.2995419','41.0310868'),mak...^HINT: No function matches the given name and argument types. You might need to add explicit type casts.

谷歌搜索我看到,可能與PostGIS的一個問題... 後來我按照本指南 http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204src我安裝在服務器上的一切......

沒有什麼工作......,我在成爲瘋狂的危險...... 有誰知道如何解決它!?

+2

也許[ST_distance_sphere](http://www.postgis.org /docs/ST_Distance_Sphere.html)? – DrColossos

+0

@DrColossos是對的,也是['ST_MakePoint'](http://postgis.refractions.net/docs/ST_MakePoint.html)。我認爲所有或至少大部分PostGIS空間函數都獲得了一個'ST_'前綴。 – elrobis

回答

1

從錯誤中可以看出你用引號括住了你的觀點,因此對未知,未知的投訴。 ST_Makepoint將期望兩個雙精度數字作爲輸入。正如評論中所述,您還應該將所有空間函數加上ST_前綴。

如果您運行從psql的提示符下輸入:

\df ST_MakePoint 

你會看到,所支持的3個版本,2,3和4個維度中,全部佔用雙打。

例如:

select st_distance_sphere(st_makepoint(14.2995419,41.0310868), st_makepoint(15.2995419,40.0310868)) as dist; 

回報139665.10米

對於什麼是值得的ST_被認爲是標準的兼容。 Oracle在所有空間函數之前使用ST_,就像Postgres/Postgis一樣,MySQL同時支持ST_和直接函數名稱,而Microsoft決定在SQL Server 2008中實現空間sql時完全刪除下劃線,例如,您擁有STUnion。

2

如前所述,這些函數以前稱爲「makepoint」和「distance_sphere」,但後來用「ST_」前綴(ST =「空間類型」)重命名。

一個非常簡單的解決方案是將legacy.sql功能添加到您的任何template_postgis(如果使用的話),或使用類似目標數據庫:

sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/legacy.sql 
+0

有趣的想法,將解決OP的直接問題。根據我的經驗,雖然乾淨升級通常會更好,並且一些功能在新版本中會得到增強。 –