Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix-#424 build-fail #485

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Updated documentation to reflect correct isochrone smoothing algorithm (Issue #471)
- Enable > 2 waypoints when geometry_simplify=true (#457)
- Made it so that the wheelchair profile only goes over bridleways if they are set to be foot or wheelchair accessible (#415)
- Fixed the build fail bug when `routing_name` was set in the config file (#424)
### Changed
- Updated pom to always build ors.war (Issue #432)
- Replace usage of packages incompatible with Java >8 (#474)
Expand Down
1 change: 1 addition & 0 deletions openrouteservice-api-tests/conf/app.config.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
init_threads: 1,
attribution: "openrouteservice.org, OpenStreetMap contributors, tmc - BASt",
distance_approximation: true,
routing_name: "ORSRouting",
profiles: {
active: ["vehicles-car", "vehicles-hgv", "bike", "bike-mtb", "bike-road", "bike-e", "pedestrian-walk", "pedestrian-hike", "wheelchair"],
default_params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.imageio.metadata.IIOMetadataNode;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -173,6 +174,7 @@ private void testGpxConsistency(Response response, boolean instructions) throws
boolean gpxMetadata = false;
boolean gpxRte = false;
boolean gpxExtensions = false;
Node gpxMetadataNode = new IIOMetadataNode();
for (int i = 0; i < doc_length; i++) {
String item = doc.getDocumentElement().getChildNodes().item(i).getNodeName();
switch (item) {
Expand All @@ -191,6 +193,7 @@ private void testGpxConsistency(Response response, boolean instructions) throws
switch (metadataItem.getNodeName()) {
case "name":
metadataName = true;
gpxMetadataNode = metadataItem;
break;
case "desc":
metadataDescription = true;
Expand Down Expand Up @@ -265,6 +268,7 @@ private void testGpxConsistency(Response response, boolean instructions) throws
}
}
Assert.assertTrue(metadataName);
Assert.assertEquals("ORSRouting", gpxMetadataNode.getTextContent());
Assert.assertTrue(metadataDescription);
Assert.assertTrue(metadataAuthor);
Assert.assertTrue(metadataCopyright);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import heigit.ors.api.responses.common.BoundingBox.BoundingBoxFactory;
import heigit.ors.exceptions.StatusCodeException;
import heigit.ors.routing.RouteResult;
import heigit.ors.services.routing.RoutingServiceSettings;
import heigit.ors.util.GeomUtility;

import javax.xml.bind.annotation.XmlElement;
Expand All @@ -45,7 +46,7 @@ public class GPXMetadata {
public GPXMetadata() {}

public GPXMetadata(RouteResult[] routeResults, RouteRequest request) throws StatusCodeException {
this.name = "openrouteservice directions";
this.name = RoutingServiceSettings.getRoutingName();
this.description = "This is a directions instructions file as GPX, generated from openrouteservice";
this.author = new GPXAuthor();
this.copyright = new GPXCopyright();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GPXRouteElement(RouteResult result) {
for(int i=0; i<steps.size(); i++) {
RouteStep step = steps.get(i);
int coordinateId = step.getWayPoints()[0];
while(coordinateId <= step.getWayPoints()[1]) {
while(coordinateId < routeCoordinates.length) {
Coordinate c = routeCoordinates[coordinateId];
routePoints.add(new GPXRoutePointElement(step, c.x, c.y, c.z, i));
coordinateId++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@


import com.vividsolutions.jts.geom.LineString;
import heigit.ors.globalResponseProcessor.gpx.GpxResponseWriter;
import heigit.ors.exceptions.MissingConfigParameterException;
import heigit.ors.services.routing.RoutingServiceSettings;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.opengis.feature.simple.SimpleFeatureType;
Expand All @@ -40,7 +38,6 @@
* @author Julian Psotta, julian@openrouteservice.org
*/
class SimpleFeatureTypes {
// TODO implement all the different kind of SimpleFeatureTypes here!
private RouteFeatureType type;

public enum RouteFeatureType {
Expand All @@ -63,24 +60,10 @@ public enum RouteFeatureType {
*/
public SimpleFeatureType create() {
if (type == RouteFeatureType.routeFeature) {
// create SimpleFeatureType template
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
// set the name --> The result looks weird but a name is required!! result --> https://go.openrouteservice.org/:openrouteservice routing
try {
if (!(RoutingServiceSettings.getParameter("routing_name") == null)) {
builder.setName(RoutingServiceSettings.getParameter("routing_name"));

} else {
builder.setName("ORSRoutingFile");
new MissingConfigParameterException(GpxResponseWriter.class, "routing_name");
}
} finally {
if (builder.getName() == null) {
builder.setName("ORSRoutingFile");
}
builder.add("geometry", LineString.class);
return builder.buildFeatureType();
}
builder.setName(RoutingServiceSettings.getRoutingName());
builder.add("geometry", LineString.class);
return builder.buildFeatureType();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,7 @@ public static String toGPX(RoutingRequest rreq, RouteResult[] routeResults) thro
new MissingConfigParameterException(GpxResponseWriter.class, "routing_description");
}
// set routing_name
if (RoutingServiceSettings.getParameter("routing_name") != null) {

metadata.setName(RoutingServiceSettings.getParameter("routing_name"));
} else {
metadata.setName("ORSRoutingFile");
new MissingConfigParameterException(GpxResponseWriter.class, "routing_name");
}
metadata.setName(RoutingServiceSettings.getRoutingName());
metadata.setTime(cal);
gpx.setMetadata(metadata);
// set author_tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class RoutingServiceSettings {
private static boolean distanceApproximation = false;
private static String storageFormat = "Native";
private static String attribution = "";
private static String routingName = "openrouteservice directions";
private static AppConfig _config;

static
Expand Down Expand Up @@ -70,6 +71,10 @@ private static void init(AppConfig config)
value = config.getServiceParameter("routing", "attribution");
if (value != null)
attribution = value;

value = config.getServiceParameter("routing", "routing_name");
if (value != null)
routingName = value;
}

public static Boolean getEnabled()
Expand Down Expand Up @@ -129,4 +134,8 @@ public static Map<String, Object> getParametersMap(String paramName, boolean quo
public static String getAttribution() {
return attribution;
}

public static String getRoutingName() {
return routingName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,33 @@

package heigit.ors.globalResponseProcessor.geoJson;

import com.vividsolutions.jts.geom.LineString;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.geotools.feature.simple.SimpleFeatureTypeImpl;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.GeometryType;

import static heigit.ors.globalResponseProcessor.geoJson.SimpleFeatureTypes.*;

import static heigit.ors.globalResponseProcessor.geoJson.SimpleFeatureTypes.RouteFeatureType;


public class SimpleFeatureTypesTest {
private static SimpleFeatureType simpleFeatureType;

/**
*
*/

@BeforeClass
public static void setUp() {
simpleFeatureType = new SimpleFeatureTypes(RouteFeatureType.routeFeature).create();
}

@Test
public void testCreateRouteFeatureType() {
Assert.assertEquals("SimpleFeatureTypeImpl http://www.opengis.net/gml:ORSRoutingFile identified extends Feature(geometry:geometry)", simpleFeatureType.toString());
Assert.assertEquals(SimpleFeatureTypeImpl.class, simpleFeatureType.getClass());
Assert.assertNotNull(simpleFeatureType.getName());
Assert.assertNotSame(-1, simpleFeatureType.indexOf("geometry"));
GeometryType type = simpleFeatureType.getGeometryDescriptor().getType();
Assert.assertEquals(LineString.class.getName(), type.getBinding().getName());
}
}
}