Skip to content

Commit

Permalink
style: code formatting & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
takb committed Jul 31, 2023
1 parent 224e634 commit 78ec9ad
Show file tree
Hide file tree
Showing 467 changed files with 17,656 additions and 17,902 deletions.
41 changes: 21 additions & 20 deletions ors-api/WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>openrouteservice API</display-name>
<!-- FILTERS -->
<filter>
<filter-name>CompressionFilter</filter-name>
<filter-class>org.heigit.ors.api.servlet.filters.CompressionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CompressionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>openrouteservice API</display-name>
<!-- FILTERS -->
<filter>
<filter-name>CompressionFilter</filter-name>
<filter-class>org.heigit.ors.api.servlet.filters.CompressionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CompressionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>StatusCodeHandlerFilter</filter-name>
<filter-class>org.heigit.ors.api.servlet.filters.StatusCodeHandlerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>StatusCodeHandlerFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter>
<filter-name>StatusCodeHandlerFilter</filter-name>
<filter-class>org.heigit.ors.api.servlet.filters.StatusCodeHandlerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>StatusCodeHandlerFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
</web-app>


14 changes: 7 additions & 7 deletions ors-api/ors-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# override: classpath:logs/DEBUG_LOGGING.json

ors:
### uncomment the following lines to change CORS settings.
# cors:
# allowed_origins: "*"
# allowed_headers: Content-Type, X-Requested-With, accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization
# preflight_max_age: 600
### uncomment the following lines to change CORS settings.
#cors:
# allowed_origins: "*"
# allowed_headers: Content-Type, X-Requested-With, accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization
# preflight_max_age: 600
engine:
### use the following line for development setup using test OSM file for Heidelberg
# source_file: ./src/test/files/heidelberg.osm.gz
### use the following line for development setup using test OSM file for Heidelberg
#source_file: ./src/test/files/heidelberg.osm.gz
source_file: ./ors-core/data/osm_file.pbf
graphs_root_path: ./ors-core/data/graphs
elevation:
Expand Down
2 changes: 0 additions & 2 deletions ors-api/src/main/java/org/heigit/ors/api/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;

import java.io.File;

@ServletComponentScan("org.heigit.ors.api.servlet.listeners")
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ public void setMaximumRangeTime(List<MaximumRangeProperties.MaximumRangeProperti
profileMaxRangeTimes.put(RoutingProfileType.getFromString(profile), maximumRangePropertiesEntry.getValue());
}

private Map<Integer, Integer> profileMaxRangeDistances = new HashMap<>();
private final Map<Integer, Integer> profileMaxRangeDistances = new HashMap<>();

public Map<Integer, Integer> getProfileMaxRangeDistances() {
return profileMaxRangeDistances;
}

private Map<Integer, Integer> profileMaxRangeTimes = new HashMap<>();
private final Map<Integer, Integer> profileMaxRangeTimes = new HashMap<>();

public Map<Integer, Integer> getProfileMaxRangeTimes() {
return profileMaxRangeTimes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.heigit.ors.api;

import org.apache.log4j.Logger;
import org.heigit.ors.util.StringUtility;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
Expand All @@ -10,7 +9,6 @@
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.FileSystemResource;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
@ConfigurationProperties(prefix = "ors")
public class SystemMessageProperties {
private List<MessageObject> messages;

public List<MessageObject> getMessages() {
return messages;
}

public void setMessages(List<MessageObject> messages) {
this.messages = messages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler;
import org.heigit.ors.api.requests.export.ExportRequest;
import org.heigit.ors.api.responses.export.json.JsonExportResponse;
Expand All @@ -39,8 +40,6 @@
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;

@RestController
@Tag(name = "Export Service", description = "Export the base graph for different modes of transport")
@RequestMapping("/v2/export")
Expand Down Expand Up @@ -74,7 +73,7 @@ public String getPostMapping(@RequestBody ExportRequest request) throws MissingP
}

// Matches any response type that has not been defined
@PostMapping(value="/{profile}/*")
@PostMapping(value = "/{profile}/*")
@Operation(hidden = true)
public void getInvalidResponseType() throws StatusCodeException {
throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "This response format is not supported");
Expand All @@ -84,9 +83,9 @@ public void getInvalidResponseType() throws StatusCodeException {
@PostMapping(value = "/{profile}")
@Operation(
description = """
Returns a list of points, edges and weights within a given bounding box for a selected profile as JSON. \
This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.\
""",
Returns a list of points, edges and weights within a given bounding box for a selected profile as JSON. \
This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.\
""",
summary = "Export Service"
)
@ApiResponse(
Expand All @@ -98,7 +97,7 @@ public void getInvalidResponseType() throws StatusCodeException {
)
})
public JsonExportResponse getDefault(@Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile,
@Parameter(description = "The request payload", required = true) @RequestBody ExportRequest request) throws StatusCodeException {
@Parameter(description = "The request payload", required = true) @RequestBody ExportRequest request) throws StatusCodeException {
return getJsonExport(profile, request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ public ResponseEntity<?> fetchHealth() {
JSONObject jsonResponse = new JSONObject();
HttpStatus status;

if (!RoutingProfileManagerStatus.isReady())
{
if (!RoutingProfileManagerStatus.isReady()) {
jsonResponse.put("status", "not ready");
status = HttpStatus.SERVICE_UNAVAILABLE;
}
else
{
} else {
jsonResponse.put("status", "ready");
status = HttpStatus.OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.heigit.ors.api.EndpointsProperties;
import org.heigit.ors.api.SystemMessageProperties;
import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler;
Expand All @@ -44,8 +45,6 @@
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;

@RestController
@Tag(name = "Isochrones Service", description = "Obtain areas of reachability from given locations")
@RequestMapping("/v2/isochrones")
Expand Down Expand Up @@ -92,10 +91,10 @@ public void getInvalidResponseType() throws StatusCodeException {
@PostMapping(value = "/{profile}", produces = "application/geo+json;charset=UTF-8")
@Operation(
description = """
The Isochrone Service supports time and distance analyses for one single or multiple locations.
You may also specify the isochrone interval or provide multiple exact isochrone range values.
This service allows the same range of profile options as the /directions endpoint,
which help you to further customize your request to obtain a more detailed reachability area response.""",
The Isochrone Service supports time and distance analyses for one single or multiple locations.
You may also specify the isochrone interval or provide multiple exact isochrone range values.
This service allows the same range of profile options as the /directions endpoint,
which help you to further customize your request to obtain a more detailed reachability area response.""",
summary = "Isochrones Service"
)
@ApiResponse(
Expand All @@ -115,10 +114,10 @@ public GeoJSONIsochronesResponse getDefaultIsochrones(
@PostMapping(value = "/{profile}/geojson", produces = "application/geo+json;charset=UTF-8")
@Operation(
description = """
The Isochrone Service supports time and distance analyses for one single or multiple locations.
You may also specify the isochrone interval or provide multiple exact isochrone range values.
This service allows the same range of profile options as the /directions endpoint,
which help you to further customize your request to obtain a more detailed reachability area response.""",
The Isochrone Service supports time and distance analyses for one single or multiple locations.
You may also specify the isochrone interval or provide multiple exact isochrone range values.
This service allows the same range of profile options as the /directions endpoint,
which help you to further customize your request to obtain a more detailed reachability area response.""",
summary = "Isochrones Service",
hidden = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.heigit.ors.api.EndpointsProperties;
import org.heigit.ors.api.SystemMessageProperties;
import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler;
Expand All @@ -44,8 +45,6 @@
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;

@RestController
@Tag(name = "Matrix Service", description = "Obtain one-to-many, many-to-one and many-to-many matrices for time and distance")
@RequestMapping("/v2/matrix")
Expand Down Expand Up @@ -93,9 +92,9 @@ public void getInvalidResponseType() throws StatusCodeException {
@PostMapping(value = "/{profile}", produces = {"application/json;charset=UTF-8"})
@Operation(
description = """
Returns duration or distance matrix for multiple source and destination points.
By default a square duration matrix is returned where every point in locations is paired with each other. The result is null if a value can’t be determined.\
""",
Returns duration or distance matrix for multiple source and destination points.
By default a square duration matrix is returned where every point in locations is paired with each other. The result is null if a value can’t be determined.\
""",
summary = "Matrix Service"
)
@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.heigit.ors.api.EndpointsProperties;
import org.heigit.ors.api.SystemMessageProperties;
import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler;
Expand All @@ -46,8 +47,6 @@
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;

@RestController
@Tag(name = "Directions Service", description = "Get directions for different modes of transport")
@RequestMapping("/v2/directions")
Expand Down Expand Up @@ -97,9 +96,9 @@ public void getInvalidResponseType() throws StatusCodeException {
@Operation(
method = "GET",
description = """
Get a basic route between two points with the profile provided. Returned response is in GeoJSON format. \
This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.\
""", summary = "Directions Service")
Get a basic route between two points with the profile provided. Returned response is in GeoJSON format. \
This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.\
""", summary = "Directions Service")
@ApiResponse(
responseCode = "200",
description = "Standard response for successfully processed requests. Returns GeoJSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.graphhopper.storage.StorableProperties;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.heigit.ors.api.EndpointsProperties;
import org.heigit.ors.api.util.AppConfigMigration;
import org.heigit.ors.api.util.AppInfo;
Expand All @@ -34,7 +35,6 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpServerErrorException;

import jakarta.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
Expand All @@ -49,6 +49,7 @@ public class StatusAPI {
public StatusAPI(EndpointsProperties endpointsProperties) {
this.endpointsProperties = AppConfigMigration.overrideEndpointsProperties(endpointsProperties);
}

@GetMapping
public ResponseEntity fetchHealth(HttpServletRequest request) throws Exception {
HttpHeaders headers = new HttpHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public void serialize(double[][] coordinates, JsonGenerator jsonGenerator, Seria
formattedCoords[1][0] = FormatUtility.roundToDecimals(coordinates[1][0], COORDINATE_PRECISION);
formattedCoords[1][1] = FormatUtility.roundToDecimals(coordinates[1][1], COORDINATE_PRECISION);

if(coordinates[0].length == 3)
if (coordinates[0].length == 3)
formattedCoords[0][2] = FormatUtility.roundToDecimals(coordinates[0][2], COORDINATE_PRECISION);
if(coordinates[1].length == 3)
if (coordinates[1].length == 3)
formattedCoords[1][2] = FormatUtility.roundToDecimals(coordinates[0][2], COORDINATE_PRECISION);

jsonGenerator.writeStartArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.locationtech.jts.geom.Coordinate;
import org.heigit.ors.api.requests.common.CoordinateListWrapper;
import org.locationtech.jts.geom.Coordinate;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -38,10 +38,10 @@ public CoordinateListWrapper deserialize(JsonParser jsonParser, DeserializationC
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
List<Coordinate> convertedCoords = new ArrayList<>();

if(node.isArray()) {
if (node.isArray()) {
Iterator<JsonNode> coordinates = node.iterator();
JsonNode coord;
while(coordinates.hasNext() && ( coord = coordinates.next()) != null) {
while (coordinates.hasNext() && (coord = coordinates.next()) != null) {
convertedCoords.add(new Coordinate(coord.get(0).asDouble(), coord.get(1).asDouble()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.locationtech.jts.geom.Coordinate;
import org.heigit.ors.api.requests.common.CoordinateListWrapper;
import org.locationtech.jts.geom.Coordinate;

import java.io.IOException;

Expand All @@ -36,7 +36,7 @@ public CoordinateListSerializer(Class<CoordinateListWrapper> listWrapper) {
public void serialize(CoordinateListWrapper listWrapper, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException {
jsonGenerator.writeStartArray();

for(Coordinate coord : listWrapper.getCoordinates()) {
for (Coordinate coord : listWrapper.getCoordinates()) {
jsonGenerator.writeStartArray();

jsonGenerator.writeNumber(coord.x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
import org.apache.log4j.Logger;
import org.heigit.ors.api.util.AppInfo;
import org.heigit.ors.exceptions.ParameterValueException;
import org.heigit.ors.exceptions.StatusCodeException;
import org.heigit.ors.exceptions.UnknownParameterException;
import org.heigit.ors.isochrones.IsochronesErrorCodes;
import org.heigit.ors.api.util.AppInfo;
import org.heigit.ors.util.DebugUtility;
import org.json.simple.JSONObject;
import org.springframework.http.HttpHeaders;
Expand Down
Loading

0 comments on commit 78ec9ad

Please sign in to comment.