Skip to content

Commit

Permalink
refactor: change edgeIDAndData to edge and replace location defin…
Browse files Browse the repository at this point in the history
…ition with nav.Location

issue: #282
  • Loading branch information
CodeBear801 committed Apr 24, 2020
1 parent 0e05d7a commit a4c429d
Show file tree
Hide file tree
Showing 12 changed files with 451 additions and 433 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions integration/service/oasis/stationgraph/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 8 additions & 5 deletions integration/service/oasis/stationgraph/graph_interface.go
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
Loading

0 comments on commit a4c429d

Please sign in to comment.