PostGIS 计算给定距离的正交点
PostGIS compute orthogonal points at a given distance
在 PostGIS 中,我需要计算直线给定距离处的 2 个垂直点 C 和 D,以便在地图上创建一个完美的矩形。投影 WGS84。 ABCD必须像下图一样逆时针旋转。
知道如何计算这 2 分吗?
给定任意线串,您可以使用 ST_OffsetCurve 计算具有自定义距离(在此示例中设置为 2 米)的平行线。之后我们将其反转。然后您可以将 2 条线串的起点和端点相互连接,这将产生“连接”线串。
WITH focus_line AS (
SELECT ST_GeomFromText('LineString(-0.108092 51.519324, -0.107643 51.517861)', 4326) AS geom
),
parallel_line AS (
SELECT ST_Reverse(
ST_Transform(
ST_OffsetCurve(
ST_Transform(
geom,
3857),
2, 'join=round'),
4326)
) AS geom
FROM focus_line
)
SELECT ST_AsText(a.geom) AS focus,
ST_AsText(b.geom) AS parallel,
ST_AsText(
ST_MakeLine(
ST_StartPoint(a.geom), ST_EndPoint(b.geom)
)
) AS connection_1,
ST_AsText(
ST_MakeLine(
ST_EndPoint(a.geom), ST_StartPoint(b.geom)
)
) AS connection_2
FROM focus_line a, parallel_line b;
在 PostGIS 中,我需要计算直线给定距离处的 2 个垂直点 C 和 D,以便在地图上创建一个完美的矩形。投影 WGS84。 ABCD必须像下图一样逆时针旋转。
知道如何计算这 2 分吗?
给定任意线串,您可以使用 ST_OffsetCurve 计算具有自定义距离(在此示例中设置为 2 米)的平行线。之后我们将其反转。然后您可以将 2 条线串的起点和端点相互连接,这将产生“连接”线串。
WITH focus_line AS (
SELECT ST_GeomFromText('LineString(-0.108092 51.519324, -0.107643 51.517861)', 4326) AS geom
),
parallel_line AS (
SELECT ST_Reverse(
ST_Transform(
ST_OffsetCurve(
ST_Transform(
geom,
3857),
2, 'join=round'),
4326)
) AS geom
FROM focus_line
)
SELECT ST_AsText(a.geom) AS focus,
ST_AsText(b.geom) AS parallel,
ST_AsText(
ST_MakeLine(
ST_StartPoint(a.geom), ST_EndPoint(b.geom)
)
) AS connection_1,
ST_AsText(
ST_MakeLine(
ST_EndPoint(a.geom), ST_StartPoint(b.geom)
)
) AS connection_2
FROM focus_line a, parallel_line b;