forked from MapGIS/WebClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint2D.js
More file actions
87 lines (80 loc) · 2.38 KB
/
Point2D.js
File metadata and controls
87 lines (80 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import {
Tangram
} from "./Tangram";
/**
* 点类型
* @class Zondy.Object.Point2D
* @classdesc 点类型
* @extends Zondy.Object.Tangram
* @param {Number} [x = null] 坐标x
* @param {Number} [y = null] 坐标y
* @param {Object} option 属性键值对
* @param {Number} [option.nearDis = null] 容差半径,只在做点查询时需赋值
*/
class Point2D extends Tangram {
constructor(x, y, option) {
var options = option ? option : {};
super(options);
/**
* @member Zondy.Object.Point2D.prototype.x
* @type {Number}
* @description 坐标x
* @default null
*/
this.x = x !== undefined ? x : null;
/**
* @member Zondy.Object.Point2D.prototype.y
* @type {Number}
* @description 坐标y
* @default null
*/
this.y = y !== undefined ? y : null;
/**
* @member Zondy.Object.Point2D.prototype.nearDis
* @type {Number}
* @description 容差半径,只在做点查询时需赋值
* @default null
*/
this.nearDis = options.nearDis !== undefined ? parseFloat(options.nearDis) : null;
this.CLASS_NAME = "Zondy.Object.Point2D";
}
/**
* @function Zondy.Object.Point2D.prototype.getGeometryType
* @description 获取几何类型名称
* @returns {String} point
*/
getGeometryType() {
return "point";
}
/**
* @function Zondy.Object.Point2D.prototype.setByOL
* @description 通过传入Openlayers的ol.geom.Point类型来设置参数
* @param {ol.geom.Point} point Openlayers定义的点类型
*/
setByOL(point) {
if (point !== undefined) {
var cordinate = point.getCoordinates();
this.x = cordinate[0];
this.y = cordinate[1];
}
}
/**
* @function Zondy.Object.Point2D.prototype.toString
* @description 对象转化为字符串
* @returns {String} 返回一个以字符串形式表示的点
*/
toString() {
/// <summary>返回一个以字符串形式表示的点</summary>
if (this.x === null || this.y === null)
return "";
var str = this.x + ',' + this.y;
if (this.nearDis !== undefined) {
str += ";" + this.nearDis;
}
return str;
}
}
export {
Point2D
};
Zondy.Object.Point2D = Point2D;