@Test(expected = ServerLimitExceededException.class) public void maximumExceedingLocationsTest() throws ParameterValueException, ServerLimitExceededException { MatrixRequestHandler.convertLocations(listOfBareCoordinatesList, maximumRoutes); }
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); } }
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); } } }
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(); }
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); }
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);  }