Repository navigation
Expand file tree
/
Copy pathFeatureSet.js
More file actions
152 lines (141 loc) · 3.93 KB
/
Copy pathFeatureSet.js
File metadata and controls
152 lines (141 loc) · 3.93 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*********************************************************************************
Copyright © SuperMap. All rights reserved.
Author: Wang zihao
E-mail: pridehao@gmail.com
**********************************************************************************/
import {NativeModules} from 'react-native';
let FS = NativeModules.JSFeatureSet;
import Geometry from './Geometry.js';
/**
* @class FeatureSet
* @description 要素资源集合类。
*/
export default class FeatureSet {
/**
* 删除要素
* @description 物理性删除指定要素集中的所有要素,即把要素从设备的物理存储介质上删除,无法恢复。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async deleteAll(){
try{
await FS.deleteAll(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
/**
* 用于删除当前要素,成功则返回 true。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async delete(){
try{
await FS.delete(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
/**
* 返回要素集合中要素的个数。
* @memberOf FeatureSet
* @returns {Promise<number>}
*/
async getFeatureCount(){
try{
var count = await FS.getFeatureCount(this._SMFeatureSetId);
return count;
}catch (e){
console.error(e);
}
}
/**
* 根据字段名指定字段,返回当前要素该字段的值。
* @memberOf FeatureSet
* @param {string} fieldName - 字段名。
* @returns {Promise<string>}
*/
async getFieldValue(fieldName){
try{
var value = await FS.getFieldValue(this._SMFeatureSetId,fieldName);
return value;
}catch (e){
console.error(e);
}
}
/**
* 获取当前要素中的几何对象。
* @memberOf FeatureSet
* @returns {Promise.<Geometry>}
*/
async getGeometry(){
try{
var {geometryId} = await FS.getGeometry(this._SMFeatureSetId);
var geometry = new Geometry();
geometry._SMGeometryId = geometryId;
return geometry;
}catch (e){
console.error(e);
}
}
/**
* 返回要素集是否是只读的,如果是只读的,则返回 true,表示要素集中的信息将不可被修改。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async isReadOnly(){
try{
await FS.isReadOnly(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
/**
* 用于移动当前要素位置到第一个要素,使第一个要素成为当前要素。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async moveFirst(){
try{
await FS.moveFirst(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
/**
* 用于移动当前要素位置到最后一个要素,使最后一个要素成为当前要素。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async moveLast(){
try{
await FS.moveLast(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
/**
* 移动当前要素位置到下一个要素,使该要素成为当前要素。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async moveNext(){
try{
await FS.moveNext(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
/**
* 移动当前要素位置到上一个要素,使该要素成为当前要素。
* @memberOf FeatureSet
* @returns {Promise.<void>}
*/
async movePrev(){
try{
await FS.movePrev(this._SMFeatureSetId);
}catch (e){
console.error(e);
}
}
}