Skip to content

Commit

Permalink
unify the JS and TS namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Oct 17, 2024
1 parent c501ec4 commit 85f420a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions test/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import qPROJ from 'proj.js';

// This allows for easier access to the TypeScript types
// which are hidden behind a Promise
import type * as Proj from 'proj.js';
import type * as PROJ from 'proj.js';

// refer to the webpack configuration to ses how this works
// @ts-ignore
Expand Down Expand Up @@ -39,7 +39,7 @@ print('Loading WASM');
const coord_op_ctxt = PROJ.CoordinateOperationContext.create(authFactory, null, 0);
const authFactoryEPSG = PROJ.AuthorityFactory.create(dbContext, 'EPSG');
const sourceCRS = authFactoryEPSG.createCoordinateReferenceSystem('4326');
const targetCRS = PROJ.createFromUserInput('+proj=utm +zone=31 +datum=WGS84 +type=crs', dbContext) as Proj.CRS;
const targetCRS = PROJ.createFromUserInput('+proj=utm +zone=31 +datum=WGS84 +type=crs', dbContext) as PROJ.CRS;
const list = PROJ.CoordinateOperationFactory.create().createOperations(sourceCRS, targetCRS, coord_op_ctxt);

const transformer = list[0].coordinateTransformer();
Expand Down
22 changes: 11 additions & 11 deletions test/shared/coordinateoperation.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { assert } from 'chai';

import qPROJ from 'proj.js';
import type * as Proj from 'proj.js';
import type * as PROJ from 'proj.js';

describe('CoordinateOperation with automatic import', () => {
let PROJ: Awaited<typeof qPROJ>;

let dbContext: Proj.DatabaseContext;
let authFactory: Proj.AuthorityFactory;
let authFactoryEPSG: Proj.AuthorityFactory;
let coord_op_ctxt: Proj.CoordinateOperationContext;
let sourceCRS, targetCRS: Proj.CRS;
let operation: Proj.CoordinateOperation;
let dbContext: PROJ.DatabaseContext;
let authFactory: PROJ.AuthorityFactory;
let authFactoryEPSG: PROJ.AuthorityFactory;
let coord_op_ctxt: PROJ.CoordinateOperationContext;
let sourceCRS, targetCRS: PROJ.CRS;
let operation: PROJ.CoordinateOperation;

before('init', async () => {
PROJ = await qPROJ;
dbContext = PROJ.DatabaseContext.create();
authFactory = PROJ.AuthorityFactory.create(dbContext, 'string');
authFactoryEPSG = PROJ.AuthorityFactory.create(dbContext, 'EPSG');
sourceCRS = authFactoryEPSG.createCoordinateReferenceSystem('4326');
targetCRS = PROJ.createFromUserInput('+proj=utm +zone=31 +datum=WGS84 +type=crs', dbContext) as Proj.CRS;
targetCRS = PROJ.createFromUserInput('+PROJ=utm +zone=31 +datum=WGS84 +type=crs', dbContext) as PROJ.CRS;
coord_op_ctxt = PROJ.CoordinateOperationContext.create(authFactory, null, 0);
const list = PROJ.CoordinateOperationFactory.create().createOperations(sourceCRS, targetCRS, coord_op_ctxt);
operation = list[0];
Expand All @@ -29,7 +29,7 @@ describe('CoordinateOperation with automatic import', () => {
assert.instanceOf(operation, PROJ.CoordinateOperation);
assert.instanceOf(operation, PROJ.ConcatenatedOperation);

const ops = (operation as Proj.ConcatenatedOperation).operations();
const ops = (operation as PROJ.ConcatenatedOperation).operations();
assert.isArray(ops);
assert.isAtLeast(ops.length, 2);

Expand All @@ -47,8 +47,8 @@ describe('CoordinateOperation with automatic import', () => {
it.skip('formula (optional string that is not empty)', () => {
// TODO: PROJ returns a dangling pointer for method and ASAN reports a heap overflow
// Remember to check it, maybe it is not supposed to work
const ops = (operation as Proj.ConcatenatedOperation).operations();
const single = ops[0] as Proj.SingleOperation;
const ops = (operation as PROJ.ConcatenatedOperation).operations();
const single = ops[0] as PROJ.SingleOperation;
const method = single.method();
assert.instanceOf(method, PROJ.OperationMethod);
assert.isString(method.formula());
Expand Down
8 changes: 4 additions & 4 deletions test/shared/crs.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { assert } from 'chai';

import qPROJ from 'proj.js';
import type * as Proj from 'proj.js';
import type * as PROJ from 'proj.js';

describe('CRS with automatic import', () => {
let PROJ: Awaited<typeof qPROJ>;

let dbContext: Proj.DatabaseContext;
let authFactory: Proj.AuthorityFactory;
let authFactoryEPSG: Proj.AuthorityFactory;
let dbContext: PROJ.DatabaseContext;
let authFactory: PROJ.AuthorityFactory;
let authFactoryEPSG: PROJ.AuthorityFactory;

before('init', async () => {
PROJ = await qPROJ;
Expand Down
4 changes: 2 additions & 2 deletions test/shared/quickstart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import qPROJ from 'proj.js';

// This allows for easier access to the TypeScript types
// which are hidden behind a Promise and PROJ is actually a variable
import type * as Proj from 'proj.js';
import type * as PROJ from 'proj.js';

// These tests are shared between Node.js and the browser
export default function (_PROJ: typeof qPROJ) {
Expand All @@ -28,7 +28,7 @@ export default function (_PROJ: typeof qPROJ) {
const sourceCRS = authFactoryEPSG.createCoordinateReferenceSystem('4326');
console.timeEnd('AuthorityFactory.create()');
console.time('createFromUserInput()');
const targetCRS = PROJ.createFromUserInput('+proj=utm +zone=31 +datum=WGS84 +type=crs', dbContext) as Proj.CRS;
const targetCRS = PROJ.createFromUserInput('+proj=utm +zone=31 +datum=WGS84 +type=crs', dbContext) as PROJ.CRS;
console.timeEnd('createFromUserInput()');
console.time('CoordinateOperationFactory.create().createOperations()');
const list = PROJ.CoordinateOperationFactory.create().createOperations(sourceCRS, targetCRS, coord_op_ctxt);
Expand Down

0 comments on commit 85f420a

Please sign in to comment.