阅读:2216回复:3
[求助]多边形面积计算
<P>那位高手用IMS写过计算多边形面积的算法啊?</P>
|
|
1楼#
发布于:2008-11-15 22:24
<P>function ComputeArea() {<BR> <BR> var workarea = 0.0;</P>
<P> cai = clickCount - 1;<BR> caj = 0;</P> <P><BR> while (caj < clickCount) {<BR> xjyi = clickPointX[caj] * clickPointY[cai];<BR> xiyj = clickPointX[cai] * clickPointY[caj];</P> <P> xydiff = (xjyi - xiyj);<BR> workarea = workarea+xydiff;</P> <P><BR> cai = caj;<BR> caj = parseFloat(caj + 1); <BR> }<BR> <BR>//alert(ScaleBarUnits);<BR>//alert(MapUnits);<BR> units2 = invertUnits(ScaleBarUnits, MapUnits);<BR>//alert(units2);<BR> units2 = units2 * units2;<BR>//alert(units2);</P> <P>/*<BR>//workarea = Math.abs(workarea / ( 2.0 * units2) * 640); // hard-coded for SqMiles to Acres<BR> workarea = Math.abs(workarea / ( 2.0 * units2)); // hard-coded for SqMiles</P> <P> var u = Math.pow(10,numDecimals);<BR> if (!isNav) workarea = parseInt(workarea * u + 0.5) / u<BR> workACRES = 10*(workarea/43560);</P> <P> currentArea = workarea*10;<BR>*/<BR>currentArea = Math.abs(workarea / 2.0);<BR>workACRES = currentArea / 1000000;<BR> <BR>}</P> |
|
2楼#
发布于:2008-11-17 15:58
多谢mytest了
|
|
3楼#
发布于:2008-11-18 19:40
<img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em04.gif" />
|
|