计算外环的角度PostGIS(多边形和多面体)

计算外环的角度PostGIS(多边形和多面体),第1张

计算外环的角度PostGIS(多边形多面体

在aengus示例中使用ST_Azimuth函数会产生错误,因为您不能将两个generate_series用作单个函数的参数。如果在另一个子查询中使用ep
/ sp值,则不会有任何麻烦。

这是我的解决方案:

-- 3.- Create segments from points and calculate azimuth for each line.--     two calls of generate_series for a single function wont work (azimuth).select id,       name,       polygon_num,       point_order as vertex,       --       case when point_order = 1         then last_value(ST_Astext(ST_Makeline(sp,ep))) over (partition by id, polygon_num)         else lag(ST_Astext(ST_Makeline(sp,ep)),1) over (partition by id, polygon_num order by point_order)       end ||' - '||ST_Astext(ST_Makeline(sp,ep)) as lines,       --       abs(abs(       case when point_order = 1         then last_value(degrees(ST_Azimuth(sp,ep))) over (partition by id, polygon_num)         else lag(degrees(ST_Azimuth(sp,ep)),1) over (partition by id, polygon_num order by point_order)       end - degrees(ST_Azimuth(sp,ep))) -180 ) as angfrom (-- 2.- extract the endpoints for every 2-point line segment for each linestring      --     Group polygons from multipolygon      select id,  name,  coalesce(path[1],0) as polygon_num,  generate_series(1, ST_Npoints(geom)-1) as point_order,  ST_Pointn(geom, generate_series(1, ST_Npoints(geom)-1)) as sp,  ST_Pointn(geom, generate_series(2, ST_Npoints(geom)  )) as ep      from ( -- 1.- Extract the individual linestrings and the Polygon number for later identification  select id,         name,         (ST_Dump(ST_Boundary(the_geom))).geom as geom,         (ST_Dump(ST_Boundary(the_geom))).path as path -- To identify the polygon   from poly_and_multipoly ) as pointlist ) as segments;

我增加了一些复杂性,因为我想标识每个多边形以避免混合用于角度计算的线。

由于sqlfiddle没有对PostGIS的支持,我上传这个例子与一些辅助代码github上这里



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5675212.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存