Skip to content

Commit

Permalink
refactor(CopcSource): use wkt to get source.crs
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Sep 6, 2024
1 parent e833511 commit 9d4f5e5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Source/CopcSource.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import proj4 from 'proj4';
import { Binary, Info, Las } from 'copc';
import Fetcher from 'Provider/Fetcher';
import LASParser from 'Parser/LASParser';
Expand Down Expand Up @@ -103,8 +104,24 @@ class CopcSource extends Source {
this.header = metadata.header;
this.info = metadata.info;
this.eb = metadata.eb;
// TODO: use wkt definition in `metadata.wkt` to infer/define crs
this.crs = config.crs || 'EPSG:4326';

proj4.defs('unknown', metadata.wkt);
this.crs = proj4.defs('unknown').name;
proj4.defs(this.crs, proj4.defs('unknown'));

if (proj4.defs('unknown').type === 'COMPD_CS') {
console.warn('CopcSource: compound coordinate system is not yet supported.');
metadata.wkt = metadata.wkt.slice(metadata.wkt.search('PROJCS'), metadata.wkt.search(',VERT_CS'));
proj4.defs('unknown', metadata.wkt);
const projCS = proj4.defs('unknown');
if (projCS.AUTHORITY) {
const authority = Object.keys(projCS.AUTHORITY)[0];
this.crs = `${authority}:${projCS.AUTHORITY[authority]}`;
proj4.defs(this.crs, proj4.defs('unknown'));
} else {
this.crs = config.crs || 'EPSG:4326';
}
}

return this;
});
Expand Down

0 comments on commit 9d4f5e5

Please sign in to comment.