1+ import SuperMap from '../SuperMap' ;
2+
3+ /**
4+ * @class SuperMap.ClipParameter
5+ * @classdesc 用于裁剪的参数。
6+ * @description 优先使用用户指定的裁剪区域多边形进行裁剪,也可以通过指定数据源和数据集名,从而使用指定数据集的边界多边形进行裁剪。
7+ * @param options - {Object} 参数。<br>
8+ * clipDatasetName - {String} 裁剪的数据集名。<br>
9+ * clipDatasourceName - {String} 裁剪的数据集所在数据源的名字。<br>
10+ * clipRegion - {Object} 用户指定的裁剪区域。面对象可以是SuperMap.Geometry.Polygon|L.Polygon|L.GeoJSON|ol.geom.Polygon|ol.format.GeoJSON。</br>
11+ * isClipInRegion - {Boolean} 是否对裁剪区内的数据集进行裁剪。<br>
12+ * isExactClip - {Boolean} 是否使用精确裁剪。
13+ */
14+ export default class ClipParameter {
15+
16+ /**
17+ * @member SuperMap.ClipParameter.prototype.clipDatasetName -{string}
18+ * @description 用于裁剪的数据集名,当clipRegion不设置时起作用。
19+ */
20+ clipDatasetName = null ;
21+
22+ /**
23+ * @member SuperMap.ClipParameter.prototype.clipDatasourceName -{string}
24+ * @description 用于裁剪的数据集所在数据源的名字。
25+ */
26+ clipDatasourceName = null ;
27+
28+ /**
29+ * @member SuperMap.ClipParameter.prototype.clipRegion -{Object}
30+ * @description 用户指定的裁剪区域,优先使用。<br>
31+ * 面对象可以是SuperMap.Geometry.Polygon|L.Polygon|L.GeoJSON|ol.geom.Polygon|ol.format.GeoJSON。
32+ */
33+ clipRegion = null ;
34+
35+ /**
36+ * @member SuperMap.ClipParameter.prototype.isClipInRegion -{boolean}
37+ * @description 是否对裁剪区内的数据集进行裁剪。
38+ */
39+ isClipInRegion = false ;
40+
41+ /**
42+ * @member SuperMap.ClipParameter.prototype.isExactClip -{boolean}
43+ * @description 是否使用精确裁剪。
44+ */
45+ isExactClip = null ;
46+
47+ constructor ( options ) {
48+ if ( options ) {
49+ SuperMap . Util . extend ( this , options ) ;
50+ }
51+ }
52+
53+
54+ /**
55+ * @function SuperMap.ClipParameter.prototype.destroy
56+ * @description 释放资源,将引用资源的属性置空。
57+ */
58+ destroy ( ) {
59+ var me = this ;
60+ me . clipDatasetName = null ;
61+ me . clipDatasourceName = null ;
62+ me . clipRegion = null ;
63+ me . isClipInRegion = null ;
64+ me . isExactClip = null ;
65+ }
66+
67+
68+ /**
69+ * @function SuperMap.ClipParameter.prototype.toJSON
70+ * @description 将 ClipParameter 对象转化为json字符串。
71+ * @return {string } 返回转换后的 JSON 字符串。
72+ */
73+ toJSON ( ) {
74+ if ( this . isClipInRegion == false )
75+ return null ;
76+ var strClipParameter = "" ;
77+ var me = this ;
78+
79+ strClipParameter += "'isClipInRegion':" + SuperMap . Util . toJSON ( me . isClipInRegion ) ;
80+
81+ if ( me . clipDatasetName != null )
82+ strClipParameter += "," + "'clipDatasetName':" + SuperMap . Util . toJSON ( me . clipDatasetName ) ;
83+
84+ if ( me . clipDatasourceName != null )
85+ strClipParameter += "," + "'clipDatasourceName':" + SuperMap . Util . toJSON ( me . clipDatasourceName ) ;
86+
87+ if ( me . isExactClip != null )
88+ strClipParameter += "," + "'isExactClip':" + SuperMap . Util . toJSON ( me . isExactClip ) ;
89+
90+ if ( me . clipRegion != null ) {
91+ var serverGeometry = SuperMap . REST . ServerGeometry . fromGeometry ( me . clipRegion ) ;
92+ if ( serverGeometry ) {
93+ var pointsCount = serverGeometry . parts [ 0 ] ;
94+ var point2ds = serverGeometry . points . splice ( 0 , pointsCount ) ;
95+ strClipParameter += "," + "'clipRegion':" + "{\"point2Ds\":" ;
96+ strClipParameter += SuperMap . Util . toJSON ( point2ds ) ;
97+ strClipParameter += "}" ;
98+ }
99+ }
100+ return "{" + strClipParameter + "}" ;
101+ }
102+
103+
104+ CLASS_NAME = "SuperMap.ClipParameter"
105+ }
106+ SuperMap . ClipParameter = ClipParameter ;
0 commit comments