Coder Social home page Coder Social logo

buildingid-rb's Introduction

Unique Building Identification (UBID)

Website: https://buildingid.pnnl.gov/

Documentation

Install

Add this line to your application's Gemfile:

gem 'pnnl-building_id'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pnnl-building_id

Usage

The pnnl-building_id package supports one usage:

  • Application programming interface (API)

The API

UBID codecs are encapsulated in separate modules:

  • PNNL::BuildingId::V3 (format: "C-n-e-s-w")

Modules export the same API:

  • decode(String) ~> PNNL::BuildingId::CodeArea
  • encode(Float, Float, Float, Float, Float, Float, Integer) ~> String
  • encode_code_area(PNNL::BuildingId::CodeArea) ~> String
  • valid?(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.
require 'pnnl/building_id'

# Initialize UBID code.
code = '849VQJH6+95J-51-58-42-50'
$stdout.puts(code)

# Decode the UBID code.
code_area = PNNL::BuildingId::V3.decode(code)
$stdout.puts(code_area)

# 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.
new_code_area = code_area.resize
$stdout.puts(new_code_area)

# Encode the new UBID code area.
new_code = PNNL::BuildingId::V3.encode_code_area(new_code_area)
$stdout.puts(new_code)

# Test that the new UBID code matches the original.
$stdout.puts(code == newCode)

License

The gem is available as open source under the terms of The 2-Clause BSD License.

Contributions

Contributions are accepted on GitHub via the fork and pull request workflow. See here for more information.

buildingid-rb's People

Contributors

markborkum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.