Skip to content

Commit 40eee05

Browse files
2 parents 0295d2f + 5299a86 commit 40eee05

File tree

3 files changed

+100
-34
lines changed

3 files changed

+100
-34
lines changed

src/common/mapping/WebMapV2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
130130
extent: [extent.leftBottom.x, extent.leftBottom.y, extent.rightTop.x, extent.rightTop.y],
131131
wkt: this._getProjectionWKT(projection)
132132
};
133-
if (!crsManager.getCRS(epsgCode)) {
133+
if (!crsManager.getCRS(epsgCode) && baseLayer.layerType !== 'ZXY_TILE') {
134134
switch (baseLayer.layerType) {
135135
case 'MAPBOXSTYLE': {
136136
let url = baseLayer.dataSource.url;

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,9 @@ describe('mapboxgl_WebMapV2', () => {
18221822
};
18231823
datavizWebmap = new WebMap({
18241824
...wmsLayer,
1825-
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\"]]',
1826-
center: { x: 113.90326937827093,y: 22.285836066567555 },
1825+
projection:
1826+
'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"]]',
1827+
center: { x: 113.90326937827093, y: 22.285836066567555 },
18271828
layers: [
18281829
{
18291830
...wmsLayer.layers[0],
@@ -2096,7 +2097,7 @@ describe('mapboxgl_WebMapV2', () => {
20962097
return Promise.resolve(new Response(JSON.stringify({})));
20972098
});
20982099
const iportalServiceProxyUrl = 'http://localhost:8195/portalproxy';
2099-
const tileCustomRequestHeaders = { 'Authorization': 'test token' };
2100+
const tileCustomRequestHeaders = { Authorization: 'test token' };
21002101
datavizWebmap = new WebMap(vectorLayer_line, {
21012102
...commonOption,
21022103
iportalServiceProxyUrlPrefix: iportalServiceProxyUrl,
@@ -2808,6 +2809,38 @@ describe('mapboxgl_WebMapV2', () => {
28082809
done();
28092810
});
28102811
});
2812+
it('initial_xyzLayer jingjin 2326', (done) => {
2813+
spyOn(FetchRequest, 'get').and.callFake((url) => {
2814+
if (url.indexOf('map.json') > -1) {
2815+
return Promise.resolve(new Response(JSON.stringify(xyzLayer2326)));
2816+
} else if (url.indexOf('portal.json') > -1) {
2817+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
2818+
}
2819+
return Promise.resolve(new Response(JSON.stringify({})));
2820+
});
2821+
const map = {
2822+
...commonMap,
2823+
getCRS: () => {
2824+
return {
2825+
epsgCode: 'EPSG:2326',
2826+
unit: 'degrees',
2827+
getExtent: () => [-4786700, -31721916.685568035, 35288316.685568035, 8353100]
2828+
};
2829+
}
2830+
};
2831+
datavizWebmap = new WebMap(id, {
2832+
server: server,
2833+
map
2834+
});
2835+
datavizWebmap.on('mapcreatesucceeded', ({ map }) => {
2836+
const layers = map.getStyle().layers;
2837+
expect(layers.length).toBe(1);
2838+
const xyzLayer = layers[0];
2839+
expect(xyzLayer.id).toBe('2326底图');
2840+
expect(xyzLayer.type).toBe('raster');
2841+
done();
2842+
});
2843+
});
28112844
it('initial_mapboxstyleLayer', (done) => {
28122845
spyOn(FetchRequest, 'get').and.callFake((url) => {
28132846
if (url.indexOf('map.json') > -1) {
@@ -3336,7 +3369,7 @@ describe('mapboxgl_WebMapV2', () => {
33363369
it('updateOverlayLayer featureProjection', (done) => {
33373370
spyOn(FetchRequest, 'get').and.callFake((url) => {
33383371
if (url.indexOf('map.json') > -1) {
3339-
webmap_rangeLayer.layers.map(item => {
3372+
webmap_rangeLayer.layers.map((item) => {
33403373
item.projection = 'EPSG:3857';
33413374
});
33423375
return Promise.resolve(new Response(JSON.stringify(webmap_rangeLayer)));
@@ -3394,7 +3427,8 @@ describe('mapboxgl_WebMapV2', () => {
33943427
it('when uncommon crs was defined, dont set repeat', (done) => {
33953428
const mapInfo = JSON.parse(raster4490);
33963429
const epsgCode = 'EPSG:4214';
3397-
const wkt_4214 = 'GEOGCS["Beijing 1954",DATUM["Beijing_1954",SPHEROID["Krassowsky 1940",6378245,298.3],TOWGS84[15.8,-154.4,-82.3,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4214"]]';
3430+
const wkt_4214 =
3431+
'GEOGCS["Beijing 1954",DATUM["Beijing_1954",SPHEROID["Krassowsky 1940",6378245,298.3],TOWGS84[15.8,-154.4,-82.3,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4214"]]';
33983432
mapInfo.projection = wkt_4214;
33993433
spyOn(FetchRequest, 'get').and.callFake((url) => {
34003434
if (url.indexOf('portal.json') > -1) {
@@ -3475,14 +3509,11 @@ describe('mapboxgl_WebMapV2', () => {
34753509
});
34763510
const originCrs = mapboxgl.CRS.get(epsgCode);
34773511
const crsSetSpy = spyOn(mapboxgl.CRS, 'set').and.callThrough();
3478-
datavizWebmap = new WebMap(
3479-
'123',
3480-
{
3481-
target: 'map',
3482-
serverUrl: 'http://fake/fakeiportal',
3483-
withCredentials: false
3484-
}
3485-
);
3512+
datavizWebmap = new WebMap('123', {
3513+
target: 'map',
3514+
serverUrl: 'http://fake/fakeiportal',
3515+
withCredentials: false
3516+
});
34863517
datavizWebmap.once('mapcreatesucceeded', ({ map: map1 }) => {
34873518
expect(originCrs).toBeFalsy();
34883519
expect(mapboxgl.CRS.get(epsgCode)).toBeTruthy();
@@ -3512,7 +3543,8 @@ describe('mapboxgl_WebMapV2', () => {
35123543
const mapInfo = JSON.parse(raster4490);
35133544
const epsgCode = 'EPSG:4215';
35143545
mapInfo.projection = epsgCode;
3515-
const wkt_4215 = 'GEOGCS["Beijing 1954",DATUM["Beijing_1954",SPHEROID["Krassowsky 1940",6378245,298.3],TOWGS84[15.8,-154.4,-82.3,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4215"]]';
3546+
const wkt_4215 =
3547+
'GEOGCS["Beijing 1954",DATUM["Beijing_1954",SPHEROID["Krassowsky 1940",6378245,298.3],TOWGS84[15.8,-154.4,-82.3,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4215"]]';
35163548
spyOn(FetchRequest, 'get').and.callFake((url) => {
35173549
if (url.indexOf('portal.json') > -1) {
35183550
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
@@ -3559,14 +3591,11 @@ describe('mapboxgl_WebMapV2', () => {
35593591
});
35603592
const originCrs = mapboxgl.CRS.get(epsgCode);
35613593
const crsSetSpy = spyOn(mapboxgl.CRS, 'set').and.callThrough();
3562-
datavizWebmap = new WebMap(
3563-
'123',
3564-
{
3565-
target: 'map',
3566-
serverUrl: 'http://fake/fakeiportal',
3567-
withCredentials: false
3568-
}
3569-
);
3594+
datavizWebmap = new WebMap('123', {
3595+
target: 'map',
3596+
serverUrl: 'http://fake/fakeiportal',
3597+
withCredentials: false
3598+
});
35703599
datavizWebmap.on('mapcreatesucceeded', ({ map }) => {
35713600
expect(originCrs).toBeFalsy();
35723601
expect(mapboxgl.CRS.get(epsgCode)).toBeTruthy();
@@ -3582,7 +3611,8 @@ describe('mapboxgl_WebMapV2', () => {
35823611

35833612
it('when uncommon crs was defined, baselayer is MAPBOXSTYLE', (done) => {
35843613
const epsgCode = 'EPSG:4216';
3585-
const wkt_4216 = 'GEOGCS["Beijing 1954",DATUM["Beijing_1954",SPHEROID["Krassowsky 1940",6378245,298.3],TOWGS84[15.8,-154.4,-82.3,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4216"]]';
3614+
const wkt_4216 =
3615+
'GEOGCS["Beijing 1954",DATUM["Beijing_1954",SPHEROID["Krassowsky 1940",6378245,298.3],TOWGS84[15.8,-154.4,-82.3,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4216"]]';
35863616
const mapInfo = {
35873617
...webmap_MAPBOXSTYLE_Tile,
35883618
layers: [],
@@ -3602,22 +3632,22 @@ describe('mapboxgl_WebMapV2', () => {
36023632
});
36033633
const originCrs = mapboxgl.CRS.get(epsgCode);
36043634
const crsSetSpy = spyOn(mapboxgl.CRS, 'set').and.callThrough();
3605-
datavizWebmap = new WebMap(
3606-
'123',
3607-
{
3608-
target: 'map',
3609-
serverUrl: 'http://fake/fakeiportal',
3610-
withCredentials: false
3611-
}
3612-
);
3635+
datavizWebmap = new WebMap('123', {
3636+
target: 'map',
3637+
serverUrl: 'http://fake/fakeiportal',
3638+
withCredentials: false
3639+
});
36133640
datavizWebmap.on('mapcreatesucceeded', ({ map }) => {
36143641
expect(originCrs).toBeFalsy();
36153642
expect(mapboxgl.CRS.get(epsgCode)).toBeTruthy();
36163643
expect(mapboxgl.CRS.get(epsgCode)).toEqual(map.getCRS());
36173644
expect(crsSetSpy).toHaveBeenCalledTimes(2);
36183645
expect(map.getCRS().getEpsgCode()).toBe(epsgCode);
36193646
expect(map.getCRS().getWKT()).toBe(wkt_4216);
3620-
expect(map.getCRS().getOrigin()).toEqual([vectorTile_style.metadata.indexbounds[0], vectorTile_style.metadata.indexbounds[3]]);
3647+
expect(map.getCRS().getOrigin()).toEqual([
3648+
vectorTile_style.metadata.indexbounds[0],
3649+
vectorTile_style.metadata.indexbounds[3]
3650+
]);
36213651
expect(map.getStyle().layers.length).toBe(vectorTile_style.layers.length - 1);
36223652
done();
36233653
});

test/resources/WebMapV5.js

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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