답변:
다각형 안에있는 점을 알려주는 PostGIS 함수를 찾고 있다면 ST_PointOnSurface 함수가 필요한 것을 줄 수 있습니다.
SELECT
ST_AsText(ST_PointOnSurface('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'::geometry));
st_astext
----------------
POINT(2.5 2.5)
(1 row)
PostGIS 메일 링리스트에서이 기능을 찾았습니다. 나는 그것이 당신이 요구하는 것 같아요 :
CREATE OR REPLACE FUNCTION point_inside_geometry(param_geom geometry)
RETURNS geometry AS
$$
DECLARE
var_cent geometry := ST_Centroid(param_geom);
var_result geometry := var_cent;
BEGIN
-- If the centroid is outside the geometry then
-- calculate a box around centroid that is guaranteed to intersect the geometry
-- take the intersection of that and find point on surface of intersection
IF NOT ST_Intersects(param_geom, var_cent) THEN
var_result := ST_PointOnSurface(ST_Intersection(param_geom, ST_Expand(var_cent, ST_Distance(var_cent,param_geom)*2) ));
END IF;
RETURN var_result;
END;
$$
LANGUAGE plpgsql IMMUTABLE STRICT
COST 100;