-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.js
35 lines (27 loc) · 990 Bytes
/
parser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Martin Pravda
// parser.js
// This file contains the main implementation of the geopackage parser
// which extracts tabular data and turns them into readable tabular format
/*jslint browser, node */
import db_header from "./db_header.js";
import page from "./page.js";
import utils from "./utils.js";
function parse(view) {
const header = db_header.parse(view);
const enconding = db_header.encodings[header.db_text_encoding - 1];
const pages = utils.make_empty_list(
header.db_pages_count
).map(function (ignore, page_number) {
if (page_number === 0) {
// database header resides within the first 100 bytes of the first page
// thus we need to start from the offset 100 in order to parse the page
return page.parse(view, 100, enconding);
}
return page.parse(view, page_number * header.page_size, enconding);
});
return Object.freeze({
header,
pages
});
}
export default Object.freeze(parse);