forked from Project-OSRM/osrm-backend
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refactor code for oasis service, more details please go to #223
issue: #223
- Loading branch information
1 parent
6a5433b
commit ff3f168
Showing
15 changed files
with
251 additions
and
188 deletions.
There are no files selected for viewing
22 changes: 0 additions & 22 deletions
22
integration/oasis/chargingstrategy/charge_strategy_creator.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package chargingstrategy | ||
|
||
// State contains charging related information | ||
type State struct { | ||
Energy float64 | ||
} | ||
|
||
// ChargingCost represents the cost needed to reach certain states | ||
type ChargingCost struct { | ||
Duration float64 | ||
// Later could add money usage, etc | ||
} | ||
|
||
// Creator creates charge states based on different charge strategy | ||
type Creator interface { | ||
// CreateChargingStates creates charge States which could be used by other algorithm | ||
CreateChargingStates() []State | ||
} | ||
|
||
// Evaluator calculate cost from given status(energy, etc) to target State | ||
type Evaluator interface { | ||
// EvaluateCost accepts current status and target status and returns cost needed | ||
EvaluateCost(arrivalEnergy float64, targetState State) ChargingCost | ||
} | ||
|
||
// Strategy defines interface related with creation and evaluation | ||
type Strategy interface { | ||
Creator | ||
Evaluator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
package haversine | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
"github.com/Telenav/osrm-backend/integration/util" | ||
) | ||
|
||
func TestGreatCircleDistance(t *testing.T) { | ||
// expect value got from http://www.onlineconversion.com/map_greatcircle_distance.htm | ||
expect := 111595.4865288326 | ||
actual := GreatCircleDistance(32.333, 122.323, 31.333, 122.423) | ||
if !floatEquals(expect, actual) { | ||
if !util.FloatEquals(expect, actual) { | ||
t.Errorf("Expected GreatCircleDistance returns %v, got %v", expect, actual) | ||
} | ||
} | ||
|
||
var epsilon float64 = 0.00000001 | ||
|
||
func floatEquals(a, b float64) bool { | ||
if (a-b) < epsilon && (b-a) < epsilon { | ||
return true | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.