forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
87 lines (79 loc) · 2.63 KB
/
index.js
File metadata and controls
87 lines (79 loc) · 2.63 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
/* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
* This program are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
import {
setCORS,
isCORS,
setRequestTimeout,
getRequestTimeout,
setRequestHeaders,
FetchRequest
} from './FetchRequest';
import { ColorsPickerUtil } from './ColorsPickerUtil';
import { EncryptRequest, getServiceKey } from './EncryptRequest';
import { ArrayStatistic } from './ArrayStatistic';
import { getMeterPerMapUnit, getWrapNum, conversionDegree } from './MapCalculateUtil';
import { Point as GeometryPoint } from "../commontypes/geometry/Point";
import { Polygon } from "../commontypes/geometry/Polygon";
import { LinearRing } from "../commontypes/geometry/LinearRing";
import { GeoJSON as GeoJSONFormat } from "../format/GeoJSON";
import { GeometryAnalysis } from './GeometryAnalysis';
function toSuperMapGeometry(geoJSON) {
if (geoJSON && geoJSON.type) {
var format = new GeoJSONFormat();
var result = format.read(geoJSON, "FeatureCollection");
return result[0].geometry;
}
}
function toSuperMapPolygon(lnglatBounds) {
const west = lnglatBounds.getWest();
const east = lnglatBounds.getEast();
const sourth = lnglatBounds.getSouth();
const north = lnglatBounds.getNorth();
return new Polygon([
new LinearRing([
new GeometryPoint(west, sourth),
new GeometryPoint(east, sourth),
new GeometryPoint(east, north),
new GeometryPoint(west, north)
])
]);
}
function extend(dest) {
for (var index = 0; index < Object.getOwnPropertyNames(arguments).length; index++) {
var arg = Object.getOwnPropertyNames(arguments)[index];
if (arg == "caller" || arg == "callee" || arg == "length" || arg == "arguments") {
continue;
}
var obj = arguments[arg];
if (obj) {
for (var j = 0; j < Object.getOwnPropertyNames(obj).length; j++) {
var key = Object.getOwnPropertyNames(obj)[j];
if (arg == "caller" || arg == "callee" || arg == "length" || arg == "arguments") {
continue;
}
dest[key] = obj[key];
}
}
}
return dest;
}
export {
toSuperMapPolygon,
toSuperMapGeometry,
setCORS,
isCORS,
setRequestTimeout,
getRequestTimeout,
setRequestHeaders,
FetchRequest,
EncryptRequest,
getServiceKey,
ColorsPickerUtil,
ArrayStatistic,
getMeterPerMapUnit,
getWrapNum,
conversionDegree,
extend,
GeometryAnalysis
};