-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preparation for PR reprojection 'a la volee' #2422
base: master
Are you sure you want to change the base?
Conversation
eefe617
to
add66c8
Compare
…er' and add 'foot'
…Back, errCallBack)
add66c8
to
3616127
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few comments for this PR (mainly on proj4 patching). Could you rename the commit "supp onPointsCreated" to "delete onPointsCreated callack"?
@@ -61,7 +64,7 @@ function toUnit(crs) { | |||
case 'EPSG:4326' : return UNIT.DEGREE; | |||
case 'EPSG:4978' : return UNIT.METER; | |||
default: { | |||
const p = proj4.defs(formatToEPSG(crs)); | |||
const p = proj4.defs(crs.startsWith('TMS') ? formatToEPSG(crs) : crs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that there is no part of the code which depends on the assumption that a crs starts either by EPSG:
or TMS:
? Maybe this conversion is not needed anymore with #2412.
} else if (projunit === 'foot') { | ||
return UNIT.FOOT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all for splitting support of foot unit and support of non-EPSG/TMS crs in two different commits.
if (this.onPointsCreated) { | ||
this.onPointsCreated(layer, pts); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not documented, nor used (except for one unit test). Shall we mark this as breaking change?
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]}`; | ||
if (!proj4.defs(this.crs)) { | ||
proj4.defs(this.crs, proj4.defs('unknown')); | ||
} | ||
} else { | ||
this.crs = projCS.name || 'EPSG:4326'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we are patching a missing feature of proj4.js
, I'm for proposing a PR directly upstream instead of patching it in iTowns
...
if (metadata.srs) { | ||
if (metadata.srs.authority && metadata.srs.horizontal) { | ||
this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`; | ||
if (!proj4.defs(this.crs)) { | ||
proj4.defs(this.crs, metadata.srs.wkt); | ||
} | ||
} else if (metadata.srs.wkt) { | ||
proj4.defs('unknown', metadata.srs.wkt); | ||
this.crs = proj4.defs('unknown').name; | ||
proj4.defs(this.crs, proj4.defs('unknown')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the wkt
parser breaks the type invariant that what type returned by proj4.defs(crs)
(i.e. the ProjectionDefinition
type) shall return a defined title
property. We could use this property to uniquely define a projection.
I suggest that we could contribute to proj4
such fix (using srs.authority) to define the title
property.
No description provided.