Skip to content

Commit dfa4272

Browse files
committed
2 parents 5b25db5 + bf878bf commit dfa4272

File tree

15 files changed

+312
-111
lines changed

15 files changed

+312
-111
lines changed

dist/mapboxgl/include-mapboxgl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
inputScript(libsurl + '/mapbox-gl-js/1.13.2/mapbox-gl.js');
6060
}
6161
if (inArray(includes, 'mapbox-gl-enhance')) {
62-
inputCSS(libsurl + '/mapbox-gl-js-enhance/1.12.1-8/mapbox-gl-enhance.css');
63-
inputScript(libsurl + '/mapbox-gl-js-enhance/1.12.1-8/mapbox-gl-enhance.js');
62+
inputCSS(libsurl + '/mapbox-gl-js-enhance/1.12.1-9/mapbox-gl-enhance.css');
63+
inputScript(libsurl + '/mapbox-gl-js-enhance/1.12.1-9/mapbox-gl-enhance.js');
6464
}
6565
if (inArray(includes, 'L7')) {
6666
inputScript(libsurl + '/mapboxgl-l7-render/0.0.2/mapboxgl-l7-render.js');

dist/maplibregl/include-maplibregl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
inputScript(libsurl + '/maplibre-gl-js/4.3.2/maplibre-gl.min.js');
6060
}
6161
if (inArray(includes, 'maplibre-gl-enhance')) {
62-
inputCSS(libsurl + '/maplibre-gl-js-enhance/4.3.0-4/maplibre-gl-enhance.css');
63-
inputScript(libsurl + '/maplibre-gl-js-enhance/4.3.0-4/maplibre-gl-enhance.js');
62+
inputCSS(libsurl + '/maplibre-gl-js-enhance/4.3.0-5/maplibre-gl-enhance.css');
63+
inputScript(libsurl + '/maplibre-gl-js-enhance/4.3.0-5/maplibre-gl-enhance.js');
6464
}
6565
if (inArray(includes, 'L7')) {
6666
inputScript(libsurl + '/maplibregl-l7-render/0.0.2/maplibregl-l7-render.js');

examples/leaflet/imageService.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ <h4 class="modal-title" id="myModalLabel"></h4>
464464
}
465465

466466
function drawCompleted(e) {
467-
var bounds = e.layer._bounds;
467+
var bounds = e.layer.getBounds();
468468
var _northEast = bounds._northEast;
469469
var _southWest = bounds._southWest;
470470
plotBbox = [_southWest.lng, _southWest.lat, _northEast.lng, _northEast.lat];

examples/leaflet/turf_gridAnalysis.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201

202202
function mapDrawListener(e) {
203203
var layer = e.layer;
204-
var layerBounds = layer._bounds;
204+
var layerBounds = layer.getBounds();
205205
if (!bounds.contains(layerBounds)) {
206206
widgets.alert.showAlert(resources.msg_beyondScope, false);
207207
return;

src/common/commontypes/geometry/LinearRing.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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.*/
44
import {LineString} from './LineString';
5+
import {Util} from '../Util';
56

67
/**
78
* @class GeometryLinearRing
@@ -36,6 +37,20 @@ export class LinearRing extends LineString {
3637
this.geometryType = "LinearRing";
3738
}
3839

40+
41+
addComponents(components) {
42+
if (!(Util.isArray(components))) {
43+
components = [components];
44+
}
45+
let len = components.length;
46+
if (len > 1 && components[0].equals(components[components.length - 1])) {
47+
len = components.length - 1;
48+
}
49+
for (var i = 0; i < len; i++) {
50+
this.addComponent(components[i]);
51+
}
52+
}
53+
3954
/**
4055
* @function GeometryLinearRing.prototype.addComponent
4156
* @description 添加一个点到几何图形数组中,如果这个点将要被添加到组件数组的末端,并且与数组中已经存在的最后一个点相同,
@@ -49,18 +64,17 @@ export class LinearRing extends LineString {
4964
var added = false;
5065

5166
//remove last point
52-
var lastPoint = this.components.pop();
67+
this.components.pop();
5368

5469
// given an index, add the point
5570
// without an index only add non-duplicate points
56-
if (index != null || !point.equals(lastPoint)) {
71+
if (index != null || !point.equals(this.components[this.components.length - 1])) {
5772
added = super.addComponent.apply(this, arguments);
5873
}
5974

6075
//append copy of first point
6176
var firstPoint = this.components[0];
6277
super.addComponent.apply(this, [firstPoint]);
63-
6478
return added;
6579
}
6680

src/common/mapping/WebMapV3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
315315
}
316316
return (url, resourceType) => {
317317
if (resourceType === 'Tile') {
318-
const withCredentials = this.options.iportalServiceProxyUrl && url.indexOf(this.options.iportalServiceProxyUrl) >= 0;
318+
const withCredentials = this.options.iportalServiceProxyUrlPrefix && url.indexOf(this.options.iportalServiceProxyUrlPrefix) >= 0;
319319
return {
320320
url: url,
321321
credentials: withCredentials ? 'include' : undefined,

src/common/mapping/utils/L7LayerUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ export function L7LayerUtil(config) {
426426
}
427427

428428
function isIportalProxyServiceUrl(url, options) {
429-
return options.iportalServiceProxyUrl && url.indexOf(options.iportalServiceProxyUrl) >= 0;
429+
return options.iportalServiceProxyUrlPrefix && url.indexOf(options.iportalServiceProxyUrlPrefix) >= 0;
430430
}
431431

432432
function handleWithRequestOptions(url, options) {

src/leaflet/core/Base.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ L.GeoJSON.include({
126126
layer.feature = L.GeoJSON.asFeature(geojson);
127127

128128
layer.defaultOptions = layer.options;
129-
var defaultGeometryOptions = this.defaultGeometryOptions[geometry.type];
130-
if (defaultGeometryOptions) {
131-
layer.commonOptions = Object.assign({}, defaultGeometryOptions);
132-
} else {
133-
this.defaultGeometryOptions[geometry.type] = L.Util.extend({}, layer.defaultOptions);
129+
if (this.defaultGeometryOptions) {
130+
var defaultGeometryOptions = this.defaultGeometryOptions[geometry.type];
131+
if (defaultGeometryOptions) {
132+
layer.commonOptions = Object.assign({}, defaultGeometryOptions);
133+
} else {
134+
this.defaultGeometryOptions[geometry.type] = L.Util.extend({}, layer.defaultOptions);
135+
}
134136
}
135137
this.resetStyle(layer);
136138

src/leaflet/mapping/TiledMapLayer.js

Lines changed: 84 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/* Copyright© 2000 - 2024 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 L from 'leaflet';
5-
import '../core/Base';
6-
import { SecurityManager } from '@supermapgis/iclient-common/security/SecurityManager';
7-
import { ServerGeometry } from '@supermapgis/iclient-common/iServer/ServerGeometry';
8-
import { Unit } from '@supermapgis/iclient-common/REST';
9-
import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util';
10-
11-
import * as Util from '../core/Util';
12-
import Attributions from '../core/Attributions';
4+
import L from 'leaflet';
5+
import '../core/Base';
6+
import { SecurityManager } from '@supermapgis/iclient-common/security/SecurityManager';
7+
import { ServerGeometry } from '@supermapgis/iclient-common/iServer/ServerGeometry';
8+
import { Unit } from '@supermapgis/iclient-common/REST';
9+
import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util';
1310

11+
import * as Util from '../core/Util';
12+
import Attributions from '../core/Attributions';
1413
/**
1514
* @class TiledMapLayer
1615
* @deprecatedclassinstance L.supermap.tiledMapLayer
@@ -41,12 +40,12 @@
4140
* @param {string} [options.attribution='Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' title='SuperMap iServer' target='_blank'>SuperMap iServer</a></span>'] - 版权描述信息。
4241
* @param {Array.<number>} [options.subdomains] - 子域名数组。
4342
* @param {ChartSetting} [options.chartSetting] - 海图显示参数设置类,用于管理海图显示环境,包括海图的显示模式、显示类型名称、颜色模式、安全水深线等各种显示风格。
43+
* @param {number} [options.overflowTiles = 0] - 绘制超出图层范围的瓦片圈数。常用于位于地图边缘的要素符号显示不全的场景。默认值为0,表示不绘制超出图层范围的瓦片。当 options.noWrap 为 true 时,overflowTiles有效。
4444
* @fires TiledMapLayer#tilesetsinfoloaded
4545
* @fires TiledMapLayer#tileversionschanged
4646
* @usage
4747
*/
4848
export var TiledMapLayer = L.TileLayer.extend({
49-
5049
options: {
5150
//如果有layersID,则是在使用专题图
5251
layersID: null,
@@ -68,9 +67,10 @@ export var TiledMapLayer = L.TileLayer.extend({
6867
crs: null,
6968
format: 'png',
7069
//启用托管地址。
71-
tileProxy:null,
70+
tileProxy: null,
7271
attribution: Attributions.Common.attribution,
73-
subdomains: null
72+
subdomains: null,
73+
overflowTiles: 0
7474
},
7575

7676
initialize: function (url, options) {
@@ -94,7 +94,52 @@ export var TiledMapLayer = L.TileLayer.extend({
9494
this._crs = this.options.crs || map.options.crs;
9595
L.TileLayer.prototype.onAdd.call(this, map);
9696
},
97+
/**
98+
* @override
99+
* @private
100+
*/
101+
_resetGrid: function () {
102+
L.TileLayer.prototype._resetGrid.call(this);
103+
const overflowTiles = this.options.overflowTiles;
104+
if (this._globalTileRange && overflowTiles && this.options.noWrap) {
105+
this._globalTileRange.min = this._globalTileRange.min.subtract([overflowTiles, overflowTiles]);
106+
this._globalTileRange.max = this._globalTileRange.max.add([overflowTiles, overflowTiles]);
107+
}
108+
if (this.options.bounds && this.options.noWrap && overflowTiles) {
109+
const bounds = L.latLngBounds(this.options.bounds);
110+
const sw = bounds.getSouthWest();
111+
const ne = bounds.getNorthEast();
112+
this._boundsTileRange = this._pxBoundsToTileRange(L.bounds(this._crs.latLngToPoint(sw, this._tileZoom), this._crs.latLngToPoint(ne, this._tileZoom)));
113+
this._boundsTileRange.min = this._boundsTileRange.min.subtract([overflowTiles, overflowTiles]);
114+
this._boundsTileRange.max = this._boundsTileRange.max.add([overflowTiles, overflowTiles]);
97115

116+
}
117+
},
118+
/**
119+
* @override
120+
* @private
121+
*/
122+
_isValidTile: function (coords) {
123+
const crs = this._map.options.crs;
124+
if (!crs.infinite) {
125+
const bounds = this._globalTileRange;
126+
if (
127+
((!crs.wrapLng || this.options.noWrap) && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||
128+
(!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))
129+
) {
130+
return false;
131+
}
132+
}
133+
if (!this.options.bounds) {
134+
return true;
135+
}
136+
if (this._boundsTileRange && this.options.noWrap) {
137+
return coords.x >= this._boundsTileRange.min.x && coords.x <= this._boundsTileRange.max.x && coords.y >= this._boundsTileRange.min.y && coords.y <= this._boundsTileRange.max.y;
138+
} else {
139+
var tileBounds = this._tileCoordsToBounds(coords);
140+
return L.latLngBounds(this.options.bounds).overlaps(tileBounds);
141+
}
142+
},
98143
/**
99144
* @function TiledMapLayer.prototype.getTileUrl
100145
* @description 根据行列号获取瓦片地址。
@@ -104,16 +149,16 @@ export var TiledMapLayer = L.TileLayer.extend({
104149
getTileUrl: function (coords) {
105150
var scale = this.getScaleFromCoords(coords);
106151
var layerUrl = this._getLayerUrl();
107-
var tileUrl = layerUrl + "&scale=" + scale + "&x=" + coords.x + "&y=" + coords.y;
152+
var tileUrl = layerUrl + '&scale=' + scale + '&x=' + coords.x + '&y=' + coords.y;
108153
//支持代理
109154
if (this.options.tileProxy) {
110155
tileUrl = this.options.tileProxy + encodeURIComponent(tileUrl);
111156
}
112157
if (!this.options.cacheEnabled) {
113-
tileUrl += "&_t=" + new Date().getTime();
158+
tileUrl += '&_t=' + new Date().getTime();
114159
}
115160
if (this.options.subdomains) {
116-
tileUrl = L.Util.template(tileUrl, {s: this._getSubdomain(coords)});
161+
tileUrl = L.Util.template(tileUrl, { s: this._getSubdomain(coords) });
117162
}
118163
return tileUrl;
119164
},
@@ -165,10 +210,7 @@ export var TiledMapLayer = L.TileLayer.extend({
165210
var ne = crs.project(tileBounds.getNorthEast());
166211
var sw = crs.project(tileBounds.getSouthWest());
167212
var tileSize = me.options.tileSize;
168-
var resolution = Math.max(
169-
Math.abs(ne.x - sw.x) / tileSize,
170-
Math.abs(ne.y - sw.y) / tileSize
171-
);
213+
var resolution = Math.max(Math.abs(ne.x - sw.x) / tileSize, Math.abs(ne.y - sw.y) / tileSize);
172214
var mapUnit = Unit.METER;
173215
if (crs.code) {
174216
var array = crs.code.split(':');
@@ -181,7 +223,6 @@ export var TiledMapLayer = L.TileLayer.extend({
181223
}
182224
},
183225

184-
185226
/**
186227
* @function TiledMapLayer.prototype.setTileSetsInfo
187228
* @description 设置瓦片集信息。
@@ -275,7 +316,7 @@ export var TiledMapLayer = L.TileLayer.extend({
275316
*/
276317
mergeTileVersionParam: function (version) {
277318
if (version) {
278-
this.requestParams["tileversion"] = version;
319+
this.requestParams['tileversion'] = version;
279320
this._paramsChanged = true;
280321
this.redraw();
281322
this._paramsChanged = false;
@@ -288,11 +329,11 @@ export var TiledMapLayer = L.TileLayer.extend({
288329
* @description 更新参数。
289330
* @param {Object} params - 参数对象。
290331
*/
291-
updateParams: function(params) {
292-
Object.assign(this.requestParams, params);
293-
this._paramsChanged = true;
294-
this.redraw();
295-
this._paramsChanged = false;
332+
updateParams: function (params) {
333+
Object.assign(this.requestParams, params);
334+
this._paramsChanged = true;
335+
this.redraw();
336+
this._paramsChanged = false;
296337
},
297338

298339
_getLayerUrl: function () {
@@ -320,60 +361,60 @@ export var TiledMapLayer = L.TileLayer.extend({
320361
if (!(tileSize instanceof L.Point)) {
321362
tileSize = L.point(tileSize, tileSize);
322363
}
323-
params["width"] = tileSize.x;
324-
params["height"] = tileSize.y;
364+
params['width'] = tileSize.x;
365+
params['height'] = tileSize.y;
325366

326-
params["redirect"] = options.redirect === true;
327-
params["transparent"] = options.transparent === true;
328-
params["cacheEnabled"] = !(options.cacheEnabled === false);
367+
params['redirect'] = options.redirect === true;
368+
params['transparent'] = options.transparent === true;
369+
params['cacheEnabled'] = !(options.cacheEnabled === false);
329370

330371
if (options.prjCoordSys) {
331-
params["prjCoordSys"] = JSON.stringify(options.prjCoordSys);
372+
params['prjCoordSys'] = JSON.stringify(options.prjCoordSys);
332373
}
333374

334375
if (options.layersID) {
335-
params["layersID"] = options.layersID.toString();
376+
params['layersID'] = options.layersID.toString();
336377
}
337378

338379
if (options.clipRegionEnabled && options.clipRegion) {
339380
options.clipRegion = ServerGeometry.fromGeometry(Util.toSuperMapGeometry(options.clipRegion));
340-
params["clipRegionEnabled"] = options.clipRegionEnabled;
341-
params["clipRegion"] = JSON.stringify(options.clipRegion);
381+
params['clipRegionEnabled'] = options.clipRegionEnabled;
382+
params['clipRegion'] = JSON.stringify(options.clipRegion);
342383
}
343384

344385
//切片的起始参考点,默认为地图范围的左上角。
345386
var crs = me._crs;
346387
if (crs.options && crs.options.origin) {
347-
params["origin"] = JSON.stringify({
388+
params['origin'] = JSON.stringify({
348389
x: crs.options.origin[0],
349390
y: crs.options.origin[1]
350391
});
351392
} else if (crs.projection && crs.projection.bounds) {
352393
var bounds = crs.projection.bounds;
353394
var tileOrigin = L.point(bounds.min.x, bounds.max.y);
354-
params["origin"] = JSON.stringify({
395+
params['origin'] = JSON.stringify({
355396
x: tileOrigin.x,
356397
y: tileOrigin.y
357398
});
358399
}
359400

360401
if (options.overlapDisplayed === false) {
361-
params["overlapDisplayed"] = false;
402+
params['overlapDisplayed'] = false;
362403
if (options.overlapDisplayedOptions) {
363-
params["overlapDisplayedOptions"] = options.overlapDisplayedOptions;
404+
params['overlapDisplayedOptions'] = options.overlapDisplayedOptions;
364405
}
365406
} else {
366-
params["overlapDisplayed"] = true;
407+
params['overlapDisplayed'] = true;
367408
}
368409

369410
if (params.cacheEnabled === true && options.tileversion) {
370-
params["tileversion"] = options.tileversion.toString();
411+
params['tileversion'] = options.tileversion.toString();
371412
}
372413
if (options.rasterfunction) {
373-
params["rasterfunction"] = JSON.stringify(options.rasterfunction);
414+
params['rasterfunction'] = JSON.stringify(options.rasterfunction);
374415
}
375416
if (options.chartSetting) {
376-
params["chartSetting"] = JSON.stringify(options.chartSetting);
417+
params['chartSetting'] = JSON.stringify(options.chartSetting);
377418
}
378419

379420
return params;

test/common/commontypes/geometry/LinearRingSpec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,22 @@ describe('LinearRing', function () {
4747
expect(pointList2).not.toBeNull();
4848
expect(pointList2.length).toEqual(5);
4949
});
50+
51+
it('addComponent_duplicate_points', function () {
52+
// 第一个点和第4个点一样,但是应该正常渲染,不应该丢弃 ICL-1570
53+
var pointsRing = [
54+
new GeometryPoint(83.4923281624, 63.2826847261),// 1
55+
new GeometryPoint(86.2710459516, 66.4473355416),// 2
56+
new GeometryPoint(80.7522036759, 66.4473355416),// 3
57+
new GeometryPoint(83.4923281624, 63.2826847261),// 4
58+
new GeometryPoint(78.9383184524, 63.2826847261),// 5
59+
new GeometryPoint(78.9383184524, 69.9979193833),// 6
60+
new GeometryPoint(88.3936775961, 69.9979193833),// 7
61+
new GeometryPoint(88.3936775961, 63.4370579366),// 8
62+
new GeometryPoint(83.4923281624, 63.2826847261)
63+
];
64+
var ring = new GeometryLinearRing(pointsRing);
65+
expect(ring.components.length).toEqual(9);
66+
expect(ring.components[3].x).toEqual(83.4923281624);
67+
});
5068
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy