栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

计算外环的角度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上这里



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/669963.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号