Efficient in-memory fleet state management.
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.
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.
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() | []
}
For more usage details please refer to https://hex.pm/packages/hive
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.
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
.
- Project logo is from https://www.flaticon.com/free-icon/honeycomb_1598428
✨ 🍰 ✨