Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/SuperMap/vue-iclient into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Dec 9, 2024
2 parents 81b99d5 + 44b96a8 commit bdd6eeb
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@supermapgis/vue-iclient",
"version": "11.3.0",
"version": "12.0.0-dev",
"description": "SuperMap iClient for Vue.js",
"homepage": "https://iclient.supermap.io",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Required metadata
sonar.projectKey=com.supermap:vue-iclient
sonar.projectName=vue-iclient
sonar.projectVersion=11.3.0
sonar.projectVersion=12.0.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src/
Expand Down
24 changes: 23 additions & 1 deletion src/common/_utils/__tests__/epsg-define.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { registerProjection, getProjection, toEpsgCode } from '../epsg-define';
import { registerProjection, getProjection, toEpsgCode, transformCoodinates } from '../epsg-define';
import proj4 from 'proj4';

describe('epsg-define', () => {
Expand Down Expand Up @@ -40,5 +40,27 @@ describe('epsg-define', () => {
expect(toEpsgCode({})).toBe('');
done();
});

it('register cover', done => {
const spy = jest.spyOn(proj4, 'defs');
registerProjection('EPSG:3857', projections['EPSG:4548'], true);
expect(getProjection('EPSG:3857')).not.toBeUndefined();
expect(spy).toHaveBeenCalledWith('EPSG:3857', projections['EPSG:4548']);
done();
});

it('transformCoodinates', done => {
registerProjection('EPSG:4548', projections['EPSG:4548']);
const result = transformCoodinates({ coordinates: [478591, 3734142], sourceProjection: 'EPSG:4548' });
expect(result).toEqual([116.76898148293563, 33.733651143352695]);
expect(() =>
transformCoodinates({
coordinates: [478591, 3734142],
sourceProjection: 'EPSG:4548',
destProjection: 'EPSG:2210'
})
).toThrow('EPSG:2210 is not defined');
done();
});
});

19 changes: 14 additions & 5 deletions src/common/_utils/epsg-define.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getDataType } from 'vue-iclient/src/common/_utils/util';
import proj4 from 'proj4';

function defineProjection(epsgCode, projection) {
if (proj4.defs(epsgCode)) {
function defineProjection(epsgCode, projection, isCover) {
if (proj4.defs(epsgCode) && !isCover) {
return;
}
if (!projection) {
Expand All @@ -12,15 +12,15 @@ function defineProjection(epsgCode, projection) {
proj4.defs(epsgCode, projection);
}

export function registerProjection(epsgKey, epsgValue) {
export function registerProjection(epsgKey, epsgValue, isCover) {
if (getDataType(arguments[0]) === '[object Object]' && arguments.length === 1) {
const projections = arguments[0];
for (const epsgCode in projections) {
defineProjection(epsgCode, projections[epsgCode]);
defineProjection(epsgCode, projections[epsgCode], isCover);
}
return;
}
defineProjection(epsgKey, epsgValue);
defineProjection(epsgKey, epsgValue, isCover);
}

export function getProjection(epsgKey) {
Expand Down Expand Up @@ -58,3 +58,12 @@ export function toEpsgCode(wkt) {
}
}
}

export function transformCoodinates({ coordinates, sourceProjection, destProjection = 'EPSG:4326' }) {
try {
return proj4(sourceProjection, destProjection, coordinates);
} catch (error) {
const errorMsg = `${error} is not defined`;
throw errorMsg;
}
}
2 changes: 1 addition & 1 deletion src/leaflet/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@supermapgis/vue-iclient-leaflet",
"description": "SuperMap iClient for Vue.js",
"version": "11.3.0",
"version": "12.0.0-dev",
"homepage": "http://iclient.supermap.io",
"main": "lib/index",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/mapboxgl/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@supermapgis/vue-iclient-mapboxgl",
"description": "SuperMap iClient for Vue.js",
"version": "11.3.0",
"version": "12.0.0-dev",
"homepage": "http://iclient.supermap.io",
"main": "lib/index",
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ interface CRSOptions {
}

interface MapHandler {
initializeMap: (mapInfo?: Record<string, any>, map?: mapboxglTypes.Map) => void;
clean: () => void;
cleanLayers: () => void;
getLayerCatalog: () => any[];
Expand Down
4 changes: 2 additions & 2 deletions static/libs/iclient-mapboxgl/iclient-mapboxgl.min.js

Large diffs are not rendered by default.

0 comments on commit bdd6eeb

Please sign in to comment.