Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0367cb4

Browse files
common mapcalculateutil 新增方法 review by luox
1 parent95e922f commit0367cb4

File tree

4 files changed

+105
-47
lines changed

4 files changed

+105
-47
lines changed

‎src/common/format/JSON.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export class JSONFormat extends Format {
234234
object=JSON.parse(json,filter);
235235
}catch(e){
236236
// Fall through if the regexp test fails.
237+
return{data:json}
237238
}
238239
}
239240

‎src/common/iServer/CommonServiceBase.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export class CommonServiceBase {
143143
options.crossOrigin=options.crossOrigin!=undefined ?options.crossOrigin :me.crossOrigin;
144144
options.headers=options.headers||me.headers;
145145
options.isInTheSameDomain=me.isInTheSameDomain;
146+
options.withoutFormatSuffix=options.scope.withoutFormatSuffix||false;
146147
//为url添加安全认证信息片段
147148
options.url=SecurityManager.appendCredential(options.url);
148149

@@ -277,6 +278,7 @@ export class CommonServiceBase {
277278
}
278279
FetchRequest.commit(options.method,options.url,options.params,{
279280
headers:options.headers,
281+
withoutFormatSuffix:options.withoutFormatSuffix,
280282
withCredentials:options.withCredentials,
281283
crossOrigin:options.crossOrigin,
282284
timeout:options.async ?0 :null,

‎src/common/util/MapCalculateUtil.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,42 @@ export function conversionDegree(degrees) {
111111
second=parseInt(second/10)===0 ?`0${second}` :second;
112112
return`${degree}°${fraction}'${second}`;
113113
}
114+
115+
exportfunctionscalesToResolutions(scales,bounds,dpi,unit,level=22){
116+
varresolutions=[];
117+
if(scales&&scales.length>0){
118+
for(leti=0;i<scales.length;i++){
119+
resolutions.push(scaleToResolution(scales[i],dpi,unit));
120+
}
121+
}else{
122+
constmaxReolution=Math.abs(bounds.left-bounds.right)/256;
123+
for(leti=0;i<level;i++){
124+
resolutions.push(maxReolution/Math.pow(2,i));
125+
}
126+
}
127+
returnresolutions.sort(function(a,b){
128+
returnb-a;
129+
});
130+
}
131+
132+
exportfunctiongetZoomByResolution(resolution,resolutions){
133+
letzoom=0;
134+
letminDistance;
135+
for(leti=0;i<resolutions.length;i++){
136+
if(i===0){
137+
minDistance=Math.abs(resolution-resolutions[i]);
138+
}
139+
if(minDistance>Math.abs(resolution-resolutions[i])){
140+
minDistance=Math.abs(resolution-resolutions[i]);
141+
zoom=i;
142+
}
143+
}
144+
returnzoom;
145+
}
146+
147+
exportfunctionscaleToResolution(scale,dpi,mapUnit){
148+
constinchPerMeter=1/0.0254;
149+
constmeterPerMapUnitValue=getMeterPerMapUnit(mapUnit);
150+
constresolution=1/(scale*dpi*inchPerMeter*meterPerMapUnitValue);
151+
returnresolution;
152+
}
Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4-
import{ServiceBase}from'./ServiceBase';
4+
import{ServiceBase}from'./ServiceBase';
55
import{MapServiceasCommonMapService}from'@supermap/iclient-common/iServer/MapService';
66
import{TilesetsService}from'@supermap/iclient-common/iServer/TilesetsService';
7-
87
/**
98
*@class MapService
109
*@category iServer Map
@@ -23,52 +22,69 @@ import { TilesetsService } from '@supermap/iclient-common/iServer/TilesetsServic
2322
*@usage
2423
*/
2524
exportclassMapServiceextendsServiceBase{
25+
constructor(url,options){
26+
super(url,options);
27+
}
2628

27-
constructor(url,options){
28-
super(url,options);
29-
}
29+
/**
30+
*@function MapService.prototype.getMapInfo
31+
*@description 地图信息查询服务。
32+
*@param {RequestCallback} callback - 回调函数。
33+
*@returns {MapService} 获取服务信息。
34+
*/
35+
getMapInfo(callback){
36+
varme=this;
37+
vargetMapStatusService=newCommonMapService(me.url,{
38+
proxy:me.options.proxy,
39+
withCredentials:me.options.withCredentials,
40+
crossOrigin:me.options.crossOrigin,
41+
headers:me.options.headers,
42+
eventListeners:{
43+
scope:me,
44+
processCompleted:callback,
45+
processFailed:callback
46+
},
47+
projection:me.options.projection
48+
});
49+
getMapStatusService.processAsync();
50+
}
3051

31-
/**
32-
*@function MapService.prototype.getMapInfo
33-
*@description 地图信息查询服务。
34-
*@param {RequestCallback} callback - 回调函数。
35-
*@returns {MapService} 获取服务信息。
36-
*/
37-
getMapInfo(callback){
38-
varme=this;
39-
vargetMapStatusService=newCommonMapService(me.url,{
40-
proxy:me.options.proxy,
41-
withCredentials:me.options.withCredentials,
42-
crossOrigin:me.options.crossOrigin,
43-
headers:me.options.headers,
44-
eventListeners:{
45-
scope:me,
46-
processCompleted:callback,
47-
processFailed:callback
48-
},projection:me.options.projection
49-
});
50-
getMapStatusService.processAsync();
51-
}
52+
getWkt(callback){
53+
varme=this;
54+
vargetMapStatusService=newCommonMapService(`${me.url}/prjCoordSys.wkt`,{
55+
proxy:me.options.proxy,
56+
withCredentials:me.options.withCredentials,
57+
withoutFormatSuffix:true,
58+
crossOrigin:me.options.crossOrigin,
59+
headers:me.options.headers,
60+
eventListeners:{
61+
scope:me,
62+
processCompleted:callback,
63+
processFailed:callback
64+
},projection:me.options.projection
65+
});
66+
getMapStatusService.processAsync();
67+
}
5268

53-
/**
54-
*@function MapService.prototype.getTilesets
55-
*@description 切片列表信息查询服务。
56-
*@param {RequestCallback} callback - 回调函数。
57-
*@returns {MapService} 获取服务信息。
58-
*/
59-
getTilesets(callback){
60-
varme=this;
61-
vartilesetsService=newTilesetsService(me.url,{
62-
proxy:me.options.proxy,
63-
withCredentials:me.options.withCredentials,
64-
crossOrigin:me.options.crossOrigin,
65-
headers:me.options.headers,
66-
eventListeners:{
67-
scope:me,
68-
processCompleted:callback,
69-
processFailed:callback
70-
}
71-
});
72-
tilesetsService.processAsync();
73-
}
69+
/**
70+
*@function MapService.prototype.getTilesets
71+
*@description 切片列表信息查询服务。
72+
*@param {RequestCallback} callback - 回调函数。
73+
*@returns {MapService} 获取服务信息。
74+
*/
75+
getTilesets(callback){
76+
varme=this;
77+
vartilesetsService=newTilesetsService(me.url,{
78+
proxy:me.options.proxy,
79+
withCredentials:me.options.withCredentials,
80+
crossOrigin:me.options.crossOrigin,
81+
headers:me.options.headers,
82+
eventListeners:{
83+
scope:me,
84+
processCompleted:callback,
85+
processFailed:callback
86+
}
87+
});
88+
tilesetsService.processAsync();
89+
}
7490
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp