-
Notifications
You must be signed in to change notification settings - Fork 303
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
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"?
src/Core/Geographic/Crs.js
Outdated
@@ -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.
src/Source/CopcSource.js
Outdated
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
...
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.
proj4js doesn't support 'COMPD_CS' wkt. Thus it can parse it without error, but proj4.defs() can't have a ProjectionDefinition as 2nd parameters.
This would be a major change on proj4js side.
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 simplified it and if ever proj4 accept my PR or a version of it, we might have to change one line in the test copc.js
src/Source/EntwinePointTileSource.js
Outdated
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.
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 did open a PR on proj4 github, to address that issue.
https://github.com/proj4js/wkt-parser/pulls
28eca27
to
b196453
Compare
b196453
to
1f59481
Compare
test/unit/entwine.js
Outdated
const eptSsAuthority = JSON.parse(eptFile); | ||
eptSsAuthority.srs = { | ||
wkt: 'PROJCS["RGF93 v1 / Lambert-93",GEOGCS["RGF93 v1",DATUM["Reseau_Geodesique_Francais_1993_v1",SPHEROID["GRS 1980",6378137,298.257222101],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4171"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["standard_parallel_1",49],PARAMETER["standard_parallel_2",44],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","2154"]]', | ||
// wkt: 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]', |
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.
Could you please remove this comment?
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.
Done
…Back, errCallBack)
1f59481
to
1843d7f
Compare
Following PR #2272 that became a big PR. I extracted commits that are needed for the reprojection but are also independants :