Skip to content

Commit 3dd676f

Browse files
committed
Add more logging while performing bulk testing.
1 parent b971e84 commit 3dd676f

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

src/main/kotlin/fi/hsl/jore4/mapmatching/service/matching/MatchRouteViaPointsOnLinksServiceImpl.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ class MatchRouteViaPointsOnLinksServiceImpl(
191191
targetRoutePointSequenceCandidates: List<List<PgRoutingPoint>>,
192192
bufferRadiusInMeters: Double
193193
): List<RouteLink>? =
194-
targetRoutePointSequenceCandidates.firstNotNullOfOrNull { targetRoutePoints ->
194+
targetRoutePointSequenceCandidates.withIndex().firstNotNullOfOrNull { (index, targetRoutePoints) ->
195+
196+
val round = index + 1
195197

196198
val bufferAreaRestriction =
197199
BufferAreaRestriction.from(
@@ -201,8 +203,19 @@ class MatchRouteViaPointsOnLinksServiceImpl(
201203
targetRoutePoints.last()
202204
)
203205

204-
routingService
205-
.findRouteViaPointsOnLinks(targetRoutePoints, vehicleType, true, bufferAreaRestriction)
206-
.ifEmpty { null }
206+
val routeLinks: List<RouteLink> =
207+
routingService.findRouteViaPointsOnLinks(
208+
targetRoutePoints,
209+
vehicleType,
210+
true,
211+
bufferAreaRestriction
212+
)
213+
214+
if (routeLinks.isNotEmpty()) {
215+
if (round > 1) LOGGER.info { "Matched route on attempt #$round." }
216+
routeLinks
217+
} else {
218+
null
219+
}
207220
}
208221
}

src/main/kotlin/fi/hsl/jore4/mapmatching/service/matching/test/MapMatchingBulkTester.kt

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,20 @@ class MapMatchingBulkTester(
8080

8181
val result: MatchResult = matchRoute(routeId, routeGeometry, routePoints, bufferRadiuses)
8282

83-
if (result is SuccessfulMatchResult) {
84-
LOGGER.info {
85-
"Successfully matched route: $routeId (with bufferRadius=${result.getLowestBufferRadius()})"
86-
}
87-
} else {
88-
LOGGER.info { "Failed to match route: $routeId" }
83+
when (result) {
84+
is SuccessfulMatchResult ->
85+
LOGGER.info {
86+
"Successfully matched route: $routeId (with bufferRadius=${result.getLowestBufferRadius()})"
87+
}
88+
89+
is RouteMatchFailure ->
90+
LOGGER.info {
91+
"Failed to match route: $routeId (${
92+
result.errorMessage ?: ""
93+
})"
94+
}
95+
96+
else -> throw IllegalStateException("Unknown route match result type")
8997
}
9098

9199
result
@@ -156,7 +164,9 @@ class MapMatchingBulkTester(
156164
val lengthsOfMatchedRoutes: MutableList<Pair<BufferRadius, Double>> = mutableListOf()
157165
val unsuccessfulBufferRadiuses: MutableSet<BufferRadius> = mutableSetOf()
158166

159-
sortedBufferRadiuses.forEach { radius ->
167+
var errorMessage: String? = null
168+
169+
sortedBufferRadiuses.withIndex().forEach { (roundIndex, radius) ->
160170
val matchingParams: PublicTransportRouteMatchingParameters = getMatchingParameters(radius)
161171

162172
val response: RoutingResponse =
@@ -170,14 +180,22 @@ class MapMatchingBulkTester(
170180

171181
val bufferRadius = BufferRadius(radius)
172182

173-
if (response is RoutingResponse.RoutingSuccessDTO) {
174-
val route: RouteResultDTO = response.routes[0]
175-
val lengthOfMatchedRoute: Double = calculateLengthOfRoute(route)
176-
// val lengthOfMatchedRoute: Double = length(route.geometry)
183+
when (response) {
184+
is RoutingResponse.RoutingSuccessDTO -> {
185+
val route: RouteResultDTO = response.routes[0]
186+
val lengthOfMatchedRoute: Double = calculateLengthOfRoute(route)
187+
// val lengthOfMatchedRoute: Double = length(route.geometry)
177188

178-
lengthsOfMatchedRoutes.add(bufferRadius to lengthOfMatchedRoute)
179-
} else {
180-
unsuccessfulBufferRadiuses.add(bufferRadius)
189+
lengthsOfMatchedRoutes.add(bufferRadius to lengthOfMatchedRoute)
190+
}
191+
192+
is RoutingResponse.RoutingFailureDTO -> {
193+
unsuccessfulBufferRadiuses.add(bufferRadius)
194+
195+
if (roundIndex == 0) {
196+
errorMessage = response.message
197+
}
198+
}
181199
}
182200
}
183201

@@ -187,8 +205,10 @@ class MapMatchingBulkTester(
187205
routeId,
188206
geometry,
189207
lengthOfSourceRoute,
190-
BufferRadius(sortedBufferRadiuses.last())
208+
BufferRadius(sortedBufferRadiuses.last()),
209+
errorMessage
191210
)
211+
192212
else ->
193213
SuccessfulRouteMatchResult(
194214
routeId,

src/main/kotlin/fi/hsl/jore4/mapmatching/service/matching/test/MatchResult.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ data class RouteMatchFailure(
9292
override val routeId: String,
9393
override val sourceRouteGeometry: LineString<G2D>,
9494
override val sourceRouteLength: Double,
95-
val bufferRadius: BufferRadius
95+
val bufferRadius: BufferRadius,
96+
val errorMessage: String?
9697
) : MatchResult {
9798
override val matchFound = false
9899
}

0 commit comments

Comments
 (0)