测量工具
<h1>测量工具</h1>
<h2>类和说明</h2>
<p><code>MeasureManager</code> 测量对象管理器
<code>MeasureConfig</code> 测量配置参数</p>
<h2>1.BCore2DFast.Extension2D.Measure.MeasureConfig</h2>
<h3>构造</h3>
<pre><code class="language-javascript">new BCore2DFast.ExtensionD.Measure.MeasureConfig()</code></pre>
<h3>成员变量</h3>
<table>
<thead>
<tr>
<th>成员变量</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>viewer</td>
<td>Viewer</td>
<td>视图对象</td>
</tr>
</tbody>
</table>
<h2>2.BCore2DFast.Extension2D.Measure.MeasureManager</h2>
<h3>构造</h3>
<pre><code class="language-javascript">new BCore2DFast.Extension2D.Measure.MeasureManager(config)</code></pre>
<h3>参数</h3>
<table>
<thead>
<tr>
<th>参数名</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>config</td>
<td>BCore2DFast.Extension2D.Measure.MeasureConfig</td>
<td>测量配置参数</td>
</tr>
</tbody>
</table>
<h3>方法</h3>
<ul>
<li><strong>beginMeasure()</strong>: 开启测量</li>
<li><strong>endMeasure()</strong>: 关闭测量</li>
<li><strong>getMeasureType()</strong>: 获取测量类型</li>
<li><strong>setMeasureType(type)</strong>: 设置测量类型</li>
<li><strong>PolygonArea(pointsData)</strong>: 计算多边形面积</li>
<li><strong>getMeasureState()</strong>: 获取测量状态</li>
<li><strong>setMeasureTagsVisible()</strong>:测量结果标签可见性</li>
<li><strong>getMeasureTagsVisible()</strong>: 获取测量结果标签可见性</li>
</ul>
<hr />
<h3>方法示例</h3>
<h4>1.开启/关闭图纸测量功能</h4>
<p><strong>简要描述</strong>:
<strong>接口</strong>:
<code>beginMeasure()</code> 打开测量
<code>endMeasure()</code> 关闭测量
<strong>示例</strong>:</p>
<pre><code class="language-javascript">var mApplication2DConfig = new BCore2DFast.Application.Application2DConfig();
var mApplication2D = new BCore2DFast.Application.Application2D(mApplication2DConfig);
var mViewer2D = new BCore2DFast.Viewer.Viewer2D('bcorecontainer-2d', new BCore2DFast.Viewer.Viewer2DConfig());
mApplication2D.addViewer2D(mViewer2D);
mViewer2D.initViewer2D('accessToken');
// 建议初始化引擎后再初始化测量
var measureConfig = new BCore2DFast.Extension2D.MeasureConfig(mViewer2D);
var measure = new BCore2DFast.Extension2D.MeasureManager(measureConfig);
measure.beginMeasure(); //开启测量
...
//关闭测量
measure.endMeasure();</code></pre>
<hr />
<h4>2.获取/设置测量工具类型</h4>
<p><strong>接口</strong>:
<code>getMeasureType()</code> 获取测量工具类型
<code>setMeasureType(type)</code> 设置测量工具类型
<strong>示例</strong>:</p>
<pre><code class="language-javascript">let mApplication2DConfig = new BCore2DFast.Application.Application2DConfig();
let mApplication2D = new BCore2DFast.Application.Application2D(mApplication2DConfig);
let mViewer2D = new BCore2DFast.Viewer.Viewer2D('bcorecontainer-2d', new BCore2DFast.Viewer.Viewer2DConfig());
mApplication2D.addViewer2D(mViewer2D);
mViewer2D.initViewer2D('accessToken');
// 建议初始化引擎后 再初始化测量
let measureConfig = new BCore2DFast.Extension2D.MeasureConfig(mViewer2D);
let measure = new BCore2DFast.Extension2D.MeasureManager(measureConfig);
let measureType = measure.getMeasureType(); //获取测量工具类型
//设置设置测量工具类型
measure.setMeasureType(BCore2DFast.Static.MeasureType.ANGLE);</code></pre>
<p><strong>返回值说明</strong>:
<code>measureType</code> : <code>string</code> - 可选值: "Length", "Angle", "Area" </p>
<hr />
<h4>3.计算多边形面积</h4>
<p><strong>接口</strong>: <code>calcPolygonArea(pointsData)</code>
<strong>参数</strong>:
<code>pointsData</code> : <code>number[]</code> - 坐标值数组,例如: [1, 1, 0, 0, 2, 0]</p>
<p><strong>示例</strong>:</p>
<pre><code class="language-javascript">let mApplication2DConfig = new BCore2DFast.Application.Application2DConfig();
let mApplication2D = new BCore2DFast.Application.Application2D(mApplication2DConfig);
let mViewer2D = new BCore2DFast.Viewer.Viewer2D('bcorecontainer-2d', new BCore2DFast.Viewer.Viewer2DConfig());
mApplication2D.addViewer2D(mViewer2D);
mViewer2D.initViewer2D('accessToken')
// 建议初始化引擎后 再初始化测量
let measureConfig = new BCore2DFast.Extension2D.MeasureConfig(mViewer2D);
let measure = new BCore2DFast.Extension2D.MeasureManager(measureConfig);
let area = measure.calcPolygonArea([0, 0, 0, 10, 0, 0, 10, 10, 0, 0, 10, 0]);</code></pre>
<p><strong>返回值说明</strong>:
<code>area</code> : <code>number</code> - 计算成功返回面积,计算失败返回 -1</p>
<h4>4.获取测量工具状态</h4>
<p><strong>接口</strong>: <code>getMeasureState()</code><br />
<strong>示例</strong>:</p>
<pre><code class="language-javascript">var state = measure.getMeasureState();</code></pre>
<p><strong>返回值说明</strong>:
<code>active</code> : <code>boolean</code> - 是否开启测量
<code>type</code> : <code>BCore.Static.MeasureType</code> - 测量类型
<code>measureState</code> : <code>string</code> - "DOING" 或 "DONE"</p>
<h4>5.获取/设置测量结果标签可见性</h4>
<p><strong>接口</strong>:
<code>getMeasureTagsVisible()</code> 获取测量结果标签可见性
<code>setMeasureTagsVisible()</code> 设置测量结果标签可见性(默认可见)
示例**:</p>
<pre><code class="language-javascript">var mApplication2DConfig = new BCore2DFast.Application.Application2DConfig();
var mApplication2D = new BCore2DFast.Application.Application2D(mApplication2DConfig);
var mViewer2D = new BCore2DFast.Viewer.Viewer2D('bcorecontainer-2d', new BCore2DFast.Viewer.Viewer2DConfig());
mApplication2D.addViewer2D(mViewer2D);
mViewer2D.initViewer2D('accessToken')
// 建议初始化引擎后 再初始化测量
let measureConfig = new BCore2DFast.Extension2D.MeasureConfig(mViewer2D);
let measure = new BCore2DFast.Extension2D.MeasureManager(measureConfig);
console.log(measure.getMeasureTagsVisible()); //打印测量结果标签可见性
measure.setMeasureTagsVisible(false); //设置测量结果标签 - 不可见</code></pre>
<table>
<thead>
<tr>
<th><strong>返回值说明</strong>:</th>
<th>参数名</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>visible</td>
<td>boolean</td>
<td>可见性值,true为可见,false为不可见</td>
</tr>
</tbody>
</table>
<hr />
<p>以上是与测量工具相关的详细接口和使用示例。根据需求进行相应的调用。</p>