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