多段线周围的长度缓冲区 [英] Length buffer around polyline

查看:96
本文介绍了多段线周围的长度缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不擅长数学,所以我遇到了一个问题。我有一条从一个到另一个距离的路线。有一段时间,我试图在固定长度的路线上应用彩色阴谋。但我无法得到一个不错的圆角,我的数学缺乏让我变得更加疯狂。

现在我得到了这个



代码

  var r = []; 
var bla = result.routes [0] .overview_path;
for(i in result.routes [0] .overview_path){
r.push(new google.maps.LatLng(bla [i] .lat()+ z,bla [i] .lng ()-z));
}
bla.reverse();
for(x in bla){
r.push(new google.maps.LatLng(bla [x] .lat() - z,bla [x] .lng()+ z));
}

var kelias = new google.maps.Polyline({
path:result.routes [0] .overview_path,
strokeColor:#00000,
strokeOpacity:1.0,
strokeWeight:2
});

kelias.setMap(MAP);

fonas = new google.maps.Polygon({
paths:r,
strokeColor:#FF0000,
strokeOpacity:0.8,
strokeWeight :2,
fillColor:#FF0000,
fillOpacity:0.35
});

fonas.setMap(MAP);

我只想索取一些信息指示,或者可能有些人已经提出功能和有一些功能



工作演示这里。不知何故,我需要得到相同的绘图结果。



解决方案


解决方案

我在SO 路径笔划算法(转换为三角形/四边形)或其他建议问题,只适用于C ++。

答案是这个PDF中的算法( http://dev.gentoo.org/~dberkholz/tutorials/cairo/siggraph.pdf )(CONVOLVE算法)。



如果您也许可以在 JSFiddle 中创建一个工作示例,那么我们可以编写解决方案在那里。



- 编辑

经过一段时间的分析, 生活演示,我发现,折线不是用javascript计算的,而是根据服务器,并通过对某些PERL程序的AJAX调用返回。


I'm not very good at mathematics, so I got a problem. I have a route from one, to another distination. Some time I was trying to apply a colored plot aroud the route in fixed length. But I cant get a nice rounded corners and my lack of math is making me a lot of truble.

Now I got this

And the code

        var r = [];
        var bla = result.routes[0].overview_path;
        for(i in result.routes[0].overview_path) {
            r.push(new google.maps.LatLng(bla[i].lat()+z, bla[i].lng()-z));
        }
        bla.reverse();
        for(x in bla) {
            r.push(new google.maps.LatLng(bla[x].lat()-z, bla[x].lng()+z));
        }

        var kelias = new google.maps.Polyline({
            path: result.routes[0].overview_path,
            strokeColor: "#00000",
            strokeOpacity: 1.0,
            strokeWeight: 2
        });

        kelias.setMap(MAP);

        fonas = new google.maps.Polygon({
            paths: r,
            strokeColor: "#FF0000",
            strokeOpacity: 0.8,
            strokeWeight: 2,
            fillColor: "#FF0000",
            fillOpacity: 0.35
        });

        fonas.setMap(MAP);

I just want to ask for some information directions OR maybe some of you already have made this functionality and have some functions

Working demo here. Somehow i need to get same result of drawing that.

SOLUTIONS

解决方案

I found this stack in SO Path stroke algorithm (convert to triangles/quads) or other suggestions where there is a similar question, just for C++.

The answer is a algorithm in this PDF ( http://dev.gentoo.org/~dberkholz/tutorials/cairo/siggraph.pdf ) on page 3 (the CONVOLVE algorithm).

If you perhaps could make a working example in JSFiddle, we could be able to programm a solution in there.

-- edit

After some time of analysing the script in the link you provided for the life demo, I found, that the polyline is not calculated in javascript, but is calculated on the server and returned with a AJAX call to some PERL programme.

这篇关于多段线周围的长度缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆