MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / lineToTF

Method lineToTF

src/common/overlay/ThemeVector.js:169–238  ·  view source on GitHub ↗

* @function FeatureThemeVector.prototype.lineToTF * @description 转换线和线环要素。 * @param {Geometry} geometry - 用户数据几何地理信息,这里必须是 GeometryLineString 或 GeometryLineRing。

(geometry)

Source from the content-addressed store, hash-verified

167 * @param {Geometry} geometry - 用户数据几何地理信息,这里必须是 GeometryLineString 或 GeometryLineRing。
168 */
169 lineToTF(geometry) {
170 var components = geometry.components;
171
172 //节点像素坐标
173 var localLX = [];
174 //参考位置,参考中心为
175 var refLocal = [];
176 var location = this.location;
177 var pointList = [];
178
179 //节点抽稀距离
180 var nCPx = this.nodesClipPixel;
181
182 for (var i = 0; i < components.length; i++) {
183 var components_i = components[i];
184 refLocal = [];
185 localLX = this.getLocalXY(components_i);
186
187 refLocal[0] = localLX[0] - location[0];
188 refLocal[1] = localLX[1] - location[1];
189
190 //抽稀 - 2 px
191 if (pointList.length > 0) {
192 var lastLocalXY = pointList[pointList.length - 1];
193 if ((Math.abs(lastLocalXY[0] - refLocal[0]) <= nCPx) && (Math.abs(lastLocalXY[1] - refLocal[1]) <= nCPx)) {
194 continue;
195 }
196 }
197
198 //使用参考点
199 pointList.push(refLocal);
200 }
201
202 if (pointList.length < 2) {
203 return null;
204 }
205
206 //赋 style
207 var style = new Object();
208 style = CommonUtil.copyAttributesWithClip(style, this.style, ['pointList']);
209 style.pointList = pointList;
210
211 //创建图形
212 var shape = new SmicBrokenLine({
213 style: style,
214 clickable: this.isClickAble,
215 hoverable: this.isHoverAble
216 });
217
218 //设置高亮样式
219 if (this.highlightStyle) {
220 shape.highlightStyle = this.highlightStyle;
221 }
222
223 //设置参考中心,指定图形位置
224 shape.refOriginalPosition = this.location;
225
226 //储存数据 id 属性,用于事件

Callers 2

constructorMethod · 0.95
multiLineStringToTFMethod · 0.95

Calls 2

getLocalXYMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected