src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
LightPauser implements Pauser { public LightPauser(long busyPeriodNS, long parkPeriodNS) { this.busyPeriodNS = busyPeriodNS; this.parkPeriodNS = parkPeriodNS; } LightPauser(long busyPeriodNS, long parkPeriodNS); @Override void reset(); @Override void pause(); void pause(long maxPauseNS); @Override void unpause(); static final long NO_BUSY_PERIOD; static final long NO_PAUSE_PERIOD; }
@Test public void testLightPauser() throws InterruptedException { final LightPauser pauser = new LightPauser(100 * 1000, 100 * 1000); Thread thread = new Thread() { @Override public void run() { while (!Thread.interrupted()) pauser.pause(); } }; thread.start(); for (int t = 0; t < 3; t++) { long start = System.nanoTime(); int runs = 10000000; for (int i = 0; i < runs; i++) pauser.unpause(); long time = System.nanoTime() - start; System.out.printf("Average time to unpark was %,d ns%n", time / runs); Thread.sleep(20); } thread.interrupt(); }
Maths { public static int intLog2(long num) { long l = Double.doubleToRawLongBits(num); return (int) ((l >> 52) - 1023); } static double round2(double d); static double round4(double d); static double round6(double d); static double round8(double d); static long power10(int n); static int nextPower2(int n, int min); static long nextPower2(long n, long min); static boolean isPowerOf2(int n); static boolean isPowerOf2(long n); static int hash(int n); static long hash(long n); static long hash(CharSequence cs); static int compare(long x, long y); static int intLog2(long num); static int toInt(long l, String error); static long agitate(long l); }
@Test public void testIntLog2() { for (int i = 0; i < 63; i++) { long l = 1L << i; assertEquals(i, Maths.intLog2(l)); } }
HelloWorldController { @RequestMapping("/") public String sayHello() { return "Hello,World!"; } @RequestMapping("/") String sayHello(); @PostMapping(value = "/request_param") String requestParam(@RequestParam(value = "name") String name); @PostMapping(value = "/request_body") UserInfo requestBody(@RequestParam(value = "name") String name, @RequestBody UserInfo info); @PostMapping(value = "/request_body1") UserInfo requestBody1(@RequestBody UserInfo info); }
@Test public void testSayHello() { assertEquals("Hello,World!",new HelloWorldController().sayHello()); }
OpenhabSseConnection extends SseConnection implements SseConnection.ISseDataListener { @Override protected String buildUrl() { return mUrl + "/rest/events?topics=" + buildTopic(); } OpenhabSseConnection(); void removeItemValueListener(IStateUpdateListener l); @Override void data(String data); }
@Test public void testBuildUrl() { OpenhabSseConnection c = new OpenhabSseConnection(); c.setServerUrl("URL"); c.setItemNames("cmdName"); assertEquals("URL/rest/events?topics=smarthome/items/cmdName/command", c.buildUrl()); c.setItemNames("cmdName","item1", "item2"); assertEquals("URL/rest/events?topics=smarthome/items/item1/statechanged,smarthome/items/item2/statechanged,smarthome/items/cmdName/command", c.buildUrl()); }
LocalizedFieldNames { public Lookup createLookup(List<String> keys) { return new LookupImpl(keys); } void setMessageSource(MessageSource messageSource); Lookup createLookup(List<String> keys); }
@Test public void backAndForth() { LocalizedFieldNames.Lookup lookup = localizedFieldNames.createLookup(Arrays.asList("dc.title")); final Locale english = new Locale("en"); String title = lookup.toLocalizedName("dc_title", english); Assert.assertEquals("Title", title); String fieldName = lookup.toFieldName(title, english); Assert.assertEquals("dc_title", fieldName); } @Test public void multiWord() { LocalizedFieldNames.Lookup lookup = localizedFieldNames.createLookup(Arrays.asList("dcterms.isReferencedBy")); final Locale english = new Locale("en"); String fieldName = lookup.toFieldName("isreferENCedby", english); Assert.assertEquals("dcterms_isReferencedBy", fieldName); }
BordersExtractor { public boolean isBorder(int edgeId) { int type = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.TYPE); return (type == BordersGraphStorage.OPEN_BORDER || type == BordersGraphStorage.CONTROLLED_BORDER); } BordersExtractor(BordersGraphStorage storage, int[] avoidCountries); int getValue(int edgeId); boolean isBorder(int edgeId); boolean isControlledBorder(int edgeId); boolean isOpenBorder(int edgeId); boolean restrictedCountry(int edgeId); boolean isSameCountry(List<Integer> edgeIds); }
@Test public void TestDetectAnyBorder() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[0]); assertEquals(true, be.isBorder(1)); assertEquals(true, be.isBorder(2)); assertEquals(false, be.isBorder(3)); }
IsochronesResponse { public BoundingBox getBbox() { return bbox; } IsochronesResponse(IsochronesRequest request); IsochronesResponseInfo getResponseInformation(); BoundingBox getBbox(); }
@Test public void getBbox() { }
GeoJSONIsochronesResponse extends IsochronesResponse { @JsonProperty("features") public List<GeoJSONIsochroneBase> getIsochrones() { return isochroneResults; } GeoJSONIsochronesResponse(IsochronesRequest request, IsochroneMapCollection isoMaps); @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_NULL) @ApiModelProperty(value = "Bounding box that covers all returned isochrones", example = "[49.414057, 8.680894, 49.420514, 8.690123]") double[] getBBoxAsArray(); @JsonProperty("features") List<GeoJSONIsochroneBase> getIsochrones(); @JsonProperty("metadata") IsochronesResponseInfo getProperties(); @JsonProperty("type") final String type; }
@Test public void getIsochrones() { }
GeoJSONIsochronesResponse extends IsochronesResponse { @JsonProperty("metadata") public IsochronesResponseInfo getProperties() { return this.responseInformation; } GeoJSONIsochronesResponse(IsochronesRequest request, IsochroneMapCollection isoMaps); @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_NULL) @ApiModelProperty(value = "Bounding box that covers all returned isochrones", example = "[49.414057, 8.680894, 49.420514, 8.690123]") double[] getBBoxAsArray(); @JsonProperty("features") List<GeoJSONIsochroneBase> getIsochrones(); @JsonProperty("metadata") IsochronesResponseInfo getProperties(); @JsonProperty("type") final String type; }
@Test public void getProperties() { }
GeoJSONIsochroneProperties { public Double getValue() { return value; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }
@Test public void getValue() { }
GeoJSONIsochroneProperties { public Double[] getCenter() { return center; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }
@Test public void getCenter() { }
GeoJSONIsochroneProperties { public Double getArea() { return area; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }
@Test public void getArea() { }
GeoJSONIsochroneProperties { public Double getReachfactor() { return reachfactor; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }
@Test public void getReachfactor() { }
MatrixRequestHandler { public static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request) throws StatusCodeException { org.heigit.ors.matrix.MatrixRequest coreRequest = new org.heigit.ors.matrix.MatrixRequest(); int sources = request.getSources() == null ? request.getLocations().size() : request.getSources().length; int destinations = request.getDestinations() == null ? request.getLocations().size() : request.getDestinations().length; Coordinate[] locations = convertLocations(request.getLocations(), sources * destinations); coreRequest.setProfileType(convertToMatrixProfileType(request.getProfile())); if (request.hasMetrics()) coreRequest.setMetrics(convertMetrics(request.getMetrics())); if (request.hasDestinations()) coreRequest.setDestinations(convertDestinations(request.getDestinations(), locations)); else { coreRequest.setDestinations(convertDestinations(new String[]{"all"}, locations)); } if (request.hasSources()) coreRequest.setSources(convertSources(request.getSources(), locations)); else { coreRequest.setSources(convertSources(new String[]{"all"}, locations)); } if (request.hasId()) coreRequest.setId(request.getId()); if (request.hasOptimized()) coreRequest.setFlexibleMode(!request.getOptimized()); if (request.hasResolveLocations()) coreRequest.setResolveLocations(request.getResolveLocations()); if (request.hasUnits()) coreRequest.setUnits(convertUnits(request.getUnits())); return coreRequest; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertMatrixRequestTest() throws StatusCodeException { org.heigit.ors.api.requests.matrix.MatrixRequest springMatrixRequest = new org.heigit.ors.api.requests.matrix.MatrixRequest(bareCoordinates); springMatrixRequest.setProfile(APIEnums.Profile.DRIVING_CAR); springMatrixRequest.setSources(new String[]{"all"}); springMatrixRequest.setDestinations(new String[]{"all"}); MatrixRequest matrixRequest = MatrixRequestHandler.convertMatrixRequest(springMatrixRequest); Assert.assertEquals(1, matrixRequest.getProfileType()); Assert.assertEquals(3, matrixRequest.getSources().length); Assert.assertEquals(3, matrixRequest.getDestinations().length); Assert.assertEquals(1, matrixRequest.getMetrics()); Assert.assertEquals(WeightingMethod.UNKNOWN, matrixRequest.getWeightingMethod()); Assert.assertEquals(DistanceUnit.METERS, matrixRequest.getUnits()); Assert.assertFalse(matrixRequest.getResolveLocations()); Assert.assertFalse(matrixRequest.getFlexibleMode()); Assert.assertNull(matrixRequest.getId()); springMatrixRequest = new org.heigit.ors.api.requests.matrix.MatrixRequest(bareCoordinates); springMatrixRequest.setProfile(APIEnums.Profile.DRIVING_CAR); springMatrixRequest.setSources(new String[]{"all"}); springMatrixRequest.setDestinations(new String[]{"all"}); MatrixRequestEnums.Metrics[] metrics = new MatrixRequestEnums.Metrics[2]; metrics[0] = MatrixRequestEnums.Metrics.DURATION; metrics[1] = MatrixRequestEnums.Metrics.DISTANCE; springMatrixRequest.setMetrics(metrics); matrixRequest = MatrixRequestHandler.convertMatrixRequest(springMatrixRequest); Assert.assertEquals(3, matrixRequest.getMetrics()); } @Test(expected = ParameterValueException.class) public void invalidLocationsTest() throws StatusCodeException { org.heigit.ors.api.requests.matrix.MatrixRequest springMatrixRequest = new org.heigit.ors.api.requests.matrix.MatrixRequest(new ArrayList<>()); springMatrixRequest.setProfile(APIEnums.Profile.DRIVING_CAR); springMatrixRequest.setSources(new String[]{"foo"}); springMatrixRequest.setDestinations(new String[]{"bar"}); MatrixRequestHandler.convertMatrixRequest(springMatrixRequest); } @Test(expected = ParameterValueException.class) public void invalidMetricsTest() throws StatusCodeException { org.heigit.ors.api.requests.matrix.MatrixRequest springMatrixRequest = new org.heigit.ors.api.requests.matrix.MatrixRequest(new ArrayList<>()); springMatrixRequest.setProfile(APIEnums.Profile.DRIVING_CAR); springMatrixRequest.setLocations(listOfBareCoordinatesList); springMatrixRequest.setMetrics(new MatrixRequestEnums.Metrics[0]); springMatrixRequest.setSources(new String[]{"foo"}); springMatrixRequest.setDestinations(new String[]{"bar"}); MatrixRequestHandler.convertMatrixRequest(springMatrixRequest); } @Test(expected = ParameterValueException.class) public void invalidSourceIndexTest() throws StatusCodeException { org.heigit.ors.api.requests.matrix.MatrixRequest springMatrixRequest = new org.heigit.ors.api.requests.matrix.MatrixRequest(new ArrayList<>()); springMatrixRequest.setProfile(APIEnums.Profile.DRIVING_CAR); springMatrixRequest.setLocations(listOfBareCoordinatesList); springMatrixRequest.setSources(new String[]{"foo"}); springMatrixRequest.setDestinations(new String[]{"bar"}); MatrixRequestHandler.convertMatrixRequest(springMatrixRequest); } @Test(expected = ParameterValueException.class) public void invalidDestinationIndexTest() throws StatusCodeException { org.heigit.ors.api.requests.matrix.MatrixRequest springMatrixRequest = new org.heigit.ors.api.requests.matrix.MatrixRequest(new ArrayList<>()); springMatrixRequest.setProfile(APIEnums.Profile.DRIVING_CAR); springMatrixRequest.setLocations(listOfBareCoordinatesList); springMatrixRequest.setSources(new String[]{"all"}); springMatrixRequest.setDestinations(new String[]{"foo"}); MatrixRequestHandler.convertMatrixRequest(springMatrixRequest); }
AvoidBordersEdgeFilter implements EdgeFilter { @Override public final boolean accept(EdgeIteratorState iter) { if (!isStorageBuilt) return true; if (avoidBorders != BordersExtractor.Avoid.NONE) { switch(avoidBorders) { case ALL: if(bordersExtractor.isBorder(iter.getEdge())) { return false; } break; case CONTROLLED: if(bordersExtractor.isControlledBorder(iter.getEdge())) { return false; } break; default: break; } } return !avoidCountries || !bordersExtractor.restrictedCountry(iter.getEdge()); } AvoidBordersEdgeFilter(RouteSearchParameters searchParams, BordersGraphStorage extBorders); AvoidBordersEdgeFilter(RouteSearchParameters searchParams, GraphStorage graphStorage); @Override final boolean accept(EdgeIteratorState iter); }
@Test public void TestAvoidSpecificBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.NONE); _searchParams.setAvoidCountries(new int[] {1, 5}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertTrue(filter.accept(ve2)); assertFalse(filter.accept(ve3)); } @Test public void TestAvoidSpecificAndControlledBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); _searchParams.setAvoidCountries(new int[] {3}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertFalse(filter.accept(ve2)); assertTrue(filter.accept(ve3)); } @Test public void TestAvoidAllBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.ALL); _searchParams.setAvoidCountries(new int[] {}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertFalse(filter.accept(ve2)); assertTrue(filter.accept(ve3)); } @Test public void TestAvoidControlledBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); _searchParams.setAvoidCountries(new int[] {}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertTrue(filter.accept(ve2)); assertTrue(filter.accept(ve3)); } @Test public void TestAvoidNoBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.NONE); _searchParams.setAvoidCountries(new int[] {}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertTrue(filter.accept(ve1)); assertTrue(filter.accept(ve2)); assertTrue(filter.accept(ve3)); }
MatrixRequestHandler { public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertMetricsTest() throws ParameterValueException { Assert.assertEquals(1, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DURATION})); Assert.assertEquals(2, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DISTANCE})); Assert.assertEquals(3, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DURATION, MatrixRequestEnums.Metrics.DISTANCE})); }
MatrixRequestHandler { protected static Coordinate[] convertLocations(List<List<Double>> locations, int numberOfRoutes) throws ParameterValueException, ServerLimitExceededException { if (locations == null || locations.size() < 2) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_LOCATIONS); int maximumNumberOfRoutes = MatrixServiceSettings.getMaximumRoutes(false); if (numberOfRoutes > maximumNumberOfRoutes) throw new ServerLimitExceededException(MatrixErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM, "Only a total of " + maximumNumberOfRoutes + " routes are allowed."); ArrayList<Coordinate> locationCoordinates = new ArrayList<>(); for (List<Double> coordinate : locations) { locationCoordinates.add(convertSingleLocationCoordinate(coordinate)); } try { return locationCoordinates.toArray(new Coordinate[locations.size()]); } catch (NumberFormatException | ArrayStoreException | NullPointerException ex) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_LOCATIONS); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test(expected = ParameterValueException.class) public void notEnoughLocationsTest() throws ParameterValueException, ServerLimitExceededException { MatrixRequestHandler.convertLocations(minimalLocations, 5); } @Test(expected = ServerLimitExceededException.class) public void maximumExceedingLocationsTest() throws ParameterValueException, ServerLimitExceededException { MatrixRequestHandler.convertLocations(listOfBareCoordinatesList, maximumRoutes); } @Test public void convertLocationsTest() throws ParameterValueException, ServerLimitExceededException { Coordinate[] coordinates = MatrixRequestHandler.convertLocations(listOfBareCoordinatesList, 3); Assert.assertEquals(8.681495, coordinates[0].x, 0); Assert.assertEquals(49.41461, coordinates[0].y, 0); Assert.assertEquals(Double.NaN, coordinates[0].z, 0); Assert.assertEquals(8.686507, coordinates[1].x, 0); Assert.assertEquals(49.41943, coordinates[1].y, 0); Assert.assertEquals(Double.NaN, coordinates[1].z, 0); Assert.assertEquals(8.687872, coordinates[2].x, 0); Assert.assertEquals(49.420318, coordinates[2].y, 0); Assert.assertEquals(Double.NaN, coordinates[2].z, 0); }
MatrixRequestHandler { protected static Coordinate convertSingleLocationCoordinate(List<Double> coordinate) throws ParameterValueException { if (coordinate.size() != 2) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_LOCATIONS); return new Coordinate(coordinate.get(0), coordinate.get(1)); } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertSingleLocationCoordinateTest() throws ParameterValueException { List<Double> locationsList = new ArrayList<>(); locationsList.add(8.681495); locationsList.add(49.41461); Coordinate coordinates = MatrixRequestHandler.convertSingleLocationCoordinate(locationsList); Assert.assertEquals(8.681495, coordinates.x, 0); Assert.assertEquals(49.41461, coordinates.y, 0); Assert.assertEquals(Double.NaN, coordinates.z, 0); } @Test(expected = ParameterValueException.class) public void convertWrongSingleLocationCoordinateTest() throws ParameterValueException { List<Double> locationsList = new ArrayList<>(); locationsList.add(8.681495); locationsList.add(49.41461); locationsList.add(123.0); MatrixRequestHandler.convertSingleLocationCoordinate(locationsList); }
MatrixRequestHandler { protected static Coordinate[] convertSources(String[] sourcesIndex, Coordinate[] locations) throws ParameterValueException { int length = sourcesIndex.length; if (length == 0) return locations; if (length == 1 && "all".equalsIgnoreCase(sourcesIndex[0])) return locations; try { ArrayList<Coordinate> indexCoordinateArray = convertIndexToLocations(sourcesIndex, locations); return indexCoordinateArray.toArray(new Coordinate[0]); } catch (Exception ex) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_SOURCES); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertSourcesTest() throws ParameterValueException { String[] emptySources = new String[0]; Coordinate[] convertedSources = MatrixRequestHandler.convertSources(emptySources, this.coordinates); Assert.assertEquals(8.681495, convertedSources[0].x, 0); Assert.assertEquals(49.41461, convertedSources[0].y, 0); Assert.assertEquals(Double.NaN, convertedSources[0].z, 0); Assert.assertEquals(8.686507, convertedSources[1].x, 0); Assert.assertEquals(49.41943, convertedSources[1].y, 0); Assert.assertEquals(Double.NaN, convertedSources[1].z, 0); Assert.assertEquals(8.687872, convertedSources[2].x, 0); Assert.assertEquals(49.420318, convertedSources[2].y, 0); Assert.assertEquals(Double.NaN, convertedSources[2].z, 0); String[] allSources = new String[]{"all"}; convertedSources = MatrixRequestHandler.convertSources(allSources, this.coordinates); Assert.assertEquals(8.681495, convertedSources[0].x, 0); Assert.assertEquals(49.41461, convertedSources[0].y, 0); Assert.assertEquals(Double.NaN, convertedSources[0].z, 0); Assert.assertEquals(8.686507, convertedSources[1].x, 0); Assert.assertEquals(49.41943, convertedSources[1].y, 0); Assert.assertEquals(Double.NaN, convertedSources[1].z, 0); Assert.assertEquals(8.687872, convertedSources[2].x, 0); Assert.assertEquals(49.420318, convertedSources[2].y, 0); Assert.assertEquals(Double.NaN, convertedSources[2].z, 0); String[] secondSource = new String[]{"1"}; convertedSources = MatrixRequestHandler.convertSources(secondSource, this.coordinates); Assert.assertEquals(8.686507, convertedSources[0].x, 0); Assert.assertEquals(49.41943, convertedSources[0].y, 0); Assert.assertEquals(Double.NaN, convertedSources[0].z, 0); } @Test(expected = ParameterValueException.class) public void convertWrongSourcesTest() throws ParameterValueException { String[] wrongSource = new String[]{"foo"}; MatrixRequestHandler.convertSources(wrongSource, this.coordinates); }
MatrixRequestHandler { protected static Coordinate[] convertDestinations(String[] destinationsIndex, Coordinate[] locations) throws ParameterValueException { int length = destinationsIndex.length; if (length == 0) return locations; if (length == 1 && "all".equalsIgnoreCase(destinationsIndex[0])) return locations; try { ArrayList<Coordinate> indexCoordinateArray = convertIndexToLocations(destinationsIndex, locations); return indexCoordinateArray.toArray(new Coordinate[0]); } catch (Exception ex) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_DESTINATIONS); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertDestinationsTest() throws ParameterValueException { String[] emptyDestinations = new String[0]; Coordinate[] convertedDestinations = MatrixRequestHandler.convertDestinations(emptyDestinations, this.coordinates); Assert.assertEquals(8.681495, convertedDestinations[0].x, 0); Assert.assertEquals(49.41461, convertedDestinations[0].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[0].z, 0); Assert.assertEquals(8.686507, convertedDestinations[1].x, 0); Assert.assertEquals(49.41943, convertedDestinations[1].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[1].z, 0); Assert.assertEquals(8.687872, convertedDestinations[2].x, 0); Assert.assertEquals(49.420318, convertedDestinations[2].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[2].z, 0); String[] allDestinations = new String[]{"all"}; convertedDestinations = MatrixRequestHandler.convertDestinations(allDestinations, this.coordinates); Assert.assertEquals(8.681495, convertedDestinations[0].x, 0); Assert.assertEquals(49.41461, convertedDestinations[0].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[0].z, 0); Assert.assertEquals(8.686507, convertedDestinations[1].x, 0); Assert.assertEquals(49.41943, convertedDestinations[1].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[1].z, 0); Assert.assertEquals(8.687872, convertedDestinations[2].x, 0); Assert.assertEquals(49.420318, convertedDestinations[2].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[2].z, 0); String[] secondDestination = new String[]{"1"}; convertedDestinations = MatrixRequestHandler.convertDestinations(secondDestination, this.coordinates); Assert.assertEquals(8.686507, convertedDestinations[0].x, 0); Assert.assertEquals(49.41943, convertedDestinations[0].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[0].z, 0); } @Test(expected = ParameterValueException.class) public void convertWrongDestinationsTest() throws ParameterValueException { String[] wrongDestinations = new String[]{"foo"}; MatrixRequestHandler.convertDestinations(wrongDestinations, this.coordinates); }
MatrixRequestHandler { protected static ArrayList<Coordinate> convertIndexToLocations(String[] index, Coordinate[] locations) { ArrayList<Coordinate> indexCoordinates = new ArrayList<>(); for (String indexString : index) { int indexInteger = Integer.parseInt(indexString); indexCoordinates.add(locations[indexInteger]); } return indexCoordinates; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertIndexToLocationsTest() throws Exception { ArrayList<Coordinate> coordinate = MatrixRequestHandler.convertIndexToLocations(new String[]{"1"}, this.coordinates); Assert.assertEquals(8.686507, coordinate.get(0).x, 0); Assert.assertEquals(49.41943, coordinate.get(0).y, 0); Assert.assertEquals(Double.NaN, coordinate.get(0).z, 0); } @Test(expected = Exception.class) public void convertWrongIndexToLocationsTest() throws Exception { MatrixRequestHandler.convertIndexToLocations(new String[]{"foo"}, this.coordinates); }
MatrixRequestHandler { protected static DistanceUnit convertUnits(APIEnums.Units unitsIn) throws ParameterValueException { DistanceUnit units = DistanceUnitUtil.getFromString(unitsIn.toString(), DistanceUnit.UNKNOWN); if (units == DistanceUnit.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_UNITS, unitsIn.toString()); return units; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertUnitsTest() throws ParameterValueException { Assert.assertEquals(DistanceUnit.METERS, MatrixRequestHandler.convertUnits(APIEnums.Units.METRES)); Assert.assertEquals(DistanceUnit.KILOMETERS, MatrixRequestHandler.convertUnits(APIEnums.Units.KILOMETRES)); Assert.assertEquals(DistanceUnit.MILES, MatrixRequestHandler.convertUnits(APIEnums.Units.MILES)); }
MatrixRequestHandler { protected static int convertToMatrixProfileType(APIEnums.Profile profile) throws ParameterValueException { try { int profileFromString = RoutingProfileType.getFromString(profile.toString()); if (profileFromString == 0) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_PROFILE); } return profileFromString; } catch (Exception e) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_PROFILE); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }
@Test public void convertToProfileTypeTest() throws ParameterValueException { Assert.assertEquals(1, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.DRIVING_CAR)); Assert.assertEquals(2, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.DRIVING_HGV)); Assert.assertEquals(10, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_REGULAR)); Assert.assertEquals(12, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_ROAD)); Assert.assertEquals(11, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_MOUNTAIN)); Assert.assertEquals(17, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_ELECTRIC)); Assert.assertEquals(20, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.FOOT_WALKING)); Assert.assertEquals(21, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.FOOT_HIKING)); Assert.assertEquals(30, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.WHEELCHAIR)); } @Test(expected = ParameterValueException.class) public void convertToWrongMatrixProfileTypeTest() throws ParameterValueException { MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.forValue("foo")); }
MatrixRequest { public String getId() { return id; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void getIdTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertNull(matrixLocationsRequest.getId()); Assert.assertNull(matrixLocationsListRequest.getId()); }
MatrixRequest { public void setId(String id) { this.id = id; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void setIdTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setId("foo1"); matrixLocationsListRequest.setId("foo2"); Assert.assertEquals("foo1", matrixLocationsRequest.getId()); Assert.assertEquals("foo2", matrixLocationsListRequest.getId()); }
MatrixRequest { public boolean hasId() { return this.id != null; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void hasIdTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertFalse(matrixLocationsRequest.hasId()); Assert.assertFalse(matrixLocationsListRequest.hasId()); matrixLocationsRequest.setId("foo1"); matrixLocationsListRequest.setId("foo2"); Assert.assertTrue(matrixLocationsRequest.hasId()); Assert.assertTrue(matrixLocationsListRequest.hasId()); }
AvoidAreasEdgeFilter implements EdgeFilter { @Override public final boolean accept(EdgeIteratorState iter ) { if (env == null) return true; boolean inEnv = false; PointList pl = iter.fetchWayGeometry(3); int size = pl.getSize(); double eMinX = Double.MAX_VALUE; double eMinY = Double.MAX_VALUE; double eMaxX = Double.MIN_VALUE; double eMaxY = Double.MIN_VALUE; for (int j = 0; j < pl.getSize(); j++) { double x = pl.getLon(j); double y = pl.getLat(j); if (env.contains(x, y)) { inEnv = true; break; } if (x < eMinX) eMinX = x; if (y < eMinY) eMinY = y; if (x > eMaxX) eMaxX = x; if (y > eMaxY) eMaxY = y; } if (inEnv || !(eMinX > env.getMaxX() || eMaxX < env.getMinX() || eMinY > env.getMaxY() || eMaxY < env.getMinY())) { coordSequence = new DefaultCoordinateSequence(new Coordinate[1], 1); if (size >= 2) { coordSequence.resize(size); for (int j = 0; j < size; j++) { double x = pl.getLon(j); double y = pl.getLat(j); Coordinate c = coordSequence.getCoordinate(j); if (c == null) { c = new Coordinate(x, y); coordSequence.setCoordinate(j, c); } else { c.x = x; c.y = y; } } LineString ls = geomFactory.createLineString(coordSequence); for (int i = 0; i < polys.length; i++) { Polygon poly = polys[i]; if (poly.contains(ls) || ls.crosses(poly)) { return false; } } } else { return false; } } return true; } AvoidAreasEdgeFilter(Polygon[] polys); @Override final boolean accept(EdgeIteratorState iter ); }
@Test public void TestAvoidPolygons() { EdgeIteratorState iter1 = _graphStorage.edge(0, 1, 100, true); iter1.setWayGeometry(Helper.createPointList(0, 0, 10, 0)); EdgeIteratorState iter2 = _graphStorage.edge(0, 2, 200, true); iter2.setWayGeometry(Helper.createPointList(0, 0, -10, 0)); GeometryFactory gf = new GeometryFactory(); Polygon poly = gf.createPolygon(new Coordinate[]{ new Coordinate(-1,5), new Coordinate(1,5), new Coordinate(1,6), new Coordinate(-1,5)}); AvoidAreasEdgeFilter filter = new AvoidAreasEdgeFilter(new Polygon[] {poly}); assertFalse(filter.accept(iter1)); assertTrue(filter.accept(iter2)); }
MatrixRequest { public APIEnums.Profile getProfile() { return profile; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void getProfileTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertNull(matrixLocationsRequest.getProfile()); Assert.assertNull(matrixLocationsListRequest.getProfile()); }
MatrixRequest { public void setProfile(APIEnums.Profile profile) { this.profile = profile; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void setProfileTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setProfile(APIEnums.Profile.DRIVING_CAR); Assert.assertEquals(APIEnums.Profile.DRIVING_CAR, matrixLocationsRequest.getProfile()); matrixLocationsListRequest.setProfile(APIEnums.Profile.DRIVING_HGV); Assert.assertEquals(APIEnums.Profile.DRIVING_HGV, matrixLocationsListRequest.getProfile()); }
MatrixRequest { public List<List<Double>> getLocations() { return locations; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void getLocationsTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsRequest.getLocations()); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsListRequest.getLocations()); }
MatrixRequest { public void setLocations(List<List<Double>> locations) { this.locations = locations; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void setLocationsTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setLocations(listOfBareCoordinatesList); matrixLocationsListRequest.setLocations(listOfBareCoordinatesList); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsRequest.getLocations()); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsListRequest.getLocations()); }
MatrixRequest { public void setSources(String[] sources) { this.sources = sources; hasSources = true; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }
@Test public void setSourcesTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setSources(new String[]{"foo"}); matrixLocationsListRequest.setSources(new String[]{"foo"}); Assert.assertArrayEquals(new String[]{"foo"}, matrixLocationsRequest.getSources()); Assert.assertArrayEquals(new String[]{"foo"}, matrixLocationsListRequest.getSources()); }
RouteRequestRoundTripOptions { public void setLength(Float length) { this.length = length; hasLength = true; } Float getLength(); void setLength(Float length); Integer getPoints(); void setPoints(Integer points); Long getSeed(); void setSeed(Long seed); boolean hasLength(); boolean hasPoints(); boolean hasSeed(); static final String PARAM_LENGTH; static final String PARAM_POINTS; static final String PARAM_SEED; }
@Test public void testSetLength() { Assert.assertFalse(options.hasLength()); options.setLength(123.4f); Assert.assertTrue(options.hasLength()); Assert.assertEquals((Float)123.4f, options.getLength()); }
RouteRequestRoundTripOptions { public void setPoints(Integer points) { this.points = points; hasPoints = true; } Float getLength(); void setLength(Float length); Integer getPoints(); void setPoints(Integer points); Long getSeed(); void setSeed(Long seed); boolean hasLength(); boolean hasPoints(); boolean hasSeed(); static final String PARAM_LENGTH; static final String PARAM_POINTS; static final String PARAM_SEED; }
@Test public void testSetPoints() { Assert.assertFalse(options.hasPoints()); options.setPoints(12); Assert.assertTrue(options.hasPoints()); Assert.assertEquals((Integer) 12, options.getPoints()); }
RouteRequestRoundTripOptions { public void setSeed(Long seed) { this.seed = seed; hasSeed = true; } Float getLength(); void setLength(Float length); Integer getPoints(); void setPoints(Integer points); Long getSeed(); void setSeed(Long seed); boolean hasLength(); boolean hasPoints(); boolean hasSeed(); static final String PARAM_LENGTH; static final String PARAM_POINTS; static final String PARAM_SEED; }
@Test public void testSetSeed() { Assert.assertFalse(options.hasSeed()); options.setSeed(1234567890l); Assert.assertTrue(options.hasSeed()); Assert.assertEquals((Long) 1234567890l, options.getSeed()); }
RouteRequestHandler extends GenericHandler { public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCodeException { RoutingRequest routingRequest = new RoutingRequest(); boolean isRoundTrip = request.hasRouteOptions() && request.getRouteOptions().hasRoundTripOptions(); routingRequest.setCoordinates(convertCoordinates(request.getCoordinates(), isRoundTrip)); routingRequest.setGeometryFormat(convertGeometryFormat(request.getResponseType())); if (request.hasUseElevation()) routingRequest.setIncludeElevation(request.getUseElevation()); if (request.hasContinueStraightAtWaypoints()) routingRequest.setContinueStraight(request.getContinueStraightAtWaypoints()); if (request.hasIncludeGeometry()) routingRequest.setIncludeGeometry(convertIncludeGeometry(request)); if (request.hasIncludeManeuvers()) routingRequest.setIncludeManeuvers(request.getIncludeManeuvers()); if (request.hasIncludeInstructions()) routingRequest.setIncludeInstructions(request.getIncludeInstructionsInResponse()); if (request.hasIncludeRoundaboutExitInfo()) routingRequest.setIncludeRoundaboutExits(request.getIncludeRoundaboutExitInfo()); if (request.hasAttributes()) routingRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); for (APIEnums.ExtraInfo extra : request.getExtraInfo()) { if (extra.compareTo(APIEnums.ExtraInfo.COUNTRY_INFO) == 0) { routingRequest.setIncludeCountryInfo(true); } } } if (request.hasLanguage()) routingRequest.setLanguage(convertLanguage(request.getLanguage())); if (request.hasInstructionsFormat()) routingRequest.setInstructionsFormat(convertInstructionsFormat(request.getInstructionsFormat())); if (request.hasUnits()) routingRequest.setUnits(convertUnits(request.getUnits())); if (request.hasSimplifyGeometry()) { routingRequest.setGeometrySimplify(request.getSimplifyGeometry()); if (request.hasExtraInfo() && request.getSimplifyGeometry()) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*"); } } if (request.hasSkipSegments()) { routingRequest.setSkipSegments(processSkipSegments(request)); } if (request.hasId()) routingRequest.setId(request.getId()); if (request.hasMaximumSpeed()) { routingRequest.setMaximumSpeed(request.getMaximumSpeed()); } int profileType = -1; int coordinatesLength = request.getCoordinates().size(); RouteSearchParameters params = new RouteSearchParameters(); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); params.setExtraInfo(convertExtraInfo(request.getExtraInfo())); } if (request.hasSuppressWarnings()) params.setSuppressWarnings(request.getSuppressWarnings()); try { profileType = convertRouteProfileType(request.getProfile()); params.setProfileType(profileType); } catch (Exception e) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_PROFILE); } if (request.hasRoutePreference()) params.setWeightingMethod(convertWeightingMethod(request.getRoutePreference())); if (request.hasBearings()) params.setBearings(convertBearings(request.getBearings(), coordinatesLength)); if (request.hasMaximumSearchRadii()) params.setMaximumRadiuses(convertMaxRadii(request.getMaximumSearchRadii(), coordinatesLength, profileType)); if (request.hasUseContractionHierarchies()) { params.setFlexibleMode(convertSetFlexibleMode(request.getUseContractionHierarchies())); params.setOptimized(request.getUseContractionHierarchies()); } if (request.hasRouteOptions()) { params = processRouteRequestOptions(request, params); } if (request.hasAlternativeRoutes()) { if (request.getCoordinates().size() > 2) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_ALTERNATIVE_ROUTES, "(number of waypoints > 2)"); } RouteRequestAlternativeRoutes alternativeRoutes = request.getAlternativeRoutes(); if (alternativeRoutes.hasTargetCount()) { params.setAlternativeRoutesCount(alternativeRoutes.getTargetCount()); String paramMaxAlternativeRoutesCount = AppConfig.getGlobal().getRoutingProfileParameter(request.getProfile().toString(), "maximum_alternative_routes"); int countLimit = StringUtility.isNullOrEmpty(paramMaxAlternativeRoutesCount) ? 0 : Integer.parseInt(paramMaxAlternativeRoutesCount); if (countLimit > 0 && alternativeRoutes.getTargetCount() > countLimit) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_ALTERNATIVE_ROUTES, Integer.toString(alternativeRoutes.getTargetCount()), "The target alternative routes count has to be equal to or less than " + paramMaxAlternativeRoutesCount); } } if (alternativeRoutes.hasWeightFactor()) params.setAlternativeRoutesWeightFactor(alternativeRoutes.getWeightFactor()); if (alternativeRoutes.hasShareFactor()) params.setAlternativeRoutesShareFactor(alternativeRoutes.getShareFactor()); } if (request.hasMaximumSpeed()) { params.setMaximumSpeed(request.getMaximumSpeed()); } params.setConsiderTurnRestrictions(false); routingRequest.setSearchParameters(params); return routingRequest; } RouteRequestHandler(); RouteResult[] generateRouteFromRequest(RouteRequest request); RoutingRequest convertRouteRequest(RouteRequest request); RouteSearchParameters processRequestOptions(RouteRequestOptions options, RouteSearchParameters params); @Override int convertRouteProfileType(APIEnums.Profile profile); }
@Test public void convertRouteRequestTest() throws Exception { RoutingRequest routingRequest; routingRequest = new RouteRequestHandler().convertRouteRequest(request); Assert.assertEquals(3, routingRequest.getCoordinates().length); Assert.assertEquals(RoutingProfileType.getFromString("driving-car"), routingRequest.getSearchParameters().getProfileType()); Assert.assertArrayEquals(new String[] {"avgspeed", "detourfactor"}, routingRequest.getAttributes()); Assert.assertTrue(routingRequest.getContinueStraight()); Assert.assertEquals(RouteExtraInfoFlag.getFromString("osmid"), routingRequest.getExtraInfo()); Assert.assertEquals("geojson", routingRequest.getGeometryFormat()); Assert.assertTrue(routingRequest.getIncludeGeometry()); Assert.assertTrue(routingRequest.getIncludeInstructions()); Assert.assertTrue(routingRequest.getIncludeRoundaboutExits()); Assert.assertTrue(routingRequest.getIncludeManeuvers()); Assert.assertEquals(RouteInstructionsFormat.HTML, routingRequest.getInstructionsFormat()); Assert.assertEquals("de", routingRequest.getLanguage()); Assert.assertEquals("geojson", routingRequest.getGeometryFormat()); Assert.assertTrue(routingRequest.getIncludeElevation()); Assert.assertEquals(WeightingMethod.FASTEST, routingRequest.getSearchParameters().getWeightingMethod()); Assert.assertEquals(DistanceUnit.METERS, routingRequest.getUnits()); Assert.assertTrue(routingRequest.getSearchParameters().getFlexibleMode()); Assert.assertEquals(BordersExtractor.Avoid.CONTROLLED, routingRequest.getSearchParameters().getAvoidBorders()); Assert.assertArrayEquals(new int[] {115}, routingRequest.getSearchParameters().getAvoidCountries()); Assert.assertEquals(AvoidFeatureFlags.getFromString("fords"), routingRequest.getSearchParameters().getAvoidFeatureTypes()); checkPolygon(routingRequest.getSearchParameters().getAvoidAreas(), geoJsonPolygon); ProfileWeightingCollection weightings = routingRequest.getSearchParameters().getProfileParameters().getWeightings(); ProfileWeighting weighting; Iterator<ProfileWeighting> iter = weightings.getIterator(); while (iter.hasNext() && (weighting = iter.next()) != null) { if (weighting.getName().equals("green")) { Assert.assertEquals(0.5, weighting.getParameters().getDouble("factor", -1), 0); } if (weighting.getName().equals("quiet")) { Assert.assertEquals(0.2, weighting.getParameters().getDouble("factor", -1), 0); } if (weighting.getName().equals("steepness_difficulty")) { Assert.assertEquals(3, weighting.getParameters().getInt("level", -1), 0); } } } @Test public void TestVehicleParameters() throws Exception { request.setProfile(APIEnums.Profile.DRIVING_HGV); request.getRouteOptions().getProfileParams().setRestrictions(vehicleParams); request.getRouteOptions().setVehicleType(APIEnums.VehicleType.AGRICULTURAL); RoutingRequest routingRequest; routingRequest = new RouteRequestHandler().convertRouteRequest(request); VehicleParameters params = (VehicleParameters) routingRequest.getSearchParameters().getProfileParameters(); Assert.assertEquals(30.0, params.getWeight(), 0); Assert.assertEquals(10.0, params.getAxleload(), 0); Assert.assertEquals(5.0, params.getHeight(), 0); Assert.assertEquals(15.0, params.getLength(), 0); Assert.assertEquals(4.5, params.getWidth(), 0); Assert.assertEquals(new VehicleLoadCharacteristicsFlags().getFromString("hazmat"), params.getLoadCharacteristics()); } @Test public void TestWheelchairParameters() throws Exception { request.setProfile(APIEnums.Profile.WHEELCHAIR); request.getRouteOptions().getProfileParams().setRestrictions(wheelchairParams); RoutingRequest routingRequest; routingRequest = new RouteRequestHandler().convertRouteRequest(request); WheelchairParameters params = (WheelchairParameters) routingRequest.getSearchParameters().getProfileParameters(); Assert.assertEquals(WheelchairTypesEncoder.getSmoothnessType("good"), params.getSmoothnessType()); Assert.assertEquals(3.0f, params.getMaximumIncline(), 0); Assert.assertEquals(1.0f, params.getMaximumSlopedKerb(), 0); Assert.assertEquals(2.0f, params.getMinimumWidth(), 0); Assert.assertEquals(WheelchairTypesEncoder.getSurfaceType("asphalt"), params.getSurfaceType()); } @Test public void testBearings() throws StatusCodeException { request.setBearings(new Double[][] {{10.0,10.0},{260.0, 90.0},{45.0, 30.0}}); RoutingRequest routingRequest = new RouteRequestHandler().convertRouteRequest(request); WayPointBearing[] bearings = routingRequest.getSearchParameters().getBearings(); Assert.assertEquals(10.0, bearings[0].getValue(), 0); Assert.assertEquals(10.0, bearings[0].getDeviation(), 0); Assert.assertEquals(260.0, bearings[1].getValue(), 0); Assert.assertEquals(90.0, bearings[1].getDeviation(), 0); Assert.assertEquals(45.0, bearings[2].getValue(), 0); Assert.assertEquals(30.0, bearings[2].getDeviation(), 0); } @Test public void skippedBearingTest() throws Exception { request.setBearings(new Double[][] {{120.0, 90.0}, { , }, {90.0, 30.0}}); RoutingRequest routingRequest; routingRequest = new RouteRequestHandler().convertRouteRequest(request); Assert.assertEquals(3, routingRequest.getSearchParameters().getBearings().length); } @Test(expected = ParameterValueException.class) public void invalidBearingLength() throws Exception { request.setBearings(new Double[][] {{123.0,123.0}}); new RouteRequestHandler().convertRouteRequest(request); } @Test public void testRadius() throws StatusCodeException { request.setMaximumSearchRadii(new Double[] { 50.0, 20.0, 100.0}); RoutingRequest routingRequest = new RouteRequestHandler().convertRouteRequest(request); Assert.assertTrue(Arrays.equals(new double[] { 50.0, 20.0, 100.0 }, routingRequest.getSearchParameters().getMaximumRadiuses())); } @Test(expected = ParameterValueException.class) public void invalidRadiusLength() throws Exception { request.setMaximumSearchRadii(new Double[] {10.0}); new RouteRequestHandler().convertRouteRequest(request); } @Test(expected = ParameterValueException.class) public void onlySetOptimizationToFalse() throws Exception { request.setUseContractionHierarchies(true); new RouteRequestHandler().convertRouteRequest(request); } @Test public void vehicleType() throws Exception{ RouteRequestOptions opts = request.getRouteOptions(); opts.setVehicleType(APIEnums.VehicleType.AGRICULTURAL); for (APIEnums.Profile profile : APIEnums.Profile.values()) { request.setProfile(profile); request.setRouteOptions(opts); if (profile != APIEnums.Profile.DRIVING_HGV) { try { new RouteRequestHandler().convertRouteRequest(request); } catch (Exception e) { Assert.assertTrue(e instanceof IncompatibleParameterException); } } else { new RouteRequestHandler().convertRouteRequest(request); } } } @Test public void testSkippedSegments() throws StatusCodeException { List<Integer> skipSegments = new ArrayList<>(); skipSegments.add(0, 1); skipSegments.add(1, 2); request.setSkipSegments(skipSegments); RoutingRequest routingRequest = new RouteRequestHandler().convertRouteRequest(request); Assert.assertEquals(2, routingRequest.getSkipSegments().size()); Assert.assertEquals(Integer.valueOf(1), routingRequest.getSkipSegments().get(0)); Assert.assertEquals(Integer.valueOf(2), routingRequest.getSkipSegments().get(1)); } @Test(expected = ParameterValueException.class) public void invalidSkipSegmentsLength() throws StatusCodeException { List<Integer> skip_segments = new ArrayList<>(); skip_segments.add(0, 1); skip_segments.add(0, 2); skip_segments.add(0, 2); request.setSkipSegments(skip_segments); new RouteRequestHandler().convertRouteRequest(request); } @Test(expected = EmptyElementException.class) public void emptySkipSegments() throws StatusCodeException { List<Integer> skip_segments = new ArrayList<>(); request.setSkipSegments(skip_segments); new RouteRequestHandler().convertRouteRequest(request); } @Test(expected = ParameterOutOfRangeException.class) public void skipSegmentsValueTooBig() throws StatusCodeException { List<Integer> skip_segments = new ArrayList<>(); skip_segments.add(0, 99); request.setSkipSegments(skip_segments); new RouteRequestHandler().convertRouteRequest(request); } @Test(expected = ParameterValueException.class) public void skipSegmentsValueTooSmall() throws StatusCodeException { List<Integer> skip_segments = new ArrayList<>(); skip_segments.add(0, -99); request.setSkipSegments(skip_segments); new RouteRequestHandler().convertRouteRequest(request); } @Test public void convertRouteRequestTestForAlternativeRoutes() throws Exception { Double[][] coords = new Double[2][2]; coords[0] = new Double[] {24.5,39.2}; coords[1] = new Double[] {26.5,37.2}; RouteRequest arRequest = new RouteRequest(coords); arRequest.setProfile(APIEnums.Profile.DRIVING_CAR); RouteRequestAlternativeRoutes ar = new RouteRequestAlternativeRoutes(); ar.setTargetCount(3); ar.setShareFactor(0.9); ar.setWeightFactor(1.8); arRequest.setAlternativeRoutes(ar); RoutingRequest routingRequest = new RouteRequestHandler().convertRouteRequest(arRequest); Assert.assertEquals(3, routingRequest.getSearchParameters().getAlternativeRoutesCount()); Assert.assertEquals(0.9, routingRequest.getSearchParameters().getAlternativeRoutesShareFactor(), 0); Assert.assertEquals(1.8, routingRequest.getSearchParameters().getAlternativeRoutesWeightFactor(), 0); } @Test(expected = MissingParameterException.class) public void testRoundTripNeedsLength() throws StatusCodeException { List<List<Double>> coordinates = new ArrayList<>(); coordinates.add(new ArrayList<>(Arrays.asList(12.1234, 34.3456))); request.setCoordinates(coordinates); RouteRequestRoundTripOptions rtOptions = new RouteRequestRoundTripOptions(); rtOptions.setPoints(4); RouteRequestOptions options = new RouteRequestOptions(); options.setRoundTripOptions(rtOptions); request.setRouteOptions(options); new RouteRequestHandler().convertRouteRequest(request); } @Test(expected = ParameterValueException.class) public void testSingleCoordinateNotValidForNonRoundTrip() throws StatusCodeException { List<List<Double>> coordinates = new ArrayList<>(); coordinates.add(new ArrayList<>(Arrays.asList(12.1234, 34.3456))); request.setCoordinates(coordinates); new RouteRequestHandler().convertRouteRequest(request); } @Test public void testSingleCoordinateValidForRoundTrip() throws StatusCodeException { List<List<Double>> coordinates = new ArrayList<>(); coordinates.add(new ArrayList<>(Arrays.asList(12.1234, 34.3456))); request.setCoordinates(coordinates); RouteRequestRoundTripOptions rtOptions = new RouteRequestRoundTripOptions(); rtOptions.setLength(400f); RouteRequestOptions options = new RouteRequestOptions(); options.setRoundTripOptions(rtOptions); request.setRouteOptions(options); RoutingRequest generatedRoutingRequest = new RouteRequestHandler().convertRouteRequest(request); Assert.assertEquals(1, generatedRoutingRequest.getCoordinates().length); }
ORSGraphHopper extends GraphHopper { public GHResponse constructFreeHandRoute(GHRequest request) { LineString directRouteGeometry = constructFreeHandRouteGeometry(request); PathWrapper directRoutePathWrapper = constructFreeHandRoutePathWrapper(directRouteGeometry); GHResponse directRouteResponse = new GHResponse(); directRouteResponse.add(directRoutePathWrapper); directRouteResponse.getHints().put("skipped_segment", "true"); return directRouteResponse; } ORSGraphHopper(GraphProcessContext procCntx); ORSGraphHopper(); @Override GraphHopper init(CmdArgs args); @SuppressWarnings("unchecked") @Override GraphHopper importOrLoad(); @Override List<Path> calcPaths(GHRequest request, GHResponse ghRsp); RouteSegmentInfo getRouteSegment(double[] latitudes, double[] longitudes, String vehicle); GHResponse constructFreeHandRoute(GHRequest request); HashMap<Integer, Long> getTmcGraphEdges(); HashMap<Long, ArrayList<Integer>> getOsmId2EdgeIds(); @Override void postProcessing(); GraphHopper setCoreEnabled(boolean enable); final boolean isCoreEnabled(); void initCoreAlgoFactoryDecorator(); final CoreAlgoFactoryDecorator getCoreFactoryDecorator(); GraphHopper setCoreLMEnabled(boolean enable); final boolean isCoreLMEnabled(); void initCoreLMAlgoFactoryDecorator(); final boolean isCHAvailable(String weighting); final boolean isLMAvailable(String weighting); final boolean isCoreAvailable(String weighting); final boolean isFastIsochroneAvailable(RouteSearchContext searchContext, TravelRangeType travelRangeType); final FastIsochroneFactory getFastIsochroneFactory(); Eccentricity getEccentricity(); }
@Test public void directRouteTest() { GHRequest ghRequest = new GHRequest(49.41281601436809, 8.686215877532959, 49.410163456220076, 8.687160015106201); GHResponse ghResponse = new ORSGraphHopper().constructFreeHandRoute(ghRequest); Assert.assertTrue(ghResponse.getHints().has("skipped_segment")); Assert.assertTrue(ghResponse.getHints().getBool("skipped_segment", false)); Assert.assertEquals(1, ghResponse.getAll().size()); PathWrapper directRouteWrapper = ghResponse.getAll().get(0); Assert.assertEquals(0, directRouteWrapper.getErrors().size()); Assert.assertEquals(0, directRouteWrapper.getDescription().size()); Assert.assertEquals(309.892f, directRouteWrapper.getDistance(), 3); Assert.assertEquals(0.0, directRouteWrapper.getAscend(), 0); Assert.assertEquals(0.0, directRouteWrapper.getDescend(), 0); Assert.assertEquals(0.0, directRouteWrapper.getRouteWeight(), 0); Assert.assertEquals(0, directRouteWrapper.getTime()); Assert.assertEquals("", directRouteWrapper.getDebugInfo()); Assert.assertEquals(2, directRouteWrapper.getInstructions().size()); Assert.assertEquals(1, directRouteWrapper.getInstructions().get(0).getPoints().size()); Assert.assertEquals(0, directRouteWrapper.getNumChanges()); Assert.assertEquals(0, directRouteWrapper.getLegs().size()); Assert.assertEquals(0, directRouteWrapper.getPathDetails().size()); Assert.assertNull(directRouteWrapper.getFare()); Assert.assertFalse(directRouteWrapper.isImpossible()); checkInstructions(directRouteWrapper.getInstructions()); checkPointList(directRouteWrapper.getWaypoints()); checkPointList(directRouteWrapper.getPoints()); }
BordersGraphStorageBuilder extends AbstractGraphStorageBuilder { @Override public void processWay(ReaderWay way) { LOGGER.warn("Borders requires geometry for the way!"); } BordersGraphStorageBuilder(); @Override GraphExtension init(GraphHopper graphhopper); void setBordersBuilder(CountryBordersReader cbr); @Override void processWay(ReaderWay way); @Override void processWay(ReaderWay way, Coordinate[] coords, HashMap<Integer, HashMap<String,String>> nodeTags); @Override void processEdge(ReaderWay way, EdgeIteratorState edge); @Override String getName(); String[] findBorderCrossing(Coordinate[] coords); CountryBordersReader getCbReader(); static final String BUILDER_NAME; }
@Test public void TestProcessWay() { ReaderWay rw = new ReaderWay(1); Coordinate[] cs = new Coordinate[] { new Coordinate(0.5,0.5), new Coordinate(1.5,0.5) }; _builder.processWay(rw, cs, null); Assert.assertEquals("c1", rw.getTag("country1")); Assert.assertEquals("c2", rw.getTag("country2")); ReaderWay rw2 = new ReaderWay(1); Coordinate[] cs2 = new Coordinate[] { new Coordinate(0.5,0.5), new Coordinate(0.75,0.5) }; _builder.processWay(rw2, cs2, null); Assert.assertEquals("c1", rw2.getTag("country1")); Assert.assertEquals("c1", rw2.getTag("country2")); }
RouteRequest { public boolean hasIncludeRoundaboutExitInfo() { return hasIncludeRoundaboutExitInfo; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasIncludeRoundaboutExitInfo() { request.setIncludeRoundaboutExitInfo(true); Assert.assertTrue(request.hasIncludeRoundaboutExitInfo()); }
RouteRequest { public boolean hasAttributes() { return hasAttributes; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasAttributes() { request.setAttributes(new APIEnums.Attributes[] {APIEnums.Attributes.AVERAGE_SPEED}); Assert.assertTrue(request.hasAttributes()); }
RouteRequest { public boolean hasMaximumSearchRadii() { return hasMaximumSearchRadii; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasMaximumSearchRadii() { request.setMaximumSearchRadii(new Double[] { 1.0 }); Assert.assertTrue(request.hasMaximumSearchRadii()); }
BordersGraphStorageBuilder extends AbstractGraphStorageBuilder { public String[] findBorderCrossing(Coordinate[] coords) { ArrayList<CountryBordersPolygon> countries = new ArrayList<>(); boolean hasInternational = false; boolean overlap = false; int lsLen = coords.length; if(lsLen > 1) { for(int i=0; i<lsLen; i++) { Coordinate c = coords[i]; if(!Double.isNaN(c.x) && !Double.isNaN(c.y)) { CountryBordersPolygon[] cnts = cbReader.getCandidateCountry(c); for (CountryBordersPolygon cbp : cnts) { if (!countries.contains(cbp)) { countries.add(cbp); } } if(cnts.length == 0) hasInternational = true; } } } if(countries.size() > 1) { ArrayList<CountryBordersPolygon> temp = new ArrayList<>(); for(int i=0; i<lsLen; i++) { Coordinate c = coords[i]; if(!Double.isNaN(c.x) && !Double.isNaN(c.y)) { boolean found = false; int countriesFound = 0; for(CountryBordersPolygon cbp : countries) { if (cbp.inArea(c)) { found = true; countriesFound++; if(!temp.contains(cbp)) { temp.add(cbp); } } } if(countriesFound > 1) { overlap = true; } if(!found) { hasInternational = true; } } } countries = temp; } if(countries.size() > 1 && overlap) { boolean crosses = false; LineString ls = gf.createLineString(coords); for (CountryBordersPolygon cp : countries) { if (cp.crossesBoundary(ls)) { crosses = true; break; } } if(!crosses) { CountryBordersPolygon cp = countries.get(0); countries.clear(); countries.add(cp); } } ArrayList<String> names = new ArrayList<>(); for(int i=0; i<countries.size(); i++) { if (!names.contains(countries.get(i).getName())) names.add(countries.get(i).getName()); } if(hasInternational && !countries.isEmpty()) { names.add(CountryBordersReader.INTERNATIONAL_NAME); } return names.toArray(new String[names.size()]); } BordersGraphStorageBuilder(); @Override GraphExtension init(GraphHopper graphhopper); void setBordersBuilder(CountryBordersReader cbr); @Override void processWay(ReaderWay way); @Override void processWay(ReaderWay way, Coordinate[] coords, HashMap<Integer, HashMap<String,String>> nodeTags); @Override void processEdge(ReaderWay way, EdgeIteratorState edge); @Override String getName(); String[] findBorderCrossing(Coordinate[] coords); CountryBordersReader getCbReader(); static final String BUILDER_NAME; }
@Test public void TestFindBorderCrossing() { String[] names = _builder.findBorderCrossing(new Coordinate[] { new Coordinate(0.5,0.5), new Coordinate(1.5,0.5) }); Assert.assertEquals(2, names.length); Assert.assertTrue(names[0].equals("c1") || names[1].equals("c1")); Assert.assertTrue(names[0].equals("c2") || names[1].equals("c2")); } @Test public void TestOverlappingRegion() { String[] names = _builder.findBorderCrossing(new Coordinate[] { new Coordinate(101.5,101.5), new Coordinate(102.5,101.5) }); Assert.assertEquals(2, names.length); String[] names2 = _builder.findBorderCrossing(new Coordinate[] { new Coordinate(101.5,101.5), new Coordinate(101.75,101.5) }); Assert.assertEquals(1, names2.length); }
RouteRequest { public boolean hasBearings() { return hasBearings; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasBearings() { request.setBearings(new Double[][] {new Double[] {0.0, 90.0}}); Assert.assertTrue(request.hasBearings()); }
RouteRequest { public boolean hasUseElevation() { return hasUseElevation; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasUseElevation() { request.setUseElevation(true); Assert.assertTrue(request.hasUseElevation()); }
RouteRequest { public boolean hasRouteOptions() { return hasRouteOptions; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasRouteOptions() { request.setRouteOptions(new RouteRequestOptions()); Assert.assertTrue(request.hasRouteOptions()); }
RouteRequest { public boolean hasUseContractionHierarchies() { return hasUseContractionHierarchies; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasUseContractionHierarchies() { request.setUseContractionHierarchies(true); Assert.assertTrue(request.hasUseContractionHierarchies()); }
RouteRequest { public boolean hasExtraInfo() { return hasExtraInfo; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasExtraInfo() { request.setExtraInfo(new APIEnums.ExtraInfo[] { APIEnums.ExtraInfo.SURFACE }); Assert.assertTrue(request.hasExtraInfo()); }
RouteRequest { public boolean hasSuppressWarnings() { return hasSuppressWarnings; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasSuppressWarnings() { request.setSuppressWarnings(true); Assert.assertTrue(request.hasSuppressWarnings()); }
RouteRequest { public boolean hasSkipSegments() { return hasSkipSegments;} @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasSkipSegments() { List<Integer> testSegments = new ArrayList<>(); testSegments.add(0, 1); Assert.assertFalse(request.hasSkipSegments()); request.setSkipSegments(testSegments); Assert.assertTrue(request.hasSkipSegments()); }
RouteRequest { public boolean hasAlternativeRoutes() { return hasAlternativeRoutes; } @JsonCreator RouteRequest(@JsonProperty(value = PARAM_COORDINATES, required = true) List<List<Double>> coordinates); RouteRequest(Double[][] coordinates); RouteRequest(Coordinate start, Coordinate end); String getId(); void setId(String id); boolean hasId(); List<List<Double>> getCoordinates(); void setCoordinates(List<List<Double>> coordinates); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); APIEnums.Languages getLanguage(); void setLanguage(APIEnums.Languages language); APIEnums.RoutePreference getRoutePreference(); void setRoutePreference(APIEnums.RoutePreference routePreference); boolean hasRoutePreference(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); APIEnums.ExtraInfo[] getExtraInfo(); void setExtraInfo(APIEnums.ExtraInfo[] extraInfo); RouteRequestOptions getRouteOptions(); void setRouteOptions(RouteRequestOptions routeOptions); boolean getIncludeGeometry(); void setIncludeGeometry(boolean includeGeometry); boolean getIncludeInstructionsInResponse(); void setIncludeInstructionsInResponse(Boolean includeInstructionsInResponse); APIEnums.InstructionsFormat getInstructionsFormat(); void setInstructionsFormat(APIEnums.InstructionsFormat instructionsFormat); boolean getIncludeRoundaboutExitInfo(); void setIncludeRoundaboutExitInfo(Boolean includeRoundaboutExitInfo); APIEnums.Attributes[] getAttributes(); void setAttributes(APIEnums.Attributes[] attributes); boolean getIncludeManeuvers(); void setIncludeManeuvers(Boolean includeManeuvers); Double[] getMaximumSearchRadii(); void setMaximumSearchRadii(Double[] maximumSearchRadii); Double[][] getBearings(); void setBearings(Double[][] bearings); boolean getContinueStraightAtWaypoints(); void setContinueStraightAtWaypoints(Boolean continueStraightAtWaypoints); boolean getUseElevation(); void setUseElevation(Boolean useElevation); boolean getUseContractionHierarchies(); void setUseContractionHierarchies(Boolean useContractionHierarchies); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); boolean getSimplifyGeometry(); void setSimplifyGeometry(boolean simplifyGeometry); List<Integer> getSkipSegments(); void setSkipSegments(List<Integer> skipSegments); RouteRequestAlternativeRoutes getAlternativeRoutes(); void setAlternativeRoutes(RouteRequestAlternativeRoutes alternativeRoutes); void setMaximumSpeed(Double maximumSpeed); double getMaximumSpeed(); boolean hasIncludeRoundaboutExitInfo(); boolean hasAttributes(); boolean hasIncludeManeuvers(); boolean hasMaximumSearchRadii(); boolean hasBearings(); boolean hasContinueStraightAtWaypoints(); boolean hasIncludeInstructions(); boolean hasIncludeGeometry(); boolean hasLanguage(); boolean hasInstructionsFormat(); boolean hasUnits(); boolean hasUseElevation(); boolean hasRouteOptions(); boolean hasUseContractionHierarchies(); boolean hasExtraInfo(); boolean hasSuppressWarnings(); boolean hasSimplifyGeometry(); boolean hasSkipSegments(); boolean hasAlternativeRoutes(); boolean hasMaximumSpeed(); static final String PARAM_ID; static final String PARAM_COORDINATES; static final String PARAM_PROFILE; static final String PARAM_PREFERENCE; static final String PARAM_FORMAT; static final String PARAM_UNITS; static final String PARAM_LANGUAGE; static final String PARAM_GEOMETRY; static final String PARAM_INSTRUCTIONS; static final String PARAM_INSTRUCTIONS_FORMAT; static final String PARAM_ROUNDABOUT_EXITS; static final String PARAM_ATTRIBUTES; static final String PARAM_MANEUVERS; static final String PARAM_RADII; static final String PARAM_BEARINGS; static final String PARAM_CONTINUE_STRAIGHT; static final String PARAM_ELEVATION; static final String PARAM_EXTRA_INFO; static final String PARAM_OPTIMIZED; static final String PARAM_OPTIONS; static final String PARAM_SUPPRESS_WARNINGS; static final String PARAM_SIMPLIFY_GEOMETRY; static final String PARAM_SKIP_SEGMENTS; static final String PARAM_ALTERNATIVE_ROUTES; static final String PARAM_MAXIMUM_SPEED; }
@Test public void testHasAlternativeRoutes() { RouteRequestAlternativeRoutes ar = new RouteRequestAlternativeRoutes(); Assert.assertFalse(request.hasAlternativeRoutes()); request.setAlternativeRoutes(ar); Assert.assertTrue(request.hasAlternativeRoutes()); }
IsochronesRequest { public String getId() { return id; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getIdTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getId()); }
IsochronesRequest { public void setId(String id) { this.id = id; this.hasId = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setIdTest() { IsochronesRequest request = new IsochronesRequest(); request.setId("foo"); Assert.assertEquals("foo", request.getId()); }
IsochronesRequest { public boolean hasId() { return hasId; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void hasIdTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertFalse(request.hasId()); request.setId("foo"); Assert.assertTrue(request.hasId()); }
IsochronesRequest { public void setAreaUnit(APIEnums.Units areaUnit) { this.areaUnit = areaUnit; hasAreaUnits = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setAreaUnitTest() throws ParameterValueException { IsochronesRequest request = new IsochronesRequest(); request.setAreaUnit(APIEnums.Units.forValue("km")); Assert.assertEquals(APIEnums.Units.KILOMETRES, request.getAreaUnit()); }
IsochronesRequest { public Double getSmoothing() { return smoothing; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getSmoothingTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getSmoothing()); }
IsochronesRequest { public void setSmoothing(Double smoothing) { this.smoothing = smoothing; this.hasSmoothing = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setSmoothingTest() { IsochronesRequest request = new IsochronesRequest(); request.setSmoothing(0.1); Assert.assertEquals(0.1, request.getSmoothing(), 0); }
IsochronesRequest { public boolean hasSmoothing() { return hasSmoothing; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void hasSmoothingTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertFalse(request.hasSmoothing()); request.setSmoothing(0.1); Assert.assertTrue(request.hasSmoothing()); }
IsochronesRequest { public APIEnums.RouteResponseType getResponseType() { return responseType; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getResponseTypeTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertEquals(APIEnums.RouteResponseType.GEOJSON, request.getResponseType()); }
IsochronesRequest { public void setResponseType(APIEnums.RouteResponseType responseType) { this.responseType = responseType; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setResponseTypeTest() { IsochronesRequest request = new IsochronesRequest(); request.setResponseType(APIEnums.RouteResponseType.JSON); Assert.assertEquals(APIEnums.RouteResponseType.JSON, request.getResponseType()); }
IsochronesRequest { public IsochronesRequestEnums.Attributes[] getAttributes() { return attributes; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getAttributesTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getAttributes()); }
IsochronesRequest { public Double[][] getLocations() { return locations; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getLocationTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertEquals(Double[][].class, request.getLocations().getClass()); }
IsochronesRequest { public void setLocationType(IsochronesRequestEnums.LocationType locationType) { this.locationType = locationType; hasLocationType = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setLocationTypeTest() { IsochronesRequest request = new IsochronesRequest(); request.setLocationType(IsochronesRequestEnums.LocationType.DESTINATION); Assert.assertEquals(IsochronesRequestEnums.LocationType.DESTINATION, request.getLocationType()); }
WheelchairSidewalkWay extends PedestrianWay { @Override public boolean hasWayBeenFullyProcessed() { if(side == OSMAttachedSidewalkProcessor.Side.BOTH && lastPrepared == OSMAttachedSidewalkProcessor.Side.RIGHT) { return true; } return side == lastPrepared; } WheelchairSidewalkWay(ReaderWay way); @Override boolean hasWayBeenFullyProcessed(); @Override void prepare(); }
@Test public void TestInitiallyProcessedIfNoSidewalk() { WheelchairSidewalkWay way = new WheelchairSidewalkWay(new ReaderWay(1)); assertTrue(way.hasWayBeenFullyProcessed()); } @Test public void TestInitiallyNotProcessedIfSidewalk() { ReaderWay readerWay = new ReaderWay(1); readerWay.setTag("sidewalk", "left"); WheelchairSidewalkWay way = new WheelchairSidewalkWay(readerWay); assertFalse(way.hasWayBeenFullyProcessed()); }
IsochronesRequest { public APIEnums.Profile getProfile() { return profile; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getProfileTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getProfile()); }
IsochronesRequest { public void setProfile(APIEnums.Profile profile) { this.profile = profile; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setProfileTest() { IsochronesRequest request = new IsochronesRequest(); request.setProfile(APIEnums.Profile.DRIVING_CAR); Assert.assertEquals(APIEnums.Profile.DRIVING_CAR, request.getProfile()); }
IsochronesRequest { public RouteRequestOptions getIsochronesOptions() { return isochronesOptions; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getIsochronesOptionsTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getIsochronesOptions()); }
IsochronesRequest { public void setIsochronesOptions(RouteRequestOptions isochronesOptions) { this.isochronesOptions = isochronesOptions; this.hasOptions = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setIsochronesOptionsTest() { IsochronesRequest request = new IsochronesRequest(); request.setIsochronesOptions(new RouteRequestOptions()); Assert.assertEquals(RouteRequestOptions.class, request.getIsochronesOptions().getClass()); }
IsochronesRequest { public List<Double> getRange() { return range; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getRangeTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getRange()); }
IsochronesRequest { public void setRange(List<Double> range) { this.range = range; hasRange = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setRangeTest() { IsochronesRequest request = new IsochronesRequest(); request.setRange(new ArrayList<>()); Assert.assertNotNull(request.getRange()); }
IsochronesRequest { public void setRangeType(IsochronesRequestEnums.RangeType rangeType) { this.rangeType = rangeType; hasRangeType = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setRangeTypeTest() { IsochronesRequest request = new IsochronesRequest(); request.setRangeType(IsochronesRequestEnums.RangeType.DISTANCE); Assert.assertEquals(IsochronesRequestEnums.RangeType.DISTANCE, request.getRangeType()); }
IsochronesRequest { public Double getInterval() { return interval; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void getIntervalTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getInterval()); }
IsochronesRequest { public void setInterval(Double interval) { this.interval = interval; hasInterval = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }
@Test public void setIntervalTest() { IsochronesRequest request = new IsochronesRequest(); request.setInterval(new Double("0.0")); Assert.assertEquals(new Double("0.0"), request.getInterval()); }
IsochronesRequestHandler extends GenericHandler { Float convertSmoothing(Double smoothingValue) throws ParameterValueException { float f = (float) smoothingValue.doubleValue(); if (smoothingValue < 0 || smoothingValue > 100) throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_SMOOTHING, smoothingValue.toString()); return f; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertSmoothing() throws ParameterValueException { Float smoothing = handler.convertSmoothing(10.234); Assert.assertEquals(10.234, smoothing, 0.01); } @Test(expected = ParameterValueException.class) public void convertSmoothingFailWhenTooHigh() throws ParameterValueException { handler.convertSmoothing(105.0); } @Test(expected = ParameterValueException.class) public void convertSmoothingFailWhenTooLow() throws ParameterValueException { handler.convertSmoothing(-5.0); }
IsochronesRequestHandler extends GenericHandler { String convertLocationType(IsochronesRequestEnums.LocationType locationType) throws ParameterValueException { IsochronesRequestEnums.LocationType value; switch (locationType) { case DESTINATION: value = IsochronesRequestEnums.LocationType.DESTINATION; break; case START: value = IsochronesRequestEnums.LocationType.START; break; default: throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_LOCATION_TYPE, locationType.toString()); } return value.toString(); } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertLocationType() throws ParameterValueException { String locationType = handler.convertLocationType(IsochronesRequestEnums.LocationType.DESTINATION); Assert.assertEquals("destination", locationType); locationType = handler.convertLocationType(IsochronesRequestEnums.LocationType.START); Assert.assertEquals("start", locationType); }
IsochronesRequestHandler extends GenericHandler { TravelRangeType convertRangeType(IsochronesRequestEnums.RangeType rangeType) throws ParameterValueException { TravelRangeType travelRangeType; switch (rangeType) { case DISTANCE: travelRangeType = TravelRangeType.DISTANCE; break; case TIME: travelRangeType = TravelRangeType.TIME; break; default: throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_RANGE_TYPE, rangeType.toString()); } return travelRangeType; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertRangeType() throws ParameterValueException { TravelRangeType rangeType = handler.convertRangeType(IsochronesRequestEnums.RangeType.DISTANCE); Assert.assertEquals(TravelRangeType.DISTANCE, rangeType); rangeType = handler.convertRangeType(IsochronesRequestEnums.RangeType.TIME); Assert.assertEquals(TravelRangeType.TIME, rangeType); }
IsochronesRequestHandler extends GenericHandler { String convertAreaUnit(APIEnums.Units unitsIn) throws ParameterValueException { DistanceUnit areaUnit; try { areaUnit = DistanceUnitUtil.getFromString(unitsIn.toString(), DistanceUnit.UNKNOWN); if (areaUnit == DistanceUnit.UNKNOWN) throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_AREA_UNITS, unitsIn.toString()); return DistanceUnitUtil.toString(areaUnit); } catch (Exception e) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_AREA_UNITS, unitsIn.toString()); } } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertAreaUnit() throws ParameterValueException { String unit = handler.convertAreaUnit(APIEnums.Units.KILOMETRES); Assert.assertEquals("km", unit); unit = handler.convertAreaUnit(APIEnums.Units.METRES); Assert.assertEquals("m", unit); unit = handler.convertAreaUnit(APIEnums.Units.MILES); Assert.assertEquals("mi", unit); }
IsochronesRequestHandler extends GenericHandler { String convertRangeUnit(APIEnums.Units unitsIn) throws ParameterValueException { DistanceUnit units; try { units = DistanceUnitUtil.getFromString(unitsIn.toString(), DistanceUnit.UNKNOWN); if (units == DistanceUnit.UNKNOWN) throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_RANGE_UNITS, unitsIn.toString()); } catch (Exception e) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_RANGE_UNITS, unitsIn.toString()); } return DistanceUnitUtil.toString(units); } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertRangeUnit() throws ParameterValueException { String unit = handler.convertRangeUnit(APIEnums.Units.KILOMETRES); Assert.assertEquals("km", unit); unit = handler.convertRangeUnit(APIEnums.Units.METRES); Assert.assertEquals("m", unit); unit = handler.convertRangeUnit(APIEnums.Units.MILES); Assert.assertEquals("mi", unit); }
IsochronesRequestHandler extends GenericHandler { Coordinate convertSingleCoordinate(Double[] coordinate) throws ParameterValueException { Coordinate realCoordinate; if (coordinate.length != 2) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_LOCATIONS); } try { realCoordinate = new Coordinate(coordinate[0], coordinate[1]); } catch (Exception e) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_LOCATIONS); } return realCoordinate; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertSingleCoordinate() throws ParameterValueException { Coordinate coord = handler.convertSingleCoordinate(new Double[]{123.4, 321.0}); Assert.assertEquals(123.4, coord.x, 0.0001); Assert.assertEquals(321.0, coord.y, 0.0001); } @Test(expected = ParameterValueException.class) public void convertSingleCoordinateInvalidLengthShort() throws ParameterValueException { handler.convertSingleCoordinate(new Double[]{123.4}); } @Test(expected = ParameterValueException.class) public void convertSingleCoordinateInvalidLengthLong() throws ParameterValueException { handler.convertSingleCoordinate(new Double[]{123.4, 123.4, 123.4}); }
IsochronesRequestHandler extends GenericHandler { void setRangeAndIntervals(TravellerInfo travellerInfo, List<Double> rangeValues, Double intervalValue) throws ParameterValueException { double rangeValue = -1; if (rangeValues.size() == 1) { try { rangeValue = rangeValues.get(0); travellerInfo.setRanges(new double[]{rangeValue}); } catch (NumberFormatException ex) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, "range"); } } else { double[] ranges = new double[rangeValues.size()]; double maxRange = Double.MIN_VALUE; for (int i = 0; i < ranges.length; i++) { double dv = rangeValues.get(i); if (dv > maxRange) maxRange = dv; ranges[i] = dv; } Arrays.sort(ranges); travellerInfo.setRanges(ranges); } if (rangeValues.size() == 1 && rangeValue != -1 && intervalValue != null){ travellerInfo.setRanges(rangeValue, intervalValue); } } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void setRangeAndIntervals() throws ParameterValueException { TravellerInfo info = new TravellerInfo(); List<Double> rangeValues = new ArrayList<>(); rangeValues.add(20.0); double intervalValue = 10; handler.setRangeAndIntervals(info, rangeValues, intervalValue); Assert.assertEquals(10.0, info.getRanges()[0], 0.0f); Assert.assertEquals(20.0, info.getRanges()[1], 0.0f); info = new TravellerInfo(); rangeValues = new ArrayList<>(); rangeValues.add(15.0); rangeValues.add(30.0); handler.setRangeAndIntervals(info, rangeValues, intervalValue); Assert.assertEquals(15.0, info.getRanges()[0], 0.0f); Assert.assertEquals(30.0, info.getRanges()[1], 0.0f); }
WheelchairSeparateWay extends PedestrianWay { @Override public boolean hasWayBeenFullyProcessed() { return hasBeenProcessed; } WheelchairSeparateWay(ReaderWay way); @Override boolean hasWayBeenFullyProcessed(); @Override void prepare(); }
@Test public void TestInitiallyNotProcessed() { assertFalse(way.hasWayBeenFullyProcessed()); }
BordersExtractor { public boolean isControlledBorder(int edgeId) { return storage.getEdgeValue(edgeId, BordersGraphStorage.Property.TYPE) == BordersGraphStorage.CONTROLLED_BORDER; } BordersExtractor(BordersGraphStorage storage, int[] avoidCountries); int getValue(int edgeId); boolean isBorder(int edgeId); boolean isControlledBorder(int edgeId); boolean isOpenBorder(int edgeId); boolean restrictedCountry(int edgeId); boolean isSameCountry(List<Integer> edgeIds); }
@Test public void TestDetectControlledBorder() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[0]); assertEquals(true, be.isControlledBorder(1)); assertEquals(false, be.isControlledBorder(2)); assertEquals(false, be.isControlledBorder(3)); }
IsochronesRequestHandler extends GenericHandler { String[] convertAttributes(IsochronesRequestEnums.Attributes[] attributes) { return convertAPIEnumListToStrings(attributes); } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertAttributes() { IsochronesRequestEnums.Attributes[] atts = new IsochronesRequestEnums.Attributes[]{IsochronesRequestEnums.Attributes.AREA, IsochronesRequestEnums.Attributes.REACH_FACTOR, IsochronesRequestEnums.Attributes.TOTAL_POPULATION}; String[] attStr = handler.convertAttributes(atts); Assert.assertEquals("area", attStr[0]); Assert.assertEquals("reachfactor", attStr[1]); Assert.assertEquals("total_pop", attStr[2]); }
IsochronesRequestHandler extends GenericHandler { String convertCalcMethod(IsochronesRequestEnums.CalculationMethod bareCalcMethod) throws ParameterValueException { try { switch (bareCalcMethod) { case CONCAVE_BALLS: return "concaveballs"; case GRID: return "grid"; case FASTISOCHRONE: return "fastisochrone"; default: return "none"; } } catch (Exception ex) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, "calc_method"); } } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertCalcMethod() throws ParameterValueException { String calcMethod = handler.convertCalcMethod(IsochronesRequestEnums.CalculationMethod.CONCAVE_BALLS); Assert.assertEquals("concaveballs", calcMethod); calcMethod = handler.convertCalcMethod(IsochronesRequestEnums.CalculationMethod.GRID); Assert.assertEquals("grid", calcMethod); }
IsochronesRequestHandler extends GenericHandler { IsochroneRequest convertIsochroneRequest(IsochronesRequest request) throws Exception { IsochroneRequest convertedIsochroneRequest = new IsochroneRequest(); Double[][] locations = request.getLocations(); for (int i = 0; i < request.getLocations().length; i++) { Double[] location = locations[i]; TravellerInfo travellerInfo = constructTravellerInfo(location, request); travellerInfo.setId(Integer.toString(i)); try { convertedIsochroneRequest.addTraveller(travellerInfo); } catch (Exception ex) { throw new InternalServerException(IsochronesErrorCodes.UNKNOWN, IsochronesRequest.PARAM_INTERVAL); } } if (request.hasId()) convertedIsochroneRequest.setId(request.getId()); if (request.hasRangeUnits()) convertedIsochroneRequest.setUnits(convertRangeUnit(request.getRangeUnit())); if (request.hasAreaUnits()) convertedIsochroneRequest.setAreaUnits(convertAreaUnit(request.getAreaUnit())); if (request.hasAttributes()) convertedIsochroneRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasSmoothing()) convertedIsochroneRequest.setSmoothingFactor(convertSmoothing(request.getSmoothing())); if (request.hasIntersections()) convertedIsochroneRequest.setIncludeIntersections(request.getIntersections()); if(request.hasOptions()) convertedIsochroneRequest.setCalcMethod(convertCalcMethod(CONCAVE_BALLS)); else convertedIsochroneRequest.setCalcMethod(convertCalcMethod(FASTISOCHRONE)); return convertedIsochroneRequest; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void convertIsochroneRequest() throws Exception { IsochronesRequest request = new IsochronesRequest(); Double[][] locations = {{9.676034, 50.409675}, {9.676034, 50.409675}}; Coordinate coord0 = new Coordinate(); coord0.x = 9.676034; coord0.y = 50.409675; request.setLocations(locations); request.setProfile(APIEnums.Profile.DRIVING_CAR); List<Double> range = new ArrayList<>(); range.add(300.0); range.add(600.0); request.setRange(range); IsochroneRequest isochroneRequest = handler.convertIsochroneRequest(request); Assert.assertNotNull(isochroneRequest); Assert.assertFalse(isochroneRequest.getIncludeIntersections()); Assert.assertNull(request.getAttributes()); Assert.assertFalse(request.hasSmoothing()); Assert.assertNull(request.getSmoothing()); Assert.assertNull(request.getId()); Assert.assertEquals(coord0.x, isochroneRequest.getLocations()[0].x, 0); Assert.assertEquals(coord0.y, isochroneRequest.getLocations()[0].y, 0); Assert.assertEquals(coord0.x, isochroneRequest.getLocations()[1].x, 0); Assert.assertEquals(coord0.y, isochroneRequest.getLocations()[1].y, 0); Assert.assertEquals(2, isochroneRequest.getTravellers().size()); for (int i = 0; i < isochroneRequest.getTravellers().size(); i++) { TravellerInfo travellerInfo = isochroneRequest.getTravellers().get(i); Assert.assertEquals(String.valueOf(i), travellerInfo.getId()); Assert.assertEquals(coord0, travellerInfo.getLocation()); Assert.assertEquals(IsochronesRequestEnums.LocationType.START.toString(), travellerInfo.getLocationType()); Assert.assertNotNull(travellerInfo.getRanges()); Assert.assertEquals(TravelRangeType.TIME, travellerInfo.getRangeType()); Assert.assertNotNull(travellerInfo.getRouteSearchParameters()); } }
IsochronesRequestHandler extends GenericHandler { TravellerInfo constructTravellerInfo(Double[] coordinate, IsochronesRequest request) throws Exception { TravellerInfo travellerInfo = new TravellerInfo(); RouteSearchParameters routeSearchParameters = constructRouteSearchParameters(request); travellerInfo.setRouteSearchParameters(routeSearchParameters); if (request.hasRangeType()) travellerInfo.setRangeType(convertRangeType(request.getRangeType())); if (request.hasLocationType()) travellerInfo.setLocationType(convertLocationType(request.getLocationType())); travellerInfo.setLocation(convertSingleCoordinate(coordinate)); travellerInfo.getRanges(); if (request.getRange() == null) { throw new ParameterValueException(IsochronesErrorCodes.MISSING_PARAMETER, IsochronesRequest.PARAM_RANGE); } List<Double> rangeValues = request.getRange(); Double intervalValue = request.getInterval(); setRangeAndIntervals(travellerInfo, rangeValues, intervalValue); return travellerInfo; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void constructTravellerInfo() throws Exception { Double[][] coordinates = {{1.0, 3.0}, {1.0, 3.0}}; Double[] coordinate = {1.0, 3.0}; Coordinate realCoordinate = new Coordinate(); realCoordinate.x = 1.0; realCoordinate.y = 3.0; IsochronesRequest request = new IsochronesRequest(); request.setProfile(APIEnums.Profile.DRIVING_CAR); request.setLocations(coordinates); List<Double> range = new ArrayList<>(); range.add(300.0); range.add(600.0); request.setRange(range); IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); TravellerInfo travellerInfo = isochronesRequestHandler.constructTravellerInfo(coordinate, request); Assert.assertEquals(String.valueOf(0), travellerInfo.getId()); Assert.assertEquals(realCoordinate, travellerInfo.getLocation()); Assert.assertEquals("start", travellerInfo.getLocationType()); Assert.assertEquals(range.toString(), Arrays.toString(travellerInfo.getRanges())); Assert.assertEquals(TravelRangeType.TIME, travellerInfo.getRangeType()); }
IsochronesRequestHandler extends GenericHandler { RouteSearchParameters constructRouteSearchParameters(IsochronesRequest request) throws Exception { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); int profileType; try { profileType = convertToIsochronesProfileType(request.getProfile()); } catch (Exception e) { throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_PROFILE); } if (profileType == RoutingProfileType.UNKNOWN) throw new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_VALUE, IsochronesRequest.PARAM_PROFILE); routeSearchParameters.setProfileType(profileType); if (request.hasOptions()) { routeSearchParameters = processIsochronesRequestOptions(request, routeSearchParameters); } routeSearchParameters.setConsiderTurnRestrictions(false); return routeSearchParameters; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void constructRouteSearchParametersTest() throws Exception { Double[][] coordinates = {{1.0, 3.0}, {1.0, 3.0}}; IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); IsochronesRequest request = new IsochronesRequest(); request.setProfile(APIEnums.Profile.DRIVING_CAR); request.setLocations(coordinates); RouteSearchParameters routeSearchParameters = isochronesRequestHandler.constructRouteSearchParameters(request); Assert.assertEquals(RoutingProfileType.DRIVING_CAR, routeSearchParameters.getProfileType()); Assert.assertEquals(WeightingMethod.FASTEST, routeSearchParameters.getWeightingMethod()); Assert.assertFalse(routeSearchParameters.getConsiderTurnRestrictions()); Assert.assertNull(routeSearchParameters.getAvoidAreas()); Assert.assertEquals(0, routeSearchParameters.getAvoidFeatureTypes()); Assert.assertEquals(0, routeSearchParameters.getVehicleType()); Assert.assertFalse(routeSearchParameters.getFlexibleMode()); Assert.assertEquals(BordersExtractor.Avoid.NONE, routeSearchParameters.getAvoidBorders()); Assert.assertNull(routeSearchParameters.getProfileParameters()); Assert.assertNull(routeSearchParameters.getBearings()); Assert.assertNull(routeSearchParameters.getMaximumRadiuses()); Assert.assertNull(routeSearchParameters.getAvoidCountries()); Assert.assertNull(routeSearchParameters.getOptions()); }
IsochronesRequestHandler extends GenericHandler { RouteSearchParameters processIsochronesRequestOptions(IsochronesRequest request, RouteSearchParameters parameters) throws StatusCodeException { RouteRequestOptions options = request.getIsochronesOptions(); parameters = new RouteRequestHandler().processRequestOptions(options, parameters); if (options.hasProfileParams()) parameters.setProfileParams(convertParameters(options, parameters.getProfileType())); return parameters; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void processIsochronesRequestOptionsTest() throws Exception { IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); RouteSearchParameters routeSearchParameters = isochronesRequestHandler.constructRouteSearchParameters(request); Assert.assertEquals(RoutingProfileType.DRIVING_CAR, routeSearchParameters.getProfileType()); Assert.assertEquals(WeightingMethod.FASTEST, routeSearchParameters.getWeightingMethod()); Assert.assertFalse(routeSearchParameters.getConsiderTurnRestrictions()); checkPolygon(routeSearchParameters.getAvoidAreas(), geoJsonPolygon); Assert.assertEquals(16, routeSearchParameters.getAvoidFeatureTypes()); Assert.assertEquals(0, routeSearchParameters.getVehicleType()); Assert.assertFalse(routeSearchParameters.getFlexibleMode()); Assert.assertEquals(BordersExtractor.Avoid.CONTROLLED, routeSearchParameters.getAvoidBorders()); Assert.assertNull(routeSearchParameters.getBearings()); Assert.assertNull(routeSearchParameters.getMaximumRadiuses()); Assert.assertNull(routeSearchParameters.getOptions()); Assert.assertEquals(115, routeSearchParameters.getAvoidCountries()[0]); ProfileWeightingCollection weightings = routeSearchParameters.getProfileParameters().getWeightings(); ProfileWeighting weighting; Iterator<ProfileWeighting> iter = weightings.getIterator(); while (iter.hasNext() && (weighting = iter.next()) != null) { if (weighting.getName().equals("green")) { Assert.assertEquals(0.5, weighting.getParameters().getDouble("factor", -1), 0); } if (weighting.getName().equals("quiet")) { Assert.assertEquals(0.2, weighting.getParameters().getDouble("factor", -1), 0); } if (weighting.getName().equals("steepness_difficulty")) { Assert.assertEquals(3, weighting.getParameters().getInt("level", -1), 0); } } }
IsochronesRequestHandler extends GenericHandler { public IsochroneMapCollection getIsoMaps() { return isoMaps; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void getIsoMapsTest() { IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); Assert.assertNull(isochronesRequestHandler.getIsoMaps()); }
IsochronesRequestHandler extends GenericHandler { public IsochroneRequest getIsochroneRequest() { return isochroneRequest; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }
@Test public void getIsochroneRequestTest() { IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); Assert.assertNull(isochronesRequestHandler.getIsochroneRequest()); }
GenericHandler { protected String[] convertAPIEnumListToStrings(Enum[] valuesIn) { String[] attributes = new String[valuesIn.length]; for (int i = 0; i < valuesIn.length; i++) { attributes[i] = convertAPIEnum(valuesIn[i]); } return attributes; } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertAPIEnumListToStrings() { String[] strVals = handler.convertAPIEnumListToStrings(new APIEnums.ExtraInfo[] {APIEnums.ExtraInfo.STEEPNESS, APIEnums.ExtraInfo.SURFACE}); Assert.assertEquals(2, strVals.length); Assert.assertEquals("steepness", strVals[0]); Assert.assertEquals("surface", strVals[1]); }
GenericHandler { protected String convertAPIEnum(Enum valuesIn) { return valuesIn.toString(); } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertAPIEnum() { String strVal = handler.convertAPIEnum(APIEnums.AvoidBorders.CONTROLLED); Assert.assertEquals("controlled", strVal); }
OSMAttachedSidewalkProcessor { protected boolean hasSidewalkInfo(ReaderWay way) { return identifySidesWhereSidewalkIsPresent(way) != Side.NONE; } ReaderWay attachSidewalkTag(ReaderWay way, Side side); Side getPreparedSide(ReaderWay way); static final String KEY_ORS_SIDEWALK_SIDE; static final String VAL_RIGHT; static final String VAL_LEFT; }
@Test public void TestDetectSidewalkInfoFromTags() { ReaderWay way = new ReaderWay(1); way.setTag("sidewalk:left:surface", "asphalt"); assertTrue(processor.hasSidewalkInfo(way)); way = new ReaderWay(1); way.setTag("footway:right:width", "0.5"); assertTrue(processor.hasSidewalkInfo(way)); way = new ReaderWay(1); assertFalse(processor.hasSidewalkInfo(way)); }
GenericHandler { protected int convertVehicleType(APIEnums.VehicleType vehicleTypeIn, int profileType) throws IncompatibleParameterException { if (!RoutingProfileType.isHeavyVehicle(profileType)) { throw new IncompatibleParameterException(getInvalidParameterValueErrorCode(), "vehicle_type", vehicleTypeIn.toString(), KEY_PROFILE, RoutingProfileType.getName(profileType)); } if (vehicleTypeIn == null) { return HeavyVehicleAttributes.UNKNOWN; } return HeavyVehicleAttributes.getFromString(vehicleTypeIn.toString()); } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertVehicleType() throws IncompatibleParameterException { int type = handler.convertVehicleType(APIEnums.VehicleType.HGV, 2); Assert.assertEquals(2, type); } @Test(expected = IncompatibleParameterException.class) public void convertVehicleTypeError() throws IncompatibleParameterException { handler.convertVehicleType(APIEnums.VehicleType.HGV, 1); }
GenericHandler { protected BordersExtractor.Avoid convertAvoidBorders(APIEnums.AvoidBorders avoidBorders) { if (avoidBorders != null) { switch (avoidBorders) { case ALL: return BordersExtractor.Avoid.ALL; case CONTROLLED: return BordersExtractor.Avoid.CONTROLLED; default: return BordersExtractor.Avoid.NONE; } } return null; } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertAvoidBorders() { BordersExtractor.Avoid avoid = handler.convertAvoidBorders(APIEnums.AvoidBorders.CONTROLLED); Assert.assertEquals(BordersExtractor.Avoid.CONTROLLED, avoid); avoid = handler.convertAvoidBorders(APIEnums.AvoidBorders.ALL); Assert.assertEquals(BordersExtractor.Avoid.ALL, avoid); avoid = handler.convertAvoidBorders(APIEnums.AvoidBorders.NONE); Assert.assertEquals(BordersExtractor.Avoid.NONE, avoid); }
GenericHandler { protected int convertRouteProfileType(APIEnums.Profile profile) { return RoutingProfileType.getFromString(profile.toString()); } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertRouteProfileType() { int type = handler.convertRouteProfileType(APIEnums.Profile.DRIVING_CAR); Assert.assertEquals(1, type); type = handler.convertRouteProfileType(APIEnums.Profile.FOOT_WALKING); Assert.assertEquals(20, type); }
GenericHandler { protected Polygon[] convertAvoidAreas(JSONObject geoJson, int profileType) throws StatusCodeException { org.json.JSONObject complexJson = new org.json.JSONObject(); complexJson.put("type", geoJson.get("type")); List<List<Double[]>> coordinates = (List<List<Double[]>>) geoJson.get("coordinates"); complexJson.put("coordinates", coordinates); Geometry convertedGeom; try { convertedGeom = GeometryJSON.parse(complexJson); } catch (Exception e) { throw new ParameterValueException(getInvalidParameterValueErrorCode(), "avoid_polygons"); } Polygon[] avoidAreas; if (convertedGeom instanceof Polygon) { avoidAreas = new Polygon[]{(Polygon) convertedGeom}; } else if (convertedGeom instanceof MultiPolygon) { MultiPolygon multiPoly = (MultiPolygon) convertedGeom; avoidAreas = new Polygon[multiPoly.getNumGeometries()]; for (int i = 0; i < multiPoly.getNumGeometries(); i++) avoidAreas[i] = (Polygon) multiPoly.getGeometryN(i); } else { throw new ParameterValueException(getInvalidParameterValueErrorCode(), "avoid_polygons"); } return avoidAreas; } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertAvoidAreas() throws StatusCodeException { JSONObject geomJSON = new JSONObject(); geomJSON.put("type", "Polygon"); JSONArray poly = generateGeoJSONPolyCoords(); JSONArray coords = new JSONArray(); coords.add(0, poly); geomJSON.put("coordinates", coords); Polygon[] avoidAreas = handler.convertAvoidAreas(geomJSON, 1); Assert.assertEquals(1, avoidAreas.length); Assert.assertEquals(4, avoidAreas[0].getCoordinates().length); Assert.assertEquals(1, avoidAreas[0].getCoordinates()[0].x, 0.0); JSONObject geomJSONMulti = new JSONObject(); geomJSONMulti.put("type", "MultiPolygon"); JSONArray polys1 = new JSONArray(); polys1.add(0, poly); JSONArray polys2 = new JSONArray(); polys2.add(0, poly); coords = new JSONArray(); coords.add(0,polys1); coords.add(0,polys2); geomJSONMulti.put("coordinates", coords); avoidAreas = handler.convertAvoidAreas(geomJSONMulti, 1); Assert.assertEquals(2, avoidAreas.length); } @Test(expected = ParameterValueException.class) public void convertAvoidAreasInvalidType() throws StatusCodeException { JSONObject geomJSON = new JSONObject(); geomJSON.put("type", "LineString"); JSONArray poly = generateGeoJSONPolyCoords(); geomJSON.put("coordinates", poly); handler.convertAvoidAreas(geomJSON, 1); } @Test(expected = ParameterValueException.class) public void convertAvoidAreasInvalidFeature() throws StatusCodeException { JSONObject geomJSON = new JSONObject(); geomJSON.put("type", "Polygon"); JSONArray poly = generateGeoJSONPolyCoords(); geomJSON.put("coooooooooooordinates", poly); handler.convertAvoidAreas(geomJSON, 1); }
GenericHandler { protected int convertFeatureTypes(APIEnums.AvoidFeatures[] avoidFeatures, int profileType) throws UnknownParameterValueException, IncompatibleParameterException { int flags = 0; for (APIEnums.AvoidFeatures avoid : avoidFeatures) { String avoidFeatureName = avoid.toString(); int flag = AvoidFeatureFlags.getFromString(avoidFeatureName); if (flag == 0) throw new UnknownParameterValueException(getInvalidParameterValueErrorCode(), "avoid_features", avoidFeatureName); if (!AvoidFeatureFlags.isValid(profileType, flag)) throw new IncompatibleParameterException(getInvalidParameterValueErrorCode(), "avoid_features", avoidFeatureName, KEY_PROFILE, RoutingProfileType.getName(profileType)); flags |= flag; } return flags; } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertFeatureTypes() throws UnknownParameterValueException, IncompatibleParameterException { APIEnums.AvoidFeatures[] avoids = new APIEnums.AvoidFeatures[] { APIEnums.AvoidFeatures.FERRIES, APIEnums.AvoidFeatures.FORDS }; int converted = handler.convertFeatureTypes(avoids, 1); Assert.assertEquals(24, converted); } @Test(expected = IncompatibleParameterException.class) public void convertFeatureTypesIncompatible() throws UnknownParameterValueException, IncompatibleParameterException { APIEnums.AvoidFeatures[] avoids = new APIEnums.AvoidFeatures[] { APIEnums.AvoidFeatures.STEPS}; handler.convertFeatureTypes(avoids, 1); }
GenericHandler { protected ProfileParameters convertParameters(RouteRequestOptions options, int profileType) throws StatusCodeException { ProfileParameters params = new ProfileParameters(); if (options.getProfileParams().hasRestrictions()) { RequestProfileParamsRestrictions restrictions = options.getProfileParams().getRestrictions(); APIEnums.VehicleType vehicleType = options.getVehicleType(); validateRestrictionsForProfile(restrictions, profileType); params = convertSpecificProfileParameters(profileType, restrictions, vehicleType); } if (options.getProfileParams().hasWeightings()) { RequestProfileParamsWeightings weightings = options.getProfileParams().getWeightings(); applyWeightings(weightings, params); } return params; } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertParameters() throws StatusCodeException { RouteRequestOptions opts = new RouteRequestOptions(); RequestProfileParams params = new RequestProfileParams(); RequestProfileParamsRestrictions restrictions = new RequestProfileParamsRestrictions(); restrictions.setHeight(10.0f); params.setRestrictions(restrictions); opts.setVehicleType(APIEnums.VehicleType.HGV); opts.setProfileParams(params); ProfileParameters generatedParams = handler.convertParameters(opts, 2); Assert.assertEquals(10.0f, ((VehicleParameters)generatedParams).getHeight(), 0.0); }
OSMAttachedSidewalkProcessor { protected Side identifySidesWhereSidewalkIsPresent(ReaderWay osmWay) { boolean sidewalkOnLeftSide = false; boolean sidewalkOnRightSide = false; boolean sidewalkOnBothSides = false; if(osmWay.hasTag("sidewalk")) { String side = osmWay.getTag("sidewalk"); switch(side) { case VAL_LEFT: sidewalkOnLeftSide = true; break; case VAL_RIGHT: sidewalkOnRightSide = true; break; case "both": sidewalkOnBothSides = true; break; default: } } Set<String> sidewalkProperties = getSidewalkKeys(osmWay); for(String key : sidewalkProperties) { if(key.startsWith("sidewalk:left") || key.startsWith("footway:left")) sidewalkOnLeftSide = true; if(key.startsWith("sidewalk:right") || key.startsWith("footway:right")) sidewalkOnRightSide = true; if(key.startsWith("sidewalk:both") || key.startsWith("footway:both")) sidewalkOnBothSides = true; } if(sidewalkOnLeftSide && sidewalkOnRightSide) { sidewalkOnBothSides = true; } if(sidewalkOnBothSides) { return Side.BOTH; } if(sidewalkOnLeftSide) { return Side.LEFT; } if(sidewalkOnRightSide) { return Side.RIGHT; } return Side.NONE; } ReaderWay attachSidewalkTag(ReaderWay way, Side side); Side getPreparedSide(ReaderWay way); static final String KEY_ORS_SIDEWALK_SIDE; static final String VAL_RIGHT; static final String VAL_LEFT; }
@Test public void TestIdentificationOfSidesWithSidewalkInfo() { ReaderWay way = new ReaderWay(1); way.setTag("sidewalk:left:surface", "asphalt"); assertEquals(OSMAttachedSidewalkProcessor.Side.LEFT, processor.identifySidesWhereSidewalkIsPresent(way)); way = new ReaderWay(1); way.setTag("sidewalk", "both"); assertEquals(OSMAttachedSidewalkProcessor.Side.BOTH, processor.identifySidesWhereSidewalkIsPresent(way)); way = new ReaderWay(1); way.setTag("sidewalk", "none"); assertEquals(OSMAttachedSidewalkProcessor.Side.NONE, processor.identifySidesWhereSidewalkIsPresent(way)); way = new ReaderWay(1); way.setTag("footway:right:width", "0.5"); assertEquals(OSMAttachedSidewalkProcessor.Side.RIGHT, processor.identifySidesWhereSidewalkIsPresent(way)); }
GenericHandler { protected ProfileParameters convertSpecificProfileParameters(int profileType, RequestProfileParamsRestrictions restrictions, APIEnums.VehicleType vehicleType) { ProfileParameters params = new ProfileParameters(); if (RoutingProfileType.isHeavyVehicle(profileType)) params = convertHeavyVehicleParameters(restrictions, vehicleType); if (RoutingProfileType.isWheelchair(profileType)) params = convertWheelchairParameters(restrictions); return params; } GenericHandler(); static final String KEY_PROFILE; }
@Test public void convertSpecificProfileParameters() { RequestProfileParamsRestrictions restrictions = new RequestProfileParamsRestrictions(); restrictions.setHeight(10.0f); ProfileParameters params = handler.convertSpecificProfileParameters(2, restrictions, APIEnums.VehicleType.HGV); Assert.assertTrue(params instanceof VehicleParameters); Assert.assertEquals(10.0f, ((VehicleParameters)params).getHeight(), 0.0); }