Skip to content

Commit

Permalink
Remove extra checks in value func
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed May 14, 2024
1 parent 06eb7e8 commit 7df7d3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions model_expression_haversine.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func (h *haversineExpression) Value(
from ModelStop,
to ModelStop,
) float64 {
if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() {
return 0.0
}
// if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() {
// return 0.0
// }
return haversineDistance(from.Location(), to.Location()).
Value(vehicle.Model().DistanceUnit())
}
6 changes: 3 additions & 3 deletions model_expression_measure_byindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (m *measureByIndexExpression) SetName(n string) {
}

func (m *measureByIndexExpression) Value(_ ModelVehicleType, from, to ModelStop) float64 {
if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() {
return 0.0
}
// if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() {
// return 0.0
// }
return m.measure.Cost(from.(*stopImpl).measureIndex, to.(*stopImpl).measureIndex)
}
12 changes: 6 additions & 6 deletions model_expression_measure_bypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func (m *measureByPointExpression) SetName(n string) {
}

func (m *measureByPointExpression) Value(_ ModelVehicleType, from, to ModelStop) float64 {
if from == nil || to == nil {
return 0.0
}
// if from == nil || to == nil {
// return 0.0
// }
locFrom := from.Location()
locTo := to.Location()
if !locFrom.IsValid() || !locTo.IsValid() {
return 0.0
}
// if !locFrom.IsValid() || !locTo.IsValid() {
// return 0.0
// }
value := m.measure.Cost(
measure.Point{locFrom.Longitude(), locFrom.Latitude()},
measure.Point{locTo.Longitude(), locTo.Latitude()},
Expand Down

0 comments on commit 7df7d3e

Please sign in to comment.