| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e5a2a79 commit e2ce2b9
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1200,12 +1200,8 @@ export class WebMapService { | |||
| 1200 | 1200 | maxFeatures: -1, | |
| 1201 | 1201 | returnContent: true | |
| 1202 | 1202 | }); | |
| 1203 | - if (baseProjection) { | ||
| 1204 | - if (baseProjection === 'EPSG:3857' || baseProjection === 'EPSG:-1000') { | ||
| 1205 | - getFeatureBySQLParams.targetEpsgCode = 4326; | ||
| 1206 | - } else { | ||
| 1207 | - getFeatureBySQLParams.targetEpsgCode = +baseProjection.split(':')[1]; | ||
| 1208 | - } | ||
| 1203 | + if (baseProjection && baseProjection !== 'EPSG:4326') { | ||
| 1204 | + getFeatureBySQLParams.targetEpsgCode = 4326; | ||
| 1209 | 1205 | } | |
| 1210 | 1206 | const proxy = this.handleProxy(); | |
| 1211 | 1207 | let options = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -405,8 +405,9 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) { | |||
| 405 | 405 | ||
| 406 | 406 | if (layer.visibleScale) { | |
| 407 | 407 | const { minScale, maxScale } = layer.visibleScale; | |
| 408 | - layer.minzoom = Math.max(this._transformScaleToZoom(minScale), 0); | ||
| 409 | - layer.maxzoom = Math.min(24, this._transformScaleToZoom(maxScale) + 0.0000001); | ||
| 408 | + const crs = this.map.getCRS(); | ||
| 409 | + layer.minzoom = Math.max(this._transformScaleToZoom(minScale, crs), 0); | ||
| 410 | + layer.maxzoom = Math.min(24, this._transformScaleToZoom(maxScale, crs) + 0.0000001); | ||
| 410 | 411 | } | |
| 411 | 412 | ||
| 412 | 413 | if (type === 'tile') { | |
@@ -455,7 +456,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) { | |||
| 455 | 456 | if ( | |
| 456 | 457 | features && | |
| 457 | 458 | projection && | |
| 458 | - (projection !== this.baseProjection || projection === 'EPSG:3857' || projection === 'EPSG:-1000') && | ||
| 459 | + projection !== 'EPSG:4326' && | ||
| 459 | 460 | layerInfo.dataSource && | |
| 460 | 461 | layerInfo.dataSource.type !== 'REST_DATA' | |
| 461 | 462 | ) { | |
@@ -884,7 +885,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) { | |||
| 884 | 885 | layerID: layerInfo.layerID | |
| 885 | 886 | }); | |
| 886 | 887 | ||
| 887 | - if (layerInfo.projection === 'EPSG:3857') { | ||
| 888 | + if (layerInfo.projection !== 'EPSG:4326') { | ||
| 888 | 889 | features = this.transformFeatures(features); | |
| 889 | 890 | } | |
| 890 | 891 | if (layerInfo.filterCondition) { | |
@@ -2837,8 +2838,8 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) { | |||
| 2837 | 2838 | } | |
| 2838 | 2839 | ||
| 2839 | 2840 | _transformScaleToZoom(scale, crs) { | |
| 2840 | - const extent = (crs || this.map.getCRS()).getExtent(); | ||
| 2841 | - const unit = (crs || this.map.getCRS()).unit; | ||
| 2841 | + const extent = crs.getExtent(); | ||
| 2842 | + const unit = crs.unit; | ||
| 2842 | 2843 | const scaleBase = 1.0 / Util.getScaleFromResolutionDpi((extent[2] - extent[0]) / 512, 96, unit); | |
| 2843 | 2844 | const scaleDenominator = scale.split(':')[1]; | |
| 2844 | 2845 | return Math.min(24, +Math.log2(scaleBase / +scaleDenominator).toFixed(2)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -860,7 +860,9 @@ describe('WebMapServiceSpec.js', () => { | |||
| 860 | 860 | }); | |
| 861 | 861 | ||
| 862 | 862 | it('get Layer Features from rest_data and dataSource is Chinese', done => { | |
| 863 | - spyOn(FetchRequest, 'post').and.callFake(() => { | ||
| 863 | + let getFeatureBySQLParams; | ||
| 864 | + spyOn(FetchRequest, 'post').and.callFake((url, options) => { | ||
| 865 | + getFeatureBySQLParams = options; | ||
| 864 | 866 | return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT))); | |
| 865 | 867 | }); | |
| 866 | 868 | const type = 'rest_data'; | |
@@ -880,6 +882,8 @@ describe('WebMapServiceSpec.js', () => { | |||
| 880 | 882 | expect(params[0]).toBe(layer.dataSource.url); | |
| 881 | 883 | expect(params[1]).toEqual(["中国矢量数据:飞机场"]); | |
| 882 | 884 | expect(params[4]).toEqual(baseProjection); | |
| 885 | + expect(typeof getFeatureBySQLParams).toBe('string'); | ||
| 886 | + expect(getFeatureBySQLParams).toContain(`'targetEpsgCode':4326`); | ||
| 883 | 887 | done(); | |
| 884 | 888 | }); | |
| 885 | 889 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1846,9 +1846,7 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 1846 | 1846 | center: [107.7815, 39.9788], | |
| 1847 | 1847 | zoom: 5, | |
| 1848 | 1848 | renderWorldCopies: false, | |
| 1849 | - crs: { | ||
| 1850 | - epsgCode: 'EPSG:3857' | ||
| 1851 | - }, | ||
| 1849 | + crs: 'EPSG:3857', | ||
| 1852 | 1850 | minzoom: 0, | |
| 1853 | 1851 | maxzoom: 22 | |
| 1854 | 1852 | }; | |
@@ -1886,9 +1884,7 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 1886 | 1884 | center: [107.7815, 39.9788], | |
| 1887 | 1885 | zoom: 5, | |
| 1888 | 1886 | renderWorldCopies: false, | |
| 1889 | - crs: { | ||
| 1890 | - epsgCode: 'EPSG:3857' | ||
| 1891 | - }, | ||
| 1887 | + crs: 'EPSG:3857', | ||
| 1892 | 1888 | minzoom: 0, | |
| 1893 | 1889 | maxzoom: 22 | |
| 1894 | 1890 | }; | |
@@ -1927,9 +1923,7 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 1927 | 1923 | center: [107.7815, 39.9788], | |
| 1928 | 1924 | zoom: 5, | |
| 1929 | 1925 | renderWorldCopies: false, | |
| 1930 | - crs: { | ||
| 1931 | - epsgCode: 'EPSG:3857' | ||
| 1932 | - }, | ||
| 1926 | + crs: 'EPSG:3857', | ||
| 1933 | 1927 | minzoom: 0, | |
| 1934 | 1928 | maxzoom: 22 | |
| 1935 | 1929 | }; | |
@@ -2734,4 +2728,55 @@ describe('mapboxgl_WebMapV2', () => { | |||
| 2734 | 2728 | }; | |
| 2735 | 2729 | datavizWebmap.once('mapcreatesucceeded', callback); | |
| 2736 | 2730 | }); | |
| 2731 | + | ||
| 2732 | + it('overlay projection is no EPSG:4326', (done) => { | ||
| 2733 | + spyOn(FetchRequest, 'get').and.callFake((url) => { | ||
| 2734 | + if (url.indexOf('portal.json') > -1) { | ||
| 2735 | + return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy))); | ||
| 2736 | + } | ||
| 2737 | + if (url.indexOf('map.json') > -1) { | ||
| 2738 | + return Promise.resolve(new Response(JSON.stringify(projection4548))); | ||
| 2739 | + } | ||
| 2740 | + if (url.indexOf('map4548%40fl-new/prjCoordSys.wkt') > -1) { | ||
| 2741 | + return Promise.resolve(new Response(projection_4548_wkt)); | ||
| 2742 | + } | ||
| 2743 | + if (url.indexOf('/map4548%40fl-new.json') > -1) { | ||
| 2744 | + return Promise.resolve( | ||
| 2745 | + new Response(JSON.stringify({ | ||
| 2746 | + bounds: { | ||
| 2747 | + top: 5178663.047080055, | ||
| 2748 | + left: 328182.9260637246, | ||
| 2749 | + bottom: 2289622.79728123, | ||
| 2750 | + leftBottom: { | ||
| 2751 | + x: 328182.9260637246, | ||
| 2752 | + y: 2289622.79728123 | ||
| 2753 | + }, | ||
| 2754 | + right: 629000.9570381088, | ||
| 2755 | + rightTop: { | ||
| 2756 | + x: 629000.9570381088, | ||
| 2757 | + y: 5178663.047080055 | ||
| 2758 | + } | ||
| 2759 | + } | ||
| 2760 | + })) | ||
| 2761 | + ); | ||
| 2762 | + } | ||
| 2763 | + if (url.indexOf('/content.json') > -1) { | ||
| 2764 | + return Promise.resolve(new Response(JSON.stringify(projection_4548_content))); | ||
| 2765 | + } | ||
| 2766 | + }); | ||
| 2767 | + spyOn(FetchRequest, 'post').and.callFake(url => { | ||
| 2768 | + if (url.indexOf('/featureResults') > -1) { | ||
| 2769 | + return Promise.resolve(new Response(JSON.stringify(projection_4548_featureResults))); | ||
| 2770 | + } | ||
| 2771 | + }); | ||
| 2772 | + datavizWebmap = new WebMap(id, { | ||
| 2773 | + server: server | ||
| 2774 | + }); | ||
| 2775 | + | ||
| 2776 | + datavizWebmap.on('mapcreatesucceeded', ({ layers, map }) => { | ||
| 2777 | + expect(layers.length).toBe(3); | ||
| 2778 | + expect(datavizWebmap._handler._unprojectProjection).toBe('EPSG:4548'); | ||
| 2779 | + done(); | ||
| 2780 | + }); | ||
| 2781 | + }); | ||
| 2737 | 2782 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1847,9 +1847,7 @@ describe('maplibregl_WebMapV2', () => { | |||
| 1847 | 1847 | center: [107.7815, 39.9788], | |
| 1848 | 1848 | zoom: 5, | |
| 1849 | 1849 | renderWorldCopies: false, | |
| 1850 | - crs: { | ||
| 1851 | - epsgCode: 'EPSG:3857' | ||
| 1852 | - }, | ||
| 1850 | + crs: 'EPSG:3857', | ||
| 1853 | 1851 | minzoom: 0, | |
| 1854 | 1852 | maxzoom: 22 | |
| 1855 | 1853 | }; | |
@@ -1887,9 +1885,7 @@ describe('maplibregl_WebMapV2', () => { | |||
| 1887 | 1885 | center: [107.7815, 39.9788], | |
| 1888 | 1886 | zoom: 5, | |
| 1889 | 1887 | renderWorldCopies: false, | |
| 1890 | - crs: { | ||
| 1891 | - epsgCode: 'EPSG:3857' | ||
| 1892 | - }, | ||
| 1888 | + crs: 'EPSG:3857', | ||
| 1893 | 1889 | minzoom: 0, | |
| 1894 | 1890 | maxzoom: 22 | |
| 1895 | 1891 | }; | |
@@ -1928,9 +1924,7 @@ describe('maplibregl_WebMapV2', () => { | |||
| 1928 | 1924 | center: [107.7815, 39.9788], | |
| 1929 | 1925 | zoom: 5, | |
| 1930 | 1926 | renderWorldCopies: false, | |
| 1931 | - crs: { | ||
| 1932 | - epsgCode: 'EPSG:3857' | ||
| 1933 | - }, | ||
| 1927 | + crs: 'EPSG:3857', | ||
| 1934 | 1928 | minzoom: 0, | |
| 1935 | 1929 | maxzoom: 22 | |
| 1936 | 1930 | }; | |
@@ -2734,4 +2728,55 @@ describe('maplibregl_WebMapV2', () => { | |||
| 2734 | 2728 | }; | |
| 2735 | 2729 | datavizWebmap.once('mapcreatesucceeded', callback); | |
| 2736 | 2730 | }); | |
| 2731 | + | ||
| 2732 | + it('overlay projection is no EPSG:4326', (done) => { | ||
| 2733 | + spyOn(FetchRequest, 'get').and.callFake((url) => { | ||
| 2734 | + if (url.indexOf('portal.json') > -1) { | ||
| 2735 | + return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy))); | ||
| 2736 | + } | ||
| 2737 | + if (url.indexOf('map.json') > -1) { | ||
| 2738 | + return Promise.resolve(new Response(JSON.stringify(projection4548))); | ||
| 2739 | + } | ||
| 2740 | + if (url.indexOf('map4548%40fl-new/prjCoordSys.wkt') > -1) { | ||
| 2741 | + return Promise.resolve(new Response(projection_4548_wkt)); | ||
| 2742 | + } | ||
| 2743 | + if (url.indexOf('/map4548%40fl-new.json') > -1) { | ||
| 2744 | + return Promise.resolve( | ||
| 2745 | + new Response(JSON.stringify({ | ||
| 2746 | + bounds: { | ||
| 2747 | + top: 5178663.047080055, | ||
| 2748 | + left: 328182.9260637246, | ||
| 2749 | + bottom: 2289622.79728123, | ||
| 2750 | + leftBottom: { | ||
| 2751 | + x: 328182.9260637246, | ||
| 2752 | + y: 2289622.79728123 | ||
| 2753 | + }, | ||
| 2754 | + right: 629000.9570381088, | ||
| 2755 | + rightTop: { | ||
| 2756 | + x: 629000.9570381088, | ||
| 2757 | + y: 5178663.047080055 | ||
| 2758 | + } | ||
| 2759 | + } | ||
| 2760 | + })) | ||
| 2761 | + ); | ||
| 2762 | + } | ||
| 2763 | + if (url.indexOf('/content.json') > -1) { | ||
| 2764 | + return Promise.resolve(new Response(JSON.stringify(projection_4548_content))); | ||
| 2765 | + } | ||
| 2766 | + }); | ||
| 2767 | + spyOn(FetchRequest, 'post').and.callFake(url => { | ||
| 2768 | + if (url.indexOf('/featureResults') > -1) { | ||
| 2769 | + return Promise.resolve(new Response(JSON.stringify(projection_4548_featureResults))); | ||
| 2770 | + } | ||
| 2771 | + }); | ||
| 2772 | + datavizWebmap = new WebMap(id, { | ||
| 2773 | + server: server | ||
| 2774 | + }); | ||
| 2775 | + | ||
| 2776 | + datavizWebmap.on('mapcreatesucceeded', ({ layers, map }) => { | ||
| 2777 | + expect(layers.length).toBe(3); | ||
| 2778 | + expect(datavizWebmap._handler._unprojectProjection).toBe('EPSG:4548'); | ||
| 2779 | + done(); | ||
| 2780 | + }); | ||
| 2781 | + }); | ||
| 2737 | 2782 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments