首页 文章

将线段转换为弧线,漂亮的运输显示

提问于
浏览
0

我试图将线段显示转到弧段显示

我的linput数据被编码为一系列MultiLineString几何,
我尝试过像st_forcecurve(st_linemerge(geom))这样的东西,它将我的数据转换成一系列非常漂亮的直线,编码为CompoundCurve几何 . 它有任何方法可以生成曲线而不是直线 .

1 回答

  • 0

    看来我不是唯一一个遇到过像这样的问题的人A very similairproblem

    其中一个答案就是我想要的 . 我刚刚将答案转换为psql函数,该函数生成一个曲线弧,使用一个因子来表示你想要答案的曲线,低值非常曲线,高值是一个直线 .

    --
    -- Draw an arc geom between two differentlocations
    --
    --   point1                    must be a point starting location
    --   point2             must be a point ending location
    --   arc_fractor            how curved you want the result
    --   returns                 a curved geometry
    
    create or replace function mk_arg_geom(point1 geometry, point2 geometry, arc_factor integer ) 
    
    returns geometry 
            as $$
    
    DECLARE
            ret                 geometry;
            ret_srid         integer;
            tmp_geom        geometry;
            c_geom                geometry;
    BEGIN
    
            ret := null;
            ret_srid:=st_srid(point1);
    
            tmp_geom=st_makeline(point1,point2);
    
            c_geom:= ST_CurveToLine('CIRCULARSTRING(' || 
                    st_x(st_startpoint(tmp_geom)) || 
                    ' ' || 
                    st_y(st_startpoint(tmp_geom)) || 
                    ', ' || 
                    st_x(st_centroid(ST_OffsetCurve(tmp_geom, st_length(tmp_geom)/arc_factor, 'quad_segs=4 join=bevel'))) || 
                    ' ' || 
                    st_y(st_centroid(ST_OffsetCurve(tmp_geom, st_length(tmp_geom)/arc_factor, 'quad_segs=4 join=bevel'))) || 
                    ', ' || 
                    st_x(st_endpoint(tmp_geom)) || 
                    ' ' ||  
                    st_y(st_endpoint(tmp_geom)) 
                    || ')');
    
            ret=st_setsrid(c_geom,ret_srid);
    
            return ret;
    END;
    
    $$
            LANGUAGE plpgsql;
    

相关问题