Git Product home page Git Product logo

hive-state's Introduction

Build Status Coverage Reviewed by Hound Hex.pm

Hive

Efficient in-memory fleet state management.

Installation 💾

This library can be installed by adding hive to the list of dependencies in your mix.exs:

def deps do
  [{:hive, "~> 0.0.1"}]
end

Add :hive to extra_applications if necessary.

Usage 🚀

Once you have it running you can infleet, defleet, update positions, get h3 index for vehicles

alias Hive.Vehicle

# Infleet new vehicles
{:ok, _pid} = Hive.infleet("autonomous-vehicle-id")
{:ok, _pid} = Hive.infleet(%Vehicle{id: "autonomous-vehicle-id"})
{:ok, _pid} = Hive.infleet("normal-vehicle-id")
{:ok, _pid} = Hive.infleet(%Vehicle{id: "normal-vehicle-id"})

# Defleet vehicles
{:ok, _pid} = Hive.defleet("normal-vehicle-id")
{:ok, _pid} = Hive.defleet(%Vehicle{id: "normal-vehicle-id"})

If we in-fleet only by vehicle_id then %Vehicle{} struct is created with default field values. We also can in-fleet giving full %Vehicle{} with all parameters you want.

Structs

Hive has two structs Vehicle and GeoPosition

%GeoPosition{
  latitude: float(),
  longitude: float(),
  accuracy: float(),
  altitude: float(),
  altitude_accuracy: float(),
  heading: float(),
  speed: float()
}

%Vehicle{
  id: String.t(),
  vin: String.t() | nil,
  name: String.t() | nil,
  license_plate: String.t() | nil,
  make: String.t() | nil,
  model: String.t() | nil,
  seat_count: non_neg_integer() | nil,
  color: String.t() | nil,
  online: boolean() | true,
  has_passengers: boolean() | false,
  is_sdc: boolean() | false,
  position: GeoPosition.t() | nil,
  telemetry: list() | []
}

Supervision tree looks like observer::Supervision tree

For more usage details please refer to https://hex.pm/packages/hive

H3 queries 🍪

H3 integration is done via https://github.com/helium/erlang-h3 and at the moment the following features are supported

# Get hexagon index for vehicle or GeoPosition
Hive.H3.index("vehicle-uuid")
Hive.H3.index(%GeoPosition{latitude: 48.8566, longitude: 2.3522})

# H3 index to GeoPosition
H3.index_to_geo("8928308280fffff")
H3.index_to_geo(617_700_169_958_293_503)

# Get geo boundary
H3.to_geo_boundary("8928308280fffff")
H3.to_geo_boundary(613_196_840_967_340_031)

# Get kRing
H3.k_ring("8928308280fffff", 1)
H3.k_ring(613_196_840_967_340_031, 1)

For more see Hive.H3 module documentation.

The future 🌈

More features and integrations with H3 will be available in the future at the moment the main goal is to stabilize the API and release the first version with clear documentation how setup and use Hive.

Assets 💄

  1. Project logo is from https://www.flaticon.com/free-icon/honeycomb_1598428

Enjoy!          

✨ 🍰 ✨            

hive-state's People

Contributors

sultaniman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

arvind-india

hive-state's Issues

Implement H3 features

  • num_hexagons/1,
  • edge_length_meters/1,
  • edge_length_kilometers/1,
  • hex_area_m2/1,
  • hex_area_km2/1,
  • get_base_cell/1,
  • is_valid/1,
  • k_ring_distances/2,
  • max_k_ring_size/1,
  • compact/1,
  • uncompact/2,
  • indices_are_neighbors/2,
  • get_unidirectional_edge/2,
  • grid_distance/2

UI frontend

  • User interface to manage and visualize fleet on the map

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.