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

Method toJson

src/common/iServer/Route.js:120–164  ·  view source on GitHub ↗

* * @function Route.prototype.toJson * @description 转换为 JSON 对象。 * @returns {Object} JSON 对象。

()

Source from the content-addressed store, hash-verified

118 * @returns {Object} JSON 对象。
119 */
120 toJson() {
121 var result = "{";
122 if (this.id != null && this.id != undefined) {
123 result += "\"id\":" + this.id + ",";
124 }
125 if (this.center != null && this.center != undefined) {
126 result += "\"center\":" + this.center + ",";
127 }
128 if (this.style != null && this.style != undefined) {
129 result += "\"style\":" + this.style + ",";
130 }
131 if (this.length != null && this.length != undefined) {
132 result += "\"length\":" + this.length + ",";
133 }
134 if (this.maxM != null && this.maxM != undefined) {
135 result += "\"maxM\":" + this.maxM + ",";
136 }
137 if (this.minM != null && this.minM != undefined) {
138 result += "\"minM\":" + this.minM + ",";
139 }
140 if (this.type != null && this.type != undefined) {
141 result += "\"type\":\"" + this.type + "\",";
142 }
143 if (this.parts != null && this.parts != undefined) {
144 result += "\"parts\":[" + this.parts[0];
145
146 for (var i = 1; i < this.parts.length; i++) {
147 result += "," + this.parts[i];
148 }
149 result += "],";
150 }
151 if (this.components != null && this.components.length > 0) {
152 result += "\"points\":[";
153 for (var j = 0, len = this.components.length; j < len; j++) {
154 for (var k = 0, len2 = this.components[j].components.length; k < len2; k++) {
155 result += this.components[j].components[k].toJson() + ",";
156 }
157 }
158 result = result.replace(/,$/g, '');
159 result += "]";
160 }
161 result = result.replace(/,$/g, '');
162 result += "}";
163 return result;
164 }
165
166
167 /**

Callers 4

RouteSpec.jsFile · 0.45
toJsonParametersMethod · 0.45
getVariablesJsonMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected