在PostGIS ST_MinimumBoundingRadius中,返回数字的半径是什么度量单位



我在PLPGSQL中编写了一个函数,用于在下面添加最小边界半径(它使用ST_MinimumBoundingRadius((函数(。它似乎起作用了,因为我收到了一个返回的号码。然而我不知道那个数字代表什么。是英里、米、公里还是经度/纬度的变化?

第二个函数是一个测试函数,它构建一个输入多边形,然后调用我的函数。

在这两个函数之后是函数使用的tfr_point_type数据类型和tfr_polygon表的定义。

提前感谢您提供的任何帮助。

CREATE OR REPLACE FUNCTION public.tfr_get_minimum_bounding_radius(
the_polygon tfr_polygon)
RETURNS SETOF double precision 
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT PARALLEL SAFE 
ROWS 1
AS $BODY$
DECLARE
the_radius double PRECISION;
points_array geometry[];        -- collects geometry of the points in the LOOP and then used to calculate the radius
point tfr_point_type;           -- used in the LOOP
BEGIN
FOREACH point IN ARRAY the_polygon.points LOOP
points_array := array_append(
points_array,
ST_MakePoint(
point.longitudedec,
point.latitudedec,
point.altitude
)
);
END LOOP;
SELECT radius
INTO the_radius
FROM ST_MinimumBoundingRadius(
ST_MakePolygon(
ST_MakeLine(
points_array
)
)
);
RETURN NEXT the_radius;
END;
$BODY$;
CREATE OR REPLACE FUNCTION public.tfr_test_polygon(
)
RETURNS SETOF  double precision
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT PARALLEL SAFE
--    ROWS 1000
AS $BODY$
DECLARE 
point1 public.tfr_point_type;
point2 public.tfr_point_type;
point3 public.tfr_point_type;
point4 public.tfr_point_type;
point5 public.tfr_point_type;
londms tfr_longitude_direction;
latdms tfr_latitude_direction;
a_polygon public.tfr_polygon;
points public.tfr_point_type[];
center geometry;
circle_radius double PRECISION;

--north public.tfr_latitude_direction := 'North'::tfr_latitude_direction;
--south public.tfr_latitude_direction := 'South'::tfr_latitude_direction;
--east public.tfr_longitude_direction := 'East'::tfr_longitude_direction;
--west public.tfr_longitude_direction := 'West'::tfr_longitude_direction;
BEGIN

RAISE log '++++++++++++++++++++++++++++++++++++++++';
point1.longitudedec = -84.351;
point1.latitudedec = 42.4643;
point1.altitude = 11000;
point1.wkt = st_AsHexEwkb(st_makepoint(point1.longitudedec, point1.latitudedec, point1.altitude));
point2.longitudedec = -104.351;
point2.latitudedec = 43.4643;
point2.altitude = 12000;
point2.wkt = st_AsHexEwkb(st_makepoint(point2.longitudedec, point2.latitudedec, point2.altitude));
point3.longitudedec = -74.351;
point3.latitudedec = 43.4643;
point3.altitude = 13000;
point3.wkt = st_AsHexEwkb(st_makepoint(point3.longitudedec, point3.latitudedec, point3.altitude));
point4.longitudedec = -74.351;
point4.latitudedec = 42.4643;
point4.altitude = 14000;
point4.wkt = st_AsHexEwkb(st_makepoint(point4.longitudedec, point4.latitudedec, point4.altitude));
point5.longitudedec = -84.351;
point5.latitudedec = 42.4643;
point5.altitude = 15000;
point5.wkt = st_AsHexEwkb(st_makepoint(point5.longitudedec, point5.latitudedec, point5.altitude));
RAISE log 'I created point1: %', point1;
RAISE log 'I created point2: %', point2;
RAISE log 'I created point3: %', point3;
RAISE log 'I created point4: %', point4;
RAISE log 'I created point5: %', point5;
points := array_append(points, point1);
points := array_append(points, point2);
points := array_append(points, point3);
points := array_append(points, point4);
points := array_append(points, point5);

a_polygon.id := 1;
a_polygon.points := points;
RAISE log 'I created a_polygon: %', a_polygon;
RAISE log '========================================';
SELECT *
INTO circle_radius
FROM public.tfr_get_minimum_bounding_radius(a_polygon);
RAISE log 'The raidus is: %', circle_radius;
--
RETURN QUERY
SELECT public.tfr_get_minimum_bounding_radius(a_polygon) AS radius;


END;
$BODY$;

CREATE TYPE public.tfr_point_type AS
(
wkt character varying,
longitudedec double precision,
latitudedec double precision,
altitude double precision,
);
ALTER TYPE public.tfr_point_type
OWNER TO postgres;

多边形表:

CREATE TABLE IF NOT EXISTS public.tfr_polygon
(
id bigint NOT NULL DEFAULT nextval('shape_base_id_seq'::regclass),
points tfr_point_type[]
)

TABLESPACE pg_default;

与大多数PostGIS函数一样,返回的单位与输入CRS相同,因此在您的示例中,它可能以度为单位。

最新更新