- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 openlayers 2.13 中使用 cubiccurve,并且我已经添加了必要的文件,但是绘制时绘制的是线而不是曲线。
文件可在网站上获得:http://trac.osgeo.org/openlayers/ticket/1715#no1
画曲线对我们来说很重要,我无法控制自己的曲线。
有人能帮帮我吗?
最佳答案
<html>
<head>
<script src="http://dev.openlayers.org/OpenLayers.js" type="text/javascript"></script>
<title>Ya Mahdi</title>
<style>
html,body {
height: 99%;
width: 99%;
}
#map {
width: 100%;
height: 100%;
border: 1px solid black;
}
</style>
<script>
mmGetCurvePoints = function(ptsa, tension, isClosed, numOfSegments)
{
if (ptsa.length <= 2)
return ptsa;
tension = typeof tension === 'number' ? tension : 0.5;
isClosed = typeof isClosed === 'boolean' ? isClosed : false;
numOfSegments = typeof numOfSegments === 'number' ? numOfSegments : 16;
var ptsaClone = ptsa.slice(0);
if (isClosed)
ptsaClone.push(ptsa[0], ptsa[1], ptsa[2], ptsa[3]);
var _pts, res = [], /// clone array
x, y, /// our x,y coords
t1x, t2x, t1y, t2y, /// tension vectors
c1, c2, c3, c4, /// cardinal points
st, t, i, /// steps based on num. of segments
pow3, pow2, /// cache powers
pow32, pow23,
p0, p1, p2, p3, /// cache points
pl = ptsaClone.length;
/// clone array so we don't change the original content
_pts = ptsaClone.concat();
_pts.unshift(ptsaClone[1]); /// copy 1. point and insert at beginning
_pts.unshift(ptsaClone[0]);
_pts.push(ptsaClone[pl - 2], ptsaClone[pl - 1]); /// copy last point and append
/// 1. loop goes through point array
/// 2. loop goes through each segment between the two points + one point before and after
for (i = 2; i < pl; i += 2) {
p0 = _pts[i];
p1 = _pts[i + 1];
p2 = _pts[i + 2];
p3 = _pts[i + 3];
/// calc tension vectors
t1x = (p2 - _pts[i - 2]) * tension;
t2x = (_pts[i + 4] - p0) * tension;
t1y = (p3 - _pts[i - 1]) * tension;
t2y = (_pts[i + 5] - p1) * tension;
for (t = 0; t <= numOfSegments; t++) {
/// calc step
st = t / numOfSegments;
pow2 = Math.pow(st, 2);
pow3 = pow2 * st;
pow23 = pow2 * 3;
pow32 = pow3 * 2;
/// calc cardinals
c1 = pow32 - pow23 + 1;
c2 = pow23 - pow32;
c3 = pow3 - 2 * pow2 + st;
c4 = pow3 - pow2;
/// calc x and y cords with common control vectors
x = c1 * p0 + c2 * p2 + c3 * t1x + c4 * t2x;
y = c1 * p1 + c2 * p3 + c3 * t1y + c4 * t2y;
/// store points in array
res.push(x, y);
}
}
if (isClosed)
res = res.slice(0, res.length - 2 * numOfSegments);
return res;
};
var map, control,layer,feature,points;
var xy = [];
var array = [];
function init(){
map = new OpenLayers.Map('map', {
center: [45.476333, 39.4854095],
zoom: 10
});
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'});
layer = new OpenLayers.Layer.Vector("Simple Geometry");
map.addLayer(wms);
map.addLayer(layer);
function drawEnd(e){
if(xy.length<6) {
xy.push(e.x);
xy.push(e.y);
return;
}
else if(xy.length==6){
feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(array),{properties: {state: 'a'}}
);
layer.addFeatures(feature);
console.log("add f");
feature="";
layer.refresh({force:true});
xy=[];
}
}
function putPoint(e){
if(xy.length<6) {
return;
}
}
function sketchModified(e, ee, eee){
if(xy.length<6)
return;
try{
layer.removeFeatures(feature);
}catch(err){}
var xytemp = [];
xytemp.push(xy[0]);
xytemp.push(xy[1]);
xytemp.push(xy[2]);
xytemp.push(xy[3]);
xytemp.push(e.x);
xytemp.push(e.y);
points = mmGetCurvePoints(xytemp, 0.5, false, 15);
var i = 0;
while(i<points.length){
array.push(new OpenLayers.Geometry.Point(points[i], points[i+1]));
i++;
i++;
}
feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(array),{properties: {state: 'a'}}
);
layer.addFeatures([feature]);
array=[];
points=[];
layer.refresh({force:true});
}
function cancel(){
}
var callBackParams = {
"done": drawEnd,
"point": putPoint,
"modify": sketchModified,
"cancel": cancel
};
var drawCrtl = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {callbacks: callBackParams});
map.addControls([drawCrtl]);
drawCrtl.activate();
}
</script>
</head>
<body onload="init()">
<div id="map" style="width: 400px; height: 400px;"></div>
</body>
</html>
关于curve - 在 OpenLayers 2 中使用 cubiccurve?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31353866/
当我用 g++ 编译时出现以下错误: Parser.cpp:(.text+0x2478): 未定义对“Curve::Curve()”的引用 Parser.cpp 的标题如下: #include "Be
问题 假设我知道希尔伯特曲线面和四叉树,例如 4/032212303102122 (第 4 面,第 15 层)。 或者我可能知道 S2 Geometry CellId,例如 9749618424903
我正在尝试将文本包裹在贝塞尔曲线中,并遵循此链接中的教程,http://www.planetclegg.com/projects/WarpingTextToSplines.html 我通过此代码获得衍
如果我有一组来 self 扫描的黑白图像的点。 它看起来像一条曲线,我想使用这些点的三次贝塞尔曲线来模拟一条平滑的曲线。 如何确定起点、2 个控制点和终点? 从图像中可以模拟出几条三次贝塞尔曲线,但我
我想将具有已知端点(p0 和 p3)的贝塞尔曲线拟合到嘈杂的二维数据。这似乎比传统的 4 点贝塞尔曲线拟合更简单,但我仍然难以弄清楚。 有人可以指出我现有的代码或算法来找到控制点 p1 和 p2 的最
我正在尝试使用 B 样条曲线拟合。 B样条曲线的阶数为4。当我有很多控制点时,它工作得很好。但是,如果控制点的数量很少,比如两个,我的程序就会崩溃。我意识到控制点的数量与结的数量和顺序有关。谁能帮我澄
我有三个形成抛物线的 X/Y 点。我只需要计算通过这三个点的抛物线顶点是多少。最好是一种快速的方法,因为我必须做很多这些计算! “Ask A Scientist”网站提供this answer : T
我想绘制 x 的函数,其中 x 应用于向量。无论如何,最简单的是举一个简单的例子: var <- c(1,2,3) curve(mean(var)+x) curve(mean(var+x)) 虽然第一
一位同事问我这个问题,我一直在努力解决这个问题。 假设我想定义一个函数,它接受一个表达式(具体来说,假设为 x^2)作为参数,并将该参数传递给 curve()。 如果我想以简单的方式做到这一点,我只需
我想绘制 x 的函数,其中 x 应用于向量。无论如何,最简单的是举一个简单的例子: var <- c(1,2,3) curve(mean(var)+x) curve(mean(var+x)) 虽然第一
ECDSA算法中256位EC key 的签名长度将是多少? 我想验证签名长度是否相同。如果某个机构可以帮助我设置一个EC key ,那将是很棒的。 最佳答案 这取决于您如何对签名进行编码。这是来自Op
我有以下代码生成四个图,但它们最终被压扁(见下图)。我该如何解决这个问题? par(mfrow=c(2,2)) curve(.5*exp(-.5*x),from=0,to=10,main="f(x)"
我编写了一个程序,它处理当前资源到几何图形表面的欧氏距离。在我们的几何考虑中,y 坐标始终为零 - 因此它在 x 和 z 维度上是一个二维结构。该图显示了它的外观: (length yellow =
为什么curve似乎不适用于从列表中提取的元素? 考虑两个看似相同的函数,但构建方式不同: a curve(m[[1]]) Error in curve(m[[1]]) : 'expr' mus
我有一个公式作为字符向量,并希望在曲线中使用它。 curve(-8*cos(2*x), 0, 10) #works as expected formula <- "-8*cos(2*x)" # not
为什么curve似乎不适用于从列表中提取的元素? 考虑两个看似相同的函数,但构建方式不同: a curve(m[[1]]) Error in curve(m[[1]]) : 'expr' mus
是否可以循环动画此图像? 我试图通过创建一个相对父级并将每个图像设置为动画(业务解决方案 div、it 解决方案 div、生命周期解决方案 div 和教育解决方案 div 为绝对)。我使用了这段代码,
如何在Flex中弯曲我的文本小部件?我有一个被文本包围的圆圈,我需要为文本创建这个样式。另外,这个圆圈占屏幕宽度的50%,所以这个曲线效果也应该是动态的
我怎样才能弯曲一张纸(立方体)?我想控制弯曲/曲线的角度。 例如 立方体([50,50,2]); 最佳答案 您可以 rotate_extrude()一个带有参数角的矩形。这需要 openscad 版本
我正在尝试寻找一种聪明的方法来创建像下一个一样的曲线(使用 Unity3d 2D 部分(不使用网格对撞机))),但我没有找到 任何帮助,将不胜感激。 最佳答案 看到最后一个答案(已删除)不符合我的要求
我是一名优秀的程序员,十分优秀!