| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -130,7 +130,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa | |||
| 130 | 130 | extent: [extent.leftBottom.x, extent.leftBottom.y, extent.rightTop.x, extent.rightTop.y], | |
| 131 | 131 | wkt: this._getProjectionWKT(projection) | |
| 132 | 132 | }; | |
| 133 | - if (!crsManager.getCRS(epsgCode)) { | ||
| 133 | + if (!crsManager.getCRS(epsgCode) && baseLayer.layerType !== 'ZXY_TILE') { | ||
| 134 | 134 | switch (baseLayer.layerType) { | |
| 135 | 135 | case 'MAPBOXSTYLE': { | |
| 136 | 136 | let url = baseLayer.dataSource.url; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1822,8 +1822,9 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 1822 | 1822 | }; | |
| 1823 | 1823 | datavizWebmap = new WebMap({ | |
| 1824 | 1824 | ...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 }, | ||
| 1827 | 1828 | layers: [ | |
| 1828 | 1829 | { | |
| 1829 | 1830 | ...wmsLayer.layers[0], | |
@@ -2096,7 +2097,7 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 2096 | 2097 | return Promise.resolve(new Response(JSON.stringify({}))); | |
| 2097 | 2098 | }); | |
| 2098 | 2099 | const iportalServiceProxyUrl = 'http://localhost:8195/portalproxy'; | |
| 2099 | - const tileCustomRequestHeaders = { 'Authorization': 'test token' }; | ||
| 2100 | + const tileCustomRequestHeaders = { Authorization: 'test token' }; | ||
| 2100 | 2101 | datavizWebmap = new WebMap(vectorLayer_line, { | |
| 2101 | 2102 | ...commonOption, | |
| 2102 | 2103 | iportalServiceProxyUrlPrefix: iportalServiceProxyUrl, | |
@@ -2808,6 +2809,38 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 2808 | 2809 | done(); | |
| 2809 | 2810 | }); | |
| 2810 | 2811 | }); | |
| 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 | + }); | ||
| 2811 | 2844 | it('initial_mapboxstyleLayer', (done) => { | |
| 2812 | 2845 | spyOn(FetchRequest, 'get').and.callFake((url) => { | |
| 2813 | 2846 | if (url.indexOf('map.json') > -1) { | |
@@ -3336,7 +3369,7 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3336 | 3369 | it('updateOverlayLayer featureProjection', (done) => { | |
| 3337 | 3370 | spyOn(FetchRequest, 'get').and.callFake((url) => { | |
| 3338 | 3371 | if (url.indexOf('map.json') > -1) { | |
| 3339 | - webmap_rangeLayer.layers.map(item => { | ||
| 3372 | + webmap_rangeLayer.layers.map((item) => { | ||
| 3340 | 3373 | item.projection = 'EPSG:3857'; | |
| 3341 | 3374 | }); | |
| 3342 | 3375 | return Promise.resolve(new Response(JSON.stringify(webmap_rangeLayer))); | |
@@ -3394,7 +3427,8 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3394 | 3427 | it('when uncommon crs was defined, dont set repeat', (done) => { | |
| 3395 | 3428 | const mapInfo = JSON.parse(raster4490); | |
| 3396 | 3429 | 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"]]'; | ||
| 3398 | 3432 | mapInfo.projection = wkt_4214; | |
| 3399 | 3433 | spyOn(FetchRequest, 'get').and.callFake((url) => { | |
| 3400 | 3434 | if (url.indexOf('portal.json') > -1) { | |
@@ -3475,14 +3509,11 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3475 | 3509 | }); | |
| 3476 | 3510 | const originCrs = mapboxgl.CRS.get(epsgCode); | |
| 3477 | 3511 | 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 | + }); | ||
| 3486 | 3517 | datavizWebmap.once('mapcreatesucceeded', ({ map: map1 }) => { | |
| 3487 | 3518 | expect(originCrs).toBeFalsy(); | |
| 3488 | 3519 | expect(mapboxgl.CRS.get(epsgCode)).toBeTruthy(); | |
@@ -3512,7 +3543,8 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3512 | 3543 | const mapInfo = JSON.parse(raster4490); | |
| 3513 | 3544 | const epsgCode = 'EPSG:4215'; | |
| 3514 | 3545 | 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"]]'; | ||
| 3516 | 3548 | spyOn(FetchRequest, 'get').and.callFake((url) => { | |
| 3517 | 3549 | if (url.indexOf('portal.json') > -1) { | |
| 3518 | 3550 | return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy))); | |
@@ -3559,14 +3591,11 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3559 | 3591 | }); | |
| 3560 | 3592 | const originCrs = mapboxgl.CRS.get(epsgCode); | |
| 3561 | 3593 | 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 | + }); | ||
| 3570 | 3599 | datavizWebmap.on('mapcreatesucceeded', ({ map }) => { | |
| 3571 | 3600 | expect(originCrs).toBeFalsy(); | |
| 3572 | 3601 | expect(mapboxgl.CRS.get(epsgCode)).toBeTruthy(); | |
@@ -3582,7 +3611,8 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3582 | 3611 | ||
| 3583 | 3612 | it('when uncommon crs was defined, baselayer is MAPBOXSTYLE', (done) => { | |
| 3584 | 3613 | 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"]]'; | ||
| 3586 | 3616 | const mapInfo = { | |
| 3587 | 3617 | ...webmap_MAPBOXSTYLE_Tile, | |
| 3588 | 3618 | layers: [], | |
@@ -3602,22 +3632,22 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 3602 | 3632 | }); | |
| 3603 | 3633 | const originCrs = mapboxgl.CRS.get(epsgCode); | |
| 3604 | 3634 | 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 | + }); | ||
| 3613 | 3640 | datavizWebmap.on('mapcreatesucceeded', ({ map }) => { | |
| 3614 | 3641 | expect(originCrs).toBeFalsy(); | |
| 3615 | 3642 | expect(mapboxgl.CRS.get(epsgCode)).toBeTruthy(); | |
| 3616 | 3643 | expect(mapboxgl.CRS.get(epsgCode)).toEqual(map.getCRS()); | |
| 3617 | 3644 | expect(crsSetSpy).toHaveBeenCalledTimes(2); | |
| 3618 | 3645 | expect(map.getCRS().getEpsgCode()).toBe(epsgCode); | |
| 3619 | 3646 | 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 | + ]); | ||
| 3621 | 3651 | expect(map.getStyle().layers.length).toBe(vectorTile_style.layers.length - 1); | |
| 3622 | 3652 | done(); | |
| 3623 | 3653 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments