Skip to content

Commit

Permalink
Less datum code modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Oct 28, 2024
1 parent e1c270c commit 4088610
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
10 changes: 2 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function setPropertiesFromWkt(wkt) {
if (wkt.datumCode.slice(0, 2) === 'd_') {
wkt.datumCode = wkt.datumCode.slice(2);
}
if (wkt.datumCode === 'new_zealand_geodetic_datum_1949' || wkt.datumCode === 'new_zealand_1949') {
if (wkt.datumCode === 'new_zealand_1949') {
wkt.datumCode = 'nzgd49';
}
if (wkt.datumCode === 'wgs_1984' || wkt.datumCode === 'world_geodetic_system_1984') {
Expand All @@ -115,13 +115,7 @@ function setPropertiesFromWkt(wkt) {
}
wkt.datumCode = 'wgs84';
}
if (wkt.datumCode.slice(-6) === '_ferro') {
wkt.datumCode = wkt.datumCode.slice(0, - 6);
}
if (wkt.datumCode.slice(-8) === '_jakarta') {
wkt.datumCode = wkt.datumCode.slice(0, - 8);
}
if (~wkt.datumCode.indexOf('belge')) {
if (wkt.datumCode === 'belge_1972') {
wkt.datumCode = 'rnb72';
}
if (geogcs.DATUM && geogcs.DATUM.SPHEROID) {
Expand Down
44 changes: 28 additions & 16 deletions test-fixtures.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[{
"code": "PROJCS[\"NZGD49 / New Zealand Map Grid\",GEOGCS[\"NZGD49\",DATUM[\"New_Zealand_Geodetic_Datum_1949\",SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]],TOWGS84[59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993],AUTHORITY[\"EPSG\",\"6272\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4272\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"New_Zealand_Map_Grid\"],PARAMETER[\"latitude_of_origin\",-41],PARAMETER[\"central_meridian\",173],PARAMETER[\"false_easting\",2510000],PARAMETER[\"false_northing\",6023150],AUTHORITY[\"EPSG\",\"27200\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]",
"value": {
"type": "PROJCS",
"name": "NZGD49 / New Zealand Map Grid",
"GEOGCS": {
"type": "GEOGCS",
"name": "NZGD49",
"DATUM": {
"name": "New_Zealand_Geodetic_Datum_1949",
Expand All @@ -17,10 +15,13 @@
}
},
"TOWGS84": [
59.47, -5.04,
59.47,
-5.04,
187.44,
0.47, -0.1,
1.024, -4.5993
0.47,
-0.1,
1.024,
-4.5993
],
"AUTHORITY": {
"EPSG": "6272"
Expand All @@ -43,11 +44,12 @@
"AUTHORITY": {
"EPSG": "4272"
},
"type": "GEOGCS",
"title": "EPSG:4272",
"projName": "longlat",
"units": "degree",
"to_meter": 111323.87156969598,
"datumCode": "nzgd49",
"datumCode": "new_zealand_geodetic_datum_1949",
"ellps": "intl",
"a": 6378388,
"rf": 297,
Expand Down Expand Up @@ -78,28 +80,38 @@
"EPSG": "27200"
},
"AXIS": [
["Easting", "EAST"],
["Northing", "NORTH"]
[
"Easting",
"EAST"
],
[
"Northing",
"NORTH"
]
],
"type": "PROJCS",
"title": "EPSG:27200",
"projName": "New_Zealand_Map_Grid",
"axis": "enu",
"units": "meter",
"to_meter": 1,
"datumCode": "nzgd49",
"datum_params": [
59.47, -5.04,
187.44, 0.47,
-0.1, 1.024,
-4.5993
],
"datumCode": "new_zealand_geodetic_datum_1949",
"ellps": "intl",
"a": 6378388,
"rf": 297,
"datum_params": [
59.47,
-5.04,
187.44,
0.47,
-0.1,
1.024,
-4.5993
],
"x0": 2510000,
"y0": 6023150,
"long0": 3.01941960595019,
"lat0": -0.7155849933176751,
"axis": "enu",
"srsCode": "NZGD49 / New Zealand Map Grid"
}
}, {
Expand Down
1 change: 0 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var fixtures = require('./test-fixtures.json');
fixtures.forEach((item, i)=>{
test(`fixture ${i + 1}`, t=>{
var out = wktParser(item.code);
//console.log(JSON.stringify(out, null, 2));
const diff = JSON.stringify(compare(item.value, JSON.parse(JSON.stringify(out))), null, 2);
t.equal(diff, '[]');
t.end();
Expand Down

0 comments on commit 4088610

Please sign in to comment.