@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); }
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); } }
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); } } }
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(); }
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); }
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);  }