Website: https://buildingid.pnnl.gov/
To complete this guide, npm is required.
Install the pnnl-buildingid
package:
npm install pnnl-buildingid
Use npm to uninstall the pnnl-buildingid
package.
npm uninstall pnnl-buildingid
The pnnl-buildingid
package and its dependency, the openlocationcode
package, are also distributed via cdnjs, and can be included directly in HTML documents.
<script src="https://cdnjs.cloudflare.com/ajax/libs/openlocationcode/1.0.4/openlocationcode.js" integrity="sha512-l89EkrJBS8wnnRi58zAA9oj1Ok7h0twzXeAltaax8t1viFQ6zTyom41s+YdMUSnbjP/eC0P+mQOldVzvsrBn3A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pnnl-buildingid/1.0.3/pnnl-buildingid.js" integrity="sha512-Lff8arMmIctm9qPOG3jwtVaiefX/JADUZqWkr7ZDu2F9tweLtPtnhj7FFeKLXDseLGGUCq4QeyWjWgWovQ/abw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/openlocationcode/1.0.4/openlocationcode.min.js" integrity="sha512-nNdmCJgFefLPn6W79uEUxH2n4+qbc0kJM8uBD8f7GlmusrQN9L13hpSBRxLHdLs+6oSDurcCuDlBXVKaz/hpcA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pnnl-buildingid/1.0.3/pnnl-buildingid.min.js" integrity="sha512-FVPTex/yDYrMDFymOsaQH4KpUt/FxnV73vABAiyy75nWgCrTCM87hol9UMyGwY9Uo1K1PtXsqXL96xXi4gxaiw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
The pnnl-buildingid
package supports one usage:
- Application programming interface (API)
UBID codecs are encapsulated in separate modules:
UniqueBuildingIdentification.v3
(format: "C-n-e-s-w")
Modules export the same API:
decode(string) ~> UniqueBuildingIdentification.CodeArea
encode(number, number, number, number, number, number, number) ~> string
encodeCodeArea(UniqueBuildingIdentification.CodeArea) ~> string
isValid(string) ~> boolean
In the following example, a UBID code is decoded and then re-encoded:
// Use the "C-n-e-s-w" format for UBID codes.
const UniqueBuildingIdentification = require('pnnl-buildingid');
// Initialize UBID code.
const code = '849VQJH6+95J-51-58-42-50';
console.log(code);
// Decode the UBID code.
const codeArea = UniqueBuildingIdentification.v3.decode(code);
console.log(codeArea);
// Resize the resulting UBID code area.
//
// The effect of this operation is that the height and width of the UBID code
// area are reduced by half an OLC code area.
const newCodeArea = codeArea.resize();
console.log(newCodeArea);
// Encode the new UBID code area.
const newCode = UniqueBuildingIdentification.v3.encodeCodeArea(newCodeArea);
console.log(newCode);
// Test that the new UBID code matches the original.
console.log(code === newCode);
The package is available as open source under the terms of The 2-Clause BSD License.
Contributions are accepted on GitHub via the fork and pull request workflow. See here for more information.