@bedrock-engineer/bro-xml-parser
v0.1.4
Published
Schema-driven parser for Dutch BRO (Basisregistratie Ondergrond) geotechnical XML data
Downloads
425
Maintainers
Readme
@bedrock-engineer/bro-xml
Parser for Dutch BRO (Basisregistratie Ondergrond) XML data, focussing on geotechnical and geological data.
Features
- CPT (Cone Penetration Test) - 41 metadata fields + measurements
- BHR-GT (Geotechnical Borehole) - soil layers + optional lab analysis
- BHR-G (Geological Borehole) - NEN5104 soil classification
Zero dependencies in browser (uses native DOMParser). Full TypeScript support.
Installation
npm install @bedrock-engineer/bro-xml
# Node.js also requires:
npm install @xmldom/xmldom fontoxpathUsage
// Browser
import { BROParser, XMLAdapter } from "@bedrock-engineer/bro-xml";
// Node.js
import { BROParser, XMLAdapter } from "@bedrock-engineer/bro-xml/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 bore = parser.parseBHRGT(xmlText); // BHR-GT
const bhrg = parser.parseBHRG(xmlText); // BHR-GCustom Schemas
Extract only the fields you need:
import {
BROParser,
XMLAdapter,
resolvers,
} from "@bedrock-engineer/bro-xml/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
Exported lookup tables for BRO domain codes (soil names, colors, procedures, etc.) are auto-generated from the BRO reference codes API. Run codegen:reference-codes to regenerate.
License
Apache 2.0 - Jules Blom at Bedrock.engineer
