【问题标题】:postgresql - center - "No function matches the given name and argument types. You might need to add explicit type casts."postgresql - 中心 - “没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。”
【发布时间】:2013-11-24 14:09:39
【问题描述】:

在带有 postgresql-9.2.4 和 postgis-2.0.3 的 Slackware 14.0 x86_64 上。 已将 essex-latest.osm.pbf 加载到数据库中。

我想到达埃塞克斯的道路中心,但遇到了问题。 这些工作正常:

SELECT st_Extent(way), st_area(st_Extent(way)) from planet_osm_roads;    
       st_extent                    |     st_area          
------------------------------------------------+------------------
 BOX(-10979.62 6693910.54,144349.79 6822695.15) | 20004037488.3802



SELECT center(box '((-10979.62, 6693910.54),(144349.79, 6822695.15))');
         center          
-------------------------
 (66685.085,6758302.845) 

(但我想知道为什么函数是中心而不是st_center)。

无论如何,为什么这不起作用:

SELECT center(st_Extent(way)) from planet_osm_roads;
ERROR:  function center(box2d) does not exist
LINE 1: SELECT center(st_Extent(way)) from planet_osm_roads;
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

干杯, 彼得

【问题讨论】:

    标签: postgresql postgis


    【解决方案1】:

    功能中心获取box类型的参数,而不是st_Extent返回的box2d。使用ST_Centroid,你甚至不需要调用 st_Extent,试试 ST_Centroid(way)

    【讨论】:

      【解决方案2】:

      center 不是 PostGIS 函数,它是 core geometry function for PostgreSQL

      找到线串中点的最佳方法是使用linear referencing function(例如,ST_Line_Interpolate_Point()ST_LineInterpolatePoint() 用于 PostGIS >=2.1)。

      另见ST_PointOnSurface

      【讨论】:

        猜你喜欢
        • 2020-08-26
        • 1970-01-01
        • 2016-01-18
        • 2021-02-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-23
        • 1970-01-01
        相关资源
        最近更新 更多