Website: https://buildingid.pnnl.gov/
This project is published via Maven Central.
Add the following <dependency>
to your pom.xml
file:
<dependency>
<groupId>gov.pnnl</groupId>
<artifactId>buildingid</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
The buildingid-java
package is a class library.
gov.pnnl.buildingid.Code
- Static methods:
gov.pnnl.buildingid.Code encode(double, double, int)
gov.pnnl.buildingid.Code encode(double, double, double, double, double, double, int)
- Instance methods:
gov.pnnl.buildingid.CodeArea decode()
boolean isValid()
- Static methods:
gov.pnnl.buildingid.CodeArea
- Instance methods:
gov.pnnl.buildingid.Code encode()
gov.pnnl.buildingid.CodeArea resize()
- Instance methods:
In the following example, a UBID code is decoded and then re-encoded:
package com.example;
import gov.pnnl.buildingid.Code;
import gov.pnnl.buildingid.CodeArea;
class Program {
public static void main(string[] args) {
// Initialize UBID code.
Code code = new Code("849VQJH6+95J-51-58-42-50");
// Is the UBID code valid?
if (code.isValid()) {
try {
// Decode the UBID code.
CodeArea codeArea = code.decode();
// 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.
CodeArea newCodeArea = codeArea.resize();
// Encode the new UBID code area.
Code newCode = newCodeArea.encode();
// Test that the new UBID code matches the original.
System.out.println(code.getValue().equals(newCode.getValue()));
} catch (IllegalStateException reason) {
System.out.println(String.format("Call to decode() method failed: %s", reason));
}
} else {
System.out.println("Code is invalid.")
}
}
}
The code 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.