Skip to content

Commit

Permalink
Merge pull request #501 from solita-sabinaf/more_osrm_logs
Browse files Browse the repository at this point in the history
More logs for routing related services
  • Loading branch information
testower authored Dec 12, 2024
2 parents 1315612 + 861f27f commit 723263c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/main/java/no/entur/uttu/routing/DefaultRoutingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.math.BigDecimal;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;

Expand All @@ -15,6 +17,14 @@
)
public class DefaultRoutingService implements RoutingService {

private static final Logger logger = LoggerFactory.getLogger(
DefaultRoutingService.class
);

public DefaultRoutingService() {
logger.info("DefaultRoutingService got initialised");
}

public RouteGeometry getRouteGeometry(
BigDecimal longitudeFrom,
BigDecimal latitudeFrom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
public class OsrmConfiguration {

@Bean
RoutingService routingService(@Value("${uttu.routing.osrm-api}") String osrmApi) {
return new OsrmService(osrmApi);
RoutingService routingService(
@Value("${uttu.routing.osrm-api}") String osrmApiEndpoint
) {
return new OsrmService(osrmApiEndpoint);
}
}
11 changes: 6 additions & 5 deletions src/main/java/no/entur/uttu/routing/osrm/OsrmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ public class OsrmService implements no.entur.uttu.routing.RoutingService {

private static final Logger logger = LoggerFactory.getLogger(OsrmService.class);

private final String osrmApi;
private final String osrmApiEndpoint;

private final Methanol httpClient;
private final ObjectMapper objectMapper;

public OsrmService(String osrmApi) {
this.osrmApi = osrmApi;
public OsrmService(String osrmApiEndpoint) {
this.osrmApiEndpoint = osrmApiEndpoint;
this.objectMapper = initializeObjectMapper();
this.httpClient = initializeHttpClient();
logger.info("OsrmService got initialised, osrmApiEndpoint is: {}", osrmApiEndpoint);
}

private static ObjectMapper initializeObjectMapper() {
Expand All @@ -53,7 +54,7 @@ private static Methanol initializeHttpClient() {
}

public boolean isEnabled() {
return osrmApi != null && !osrmApi.isBlank();
return osrmApiEndpoint != null && !osrmApiEndpoint.isBlank();
}

public RouteGeometry getRouteGeometry(
Expand All @@ -65,7 +66,7 @@ public RouteGeometry getRouteGeometry(
List<List<BigDecimal>> routeCoordinates = new ArrayList<>();
MutableRequest request = MutableRequest
.GET(
osrmApi +
osrmApiEndpoint +
"/route/v1/driving/" +
longitudeFrom +
"," +
Expand Down

0 comments on commit 723263c

Please sign in to comment.