eco

package module
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

README

eco

eco is a simple package exposing tools to investigate the carbon footprint of LPC stemming from travel (plane, train, car, bus, ...)

eco consists of 3 parts:

  • cmd/eco-ingest: a command that loads LPC travel (internal) database, analyzes travel missions and uploads cleaned up data to `eco-srv
  • cmd/eco-srv: a HTTP server that computes statistical data from the cleaned up travel missions
  • cmd/eco-stats: a simple command that queries eco-srv and dumps statistical data on screen.

Example:

$> eco-srv -addr=eco-srv.example.com:80 &
eco-srv: serving "eco-srv.example.com:80"...

$> eco-stats -addr=eco-srv.example.com
eco-stats: querying "eco-srv.example.com"...
eco-stats: missions: 582
eco-stats: === transport ===
eco-stats: bike       0
eco-stats: tramway    2
eco-stats: train      120
eco-stats: bus        6
eco-stats: passenger  10
eco-stats: car        355
eco-stats: plane      89
eco-stats: === distances ===
eco-stats: bike       0 km
eco-stats: tramway    10 km
eco-stats: train      79056 km
eco-stats: bus        1685 km
eco-stats: passenger  2981 km
eco-stats: car        145968 km
eco-stats: plane      722748 km

References

Example

# CO2 Evolution

Last Updated: 2019-10-18 08:06:05 (UTC)
Stats
missions:     591 (executed)
missions:      57 (planned)
missions:     648 (all)
time period: 2018-10-02 -> 2019-10-18

## Transport (executed, planned, all)

bike           0     0     0
tramway        3     0     3
train        123     8   131
bus            6     0     6
passenger     10     0    10
car          367    34   401
plane         82    15    97

## Distances (executed, planned, all)

bike              0 km        0 km        0 km
tramway          15 km        0 km       15 km
train         81093 km     5844 km    86937 km
bus            1685 km        0 km     1685 km
passenger      2981 km        0 km     2981 km
car          148395 km    16149 km   164544 km
plane        638511 km   159958 km   798469 km

co2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TransIDs = []TransID{
	Bike,
	Tramway,
	Train,
	Bus,
	Passenger,
	Car,
	Plane,
}

List of all known TransIDs

Functions

func CostLess

func CostLess(a, b TransID) bool

CostLess returns whether a is costing less than b in terms of CO2.

func CostOf added in v0.6.0

func CostOf(tid TransID, dist float64) float64

CostOf returns the equivalent CO2 emission of a given distance (in meters), for a given transportation mode.

Factors extracted from:

Types

type Location

type Location struct {
	Name string  `json:"name"`
	Lat  float64 `json:"lat"`
	Lng  float64 `json:"lng"`
}

func (*Location) MarshalBinary

func (o *Location) MarshalBinary() (data []byte, err error)

MarshalBinary implements encoding.BinaryMarshaler

func (*Location) UnmarshalBinary

func (o *Location) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaler

type Mission

type Mission struct {
	ID int32 `json:"id"`

	Date  time.Time `json:"date"`
	Start Location  `json:"start"`
	Dest  Location  `json:"dest"`
	Dist  float64   `json:"dist"`
	Trans TransID   `json:"transport_id"`
}

func (*Mission) MarshalBinary

func (o *Mission) MarshalBinary() (data []byte, err error)

MarshalBinary implements encoding.BinaryMarshaler

func (Mission) String

func (m Mission) String() string

func (*Mission) UnmarshalBinary

func (o *Mission) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaler

type Stats

type Stats struct {
	N        int               `json:"missions"`
	TransIDs map[TransID]int   `json:"trans_ids"`
	Dists    map[TransID]int64 `json:"dists"`
}

func NewStats

func NewStats() Stats

func (*Stats) Add

func (stats *Stats) Add(m Mission)

type Summary added in v0.9.0

type Summary struct {
	Start     time.Time      `json:"start"`
	Stop      time.Time      `json:"stop"`
	Countries map[string]int `json:"countries"`
	Cities    map[string]int `json:"cities"`
	All       Stats          `json:"all_missions"`
	Planned   Stats          `json:"planned_missions"`
	Executed  Stats          `json:"executed_missions"`
}

func NewSummary added in v0.9.0

func NewSummary() *Summary

func (*Summary) Add added in v0.9.0

func (summ *Summary) Add(m Mission)

type TransID

type TransID byte
const (
	Unknown TransID = iota
	Bike
	Tramway
	Train
	Bus
	Passenger
	Car
	Plane
)

List of transport IDs, sorted by cost.

func (TransID) String

func (tid TransID) String() string

Directories

Path Synopsis
cmd
eco-osm
Command eco-osm queries the Nominatim service using OpenStreetMap data to locate a place.
Command eco-osm queries the Nominatim service using OpenStreetMap data to locate a place.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL