Skip to content

Commit 0776e8a

Browse files
committed
Update XML parsing utils
1 parent ade97a5 commit 0776e8a

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

datasets/datasets_local.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,27 @@
3030
"drop_variables": ["Itime2"]
3131
},
3232
"ngofs2_2d": {
33-
"path": "s3://nextgen-dmac-cloud-ingest/nos/ngofs2/nos.ngofs2.2ds.best.nc.zarr",
33+
"path": "s3://nextgen-dmac-cloud-ingest-nosofs/nos/ngofs2/nos.ngofs2.2ds.best.nc.zarr",
3434
"type": "kerchunk",
3535
"chunks": {},
3636
"drop_variables": ["Itime2"]
3737
},
38-
"hrrr": {
39-
"path": "./datasets/hrrr.dswrf.nc",
40-
"type": "netcdf",
38+
"nyofs": {
39+
"path": "s3://nextgen-dmac-cloud-ingest-nosofs/nos/nyofs/nos.nyofs.fields.forecast.20240409.t23z.nc.zarr",
40+
"type": "kerchunk",
4141
"chunks": {},
4242
"drop_variables": []
4343
},
44-
"hrrr_subhourly": {
45-
"path": "s3://nextgen-dmac/kerchunk/hrrr_subhourly.json",
44+
"sscofs": {
45+
"path": "s3://nextgen-dmac-cloud-ingest-nosofs/nos/sscofs/sscofs.fields.best.nc.zarr",
4646
"type": "kerchunk",
4747
"chunks": {},
48+
"drop_variables": ["Itime", "Itime2"]
49+
},
50+
"hrrr": {
51+
"path": "./datasets/hrrr.dswrf.nc",
52+
"type": "netcdf",
53+
"chunks": {},
4854
"drop_variables": []
4955
}
5056
}

viewer/package-lock.json

+16-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

viewer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"fast-xml-parser": "^3.21.1",
12+
"fast-xml-parser": "^4.3.2",
1313
"he": "^1.2.0",
1414
"maplibre-gl": "^2.4.0",
1515
"material-icons": "^1.12.2",

viewer/src/tools.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { parse, X2jOptions } from 'fast-xml-parser';
1+
import { XMLParser, X2jOptions } from 'fast-xml-parser';
22
import { Map, LngLat, LngLatBounds } from "maplibre-gl";
33
import he from 'he';
44

55
const XML_PARSER_OPTIONS: Partial<X2jOptions> = {
66
ignoreAttributes: false,
77
parseAttributeValue: true,
8-
tagValueProcessor: a => he.decode(a),
9-
attrValueProcessor: a => he.decode(a, { isAttributeValue: true })
8+
tagValueProcessor: (_, tagValue) => he.decode(tagValue),
109
};
1110

1211
/**
1312
* Parses XML data to a javascript object
14-
* @param data
13+
* @param data
1514
* @returns a javascript object representation of the xml data tree
1615
*/
1716
export function xmlToJSON(data: any): any {
18-
return parse(data, XML_PARSER_OPTIONS);
17+
const parser = new XMLParser(XML_PARSER_OPTIONS);
18+
return parser.parse(data, false);
1919
}
2020

2121
/**
@@ -36,7 +36,7 @@ export function bboxContainsPoint(bbox: [number, number, number, number], point:
3636
if (bbox[0] === -180 && bbox[2] === -180) {
3737
inLon = true;
3838
}
39-
39+
4040
return (inLon && inLat);
4141
} catch (e) {
4242
console.error(e);

0 commit comments

Comments
 (0)