From a4c429d0a280e54c463ffc55d6db0f579064ae62 Mon Sep 17 00:00:00 2001 From: codebear801 Date: Fri, 24 Apr 2020 10:11:12 -0700 Subject: [PATCH] refactor: change `edgeIDAndData` to `edge` and replace location definition with nav.Location issue: https://github.com/Telenav/osrm-backend/issues/282 --- CHANGELOG-FORK.md | 1 + .../stationfinderalg/stations_iterator_alg.go | 4 +- .../service/oasis/stationgraph/edge.go | 6 +- .../oasis/stationgraph/graph_interface.go | 13 +- .../service/oasis/stationgraph/graph_mock.go | 315 +++++++++--------- .../service/oasis/stationgraph/node.go | 8 +- .../oasis/stationgraph/node_container.go | 18 +- .../oasis/stationgraph/node_container_test.go | 101 +++--- .../service/oasis/stationgraph/node_graph.go | 16 +- .../oasis/stationgraph/node_graph_test.go | 114 ++++--- .../oasis/stationgraph/station_graph.go | 22 +- .../oasis/stationgraph/station_graph_test.go | 266 +++++++-------- 12 files changed, 451 insertions(+), 433 deletions(-) diff --git a/CHANGELOG-FORK.md b/CHANGELOG-FORK.md index fb36895f873..deac0b433fd 100644 --- a/CHANGELOG-FORK.md +++ b/CHANGELOG-FORK.md @@ -4,6 +4,7 @@ Changes from v10.2.0 - Feature: - ADDED **HTTP API** `annotation/ways` in OSRM route response after `osrm-ranking` process(retrieve `annotation/ways` from `annotation/nodes`) [#296](https://github.com/Telenav/osrm-backend/pull/296) - CHANGED for internal refactoring, moved `unidbpatch` and `mapsource` packages into `integration/util` folder [#300](https://github.com/Telenav/osrm-backend/pull/300) + - CHANGED for internal refactoring, refactor staiongraph to isolate algorithm, data structure and topological [#302] - Bugfix: - CHANGED `osrm-ranking` parsing of OSRM route response to compatible with `string` array `annotation/nodes` [#296](https://github.com/Telenav/osrm-backend/pull/296) - Performance: diff --git a/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go b/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go index b61615c86f4..8ac722a0c18 100644 --- a/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go +++ b/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go @@ -32,7 +32,7 @@ func FindOverlapBetweenStations(iterF stationfindertype.NearbyStationsIterator, // CalcWeightBetweenChargeStationsPair accepts two iterators and calculates weights between each pair of iterators func CalcWeightBetweenChargeStationsPair(from stationfindertype.NearbyStationsIterator, to stationfindertype.NearbyStationsIterator, table osrmconnector.TableRequster) ([]stationfindertype.NeighborInfo, error) { - // collect (lat,lon)&ID for current location's nearby charge stations + // collect (Lat,Lon)&ID for current location's nearby charge stations var startPoints coordinate.Coordinates var startIDs []string for v := range from.IterateNearbyStations() { @@ -48,7 +48,7 @@ func CalcWeightBetweenChargeStationsPair(from stationfindertype.NearbyStationsIt return nil, err } - // collect (lat,lon)&ID for target location's nearby charge stations + // collect (Lat,Lon)&ID for target location's nearby charge stations var targetPoints coordinate.Coordinates var targetIDs []string for v := range to.IterateNearbyStations() { diff --git a/integration/service/oasis/stationgraph/edge.go b/integration/service/oasis/stationgraph/edge.go index 3d8dfc39802..a5b4c174592 100644 --- a/integration/service/oasis/stationgraph/edge.go +++ b/integration/service/oasis/stationgraph/edge.go @@ -5,12 +5,12 @@ type edgeID struct { toNodeID nodeID } -type edge struct { +type edgeMetric struct { distance float64 duration float64 } -type edgeIDAndData struct { +type edge struct { edgeId edgeID - edgeData *edge + edgeData *edgeMetric } diff --git a/integration/service/oasis/stationgraph/graph_interface.go b/integration/service/oasis/stationgraph/graph_interface.go index f1fdcbadac2..8688b02dca6 100644 --- a/integration/service/oasis/stationgraph/graph_interface.go +++ b/integration/service/oasis/stationgraph/graph_interface.go @@ -1,10 +1,13 @@ package stationgraph -import "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" +import ( + "github.com/Telenav/osrm-backend/integration/pkg/api/nav" + "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" +) // Graph defines interface used for Graph type Graph interface { - + // Node returns node object by its nodeID Node(id nodeID) *node @@ -13,13 +16,13 @@ type Graph interface { AdjacentNodes(id nodeID) []nodeID // Edge returns edge information between given two nodes - Edge(from, to nodeID) *edge + Edge(from, to nodeID) *edgeMetric // SetStart generates start node for the graph - SetStart(stationID string, targetState chargingstrategy.State, location locationInfo) Graph + SetStart(stationID string, targetState chargingstrategy.State, location nav.Location) Graph // SetEnd generates end node for the graph - SetEnd(stationID string, targetState chargingstrategy.State, location locationInfo) Graph + SetEnd(stationID string, targetState chargingstrategy.State, location nav.Location) Graph // StartNodeID returns start node's ID for given graph StartNodeID() nodeID diff --git a/integration/service/oasis/stationgraph/graph_mock.go b/integration/service/oasis/stationgraph/graph_mock.go index b4f3b4abb08..1af78fad4d7 100644 --- a/integration/service/oasis/stationgraph/graph_mock.go +++ b/integration/service/oasis/stationgraph/graph_mock.go @@ -1,6 +1,9 @@ package stationgraph -import "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" +import ( + "github.com/Telenav/osrm-backend/integration/pkg/api/nav" + "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" +) // node_0 -> node_1, duration = 30, distance = 30 // node_0 -> node_2, duration = 20, distance = 20 @@ -19,9 +22,9 @@ func NewMockGraph1() Graph { Energy: 999, }, }, - locationInfo{ - lat: 0.0, - lon: 0.0, + nav.Location{ + Lat: 0.0, + Lon: 0.0, }, }, { @@ -31,9 +34,9 @@ func NewMockGraph1() Graph { Energy: 999, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -43,9 +46,9 @@ func NewMockGraph1() Graph { Energy: 999, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { @@ -55,9 +58,9 @@ func NewMockGraph1() Graph { Energy: 999, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { @@ -67,9 +70,9 @@ func NewMockGraph1() Graph { Energy: 999, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, }, @@ -80,26 +83,26 @@ func NewMockGraph1() Graph { "node_3", "node_4", }, - map[nodeID][]*edgeIDAndData{ + map[nodeID][]*edge{ // node_0 -> node_1, duration = 30, distance = 30 // node_0 -> node_2, duration = 20, distance = 20 0: { - {edgeID{0, 1}, &edge{30, 30}}, - {edgeID{0, 2}, &edge{20, 20}}, + {edgeID{0, 1}, &edgeMetric{30, 30}}, + {edgeID{0, 2}, &edgeMetric{20, 20}}, }, // node_1 -> node_3, duration = 10, distance = 10 1: { - {edgeID{1, 3}, &edge{10, 10}}, + {edgeID{1, 3}, &edgeMetric{10, 10}}, }, // node_2 -> node_4, duration = 50, distance = 50 // node_2 -> node_3, duration = 50, distance = 50 2: { - {edgeID{2, 4}, &edge{50, 50}}, - {edgeID{2, 3}, &edge{50, 50}}, + {edgeID{2, 4}, &edgeMetric{50, 50}}, + {edgeID{2, 3}, &edgeMetric{50, 50}}, }, // node_3 -> node_4, duration = 10, distance = 10 3: { - {edgeID{3, 4}, &edge{10, 10}}, + {edgeID{3, 4}, &edgeMetric{10, 10}}, }, }, chargingstrategy.NewNullChargeStrategy(), @@ -132,9 +135,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 0.0, - lon: 0.0, + nav.Location{ + Lat: 0.0, + Lon: 0.0, }, }, { @@ -144,9 +147,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -156,9 +159,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { @@ -168,9 +171,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { @@ -180,9 +183,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, { @@ -192,9 +195,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 5.5, - lon: 5.5, + nav.Location{ + Lat: 5.5, + Lon: 5.5, }, }, { @@ -204,9 +207,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 6.6, - lon: 6.6, + nav.Location{ + Lat: 6.6, + Lon: 6.6, }, }, { @@ -216,9 +219,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 7.7, - lon: 7.7, + nav.Location{ + Lat: 7.7, + Lon: 7.7, }, }, { @@ -228,9 +231,9 @@ func NewMockGraph2() Graph { Energy: 999, }, }, - locationInfo{ - lat: 8.8, - lon: 8.8, + nav.Location{ + Lat: 8.8, + Lon: 8.8, }, }, }, @@ -245,7 +248,7 @@ func NewMockGraph2() Graph { "node_7", "node_8", }, - map[nodeID][]*edgeIDAndData{ + map[nodeID][]*edge{ // node_0 -> node_1, duration = 30, distance = 30 // node_0 -> node_2, duration = 20, distance = 20 0: { @@ -254,7 +257,7 @@ func NewMockGraph2() Graph { 0, 1, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -264,7 +267,7 @@ func NewMockGraph2() Graph { 0, 2, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -278,7 +281,7 @@ func NewMockGraph2() Graph { 1, 3, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -288,7 +291,7 @@ func NewMockGraph2() Graph { 1, 4, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -302,7 +305,7 @@ func NewMockGraph2() Graph { 2, 3, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -312,7 +315,7 @@ func NewMockGraph2() Graph { 2, 4, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -327,7 +330,7 @@ func NewMockGraph2() Graph { 3, 5, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -337,7 +340,7 @@ func NewMockGraph2() Graph { 3, 6, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -347,7 +350,7 @@ func NewMockGraph2() Graph { 3, 7, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -362,7 +365,7 @@ func NewMockGraph2() Graph { 4, 5, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -372,7 +375,7 @@ func NewMockGraph2() Graph { 4, 6, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -382,7 +385,7 @@ func NewMockGraph2() Graph { 4, 7, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -395,7 +398,7 @@ func NewMockGraph2() Graph { 5, 8, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -408,7 +411,7 @@ func NewMockGraph2() Graph { 6, 8, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -421,7 +424,7 @@ func NewMockGraph2() Graph { 7, 8, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -458,9 +461,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 0.0, - lon: 0.0, + nav.Location{ + Lat: 0.0, + Lon: 0.0, }, }, { @@ -470,9 +473,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -482,9 +485,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { @@ -494,9 +497,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { @@ -506,9 +509,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, { @@ -518,9 +521,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 5.5, - lon: 5.5, + nav.Location{ + Lat: 5.5, + Lon: 5.5, }, }, { @@ -530,9 +533,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 6.6, - lon: 6.6, + nav.Location{ + Lat: 6.6, + Lon: 6.6, }, }, { @@ -542,9 +545,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 7.7, - lon: 7.7, + nav.Location{ + Lat: 7.7, + Lon: 7.7, }, }, { @@ -554,9 +557,9 @@ func NewMockGraph3() Graph { Energy: 999, }, }, - locationInfo{ - lat: 8.8, - lon: 8.8, + nav.Location{ + Lat: 8.8, + Lon: 8.8, }, }, }, @@ -571,7 +574,7 @@ func NewMockGraph3() Graph { "node_7", "node_8", }, - map[nodeID][]*edgeIDAndData{ + map[nodeID][]*edge{ // node_0 -> node_1, duration = 15, distance = 15 // node_0 -> node_2, duration = 20, distance = 20 0: { @@ -580,7 +583,7 @@ func NewMockGraph3() Graph { 0, 1, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -590,7 +593,7 @@ func NewMockGraph3() Graph { 0, 2, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -604,7 +607,7 @@ func NewMockGraph3() Graph { 1, 3, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -614,7 +617,7 @@ func NewMockGraph3() Graph { 1, 4, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -628,7 +631,7 @@ func NewMockGraph3() Graph { 2, 3, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -638,7 +641,7 @@ func NewMockGraph3() Graph { 2, 4, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -653,7 +656,7 @@ func NewMockGraph3() Graph { 3, 5, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -663,7 +666,7 @@ func NewMockGraph3() Graph { 3, 6, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -673,7 +676,7 @@ func NewMockGraph3() Graph { 3, 7, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -688,7 +691,7 @@ func NewMockGraph3() Graph { 4, 5, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -698,7 +701,7 @@ func NewMockGraph3() Graph { 4, 6, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -708,7 +711,7 @@ func NewMockGraph3() Graph { 4, 7, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -721,7 +724,7 @@ func NewMockGraph3() Graph { 5, 8, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -734,7 +737,7 @@ func NewMockGraph3() Graph { 6, 8, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -747,7 +750,7 @@ func NewMockGraph3() Graph { 7, 8, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -785,9 +788,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 0.0, - lon: 0.0, + nav.Location{ + Lat: 0.0, + Lon: 0.0, }, }, { @@ -797,9 +800,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -809,9 +812,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { @@ -821,9 +824,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { @@ -833,9 +836,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, { @@ -845,9 +848,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 5.5, - lon: 5.5, + nav.Location{ + Lat: 5.5, + Lon: 5.5, }, }, { @@ -857,9 +860,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 6.6, - lon: 6.6, + nav.Location{ + Lat: 6.6, + Lon: 6.6, }, }, { @@ -869,9 +872,9 @@ func NewMockGraph4() Graph { Energy: 16, }, }, - locationInfo{ - lat: 7.7, - lon: 7.7, + nav.Location{ + Lat: 7.7, + Lon: 7.7, }, }, { @@ -881,9 +884,9 @@ func NewMockGraph4() Graph { Energy: 0, }, }, - locationInfo{ - lat: 8.8, - lon: 8.8, + nav.Location{ + Lat: 8.8, + Lon: 8.8, }, }, }, @@ -898,7 +901,7 @@ func NewMockGraph4() Graph { "node_7", "node_8", }, - map[nodeID][]*edgeIDAndData{ + map[nodeID][]*edge{ // node_0 -> node_1, duration = 15, distance = 15 // node_0 -> node_2, duration = 20, distance = 20 0: { @@ -907,7 +910,7 @@ func NewMockGraph4() Graph { 0, 1, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -917,7 +920,7 @@ func NewMockGraph4() Graph { 0, 2, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -931,7 +934,7 @@ func NewMockGraph4() Graph { 1, 3, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -941,7 +944,7 @@ func NewMockGraph4() Graph { 1, 4, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -955,7 +958,7 @@ func NewMockGraph4() Graph { 2, 3, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -965,7 +968,7 @@ func NewMockGraph4() Graph { 2, 4, }, - &edge{ + &edgeMetric{ 5, 5, }, @@ -980,7 +983,7 @@ func NewMockGraph4() Graph { 3, 5, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -990,7 +993,7 @@ func NewMockGraph4() Graph { 3, 6, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -1000,7 +1003,7 @@ func NewMockGraph4() Graph { 3, 7, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -1015,7 +1018,7 @@ func NewMockGraph4() Graph { 4, 5, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -1025,7 +1028,7 @@ func NewMockGraph4() Graph { 4, 6, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -1035,7 +1038,7 @@ func NewMockGraph4() Graph { 4, 7, }, - &edge{ + &edgeMetric{ 15, 15, }, @@ -1048,7 +1051,7 @@ func NewMockGraph4() Graph { 5, 8, }, - &edge{ + &edgeMetric{ 10, 10, }, @@ -1061,7 +1064,7 @@ func NewMockGraph4() Graph { 6, 8, }, - &edge{ + &edgeMetric{ 20, 20, }, @@ -1074,7 +1077,7 @@ func NewMockGraph4() Graph { 7, 8, }, - &edge{ + &edgeMetric{ 30, 30, }, @@ -1088,7 +1091,7 @@ func NewMockGraph4() Graph { type mockGraph struct { nodes []*node stationIDs []string - edges map[nodeID][]*edgeIDAndData + edges map[nodeID][]*edge strategy chargingstrategy.Strategy } @@ -1117,7 +1120,7 @@ func (graph *mockGraph) AdjacentNodes(id nodeID) []nodeID { } // Edge returns edge information between given two nodes -func (graph *mockGraph) Edge(from, to nodeID) *edge { +func (graph *mockGraph) Edge(from, to nodeID) *edgeMetric { if graph.isValidNodeID(from) && graph.isValidNodeID(to) { edges, ok := graph.edges[from] if ok { @@ -1133,12 +1136,12 @@ func (graph *mockGraph) Edge(from, to nodeID) *edge { } // SetStart generates start node for the graph -func (graph *mockGraph) SetStart(stationID string, targetState chargingstrategy.State, location locationInfo) Graph { +func (graph *mockGraph) SetStart(stationID string, targetState chargingstrategy.State, location nav.Location) Graph { return graph } // SetEnd generates end node for the graph -func (graph *mockGraph) SetEnd(stationID string, targetState chargingstrategy.State, location locationInfo) Graph { +func (graph *mockGraph) SetEnd(stationID string, targetState chargingstrategy.State, location nav.Location) Graph { return graph } diff --git a/integration/service/oasis/stationgraph/node.go b/integration/service/oasis/stationgraph/node.go index 81cc972e5dc..c1de1ee9227 100644 --- a/integration/service/oasis/stationgraph/node.go +++ b/integration/service/oasis/stationgraph/node.go @@ -3,6 +3,7 @@ package stationgraph import ( "math" + "github.com/Telenav/osrm-backend/integration/pkg/api/nav" "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" "github.com/golang/glog" ) @@ -13,15 +14,10 @@ type chargeInfo struct { targetState chargingstrategy.State } -type locationInfo struct { - lat float64 - lon float64 -} - type node struct { id nodeID chargeInfo - locationInfo + nav.Location } type nodeID uint32 diff --git a/integration/service/oasis/stationgraph/node_container.go b/integration/service/oasis/stationgraph/node_container.go index 514d23b8adc..682f8be4bbf 100644 --- a/integration/service/oasis/stationgraph/node_container.go +++ b/integration/service/oasis/stationgraph/node_container.go @@ -1,6 +1,9 @@ package stationgraph -import "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" +import ( + "github.com/Telenav/osrm-backend/integration/pkg/api/nav" + "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" +) type logicNodeIdentifier2NodePtr map[logicNodeIdentifier]*node type nodeID2NodePtr map[nodeID]*node @@ -22,20 +25,22 @@ func newNodeContainer() *nodeContainer { } } -func (nc *nodeContainer) addNode(stationID string, targetState chargingstrategy.State, location locationInfo) *node { +func (nc *nodeContainer) addNode(stationID string, targetState chargingstrategy.State, location nav.Location) *node { key := logicNodeIdentifier{stationID, targetState} if n, ok := nc.logicNode2NodePtr[key]; ok { return n } else { n = &node{ - id: (nodeID(nc.counter)), - chargeInfo: chargeInfo{ + (nodeID(nc.counter)), + chargeInfo{ arrivalEnergy: 0.0, chargeTime: 0.0, targetState: targetState, }, - locationInfo: location, + nav.Location{ + Lat: location.Lat, + Lon: location.Lon}, } nc.logicNode2NodePtr[key] = n nc.id2NodePtr[n.id] = n @@ -49,10 +54,9 @@ func (nc *nodeContainer) addNode(stationID string, targetState chargingstrategy. func (nc *nodeContainer) getNode(id nodeID) *node { if n, ok := nc.id2NodePtr[id]; ok { return n - } else { - return nil } + return nil } func (nc *nodeContainer) isNodeVisited(id nodeID) bool { diff --git a/integration/service/oasis/stationgraph/node_container_test.go b/integration/service/oasis/stationgraph/node_container_test.go index ed5e1076249..3cf2c879d1a 100644 --- a/integration/service/oasis/stationgraph/node_container_test.go +++ b/integration/service/oasis/stationgraph/node_container_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/Telenav/osrm-backend/integration/pkg/api/nav" "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" ) @@ -13,16 +14,16 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { input := []struct { stationID string chargeState chargingstrategy.State - location locationInfo + location nav.Location }{ { "station1", chargingstrategy.State{ Energy: 10.0, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -30,9 +31,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 20.0, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -40,9 +41,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 30.0, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -50,9 +51,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 10.0, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { @@ -60,9 +61,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 20.0, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { @@ -70,9 +71,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 15.0, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, } @@ -89,9 +90,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { Energy: 10.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, "station1", @@ -104,9 +105,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { Energy: 20.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, "station1", @@ -119,9 +120,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { Energy: 30.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, "station1", @@ -134,9 +135,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { Energy: 10.0, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, "station2", @@ -149,9 +150,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { Energy: 20.0, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, "station2", @@ -164,9 +165,9 @@ func TestAddAndGetFunctionsForNodeContainer(t *testing.T) { Energy: 15.0, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, "station3", @@ -222,16 +223,16 @@ func TestAddDuplicateNodeForNodeContainer(t *testing.T) { input := []struct { stationID string chargeState chargingstrategy.State - location locationInfo + location nav.Location }{ { "station1", chargingstrategy.State{ Energy: 10.0, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -239,9 +240,9 @@ func TestAddDuplicateNodeForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 10.0, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, { @@ -249,9 +250,9 @@ func TestAddDuplicateNodeForNodeContainer(t *testing.T) { chargingstrategy.State{ Energy: 10.0, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, } @@ -267,9 +268,9 @@ func TestAddDuplicateNodeForNodeContainer(t *testing.T) { Energy: 10.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, "station1", diff --git a/integration/service/oasis/stationgraph/node_graph.go b/integration/service/oasis/stationgraph/node_graph.go index ef926d4d4c0..57b0be4f206 100644 --- a/integration/service/oasis/stationgraph/node_graph.go +++ b/integration/service/oasis/stationgraph/node_graph.go @@ -8,7 +8,7 @@ import ( ) type nodeID2AdjacentNodes map[nodeID][]nodeID -type edgeID2EdgeData map[edgeID]*edge +type edgeID2EdgeData map[edgeID]*edgeMetric type nodeGraph struct { nodeContainer *nodeContainer @@ -57,7 +57,7 @@ func (g *nodeGraph) AdjacentNodes(id nodeID) []nodeID { } // Edge returns edge information between given two nodes -func (g *nodeGraph) Edge(from, to nodeID) *edge { +func (g *nodeGraph) Edge(from, to nodeID) *edgeMetric { edgeID := edgeID{ fromNodeID: from, toNodeID: to, @@ -67,14 +67,14 @@ func (g *nodeGraph) Edge(from, to nodeID) *edge { } // SetStart generates start node for the nodeGraph -func (g *nodeGraph) SetStart(stationID string, targetState chargingstrategy.State, location locationInfo) Graph { +func (g *nodeGraph) SetStart(stationID string, targetState chargingstrategy.State, location nav.Location) Graph { n := g.nodeContainer.addNode(stationID, targetState, location) g.startNodeID = n.id return g } // SetEnd generates end node for the nodeGraph -func (g *nodeGraph) SetEnd(stationID string, targetState chargingstrategy.State, location locationInfo) Graph { +func (g *nodeGraph) SetEnd(stationID string, targetState chargingstrategy.State, location nav.Location) Graph { n := g.nodeContainer.addNode(stationID, targetState, location) g.endNodeID = n.id return g @@ -115,17 +115,19 @@ func (g *nodeGraph) createLogicalNodes(from nodeID, toStationID string, toLocati endNodeID := g.EndNodeID() if toStationID == g.StationID(endNodeID) { results = append(results, g.Node(endNodeID)) - g.edgeData[edgeID{from, endNodeID}] = &edge{ + g.edgeData[edgeID{from, endNodeID}] = &edgeMetric{ distance: distance, duration: duration} return results } for _, state := range g.strategy.CreateChargingStates() { - n := g.nodeContainer.addNode(toStationID, state, locationInfo{toLocation.Lat, toLocation.Lon}) + n := g.nodeContainer.addNode(toStationID, state, nav.Location{ + Lat: toLocation.Lat, + Lon: toLocation.Lon}) results = append(results, n) - g.edgeData[edgeID{from, n.id}] = &edge{ + g.edgeData[edgeID{from, n.id}] = &edgeMetric{ distance: distance, duration: duration} } diff --git a/integration/service/oasis/stationgraph/node_graph_test.go b/integration/service/oasis/stationgraph/node_graph_test.go index b4f6b1cc397..7043f011617 100644 --- a/integration/service/oasis/stationgraph/node_graph_test.go +++ b/integration/service/oasis/stationgraph/node_graph_test.go @@ -15,9 +15,13 @@ func TestAddAndGetStartAndEndNodeForNodeGraph(t *testing.T) { graph := NewNodeGraph(nil, nil) expectStartChargeState := chargingstrategy.State{Energy: 10.0} - expectStartLocation := locationInfo{33.33, -122.22} + expectStartLocation := nav.Location{ + Lat: 33.33, + Lon: -122.22} expectEndChargeState := chargingstrategy.State{} - expectEndLocation := locationInfo{34.44, -124.44} + expectEndLocation := nav.Location{ + Lat: 34.44, + Lon: -124.44} graph.SetStart(stationfindertype.OrigLocationID, expectStartChargeState, expectStartLocation). SetEnd(stationfindertype.DestLocationID, expectEndChargeState, expectEndLocation) @@ -31,16 +35,18 @@ func TestAddAndGetStartAndEndNodeForNodeGraph(t *testing.T) { } startNode := graph.Node(graph.StartNodeID()) - if !reflect.DeepEqual(startNode.locationInfo, expectStartLocation) { - t.Errorf("Incorrect result for start's location, expect %#v but got %#v.\n", expectStartLocation, startNode.locationInfo) + if !(reflect.DeepEqual(startNode.Lat, expectStartLocation.Lat) && + reflect.DeepEqual(startNode.Lon, expectStartLocation.Lon)) { + t.Errorf("Incorrect result for start's location, expect %#v but got %#v.\n", expectStartLocation, startNode) } if !reflect.DeepEqual(startNode.chargeInfo.targetState, expectStartChargeState) { t.Errorf("Incorrect result for start's charge state, expect %#v but got %#v.\n", expectStartChargeState, startNode.chargeInfo.targetState) } endNode := graph.Node(graph.EndNodeID()) - if !reflect.DeepEqual(endNode.locationInfo, expectEndLocation) { - t.Errorf("Incorrect result for end's location, expect %#v but got %#v.\n", expectEndLocation, endNode.locationInfo) + if !(reflect.DeepEqual(endNode.Lat, expectEndLocation.Lat) && + reflect.DeepEqual(endNode.Lon, expectEndLocation.Lon)) { + t.Errorf("Incorrect result for end's location, expect %#v but got %#v.\n", expectEndLocation, endNode) } if !reflect.DeepEqual(endNode.chargeInfo.targetState, expectEndChargeState) { t.Errorf("Incorrect result for end's charge state, expect %#v but got %#v.\n", expectEndChargeState, endNode.chargeInfo.targetState) @@ -59,111 +65,111 @@ func TestAdjacentNodesInterfaceForNodeGraph(t *testing.T) { expectNodes := []*node{ { - id: 1, - chargeInfo: chargeInfo{ + 1, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 60.0, }, }, - locationInfo: locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { - id: 2, - chargeInfo: chargeInfo{ + 2, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 80.0, }, }, - locationInfo: locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { - id: 3, - chargeInfo: chargeInfo{ + 3, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 100.0, }, }, - locationInfo: locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, { - id: 4, - chargeInfo: chargeInfo{ + 4, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 60.0, }, }, - locationInfo: locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { - id: 5, - chargeInfo: chargeInfo{ + 5, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 80.0, }, }, - locationInfo: locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { - id: 6, - chargeInfo: chargeInfo{ + 6, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 100.0, }, }, - locationInfo: locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, { - id: 7, - chargeInfo: chargeInfo{ + 7, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 60.0, }, }, - locationInfo: locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, { - id: 8, - chargeInfo: chargeInfo{ + 8, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 80.0, }, }, - locationInfo: locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, { - id: 9, - chargeInfo: chargeInfo{ + 9, + chargeInfo{ targetState: chargingstrategy.State{ Energy: 100.0, }, }, - locationInfo: locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, } @@ -180,7 +186,7 @@ func TestEdgeInterfaceForNodeGraph(t *testing.T) { graph := generateMockNodeGraph() nodeIDs := graph.AdjacentNodes(graph.StartNodeID()) - expectEdges := []*edge{ + expectEdges := []*edgeMetric{ { distance: 2, duration: 2, @@ -219,7 +225,7 @@ func TestEdgeInterfaceForNodeGraph(t *testing.T) { }, } - actualEdges := make([]*edge, 0, len(nodeIDs)) + actualEdges := make([]*edgeMetric, 0, len(nodeIDs)) fromNodeID := graph.StartNodeID() for _, toNodeID := range nodeIDs { actualEdges = append(actualEdges, graph.Edge(fromNodeID, toNodeID)) @@ -263,7 +269,7 @@ func generateMockNodeGraph() Graph { graph := NewNodeGraph(strategy, querier) origLocation := querier.GetLocation(testStationID1) - graph.SetStart(testStationID1, chargingstrategy.State{Energy: currEnergyLevel}, locationInfo{lat: origLocation.Lat, lon: origLocation.Lon}) + graph.SetStart(testStationID1, chargingstrategy.State{Energy: currEnergyLevel}, nav.Location{Lat: origLocation.Lat, Lon: origLocation.Lon}) return graph } diff --git a/integration/service/oasis/stationgraph/station_graph.go b/integration/service/oasis/stationgraph/station_graph.go index 17f949b2d97..8f14d7a8951 100644 --- a/integration/service/oasis/stationgraph/station_graph.go +++ b/integration/service/oasis/stationgraph/station_graph.go @@ -45,15 +45,15 @@ func (sg *stationGraph) setStartAndEndForGraph(currEnergyLevel, maxEnergyLevel f chargingstrategy.State{ Energy: currEnergyLevel, }, - locationInfo{ - startLocation.Lat, - startLocation.Lon}) + nav.Location{ + Lat: startLocation.Lat, + Lon: startLocation.Lon}) sg.g = sg.g.SetEnd(stationfindertype.DestLocationID, chargingstrategy.State{}, - locationInfo{ - endLocation.Lat, - endLocation.Lon}) + nav.Location{ + Lat: endLocation.Lat, + Lon: endLocation.Lon}) return true } @@ -95,8 +95,8 @@ func (sg *stationGraph) generateSolutionsBasedOnStationCandidates(stationNodes [ station.ChargeRange = getChargeInfo(sg.g, stationNodes[i]).targetState.Energy station.ChargeTime = getChargeInfo(sg.g, stationNodes[i]).chargeTime station.Location = nav.Location{ - Lat: getLocationInfo(sg.g, stationNodes[i]).lat, - Lon: getLocationInfo(sg.g, stationNodes[i]).lon, + Lat: getLocationInfo(sg.g, stationNodes[i]).Lat, + Lon: getLocationInfo(sg.g, stationNodes[i]).Lon, } station.StationID = sg.g.StationID(stationNodes[i]) @@ -148,12 +148,14 @@ func getChargeInfo(g Graph, n nodeID) chargeInfo { return g.Node(n).chargeInfo } -func getLocationInfo(g Graph, n nodeID) locationInfo { +func getLocationInfo(g Graph, n nodeID) nav.Location { if g.Node(n) == nil { glog.Fatalf("While calling getLocationInfo, incorrect nodeID passed into graph %v\n", n) } - return g.Node(n).locationInfo + return nav.Location{ + Lat: g.Node(n).Lat, + Lon: g.Node(n).Lon} } func (sg *stationGraph) isStart(id string) bool { diff --git a/integration/service/oasis/stationgraph/station_graph_test.go b/integration/service/oasis/stationgraph/station_graph_test.go index 07c6aee6277..6556cfb7c27 100644 --- a/integration/service/oasis/stationgraph/station_graph_test.go +++ b/integration/service/oasis/stationgraph/station_graph_test.go @@ -264,9 +264,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 20.0, }, }, - locationInfo{ - lat: 0.0, - lon: 0.0, + nav.Location{ + Lat: 0.0, + Lon: 0.0, }, }, // stationfindertype.DestLocationID, @@ -275,9 +275,9 @@ var mockedGraph4StationGraph = mockGraph{ chargeInfo{ targetState: chargingstrategy.State{}, }, - locationInfo{ - lat: 6.6, - lon: 6.6, + nav.Location{ + Lat: 6.6, + Lon: 6.6, }, }, // station 1 @@ -288,9 +288,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 30.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, // station 1 @@ -301,9 +301,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 40.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, // station 1 @@ -314,9 +314,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 50.0, }, }, - locationInfo{ - lat: 1.1, - lon: 1.1, + nav.Location{ + Lat: 1.1, + Lon: 1.1, }, }, // station 2 @@ -327,9 +327,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 30.0, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, // station 2 @@ -340,9 +340,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 40.0, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, // station 2 @@ -353,9 +353,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 50.0, }, }, - locationInfo{ - lat: 2.2, - lon: 2.2, + nav.Location{ + Lat: 2.2, + Lon: 2.2, }, }, // station 3 @@ -366,9 +366,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 30.0, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, // station 3 @@ -379,9 +379,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 40.0, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, // station 3 @@ -392,9 +392,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 50.0, }, }, - locationInfo{ - lat: 3.3, - lon: 3.3, + nav.Location{ + Lat: 3.3, + Lon: 3.3, }, }, // station 4 @@ -405,9 +405,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 30.0, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, // station 4 @@ -418,9 +418,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 40.0, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, // station 4 @@ -431,9 +431,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 50.0, }, }, - locationInfo{ - lat: 4.4, - lon: 4.4, + nav.Location{ + Lat: 4.4, + Lon: 4.4, }, }, // station 5 @@ -444,9 +444,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 30.0, }, }, - locationInfo{ - lat: 5.5, - lon: 5.5, + nav.Location{ + Lat: 5.5, + Lon: 5.5, }, }, // station 5 @@ -457,9 +457,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 40.0, }, }, - locationInfo{ - lat: 5.5, - lon: 5.5, + nav.Location{ + Lat: 5.5, + Lon: 5.5, }, }, // station 5 @@ -470,9 +470,9 @@ var mockedGraph4StationGraph = mockGraph{ Energy: 50.0, }, }, - locationInfo{ - lat: 5.5, - lon: 5.5, + nav.Location{ + Lat: 5.5, + Lon: 5.5, }, }, }, @@ -495,146 +495,146 @@ var mockedGraph4StationGraph = mockGraph{ "station5", "station5", }, - map[nodeID][]*edgeIDAndData{ + map[nodeID][]*edge{ 0: { // orig -> station 1 - {edgeID{0, 2}, &edge{22.2, 22.2}}, - {edgeID{0, 3}, &edge{22.2, 22.2}}, - {edgeID{0, 4}, &edge{22.2, 22.2}}, + {edgeID{0, 2}, &edgeMetric{22.2, 22.2}}, + {edgeID{0, 3}, &edgeMetric{22.2, 22.2}}, + {edgeID{0, 4}, &edgeMetric{22.2, 22.2}}, // orig -> station 2 - {edgeID{0, 5}, &edge{11.1, 11.1}}, - {edgeID{0, 6}, &edge{11.1, 11.1}}, - {edgeID{0, 7}, &edge{11.1, 11.1}}, + {edgeID{0, 5}, &edgeMetric{11.1, 11.1}}, + {edgeID{0, 6}, &edgeMetric{11.1, 11.1}}, + {edgeID{0, 7}, &edgeMetric{11.1, 11.1}}, // orig -> station 3 - {edgeID{0, 8}, &edge{33.3, 33.3}}, - {edgeID{0, 9}, &edge{33.3, 33.3}}, - {edgeID{0, 10}, &edge{33.3, 33.3}}, + {edgeID{0, 8}, &edgeMetric{33.3, 33.3}}, + {edgeID{0, 9}, &edgeMetric{33.3, 33.3}}, + {edgeID{0, 10}, &edgeMetric{33.3, 33.3}}, }, 2: { // station 1 -> station 4 - {edgeID{2, 11}, &edge{44.4, 44.4}}, - {edgeID{2, 12}, &edge{44.4, 44.4}}, - {edgeID{2, 13}, &edge{44.4, 44.4}}, + {edgeID{2, 11}, &edgeMetric{44.4, 44.4}}, + {edgeID{2, 12}, &edgeMetric{44.4, 44.4}}, + {edgeID{2, 13}, &edgeMetric{44.4, 44.4}}, // station 1 -> station 5 - {edgeID{2, 14}, &edge{34.4, 34.4}}, - {edgeID{2, 15}, &edge{34.4, 34.4}}, - {edgeID{2, 16}, &edge{34.4, 34.4}}, + {edgeID{2, 14}, &edgeMetric{34.4, 34.4}}, + {edgeID{2, 15}, &edgeMetric{34.4, 34.4}}, + {edgeID{2, 16}, &edgeMetric{34.4, 34.4}}, }, 3: { // station 1 -> station 4 - {edgeID{3, 11}, &edge{44.4, 44.4}}, - {edgeID{3, 12}, &edge{44.4, 44.4}}, - {edgeID{3, 13}, &edge{44.4, 44.4}}, + {edgeID{3, 11}, &edgeMetric{44.4, 44.4}}, + {edgeID{3, 12}, &edgeMetric{44.4, 44.4}}, + {edgeID{3, 13}, &edgeMetric{44.4, 44.4}}, // station 1 -> station 5 - {edgeID{3, 14}, &edge{34.4, 34.4}}, - {edgeID{3, 15}, &edge{34.4, 34.4}}, - {edgeID{3, 16}, &edge{34.4, 34.4}}, + {edgeID{3, 14}, &edgeMetric{34.4, 34.4}}, + {edgeID{3, 15}, &edgeMetric{34.4, 34.4}}, + {edgeID{3, 16}, &edgeMetric{34.4, 34.4}}, }, 4: { // station 1 -> station 4 - {edgeID{4, 11}, &edge{44.4, 44.4}}, - {edgeID{4, 12}, &edge{44.4, 44.4}}, - {edgeID{4, 13}, &edge{44.4, 44.4}}, + {edgeID{4, 11}, &edgeMetric{44.4, 44.4}}, + {edgeID{4, 12}, &edgeMetric{44.4, 44.4}}, + {edgeID{4, 13}, &edgeMetric{44.4, 44.4}}, // station 1 -> station 5 - {edgeID{4, 14}, &edge{34.4, 34.4}}, - {edgeID{4, 15}, &edge{34.4, 34.4}}, - {edgeID{4, 16}, &edge{34.4, 34.4}}, + {edgeID{4, 14}, &edgeMetric{34.4, 34.4}}, + {edgeID{4, 15}, &edgeMetric{34.4, 34.4}}, + {edgeID{4, 16}, &edgeMetric{34.4, 34.4}}, }, 5: { // station 2 -> station 4 - {edgeID{5, 11}, &edge{11.1, 11.1}}, - {edgeID{5, 12}, &edge{11.1, 11.1}}, - {edgeID{5, 13}, &edge{11.1, 11.1}}, + {edgeID{5, 11}, &edgeMetric{11.1, 11.1}}, + {edgeID{5, 12}, &edgeMetric{11.1, 11.1}}, + {edgeID{5, 13}, &edgeMetric{11.1, 11.1}}, // station 2 -> station 5 - {edgeID{5, 14}, &edge{14.4, 14.4}}, - {edgeID{5, 15}, &edge{14.4, 14.4}}, - {edgeID{5, 16}, &edge{14.4, 14.4}}, + {edgeID{5, 14}, &edgeMetric{14.4, 14.4}}, + {edgeID{5, 15}, &edgeMetric{14.4, 14.4}}, + {edgeID{5, 16}, &edgeMetric{14.4, 14.4}}, }, 6: { // station 2 -> station 4 - {edgeID{6, 11}, &edge{11.1, 11.1}}, - {edgeID{6, 12}, &edge{11.1, 11.1}}, - {edgeID{6, 13}, &edge{11.1, 11.1}}, + {edgeID{6, 11}, &edgeMetric{11.1, 11.1}}, + {edgeID{6, 12}, &edgeMetric{11.1, 11.1}}, + {edgeID{6, 13}, &edgeMetric{11.1, 11.1}}, // station 2 -> station 5 - {edgeID{6, 14}, &edge{14.4, 14.4}}, - {edgeID{6, 15}, &edge{14.4, 14.4}}, - {edgeID{6, 16}, &edge{14.4, 14.4}}, + {edgeID{6, 14}, &edgeMetric{14.4, 14.4}}, + {edgeID{6, 15}, &edgeMetric{14.4, 14.4}}, + {edgeID{6, 16}, &edgeMetric{14.4, 14.4}}, }, 7: { // station 2 -> station 4 - {edgeID{7, 11}, &edge{11.1, 11.1}}, - {edgeID{7, 12}, &edge{11.1, 11.1}}, - {edgeID{7, 13}, &edge{11.1, 11.1}}, + {edgeID{7, 11}, &edgeMetric{11.1, 11.1}}, + {edgeID{7, 12}, &edgeMetric{11.1, 11.1}}, + {edgeID{7, 13}, &edgeMetric{11.1, 11.1}}, // station 2 -> station 5 - {edgeID{7, 14}, &edge{14.4, 14.4}}, - {edgeID{7, 15}, &edge{14.4, 14.4}}, - {edgeID{7, 16}, &edge{14.4, 14.4}}, + {edgeID{7, 14}, &edgeMetric{14.4, 14.4}}, + {edgeID{7, 15}, &edgeMetric{14.4, 14.4}}, + {edgeID{7, 16}, &edgeMetric{14.4, 14.4}}, }, 8: { // station 3 -> station 4 - {edgeID{8, 11}, &edge{22.2, 22.2}}, - {edgeID{8, 12}, &edge{22.2, 22.2}}, - {edgeID{8, 13}, &edge{22.2, 22.2}}, + {edgeID{8, 11}, &edgeMetric{22.2, 22.2}}, + {edgeID{8, 12}, &edgeMetric{22.2, 22.2}}, + {edgeID{8, 13}, &edgeMetric{22.2, 22.2}}, // station 3 -> station 5 - {edgeID{8, 14}, &edge{15.5, 15.5}}, - {edgeID{8, 15}, &edge{15.5, 15.5}}, - {edgeID{8, 16}, &edge{15.5, 15.5}}, + {edgeID{8, 14}, &edgeMetric{15.5, 15.5}}, + {edgeID{8, 15}, &edgeMetric{15.5, 15.5}}, + {edgeID{8, 16}, &edgeMetric{15.5, 15.5}}, }, 9: { // station 3 -> station 4 - {edgeID{9, 11}, &edge{22.2, 22.2}}, - {edgeID{9, 12}, &edge{22.2, 22.2}}, - {edgeID{9, 13}, &edge{22.2, 22.2}}, + {edgeID{9, 11}, &edgeMetric{22.2, 22.2}}, + {edgeID{9, 12}, &edgeMetric{22.2, 22.2}}, + {edgeID{9, 13}, &edgeMetric{22.2, 22.2}}, // station 3 -> station 5 - {edgeID{9, 14}, &edge{15.5, 15.5}}, - {edgeID{9, 15}, &edge{15.5, 15.5}}, - {edgeID{9, 16}, &edge{15.5, 15.5}}, + {edgeID{9, 14}, &edgeMetric{15.5, 15.5}}, + {edgeID{9, 15}, &edgeMetric{15.5, 15.5}}, + {edgeID{9, 16}, &edgeMetric{15.5, 15.5}}, }, 10: { // station 3 -> station 4 - {edgeID{10, 11}, &edge{22.2, 22.2}}, - {edgeID{10, 12}, &edge{22.2, 22.2}}, - {edgeID{10, 13}, &edge{22.2, 22.2}}, + {edgeID{10, 11}, &edgeMetric{22.2, 22.2}}, + {edgeID{10, 12}, &edgeMetric{22.2, 22.2}}, + {edgeID{10, 13}, &edgeMetric{22.2, 22.2}}, // station 3 -> station 5 - {edgeID{10, 14}, &edge{15.5, 15.5}}, - {edgeID{10, 15}, &edge{15.5, 15.5}}, - {edgeID{10, 16}, &edge{15.5, 15.5}}, + {edgeID{10, 14}, &edgeMetric{15.5, 15.5}}, + {edgeID{10, 15}, &edgeMetric{15.5, 15.5}}, + {edgeID{10, 16}, &edgeMetric{15.5, 15.5}}, }, 11: { // station 4 -> end - {edgeID{11, 1}, &edge{44.4, 44.4}}, - {edgeID{11, 1}, &edge{44.4, 44.4}}, - {edgeID{11, 1}, &edge{44.4, 44.4}}, + {edgeID{11, 1}, &edgeMetric{44.4, 44.4}}, + {edgeID{11, 1}, &edgeMetric{44.4, 44.4}}, + {edgeID{11, 1}, &edgeMetric{44.4, 44.4}}, }, 12: { // station 4 -> end - {edgeID{12, 1}, &edge{44.4, 44.4}}, - {edgeID{12, 1}, &edge{44.4, 44.4}}, - {edgeID{12, 1}, &edge{44.4, 44.4}}, + {edgeID{12, 1}, &edgeMetric{44.4, 44.4}}, + {edgeID{12, 1}, &edgeMetric{44.4, 44.4}}, + {edgeID{12, 1}, &edgeMetric{44.4, 44.4}}, }, 13: { // station 4 -> end - {edgeID{13, 1}, &edge{44.4, 44.4}}, - {edgeID{13, 1}, &edge{44.4, 44.4}}, - {edgeID{13, 1}, &edge{44.4, 44.4}}, + {edgeID{13, 1}, &edgeMetric{44.4, 44.4}}, + {edgeID{13, 1}, &edgeMetric{44.4, 44.4}}, + {edgeID{13, 1}, &edgeMetric{44.4, 44.4}}, }, 14: { // station 5 -> end - {edgeID{14, 1}, &edge{33.3, 33.3}}, - {edgeID{14, 1}, &edge{33.3, 33.3}}, - {edgeID{14, 1}, &edge{33.3, 33.3}}, + {edgeID{14, 1}, &edgeMetric{33.3, 33.3}}, + {edgeID{14, 1}, &edgeMetric{33.3, 33.3}}, + {edgeID{14, 1}, &edgeMetric{33.3, 33.3}}, }, 15: { // station 5 -> end - {edgeID{15, 1}, &edge{33.3, 33.3}}, - {edgeID{15, 1}, &edge{33.3, 33.3}}, - {edgeID{15, 1}, &edge{33.3, 33.3}}, + {edgeID{15, 1}, &edgeMetric{33.3, 33.3}}, + {edgeID{15, 1}, &edgeMetric{33.3, 33.3}}, + {edgeID{15, 1}, &edgeMetric{33.3, 33.3}}, }, 16: { // station 5 -> end - {edgeID{16, 1}, &edge{33.3, 33.3}}, - {edgeID{16, 1}, &edge{33.3, 33.3}}, - {edgeID{16, 1}, &edge{33.3, 33.3}}, + {edgeID{16, 1}, &edgeMetric{33.3, 33.3}}, + {edgeID{16, 1}, &edgeMetric{33.3, 33.3}}, + {edgeID{16, 1}, &edgeMetric{33.3, 33.3}}, }, }, chargingstrategy.NewFakeChargingStrategy(50.0),