diff --git a/CHANGELOG-FORK.md b/CHANGELOG-FORK.md index 894f9625e35..1d35faf80dc 100644 --- a/CHANGELOG-FORK.md +++ b/CHANGELOG-FORK.md @@ -2,6 +2,10 @@ # Unreleased Changes from v10.3.0 - Feature: + - ADDED package `oasis/selectionstrategy`, move logic related with how to select optimum charge stations into this package [#339](https://github.com/Telenav/osrm-backend/pull/339) + - CHANGED for integration of pre-generated connectivity data with OASIS service [#339](https://github.com/Telenav/osrm-backend/pull/339) + - CHANGED for internal refactoring, replace `Location` in `spatialindexer` to nav.Location, replace all name of `point` to `place` [#341](https://github.com/Telenav/osrm-backend/pull/341) + - CHANGED for internal refactoring, move package oasis/solution, oasis/osrmhelper and oasis/searchhelper into oasis/internal [#343](https://github.com/Telenav/osrm-backend/pull/343) - Bugfix: - Performance: - Tools: @@ -31,9 +35,7 @@ Changes from v10.2.0 - CHANGED for epsilon of util/floatequals, use different epsilon for float32 compare and float64 compare [#332](https://github.com/Telenav/osrm-backend/issues/332) - ADDED interface test for `trafficapplyingmodel` implementation(both `appendspeedonly` and `preferlivetraffic`) [#330](https://github.com/Telenav/osrm-backend/pull/330) - CHANGED for mock objects, hide them in internal/mock package for OASIS service [#334](https://github.com/Telenav/osrm-backend/issues/334) - - ADDED package `oasis/selectionstrategy`, move logic related with how to select optimum charge stations into this package [#339](https://github.com/Telenav/osrm-backend/pull/339) - - CHANGED for integration of pre-generated connectivity data with OASIS service [#339](https://github.com/Telenav/osrm-backend/pull/339) - - CHANGED for internal refactoring, replace `Location` in `spatialindexer` to nav.Location, replace all name of `point` to `place` [#341](https://github.com/Telenav/osrm-backend/pull/341) + - 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) diff --git a/integration/service/oasis/handler.go b/integration/service/oasis/handler.go index 062a4de6632..a17e8d9ef92 100644 --- a/integration/service/oasis/handler.go +++ b/integration/service/oasis/handler.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/Telenav/osrm-backend/integration/api/oasis" - "github.com/Telenav/osrm-backend/integration/service/oasis/osrmhelper" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/osrmhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/selectionstrategy" "github.com/golang/glog" ) diff --git a/integration/service/oasis/haversine/distance.go b/integration/service/oasis/haversine/distance.go deleted file mode 100644 index 382e92400ad..00000000000 --- a/integration/service/oasis/haversine/distance.go +++ /dev/null @@ -1,29 +0,0 @@ -package haversine - -import ( - "math" -) - -const ( - // According to Wikipedia, the Earth's radius is about 6,371km - EARTH_RADIUS = 6371000 -) - -// GreatCircleDistance: Calculates the Haversine distance between two points in meters. -// Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html -func GreatCircleDistance(lat1, lon1, lat2, lon2 float64) float64 { - dLat := (lat2 - lat1) * (math.Pi / 180.0) - dLon := (lon2 - lon1) * (math.Pi / 180.0) - - lat1 = lat1 * (math.Pi / 180.0) - lat2 = lat2 * (math.Pi / 180.0) - - a1 := math.Sin(dLat/2) * math.Sin(dLat/2) - a2 := math.Sin(dLon/2) * math.Sin(dLon/2) * math.Cos(lat1) * math.Cos(lat2) - - a := a1 + a2 - - c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a)) - - return EARTH_RADIUS * c -} diff --git a/integration/service/oasis/haversine/distance_test.go b/integration/service/oasis/haversine/distance_test.go deleted file mode 100644 index ee146189d27..00000000000 --- a/integration/service/oasis/haversine/distance_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package haversine - -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 !util.Float64Equal(expect, actual) { - t.Errorf("Expected GreatCircleDistance returns %v, got %v", expect, actual) - } -} diff --git a/integration/service/oasis/osrmhelper/helper.go b/integration/service/oasis/internal/osrmhelper/helper.go similarity index 100% rename from integration/service/oasis/osrmhelper/helper.go rename to integration/service/oasis/internal/osrmhelper/helper.go diff --git a/integration/service/oasis/searchhelper/helper.go b/integration/service/oasis/internal/searchhelper/helper.go similarity index 100% rename from integration/service/oasis/searchhelper/helper.go rename to integration/service/oasis/internal/searchhelper/helper.go diff --git a/integration/service/oasis/solution/doc.go b/integration/service/oasis/internal/solution/doc.go similarity index 100% rename from integration/service/oasis/solution/doc.go rename to integration/service/oasis/internal/solution/doc.go diff --git a/integration/service/oasis/solution/solution.go b/integration/service/oasis/internal/solution/solution.go similarity index 100% rename from integration/service/oasis/solution/solution.go rename to integration/service/oasis/internal/solution/solution.go diff --git a/integration/service/oasis/selectionstrategy/reachable_by_multiple_charge.go b/integration/service/oasis/selectionstrategy/reachable_by_multiple_charge.go index 12a84834def..227e8dbca95 100644 --- a/integration/service/oasis/selectionstrategy/reachable_by_multiple_charge.go +++ b/integration/service/oasis/selectionstrategy/reachable_by_multiple_charge.go @@ -8,13 +8,13 @@ import ( "github.com/Telenav/osrm-backend/integration/api/oasis" "github.com/Telenav/osrm-backend/integration/api/osrm/route" "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" - "github.com/Telenav/osrm-backend/integration/service/oasis/haversine" "github.com/Telenav/osrm-backend/integration/service/oasis/osrmconnector" "github.com/Telenav/osrm-backend/integration/service/oasis/spatialindexer/ranker" "github.com/Telenav/osrm-backend/integration/service/oasis/stationconnquerier" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder/stationfinderalg" "github.com/Telenav/osrm-backend/integration/service/oasis/stationgraph" + "github.com/blevesearch/bleve/geo" "github.com/golang/glog" "github.com/twpayne/go-polyline" @@ -119,7 +119,8 @@ func findChargeLocation4Route(route *route.Route, result []*nav.Location, currEn tmp := 0.0 for i := 0; i < len(coords)-1; i++ { - tmp += haversine.GreatCircleDistance(coords[i][0], coords[i][1], coords[i+1][0], coords[i+1][1]) + // geo.Haversin's unit is kilometer, convert to meter + tmp += geo.Haversin(coords[i][1], coords[i][0], coords[i+1][1], coords[i+1][0]) * 1000 if currEnergy-tmp < preferLevel { currEnergy = maxRange result = append(result, &nav.Location{ diff --git a/integration/service/oasis/selectionstrategy/reachable_by_single_charge.go b/integration/service/oasis/selectionstrategy/reachable_by_single_charge.go index 3fa9ec08b74..41dfff0fe83 100644 --- a/integration/service/oasis/selectionstrategy/reachable_by_single_charge.go +++ b/integration/service/oasis/selectionstrategy/reachable_by_single_charge.go @@ -10,8 +10,8 @@ import ( "github.com/Telenav/osrm-backend/integration/api/osrm" "github.com/Telenav/osrm-backend/integration/api/osrm/table" "github.com/Telenav/osrm-backend/integration/api/search/nearbychargestation" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/osrmhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/osrmconnector" - "github.com/Telenav/osrm-backend/integration/service/oasis/osrmhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder/stationfinderalg" "github.com/golang/glog" ) diff --git a/integration/service/oasis/stationfinder/cloudfinder/dest_station_finder.go b/integration/service/oasis/stationfinder/cloudfinder/dest_station_finder.go index 52490e6ef8b..c79aff3ab25 100644 --- a/integration/service/oasis/stationfinder/cloudfinder/dest_station_finder.go +++ b/integration/service/oasis/stationfinder/cloudfinder/dest_station_finder.go @@ -3,8 +3,8 @@ package cloudfinder import ( "github.com/Telenav/osrm-backend/integration/api/oasis" "github.com/Telenav/osrm-backend/integration/api/search/searchcoordinate" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/searchhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/searchconnector" - "github.com/Telenav/osrm-backend/integration/service/oasis/searchhelper" ) //@todo: This number need to be adjusted based on charge station profile diff --git a/integration/service/oasis/stationfinder/cloudfinder/low_energy_location_station_finder.go b/integration/service/oasis/stationfinder/cloudfinder/low_energy_location_station_finder.go index c1ff88256cf..402ddb323fb 100644 --- a/integration/service/oasis/stationfinder/cloudfinder/low_energy_location_station_finder.go +++ b/integration/service/oasis/stationfinder/cloudfinder/low_energy_location_station_finder.go @@ -3,8 +3,8 @@ package cloudfinder import ( "github.com/Telenav/osrm-backend/integration/api/nav" "github.com/Telenav/osrm-backend/integration/api/search/searchcoordinate" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/searchhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/searchconnector" - "github.com/Telenav/osrm-backend/integration/service/oasis/searchhelper" ) // LowEnergyLocationCandidateNumber indicates how much charge station to be searched for low energy point diff --git a/integration/service/oasis/stationfinder/cloudfinder/orig_station_finder.go b/integration/service/oasis/stationfinder/cloudfinder/orig_station_finder.go index aaf0996ba8c..2cec717a4f0 100644 --- a/integration/service/oasis/stationfinder/cloudfinder/orig_station_finder.go +++ b/integration/service/oasis/stationfinder/cloudfinder/orig_station_finder.go @@ -3,8 +3,8 @@ package cloudfinder import ( "github.com/Telenav/osrm-backend/integration/api/oasis" "github.com/Telenav/osrm-backend/integration/api/search/searchcoordinate" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/searchhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/searchconnector" - "github.com/Telenav/osrm-backend/integration/service/oasis/searchhelper" ) //@todo: This number need to be adjusted based on charge station profile diff --git a/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go b/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go index f8fb1aaa184..daf88ef5cb4 100644 --- a/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go +++ b/integration/service/oasis/stationfinder/stationfinderalg/stations_iterator_alg.go @@ -6,8 +6,8 @@ import ( "github.com/Telenav/osrm-backend/integration/api/nav" "github.com/Telenav/osrm-backend/integration/api/osrm" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/osrmhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/osrmconnector" - "github.com/Telenav/osrm-backend/integration/service/oasis/osrmhelper" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder/stationfindertype" "github.com/golang/glog" diff --git a/integration/service/oasis/stationgraph/station_graph.go b/integration/service/oasis/stationgraph/station_graph.go index fe2a86c06bf..6a306325648 100644 --- a/integration/service/oasis/stationgraph/station_graph.go +++ b/integration/service/oasis/stationgraph/station_graph.go @@ -4,7 +4,7 @@ import ( "github.com/Telenav/osrm-backend/integration/api/nav" "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" "github.com/Telenav/osrm-backend/integration/service/oasis/connectivitymap" - "github.com/Telenav/osrm-backend/integration/service/oasis/solution" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/solution" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder/stationfindertype" "github.com/golang/glog" ) diff --git a/integration/service/oasis/stationgraph/station_graph_test.go b/integration/service/oasis/stationgraph/station_graph_test.go index 51ff6677071..f82b23d0534 100644 --- a/integration/service/oasis/stationgraph/station_graph_test.go +++ b/integration/service/oasis/stationgraph/station_graph_test.go @@ -7,7 +7,7 @@ import ( "github.com/Telenav/osrm-backend/integration/api/nav" "github.com/Telenav/osrm-backend/integration/service/oasis/chargingstrategy" "github.com/Telenav/osrm-backend/integration/service/oasis/connectivitymap" - "github.com/Telenav/osrm-backend/integration/service/oasis/solution" + "github.com/Telenav/osrm-backend/integration/service/oasis/internal/solution" "github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder/stationfindertype" "github.com/Telenav/osrm-backend/integration/util" "github.com/golang/glog"