@bedrock-engineer/bro-xml-parser
v0.1.5
Published
Schema-driven parser for Dutch BRO (Basisregistratie Ondergrond) geotechnical and geological XML data
Maintainers
Readme
@bedrock-engineer/bro-xml-parser
TypeScript parser library for Dutch Basisregistratie Ondergrond (BRO) XML data, focussing on geotechnical and geological data.
The BRO contains many registration object types. This library currently only covers three:
- CPT (Cone Penetration Test)
- BHR-GT (Geotechnical Borehole)
- BHR-G (Geological Borehole)
No dependencies in browser. For use in node.js, you need to install two extra dependencies.
Live demo: bro.bedrock.engineer (source)
Pre-1.0: This library is under active development. Minor versions may include breaking changes.
Installation
npm install @bedrock-engineer/bro-xml-parser
# Node.js also requires:
npm install @xmldom/xmldom fontoxpathUsage
Browser (zero dependencies):
import { BROParser, XMLAdapter } from "@bedrock-engineer/bro-xml-parser";
const parser = new BROParser(new XMLAdapter());
const cpt = parser.parseCPT(xmlText);Node.js (requires peer deps):
import { BROParser, XMLAdapter } from "@bedrock-engineer/bro-xml-parser/node";
const parser = new BROParser(new XMLAdapter());
// Auto-detect file type
const data = parser.parse(xmlText);
console.log(data.meta.dataType); // 'CPT' | 'BHR-GT' | 'BHR-G'
// Or parse specific types
const cpt = parser.parseCPT(xmlText);
const bhr_gt = parser.parseBHRGT(xmlText);
const bhr_g = parser.parseBHRG(xmlText);Custom Schemas
Extract only the fields you need:
import {
BROParser,
XMLAdapter,
resolvers,
} from "@bedrock-engineer/bro-xml-parser/node";
const parser = new BROParser(new XMLAdapter());
const mySchema = {
id: { xpath: "brocom:broId" },
depth: { xpath: ".//cptcommon:finalDepth", resolver: resolvers.parseFloat },
location: {
xpath: "./dscpt:deliveredLocation/cptcommon:location",
resolver: resolvers.parseGMLLocation,
},
};
const result = parser.parseCustom(xmlText, mySchema, "CPT");
// { id: "CPT000000099543", depth: 25.5, location: { x: 155000, y: 463000, epsg: "28992" } }API
| Method | Returns | Description |
| --------------------------------- | ----------- | -------------------------- |
| parse(xml) | BROData | Auto-detect type and parse |
| parseCPT(xml) | CPTData | Parse CPT file |
| parseBHRGT(xml) | BHRGTData | Parse BHR-GT file |
| parseBHRG(xml) | BHRGData | Parse BHR-G file |
| parseCustom(xml, schema, type?) | T | Parse with custom schema |
See src/types/index.ts for full type definitions.
Supported Schemas
| Type | Schema Version | Link |
| ------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CPT | dscpt/1.1 | BRO CPT docs |
| BHR-GT | dsbhr-gt/2.1 | BRO BHR-GT docs |
| BHR-G | dsbhrg/3.1 | BRO BHR-G docs |
Reference Codes
BRO/XML values use camelCase domain codes like "langwerpig", "mechanischDiscontinu", or "ISO19901d8v2014" some are intuitive, some are cryptic. The BRO publishes official human-readable descriptions for all of these codes.
This library exports lookup functions auto-generated from the BRO reference codes API, so you can resolve any code to its full description:
import { getBhrgtGeotechnicalSoilNameDescription } from "@bedrock-engineer/bro-xml-parser/reference-codes";
const bore = parser.parseBHRGT(xmlText);
bore.data.forEach((layer) => {
const description = getBhrgtGeotechnicalSoilNameDescription(layer.geotechnicalSoilName);
console.log(`${layer.upperBoundary}–${layer.lowerBoundary}m: ${description}`);
// e.g. "0–2m: Grove minerale grond, waarvan de grove fractie uit zand bestaat..."
});Run npm run codegen:reference-codes to regenerate the lookup tables from the latest API.
License
Apache 2.0 — Jules Blom at Bedrock.engineer
