|
楼主 |
发表于 2012-11-1 08:02
|
显示全部楼层
- <p>
- </p><p>//求共界线</p><p>void MutualBoundary(wkLayer layer, double eps, bool bSel)</p><p>{</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>int nFeaCount = bSel ? layer.getSelectionCount() : layer.getFeatureCount();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>//求不同的边界线</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>wkClean cln;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>int i = 0;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.create(layer.getBox());<span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>for (i = 0; i < nFeaCount; ++i)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>{</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>wkGeometry geom = bSel ? layer.getSelectionAt(i).getGeometry()</p><p><span class="Apple-tab-span" style="white-space:pre"> </span> : layer.getFeatureAt(i).getGeometry();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.xorOverLine(geom, eps);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.cleanZero(eps);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.combineToArc();<span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>array ps;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>wkParts parts = cln.getFirstArc();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>while (parts.handle())</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>{</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>ps.add(parts);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>parts = cln.getNextArc();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>//用所有地物边界减去不同的部分,得到共界的部分</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>for (i = 0; i < nFeaCount; ++i)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>{</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>wkGeometry geom = bSel ? layer.getSelectionAt(i).getGeometry() </p><p><span class="Apple-tab-span" style="white-space:pre"> </span> : layer.getFeatureAt(i).getGeometry();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.orOverLine(geom, eps);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}<span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>for (i = 0; i < ps.getSize(); ++i)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>{</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.diffOverLine(ps[i], eps);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}<span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.cleanZero(eps);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>int nCount = cln.combineToArc();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>parts = cln.getFirstArc();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>while (parts.handle())</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>{</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (parts.handle())</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>layer.addFeature(parts,false);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>parts = cln.getNextArc();<span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>cln.free();<span class="Apple-tab-span" style="white-space:pre"> </span></p><p>}</p><div></div>
复制代码 |
|