Skip to content

Commit c722836

Browse files
committed
【fix】wms130 bounds顺序跟投影轴顺序关联
1 parent 1c99bb5 commit c722836

File tree

3 files changed

+71
-12
lines changed

3 files changed

+71
-12
lines changed

src/common/mapping/WebMapV2.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
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 cloneDeep from 'lodash.clonedeep';
5-
import { getProjection, registerProjection, toEpsgCode, transformCoodinates } from './utils/epsg-define';
6-
import { ColorsPickerUtil } from '../util/ColorsPickerUtil';
75
import { Util } from '../commontypes/Util';
86
import { ArrayStatistic } from '../util/ArrayStatistic';
7+
import { ColorsPickerUtil } from '../util/ColorsPickerUtil';
98
import { FetchRequest } from '../util/FetchRequest';
9+
import { getProjection, registerProjection, toEpsgCode, transformCoodinates } from './utils/epsg-define';
1010
import { SourceListModelV2 } from './utils/SourceListModelV2';
1111
import { isSameRasterLayer, mergeFeatures } from './utils/util';
1212

@@ -124,12 +124,14 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, DataF
124124
this._mapInfo = mapInfo;
125125
const { projection } = mapInfo;
126126
let bounds, wkt;
127-
this.baseProjection = toEpsgCode(projection);
128-
let defaultWktValue = getProjection(this.baseProjection, this.specifiedProj4);
129-
130-
if (defaultWktValue) {
131-
wkt = defaultWktValue;
127+
if (projection.indexOf('EPSG') === 0) {
128+
this.baseProjection = projection;
129+
wkt = getProjection(projection, this.specifiedProj4);
130+
} else {
131+
this.baseProjection = toEpsgCode(projection);
132+
wkt = projection;
132133
}
134+
133135
if (!mapRepo.CRS.get(this.baseProjection)) {
134136
if (mapInfo.baseLayer && mapInfo.baseLayer.layerType === 'MAPBOXSTYLE') {
135137
let url = mapInfo.baseLayer.dataSource.url;
@@ -865,12 +867,17 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, DataF
865867
width: 256,
866868
height: 256
867869
};
870+
options.bbox = '{bbox}';
871+
options.crs = this.baseProjection;
868872
if (version === '1.3.0') {
869-
options.bbox = this.baseProjection === 'EPSG:4326' ? '{bbox-wms-1.3.0}' : '{bbox-epsg-3857}';
870-
options.crs = this.baseProjection;
871-
} else {
872-
options.bbox = '{bbox-epsg-3857}';
873-
options.srs = this.baseProjection;
873+
if (this.baseProjection === 'EPSG:4326') {
874+
options.bbox = '{bbox-wms-1.3.0}';
875+
} else {
876+
const proj = getProjection(this.baseProjection, this.specifiedProj4);
877+
if (proj.axis && proj.axis.indexOf('ne') === 0) {
878+
options.bbox = '{bbox-wms-1.3.0}';
879+
}
880+
}
874881
}
875882
return Util.urlAppend(url, this._getParamString(options, url));
876883
}

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,32 @@ describe('mapboxgl_WebMapV2', () => {
17971797
datavizWebmap.on('mapcreatesucceeded', callback);
17981798
});
17991799

1800+
it('add wmsLayer with 2326WKT and version is 1.3.0', (done) => {
1801+
spyOn(FetchRequest, 'get').and.callFake((url) => {
1802+
if (url.indexOf('map-world/wms130') > -1) {
1803+
return Promise.resolve(new Response(wmsCapabilitiesTextWith130));
1804+
}
1805+
return Promise.resolve(new Response(JSON.stringify({})));
1806+
});
1807+
const callback = function (data) {
1808+
expect(data).not.toBeUndefined();
1809+
expect(data.map.getSource('世界地图_Day').tiles[0].indexOf('{bbox-wms-1.3.0}')).toBeGreaterThan(-1);
1810+
done();
1811+
};
1812+
datavizWebmap = new WebMap({
1813+
...wmsLayer,
1814+
projection: 'PROJCS[\"Hong Kong 1980 Grid System\", \r\n GEOGCS[\"Hong Kong 1980\", \r\n DATUM[\"Hong Kong 1980\", \r\n SPHEROID[\"International 1924\", 6378388.0, 297.0, AUTHORITY[\"EPSG\",\"7022\"]], \r\n TOWGS84[-162.619, -276.959, -161.764, 0.067753, -2.243649, -1.158827, -1.094246], \r\n AUTHORITY[\"EPSG\",\"6611\"]], \r\n PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], \r\n UNIT[\"degree\", 0.017453292519943295], \r\n AXIS[\"lat\", NORTH], \r\n AXIS[\"lon\", EAST], \r\n AUTHORITY[\"EPSG\",\"4611\"]], \r\n PROJECTION[\"Transverse_Mercator\", AUTHORITY[\"EPSG\",\"9807\"]], \r\n PARAMETER[\"central_meridian\", 114.17855555555556], \r\n PARAMETER[\"latitude_of_origin\", 22.312133333333335], \r\n PARAMETER[\"scale_factor\", 1.0], \r\n PARAMETER[\"false_easting\", 836694.05], \r\n PARAMETER[\"false_northing\", 819069.8], \r\n UNIT[\"m\", 1.0], \r\n AXIS[\"Northing\", NORTH], \r\n AXIS[\"Easting\", EAST], \r\n AUTHORITY[\"EPSG\",\"2326\"]]',
1815+
center: { x: 113.90326937827093,y: 22.285836066567555 },
1816+
layers: [
1817+
{
1818+
...wmsLayer.layers[0],
1819+
url: 'http://fack/iserver/services/map-world/wms130/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Day?'
1820+
}
1821+
]
1822+
});
1823+
datavizWebmap.on('mapcreatesucceeded', callback);
1824+
});
1825+
18001826
it('add wmtsLayer with correct url', (done) => {
18011827
spyOn(FetchRequest, 'get').and.callFake((url) => {
18021828
if (url.indexOf('map-china400/wmts100') > -1) {

test/maplibregl/mapping/WebMapV2Spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,32 @@ describe('maplibregl_WebMapV2', () => {
17081708
datavizWebmap.on('mapcreatesucceeded', callback);
17091709
});
17101710

1711+
it('add wmsLayer with 2326WKT and version is 1.3.0', (done) => {
1712+
spyOn(FetchRequest, 'get').and.callFake((url) => {
1713+
if (url.indexOf('map-world/wms130') > -1) {
1714+
return Promise.resolve(new Response(wmsCapabilitiesTextWith130));
1715+
}
1716+
return Promise.resolve(new Response(JSON.stringify({})));
1717+
});
1718+
const callback = function (data) {
1719+
expect(data).not.toBeUndefined();
1720+
expect(data.map.getSource('世界地图_Day').tiles[0].indexOf('{bbox-wms-1.3.0}')).toBeGreaterThan(-1);
1721+
done();
1722+
};
1723+
datavizWebmap = new WebMap({
1724+
...wmsLayer,
1725+
projection: 'PROJCS[\"Hong Kong 1980 Grid System\", \r\n GEOGCS[\"Hong Kong 1980\", \r\n DATUM[\"Hong Kong 1980\", \r\n SPHEROID[\"International 1924\", 6378388.0, 297.0, AUTHORITY[\"EPSG\",\"7022\"]], \r\n TOWGS84[-162.619, -276.959, -161.764, 0.067753, -2.243649, -1.158827, -1.094246], \r\n AUTHORITY[\"EPSG\",\"6611\"]], \r\n PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], \r\n UNIT[\"degree\", 0.017453292519943295], \r\n AXIS[\"lat\", NORTH], \r\n AXIS[\"lon\", EAST], \r\n AUTHORITY[\"EPSG\",\"4611\"]], \r\n PROJECTION[\"Transverse_Mercator\", AUTHORITY[\"EPSG\",\"9807\"]], \r\n PARAMETER[\"central_meridian\", 114.17855555555556], \r\n PARAMETER[\"latitude_of_origin\", 22.312133333333335], \r\n PARAMETER[\"scale_factor\", 1.0], \r\n PARAMETER[\"false_easting\", 836694.05], \r\n PARAMETER[\"false_northing\", 819069.8], \r\n UNIT[\"m\", 1.0], \r\n AXIS[\"Northing\", NORTH], \r\n AXIS[\"Easting\", EAST], \r\n AUTHORITY[\"EPSG\",\"2326\"]]',
1726+
center: { x: 113.90326937827093,y: 22.285836066567555 },
1727+
layers: [
1728+
{
1729+
...wmsLayer.layers[0],
1730+
url: 'http://fack/iserver/services/map-world/wms130/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Day?'
1731+
}
1732+
]
1733+
});
1734+
datavizWebmap.on('mapcreatesucceeded', callback);
1735+
});
1736+
17111737
it('add wmtsLayer with correct url', (done) => {
17121738
spyOn(FetchRequest, 'get').and.callFake((url) => {
17131739
if (url.indexOf('map-china400/wmts100') > -1) {

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