POSTGIS-Find-Geometry-Center-Point

所属分类:PostgreSQL
开发工具:PLpgSQL
文件大小:1KB
下载次数:0
上传日期:2018-04-16 04:45:31
上 传 者sh-1993
说明:  一个简单的plpgSQL函数,返回给定几何体的中心点,该中心点位于基于几何体的几何体上...
(A simple plpgSQL function that returns center point of given geometry which lies on the geometry based on the geometry type.)

文件列表:
ap_find_geometry_center.sql (886, 2018-04-16)

# POSTGIS-Find-Geometry-Center-Point Use this function instead of **ST_Centroid** to make sure that the returned center point is lied on the given geometry. It also can be used for dynamic senario where you don't know what the type of the geometry is and wouldn't like to call ST_Centroid for geometries like linestring or point which they have nothing to do with that. So, when you're querying more than one table with a different geometry types, this function can be helpful. **Usage:** Execute the **ap_find_geometry_center.sql** function in the PostgreSQL and call it like the following: **1. LineString** ``` select public.ap_find_geometry_center('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)') ``` **2. Polygon** ``` select public.ap_find_geometry_center('POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239, -71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))') ``` **3. Point** Please notice that it'll return the same point as given geometry for point type geometries. ``` select st_astext(public.ap_find_geometry_center('POINT(-71.0***544 42.28787)')) ``` **4. MultiLineString** ``` select public.ap_find_geometry_center('MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45 -33,-46 -32))') ```

近期下载者

相关文件


收藏者