method2testcases
stringlengths
118
6.63k
### Question: 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; }### Answer: @Test public void getIsochronesOptionsTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getIsochronesOptions()); }
### Question: 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; }### Answer: @Test public void setIsochronesOptionsTest() { IsochronesRequest request = new IsochronesRequest(); request.setIsochronesOptions(new RouteRequestOptions()); Assert.assertEquals(RouteRequestOptions.class, request.getIsochronesOptions().getClass()); }
### Question: 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; }### Answer: @Test public void getRangeTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getRange()); }
### Question: 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; }### Answer: @Test public void setRangeTest() { IsochronesRequest request = new IsochronesRequest(); request.setRange(new ArrayList<>()); Assert.assertNotNull(request.getRange()); }
### Question: 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; }### Answer: @Test public void setRangeTypeTest() { IsochronesRequest request = new IsochronesRequest(); request.setRangeType(IsochronesRequestEnums.RangeType.DISTANCE); Assert.assertEquals(IsochronesRequestEnums.RangeType.DISTANCE, request.getRangeType()); }
### Question: 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; }### Answer: @Test public void getIntervalTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getInterval()); }
### Question: 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; }### Answer: @Test public void setIntervalTest() { IsochronesRequest request = new IsochronesRequest(); request.setInterval(new Double("0.0")); Assert.assertEquals(new Double("0.0"), request.getInterval()); }
### Question: 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(); }### Answer: @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); }
### Question: 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(); }### Answer: @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); }
### Question: 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(); }### Answer: @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); }
### Question: 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(); }### Answer: @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); }
### Question: 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(); }### Answer: @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); }
### Question: 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(); }### Answer: @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}); }
### Question: 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(); }### Answer: @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); }
### Question: WheelchairSeparateWay extends PedestrianWay { @Override public boolean hasWayBeenFullyProcessed() { return hasBeenProcessed; } WheelchairSeparateWay(ReaderWay way); @Override boolean hasWayBeenFullyProcessed(); @Override void prepare(); }### Answer: @Test public void TestInitiallyNotProcessed() { assertFalse(way.hasWayBeenFullyProcessed()); }
### Question: 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); }### Answer: @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)); }
### Question: IsochronesRequestHandler extends GenericHandler { String[] convertAttributes(IsochronesRequestEnums.Attributes[] attributes) { return convertAPIEnumListToStrings(attributes); } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }### Answer: @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]); }
### Question: 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(); }### Answer: @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); }
### Question: 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(); }### Answer: @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()); } }
### Question: 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(); }### Answer: @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()); }
### Question: 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(); }### Answer: @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()); }
### Question: 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(); }### Answer: @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); } } }
### Question: IsochronesRequestHandler extends GenericHandler { public IsochroneMapCollection getIsoMaps() { return isoMaps; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }### Answer: @Test public void getIsoMapsTest() { IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); Assert.assertNull(isochronesRequestHandler.getIsoMaps()); }
### Question: IsochronesRequestHandler extends GenericHandler { public IsochroneRequest getIsochroneRequest() { return isochroneRequest; } IsochronesRequestHandler(); void generateIsochronesFromRequest(IsochronesRequest request); IsochroneMapCollection getIsoMaps(); IsochroneRequest getIsochroneRequest(); }### Answer: @Test public void getIsochroneRequestTest() { IsochronesRequestHandler isochronesRequestHandler = new IsochronesRequestHandler(); Assert.assertNull(isochronesRequestHandler.getIsochroneRequest()); }
### Question: 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; }### Answer: @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]); }
### Question: GenericHandler { protected String convertAPIEnum(Enum valuesIn) { return valuesIn.toString(); } GenericHandler(); static final String KEY_PROFILE; }### Answer: @Test public void convertAPIEnum() { String strVal = handler.convertAPIEnum(APIEnums.AvoidBorders.CONTROLLED); Assert.assertEquals("controlled", strVal); }
### Question: 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; }### Answer: @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)); }
### Question: 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; }### Answer: @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); }
### Question: 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; }### Answer: @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); }
### Question: GenericHandler { protected int convertRouteProfileType(APIEnums.Profile profile) { return RoutingProfileType.getFromString(profile.toString()); } GenericHandler(); static final String KEY_PROFILE; }### Answer: @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); }
### Question: 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; }### Answer: @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); }
### Question: 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; }### Answer: @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); }
### Question: 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; }### Answer: @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); }
### Question: 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; }### Answer: @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)); }
### Question: 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; }### Answer: @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); }
### Question: Contour { public void calculateContour() { handleBaseCells(); cellStorage.flush(); IntObjectMap<IntHashSet> superCells = handleSuperCells(); cellStorage.storeContourPointerMap(); if (isSupercellsEnabled()) cellStorage.storeSuperCells(superCells); cellStorage.setContourPrepared(true); cellStorage.flush(); } Contour(GraphHopperStorage ghStorage, NodeAccess nodeAccess, IsochroneNodeStorage isochroneNodeStorage, CellStorage cellStorage); static double distance(double lat1, double lat2, double lon1, double lon2); void calculateContour(); Contour setGhStorage(GraphHopperStorage ghStorage); }### Answer: @Test public void testCalculateContour() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createSimpleGraph(encodingManager); createMockStorages(graphHopperStorage); Contour contour = new Contour(graphHopperStorage, graphHopperStorage.getBaseGraph().getNodeAccess(), ins, cs); contour.calculateContour(); List<Double> coordinatesCell2 = cs.getCellContourOrder(2); assertEquals(2686, coordinatesCell2.size()); assertEquals(3.0, coordinatesCell2.get(0), 1e-10); assertEquals(1.0, coordinatesCell2.get(1), 1e-10); assertEquals(3.0, coordinatesCell2.get(2), 1e-10); assertEquals(1.003596954128078, coordinatesCell2.get(3), 1e-10); assertEquals(3.0, coordinatesCell2.get(2684), 1e-10); assertEquals(1.0, coordinatesCell2.get(2685), 1e-10); }
### Question: Contour { public static double distance(double lat1, double lat2, double lon1, double lon2) { final int R = 6371; double latDistance = Math.toRadians(lat2 - lat1); double lonDistance = Math.toRadians(lon2 - lon1); double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double distance = R * c * 1000; distance = Math.pow(distance, 2); return Math.sqrt(distance); } Contour(GraphHopperStorage ghStorage, NodeAccess nodeAccess, IsochroneNodeStorage isochroneNodeStorage, CellStorage cellStorage); static double distance(double lat1, double lat2, double lon1, double lon2); void calculateContour(); Contour setGhStorage(GraphHopperStorage ghStorage); }### Answer: @Test public void testDistance() { double distance = Contour.distance(1, 1, 1, 2); assertEquals(111177.99068882648, distance, 1e-10); double distance2 = Contour.distance(1, 1, 0.5, -0.5); assertEquals(111177.99068882648, distance2, 1e-10); }
### Question: FastIsochroneAlgorithm extends AbstractIsochroneAlgorithm { public IntObjectMap<SPTEntry> getStartCellMap() { return startCellMap; } FastIsochroneAlgorithm(Graph graph, Weighting weighting, TraversalMode tMode, CellStorage cellStorage, IsochroneNodeStorage isochroneNodeStorage, EccentricityStorage eccentricityStorage, BorderNodeDistanceStorage borderNodeDistanceStorage, EdgeFilter additionalEdgeFilter); @Override void init(int from, double isochroneLimit); @Override boolean finishedStartCellPhase(); @Override boolean finishedBorderNodePhase(); @Override boolean finishedActiveCellPhase(); Set<Integer> getFullyReachableCells(); IntObjectMap<SPTEntry> getStartCellMap(); String getName(); Map<Integer, IntObjectMap<SPTEntry>> getActiveCellMaps(); }### Answer: @Test public void testStartCell() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraphWithAdditionalEdge(encodingManager); Weighting shortestWeighting = new ShortestWeighting(carEncoder); createMockStorages(graphHopperStorage); Eccentricity ecc = new Eccentricity(graphHopperStorage, null, ins, cs); ecc.loadExisting(shortestWeighting); ecc.calcEccentricities(shortestWeighting, carEncoder); ecc.calcBorderNodeDistances(shortestWeighting, carEncoder); FastIsochroneAlgorithm fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 5.5); Set<Integer> nodeIds = new HashSet<>(); Set<Integer> expectedNodeIds = new HashSet<>(); expectedNodeIds.add(0); expectedNodeIds.add(1); expectedNodeIds.add(2); expectedNodeIds.add(3); expectedNodeIds.add(8); for (IntObjectCursor<SPTEntry> entry : fastIsochroneAlgorithm.getStartCellMap()) { nodeIds.add(entry.value.adjNode); } assertEquals(expectedNodeIds, nodeIds); assertEquals(1.0, fastIsochroneAlgorithm.getStartCellMap().get(0).weight, 1e-10); assertEquals(0.0, fastIsochroneAlgorithm.getStartCellMap().get(1).weight, 1e-10); assertEquals(1.0, fastIsochroneAlgorithm.getStartCellMap().get(2).weight, 1e-10); assertEquals(3.0, fastIsochroneAlgorithm.getStartCellMap().get(3).weight, 1e-10); assertEquals(2.0, fastIsochroneAlgorithm.getStartCellMap().get(8).weight, 1e-10); }
### Question: FastIsochroneAlgorithm extends AbstractIsochroneAlgorithm { public Set<Integer> getFullyReachableCells() { return fullyReachableCells; } FastIsochroneAlgorithm(Graph graph, Weighting weighting, TraversalMode tMode, CellStorage cellStorage, IsochroneNodeStorage isochroneNodeStorage, EccentricityStorage eccentricityStorage, BorderNodeDistanceStorage borderNodeDistanceStorage, EdgeFilter additionalEdgeFilter); @Override void init(int from, double isochroneLimit); @Override boolean finishedStartCellPhase(); @Override boolean finishedBorderNodePhase(); @Override boolean finishedActiveCellPhase(); Set<Integer> getFullyReachableCells(); IntObjectMap<SPTEntry> getStartCellMap(); String getName(); Map<Integer, IntObjectMap<SPTEntry>> getActiveCellMaps(); }### Answer: @Test public void testFullyReachableCells() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraphWithAdditionalEdge(encodingManager); Weighting shortestWeighting = new ShortestWeighting(carEncoder); createMockStorages(graphHopperStorage); Eccentricity ecc = new Eccentricity(graphHopperStorage, null, ins, cs); ecc.loadExisting(shortestWeighting); ecc.calcEccentricities(shortestWeighting, carEncoder); ecc.calcBorderNodeDistances(shortestWeighting, carEncoder); FastIsochroneAlgorithm fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 5.5); Set<Integer> cellIds = fastIsochroneAlgorithm.getFullyReachableCells(); Set<Integer> expectedCellIds = new HashSet<>(); assertEquals(expectedCellIds, cellIds); fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 6); cellIds = fastIsochroneAlgorithm.getFullyReachableCells(); expectedCellIds = new HashSet<>(); expectedCellIds.add(2); assertEquals(expectedCellIds, cellIds); fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(8, 6); cellIds = fastIsochroneAlgorithm.getFullyReachableCells(); expectedCellIds = new HashSet<>(); expectedCellIds.add(2); expectedCellIds.add(3); assertEquals(expectedCellIds, cellIds); }
### Question: ActiveCellDijkstra extends AbstractIsochroneDijkstra { protected void addInitialBordernode(int nodeId, double weight) { SPTEntry entry = new SPTEntry(nodeId, weight); fromHeap.add(entry); fromMap.put(nodeId, entry); } ActiveCellDijkstra(Graph graph, Weighting weighting, IsochroneNodeStorage isochroneNodeStorage, int cellId); void setIsochroneLimit(double limit); @Override String getName(); }### Answer: @Test public void testAddInitialBorderNode() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraph(encodingManager); createMockStorages(graphHopperStorage); Weighting shortestWeighting = new ShortestWeighting(carEncoder); ActiveCellDijkstra activeCellDijkstra = new ActiveCellDijkstra(graphHopperStorage.getBaseGraph(), shortestWeighting, ins, 2); activeCellDijkstra.setIsochroneLimit(5000); for (int nodeId : new int[]{3, 8}) { activeCellDijkstra.addInitialBordernode(nodeId, 0); } SPTEntry entry = activeCellDijkstra.fromHeap.poll(); assertEquals(3, entry.adjNode); assertEquals(0.0, entry.getWeightOfVisitedPath(), 1e-10); entry = activeCellDijkstra.fromHeap.poll(); assertEquals(8, entry.adjNode); assertEquals(0.0, entry.getWeightOfVisitedPath(), 1e-10); assertEquals(2, activeCellDijkstra.getFromMap().size()); }
### Question: RangeDijkstra extends AbstractIsochroneDijkstra { private void getMaxWeight() { for (IntObjectCursor<SPTEntry> entry : fromMap) { if (USERELEVANTONLY && !relevantNodes.contains(entry.key)) continue; if (maximumWeight < entry.value.weight) maximumWeight = entry.value.weight; } } RangeDijkstra(Graph graph, Weighting weighting); double calcMaxWeight(int from, IntHashSet relevantNodes); void setCellNodes(IntHashSet cellNodes); int getFoundCellNodeSize(); @Override String getName(); }### Answer: @Test public void testGetMaxWeight() { GraphHopperStorage graphHopperStorage = createSimpleGraph(); RangeDijkstra rangeDijkstra = new RangeDijkstra(graphHopperStorage.getBaseGraph(), new ShortestWeighting(carEncoder)); rangeDijkstra.setMaxVisitedNodes(getMaxCellNodesNumber() * 10); IntHashSet cellNodes = new IntHashSet(); IntHashSet relevantNodes = new IntHashSet(); cellNodes.addAll(0, 1, 2, 5); relevantNodes.addAll(0, 1, 2); rangeDijkstra.setCellNodes(cellNodes); assertEquals(3.0, rangeDijkstra.calcMaxWeight(0, cellNodes), 1e-10); rangeDijkstra = new RangeDijkstra(graphHopperStorage.getBaseGraph(), new ShortestWeighting(carEncoder)); rangeDijkstra.setMaxVisitedNodes(getMaxCellNodesNumber() * 10); rangeDijkstra.setCellNodes(cellNodes); assertEquals(1.0, rangeDijkstra.calcMaxWeight(0, relevantNodes), 1e-10); }
### Question: PartitioningDataBuilder { PartitioningDataBuilder(Graph graph, PartitioningData pData) { this.graph = graph; this.pData = pData; } PartitioningDataBuilder(Graph graph, PartitioningData pData); void run(); }### Answer: @Test public void testPartitioningDataBuilder() { GraphHopperStorage ghStorage = ToyGraphCreationUtil.createMediumGraph(encodingManager); PartitioningData pData = new PartitioningData(); EdgeFilter edgeFilter = new EdgeFilterSequence(); PartitioningDataBuilder partitioningDataBuilder = new PartitioningDataBuilder(ghStorage.getBaseGraph(), pData); partitioningDataBuilder.run(); assertEquals(28, pData.flowEdgeBaseNode.length); assertEquals(28, pData.flow.length); assertEquals(0, pData.flowEdgeBaseNode[0]); assertEquals(1, pData.flowEdgeBaseNode[1]); assertEquals(0, pData.flowEdgeBaseNode[2]); assertEquals(2, pData.flowEdgeBaseNode[3]); assertEquals(10, pData.visited.length); assertEquals(0, pData.visited[0]); }
### Question: OSMAttachedSidewalkProcessor { public ReaderWay attachSidewalkTag(ReaderWay way, Side side) { switch(side) { case LEFT: way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_LEFT); break; case RIGHT: way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_RIGHT); break; case BOTH: if(way.hasTag(KEY_ORS_SIDEWALK_SIDE) && way.getTag(KEY_ORS_SIDEWALK_SIDE).equalsIgnoreCase(VAL_LEFT)) { way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_RIGHT); } else { way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_LEFT); } break; case NONE: if(way.hasTag(KEY_ORS_SIDEWALK_SIDE)) { way.removeTag(KEY_ORS_SIDEWALK_SIDE); } } return way; } 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; }### Answer: @Test public void TestAttachingORSSidewalkSideTagForWayWithSingleSide() { ReaderWay way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.LEFT); assertTrue(way.hasTag("ors-sidewalk-side")); String side = way.getTag("ors-sidewalk-side"); assertEquals("left", side); way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.RIGHT); assertTrue(way.hasTag("ors-sidewalk-side")); side = way.getTag("ors-sidewalk-side"); assertEquals("right", side); } @Test public void TestAttchingNoSidewalkRemovesAnyAlreadyAttachedORSSidewalkTags() { ReaderWay way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.NONE); assertFalse(way.hasTag("ors-sidewalk-side")); way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.LEFT); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.NONE); assertFalse(way.hasTag("ors-sidewalk-side")); } @Test public void TestAttachingORSSidealkTagsWhenBothSidesHaveValues() { ReaderWay way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.BOTH); assertTrue(way.hasTag("ors-sidewalk-side")); String side = way.getTag("ors-sidewalk-side"); assertEquals("left", side); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.BOTH); assertTrue(way.hasTag("ors-sidewalk-side")); side = way.getTag("ors-sidewalk-side"); assertEquals("right", side); }
### Question: Projector { protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; } Projector(); void setGHStorage(GraphHopperStorage ghStorage); }### Answer: @Test public void testCalculateProjections() { Projector projector = new Projector(); projector.setGHStorage(ToyGraphCreationUtil.createMediumGraph2(encodingManager)); Map<Projector.Projection, IntArrayList> projections = projector.calculateProjections(); IntArrayList expected_m00 = new IntArrayList(); expected_m00.add(1, 2, 3, 0, 8, 4, 6, 5, 7); assertEquals(expected_m00, projections.get(Projector.Projection.LINE_M00)); IntArrayList expected_p90 = new IntArrayList(); expected_p90.add(1, 8, 0, 2, 6, 7, 3, 4, 5); assertEquals(expected_p90, projections.get(Projector.Projection.LINE_P90)); IntArrayList expected_p45 = new IntArrayList(); expected_p45.add(1, 2, 8, 0, 3, 6, 4, 7, 5); assertEquals(expected_p45, projections.get(Projector.Projection.LINE_P45)); }
### Question: Projector { protected List<Projection> calculateProjectionOrder(Map<Projection, IntArrayList> projections) { List<Projection> order; EnumMap<Projection, Double> squareRangeProjMap = new EnumMap<>(Projection.class); EnumMap<Projection, Double> orthogonalDiffProjMap = new EnumMap<>(Projection.class); for (Map.Entry<Projection, IntArrayList> proj : projections.entrySet()) { int idx = (int) (proj.getValue().size() * getSplitValue()); squareRangeProjMap.put(proj.getKey(), projIndividualValue(projections, proj.getKey(), idx)); } for (Projection proj : projections.keySet()) { orthogonalDiffProjMap.put(proj, projCombinedValue(squareRangeProjMap, proj)); } Sort sort = new Sort(); order = sort.sortByValueReturnList(orthogonalDiffProjMap, false); return order; } Projector(); void setGHStorage(GraphHopperStorage ghStorage); }### Answer: @Test public void testCalculateProjectionOrder() { double originalSplitValue = getSplitValue(); setSplitValue(0); Projector projector = new Projector(); projector.setGHStorage(ToyGraphCreationUtil.createMediumGraph2(encodingManager)); Map<Projector.Projection, IntArrayList> projections = projector.calculateProjections(); List<Projector.Projection> projectionOrder = projector.calculateProjectionOrder(projections); assertEquals(Projector.Projection.LINE_P675, projectionOrder.get(0)); assertEquals(Projector.Projection.LINE_P45, projectionOrder.get(1)); assertEquals(Projector.Projection.LINE_M225, projectionOrder.get(7)); setSplitValue(originalSplitValue); }
### Question: MaxFlowMinCut { protected void reset() { resetAlgorithm(); resetData(); } MaxFlowMinCut(Graph graph, PartitioningData pData, EdgeFilter edgeFilter); void setVisited(int node); boolean isVisited(int visited); void setUnvisitedAll(); abstract int getMaxFlow(); BiPartition calcNodePartition(); void setNodeOrder(); void setOrderedNodes(IntArrayList orderedNodes); void setAdditionalEdgeFilter(EdgeFilter edgeFilter); }### Answer: @Test public void testReset() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraph(encodingManager); Graph graph = graphHopperStorage.getBaseGraph(); int[] flowEdgeBaseNode = new int[]{ 0, 1, 0, 2, 0, 3, 0, 8, 1, 2, 1, 8, 2, 3, 3, 4, 4, 5, 4, 6, 5, 7, 6, 7, 7, 8, -1, -1 }; boolean[] flow = new boolean[]{ false, true, false, true, false, true, false, false, true, false, true, false, true, false, false, true, false, true, false, true, false, false, true, false, true, false, false, false }; int[] visited = new int[]{ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 }; PartitioningData pData = new PartitioningData(flowEdgeBaseNode, flow, visited); IntArrayList projection_m00 = new IntArrayList(); projection_m00.add(1, 2, 3, 0, 4, 6, 8, 5, 7); MaxFlowMinCut maxFlowMinCut = new EdmondsKarpAStar(graph, pData, null); maxFlowMinCut.setOrderedNodes(projection_m00); maxFlowMinCut.setNodeOrder(); maxFlowMinCut.reset(); for (boolean f : pData.flow) assertEquals(false, f); for (int v : pData.visited) assertEquals(0, v); }
### Question: FastIsochroneFactory { public void init(CmdArgs args) { setMaxThreadCount(args.getInt(FastIsochrone.PREPARE + "threads", getMaxThreadCount())); setMaxCellNodesNumber(args.getInt(FastIsochrone.PREPARE + "maxcellnodes", getMaxCellNodesNumber())); String weightingsStr = args.get(FastIsochrone.PREPARE + "weightings", ""); if ("no".equals(weightingsStr)) { fastisochroneProfileStrings.clear(); } else if (!weightingsStr.isEmpty()) { setFastIsochroneProfilesAsStrings(Arrays.asList(weightingsStr.split(","))); } boolean enableThis = !fastisochroneProfileStrings.isEmpty(); setEnabled(enableThis); if (enableThis) { setDisablingAllowed(args.getBool(FastIsochrone.INIT_DISABLING_ALLOWED, isDisablingAllowed())); IsochronesServiceSettings.setFastIsochronesActive(args.get(FastIsochrone.PROFILE, "")); } } void init(CmdArgs args); FastIsochroneFactory setFastIsochroneProfilesAsStrings(List<String> profileStrings); Set<String> getFastisochroneProfileStrings(); FastIsochroneFactory addFastIsochroneProfileAsString(String profileString); final boolean isEnabled(); final FastIsochroneFactory setEnabled(boolean enabled); final boolean isDisablingAllowed(); final FastIsochroneFactory setDisablingAllowed(boolean disablingAllowed); FastIsochroneFactory setPartition(PreparePartition pp); PreparePartition getPartition(); void prepare(final StorableProperties properties); void createPreparation(GraphHopperStorage ghStorage, EdgeFilterSequence edgeFilters); void setExistingStorages(); IsochroneNodeStorage getIsochroneNodeStorage(); void setIsochroneNodeStorage(IsochroneNodeStorage isochroneNodeStorage); CellStorage getCellStorage(); void setCellStorage(CellStorage cellStorage); }### Answer: @Test public void testInit() { FastIsochroneFactory fastIsochroneFactory = intitFastIsochroneFactory(); assertTrue(fastIsochroneFactory.isEnabled()); assertTrue(fastIsochroneFactory.isDisablingAllowed()); assertEquals("fastest", fastIsochroneFactory.getFastisochroneProfileStrings().iterator().next()); }
### Question: FastIsochroneFactory { public void prepare(final StorableProperties properties) { ExecutorService threadPool = Executors.newFixedThreadPool(1); ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(threadPool); final String name = "PreparePartition"; completionService.submit(() -> { Thread.currentThread().setName(name); getPartition().prepare(); setIsochroneNodeStorage(getPartition().getIsochroneNodeStorage()); setCellStorage(getPartition().getCellStorage()); properties.put(FastIsochrone.PREPARE + "date." + name, Helper.createFormatter().format(new Date())); }, name); threadPool.shutdown(); try { completionService.take().get(); } catch (Exception e) { threadPool.shutdownNow(); throw new IllegalStateException(e); } } void init(CmdArgs args); FastIsochroneFactory setFastIsochroneProfilesAsStrings(List<String> profileStrings); Set<String> getFastisochroneProfileStrings(); FastIsochroneFactory addFastIsochroneProfileAsString(String profileString); final boolean isEnabled(); final FastIsochroneFactory setEnabled(boolean enabled); final boolean isDisablingAllowed(); final FastIsochroneFactory setDisablingAllowed(boolean disablingAllowed); FastIsochroneFactory setPartition(PreparePartition pp); PreparePartition getPartition(); void prepare(final StorableProperties properties); void createPreparation(GraphHopperStorage ghStorage, EdgeFilterSequence edgeFilters); void setExistingStorages(); IsochroneNodeStorage getIsochroneNodeStorage(); void setIsochroneNodeStorage(IsochroneNodeStorage isochroneNodeStorage); CellStorage getCellStorage(); void setCellStorage(CellStorage cellStorage); }### Answer: @Test public void testPrepare() { GraphHopperStorage gs = ToyGraphCreationUtil.createMediumGraph(encodingManager); FastIsochroneFactory fastIsochroneFactory = intitFastIsochroneFactory(); fastIsochroneFactory.createPreparation(gs, null); fastIsochroneFactory.prepare(gs.getProperties()); assertNotNull(fastIsochroneFactory.getCellStorage()); assertNotNull(fastIsochroneFactory.getIsochroneNodeStorage()); }
### Question: GeoJsonResponseWriter { public static JSONObject addProperties(SimpleFeature simpleFeature, Map<String, Map<String, Object>> featurePropertiesMap) throws IOException { StringWriter stringWriter = new StringWriter(); fjson.writeFeature(simpleFeature, stringWriter); JSONObject featureAsJSON = new JSONObject(stringWriter.toString()); stringWriter.close(); return featureProperties(featureAsJSON, featurePropertiesMap); } static JSONObject toGeoJson(RoutingRequest rreq, RouteResult[] routeResult); JSONObject toGeoJson(IsochroneRequest rreq, RouteResult[] routeResults); static JSONObject addProperties(SimpleFeature simpleFeature, Map<String, Map<String, Object>> featurePropertiesMap); static JSONObject addProperties(DefaultFeatureCollection defaultFeatureCollection, Map<String, Map<String, Object>> featurePropertiesMap, Map<String, Object> defaultFeatureCollectionProperties); static final String KEY_ROUTES; static final String KEY_FEATURES; static final String KEY_PROPERTIES; }### Answer: @Test public void testAddProperties() throws Exception { JSONObject expectedJSON = new JSONObject("{\"geometry\":{\"coordinates\":[[1,1],[1,1],[1,1]],\"type\":\"LineString\"},\"id\":\"" + routingFeatureID + "\",\"type\":\"Feature\",\"properties\":{\"bbox\":[1,1,1,1],\"way_points\":[1,1],\"segments\":[1]}}"); JSONObject resultJSON = GeoJsonResponseWriter.addProperties(routingFeature, featurePropertiesMap); JSONAssert.assertEquals(expectedJSON, resultJSON, JSONCompareMode.NON_EXTENSIBLE); } @Test public void testAddProperties1() throws Exception { JSONObject expectedJSON = new JSONObject("{\"features\":[{\"geometry\":{\"coordinates\":[[1,1],[1,1],[1,1]],\"type\":\"LineString\"},\"id\":\"" + routingFeatureID + "\",\"type\":\"Feature\",\"properties\":{\"bbox\":[1,1,1,1],\"way_points\":[1,1],\"segments\":[1]}}],\"bbox\":[1,1,1,1],\"type\":\"FeatureCollection\",\"info\":[1]}"); JSONObject resultJSON = GeoJsonResponseWriter.addProperties(defaultFeatureCollection, featurePropertiesMap, defaultFeatureCollectionProperties); JSONAssert.assertEquals(expectedJSON, resultJSON, JSONCompareMode.NON_EXTENSIBLE); }
### Question: CountryBordersPolygon { public String getName() { return this.name; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); }### Answer: @Test public void TestName() { assertEquals("name", cbp.getName()); }
### Question: CountryBordersPolygon { public MultiPolygon getBoundary() { return this.boundary; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); }### Answer: @Test public void TestBoundaryGeometry() { MultiPolygon boundary = cbp.getBoundary(); Coordinate[] cbpCoords = boundary.getCoordinates(); assertEquals(country1Geom.length, cbpCoords.length); assertEquals(country1Geom[0].x, cbpCoords[0].x, 0.0); assertEquals(country1Geom[3].y, cbpCoords[3].y,0.0); }
### Question: CountryBordersPolygon { public double[] getBBox() { return new double[] {minLon, maxLon, minLat, maxLat}; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); }### Answer: @Test public void TestBBox() { double[] bbox = cbp.getBBox(); assertEquals(-1.0, bbox[0], 0.0); assertEquals(1.0, bbox[1], 0.0); assertEquals(-1.0, bbox[2], 0.0); assertEquals(2.0, bbox[3], 0.0); }
### Question: CountryBordersPolygon { public boolean crossesBoundary(LineString line) { return this.boundaryLine.intersects(line); } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); }### Answer: @Test public void TestIntersection() { LineString ls = gf.createLineString(new Coordinate[] { new Coordinate(0.5, 0.5), new Coordinate(-10.5, -10.5) }); assertTrue(cbp.crossesBoundary(ls)); ls = gf.createLineString(new Coordinate[] { new Coordinate(0.5, 0.5), new Coordinate(0.25, 0.25) }); assertFalse(cbp.crossesBoundary(ls)); }
### Question: CountryBordersPolygon { public boolean inBbox(Coordinate c) { return !(c.x < minLon || c.x > maxLon || c.y < minLat || c.y > maxLat); } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); }### Answer: @Test public void TestBBoxContains() { assertTrue(cbp.inBbox(new Coordinate(0.5, 0.5))); assertFalse(cbp.inBbox(new Coordinate(10.0, 0.5))); }
### Question: BordersExtractor { public boolean isOpenBorder(int edgeId) { return storage.getEdgeValue(edgeId, BordersGraphStorage.Property.TYPE) == BordersGraphStorage.OPEN_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); }### Answer: @Test public void TestDetectOpenBorder() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[0]); assertEquals(false, be.isOpenBorder(1)); assertEquals(true, be.isOpenBorder(2)); assertEquals(false, be.isOpenBorder(3)); }
### Question: CountryBordersPolygon { public boolean inArea(Coordinate c) { if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { GeometryFactory gf = new GeometryFactory(); return boundary.contains(gf.createPoint(c)); } return false; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); }### Answer: @Test public void TestPolygonContains() { assertTrue(cbp.inArea(new Coordinate(0.5, 0.5))); assertFalse(cbp.inArea(new Coordinate(-0.5, -0.5))); }
### Question: CountryBordersReader { public CountryBordersPolygon[] getCountry(Coordinate c) { ArrayList<CountryBordersPolygon> countries = new ArrayList<>(); Iterator it = hierarchies.entrySet().iterator(); while(it.hasNext()) { Map.Entry<Long, CountryBordersHierarchy> pair = (Map.Entry)it.next(); CountryBordersHierarchy h = pair.getValue(); if(h.inBbox(c)) { List<CountryBordersPolygon> ps = h.getPolygons(); for(CountryBordersPolygon cp : ps) { if(cp.inBbox(c) && cp.inArea(c)) { countries.add(cp); } } } } return countries.toArray(new CountryBordersPolygon[countries.size()]); } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; }### Answer: @Test public void TestGetCountry() { Coordinate c = new Coordinate(0.5, 0.5); CountryBordersPolygon[] polys = _reader.getCountry(c); assertEquals(1, polys.length); assertEquals("country1", polys[0].getName()); }
### Question: CountryBordersReader { public CountryBordersPolygon[] getCandidateCountry(Coordinate c) { ArrayList<CountryBordersPolygon> countries = new ArrayList<>(); Iterator it = hierarchies.entrySet().iterator(); while(it.hasNext()) { Map.Entry<Long, CountryBordersHierarchy> pair = (Map.Entry)it.next(); CountryBordersHierarchy h = pair.getValue(); if(h.inBbox(c)) { List<CountryBordersPolygon> ps = h.getPolygons(); for(CountryBordersPolygon cp : ps) { if(cp.inBbox(c)) { countries.add(cp); } } } } return countries.toArray(new CountryBordersPolygon[countries.size()]); } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; }### Answer: @Test public void TestGetCandidateCountry() { Coordinate c = new Coordinate(-0.25, -0.25); CountryBordersPolygon[] polys = _reader.getCandidateCountry(c); assertEquals(1, polys.length); assertEquals("country3", polys[0].getName()); }
### Question: CountryBordersReader { public String getId(String name) { if(name.equals(INTERNATIONAL_NAME)) return INTERNATIONAL_ID; if(ids.containsKey(name)) return ids.get(name).id; else return ""; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; }### Answer: @Test public void TestGetCountryId() { assertEquals("1", _reader.getId("country1")); }
### Question: CountryBordersReader { public String getEngName(String name) { if(name.equals(INTERNATIONAL_NAME)) return INTERNATIONAL_NAME; if(ids.containsKey(name)) return ids.get(name).nameEng; else return ""; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; }### Answer: @Test public void TestGetCountryEnglishName() { assertEquals("country1 English", _reader.getEngName("country1")); }
### Question: CountryBordersReader { public boolean isOpen(String c1, String c2) { if(openBorders.containsKey(c1)) { return openBorders.get(c1).contains(c2); } else if(openBorders.containsKey(c2)) return openBorders.get(c2).contains(c1); return false; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; }### Answer: @Test public void TestGetOpenBorder() { assertTrue(_reader.isOpen("country1", "country2")); assertFalse(_reader.isOpen("country1", "country3")); }
### Question: CountryBordersReader { public static int getCountryIdByISOCode(String code) { return currentInstance != null ? currentInstance.isoCodes.getOrDefault(code.toUpperCase(), 0) : 0; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; }### Answer: @Test public void TestGetCountryIdByISOCode() { assertEquals(1, CountryBordersReader.getCountryIdByISOCode("CT")); assertEquals(1, CountryBordersReader.getCountryIdByISOCode("CTR")); assertEquals(0, CountryBordersReader.getCountryIdByISOCode("FOO")); }
### Question: CountryBordersHierarchy { public double[] getBBox() { return new double[] {minLon, maxLon, minLat, maxLat}; } void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); }### Answer: @Test public void GetBBoxTest() { double[] bbox = cbh1.getBBox(); assertEquals(-1.0, bbox[0], 0.0); assertEquals(1.0, bbox[1], 0.0); assertEquals(-1.0, bbox[2], 0.0); assertEquals(1.0, bbox[3], 0.0); bbox = cbh2.getBBox(); assertEquals(5.0, bbox[0], 0.0); assertEquals(10.0, bbox[1], 0.0); assertEquals(5.0, bbox[2], 0.0); assertEquals(10.0, bbox[3], 0.0); }
### Question: CountryBordersHierarchy { public boolean inBbox(Coordinate c) { return !(c.x <= minLon || c.x >= maxLon || c.y <= minLat || c.y >= maxLat); } void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); }### Answer: @Test public void InBBoxTest() { assertTrue(cbh1.inBbox(new Coordinate(0.5, 0.5))); assertTrue(cbh1.inBbox(new Coordinate(-0.5, 0.5))); assertFalse(cbh1.inBbox(new Coordinate(7.5, 7.5))); assertFalse(cbh1.inBbox(new Coordinate(100, 100))); }
### Question: CountryBordersHierarchy { public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; } void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); }### Answer: @Test public void GetCountryTest() { List<CountryBordersPolygon> containing = cbh1.getContainingPolygons(new Coordinate(0.9, 0.9)); assertEquals(1, containing.size()); assertEquals("name1", containing.get(0).getName()); containing = cbh1.getContainingPolygons(new Coordinate(0.0, 0.0)); assertEquals(2, containing.size()); containing = cbh1.getContainingPolygons(new Coordinate(10, 10)); assertEquals(0, containing.size()); }
### Question: BordersExtractor { public boolean restrictedCountry(int edgeId) { int startCountry = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.START); int endCountry = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.END); for(int i = 0; i< avoidCountries.length; i++) { if(startCountry == avoidCountries[i] || endCountry == avoidCountries[i] ) { return true; } } return false; } 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); }### Answer: @Test public void TestAvoidCountry() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[] {2, 4}); assertEquals(true, be.restrictedCountry(1)); assertEquals(true, be.restrictedCountry(2)); assertEquals(false, be.restrictedCountry(3)); }
### Question: RouteSearchParameters { public int getProfileType() { return profileType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getProfileType() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(0, routeSearchParameters.getProfileType()); }
### Question: RouteSearchParameters { public void setProfileType(int profileType) throws Exception { if (profileType == RoutingProfileType.UNKNOWN) throw new Exception("Routing profile is unknown."); this.profileType = profileType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setProfileType() throws Exception { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setProfileType(2); Assert.assertEquals(2, routeSearchParameters.getProfileType()); }
### Question: RouteSearchParameters { public int getWeightingMethod() { return weightingMethod; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getWeightingMethod() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(WeightingMethod.FASTEST, routeSearchParameters.getWeightingMethod(), 0.0); }
### Question: RouteSearchParameters { public void setWeightingMethod(int weightingMethod) { this.weightingMethod = weightingMethod; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setWeightingMethod() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setWeightingMethod(WeightingMethod.RECOMMENDED); Assert.assertEquals(WeightingMethod.RECOMMENDED, routeSearchParameters.getWeightingMethod(), 0.0); }
### Question: RouteSearchParameters { public Polygon[] getAvoidAreas() { return avoidAreas; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getAvoidAreas() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertArrayEquals(null, routeSearchParameters.getAvoidAreas()); }
### Question: RouteSearchParameters { public void setAvoidAreas(Polygon[] avoidAreas) { this.avoidAreas = avoidAreas; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setAvoidAreas() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidAreas(new Polygon[0]); Assert.assertArrayEquals(new Polygon[0], routeSearchParameters.getAvoidAreas()); }
### Question: RouteSearchParameters { public boolean hasAvoidAreas() { return avoidAreas != null && avoidAreas.length > 0; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void hasAvoidAreas() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidAreas()); routeSearchParameters.setAvoidAreas(new Polygon[1]); Assert.assertTrue(routeSearchParameters.hasAvoidAreas()); }
### Question: RouteSearchParameters { public int getAvoidFeatureTypes() { return avoidFeaturesTypes; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getAvoidFeatureTypes() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(0, routeSearchParameters.getAvoidFeatureTypes()); }
### Question: RouteSearchParameters { public void setAvoidFeatureTypes(int avoidFeatures) { avoidFeaturesTypes = avoidFeatures; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setAvoidFeatureTypes() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidFeatureTypes(1); Assert.assertEquals(1, routeSearchParameters.getAvoidFeatureTypes()); }
### Question: BordersExtractor { public boolean isSameCountry(List<Integer> edgeIds){ if(edgeIds.isEmpty()) return true; short country0 = storage.getEdgeValue(edgeIds.get(0), BordersGraphStorage.Property.START); short country1 = storage.getEdgeValue(edgeIds.get(0), BordersGraphStorage.Property.END); for(int edgeId : edgeIds) { short country2 = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.START); short country3 = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.END); if(country0 != country2 && country0 != country3 && country1 != country2 && country1 != country3) return false; } return true; } 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); }### Answer: @Test public void TestIsSameCountry() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[] {2, 4}); List<Integer> countries = new ArrayList<>(); countries.add(1); countries.add(2); assertFalse(be.isSameCountry(countries)); countries = new ArrayList<>(); countries.add(3); countries.add(4); assertTrue(be.isSameCountry(countries)); countries = new ArrayList<>(); countries.add(4); countries.add(5); assertFalse(be.isSameCountry(countries)); countries = new ArrayList<>(); countries.add(5); countries.add(6); assertTrue(be.isSameCountry(countries)); }
### Question: RouteSearchParameters { public boolean hasAvoidFeatures() { return avoidFeaturesTypes > 0; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void hasAvoidFeatures() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidFeatures()); routeSearchParameters.setAvoidFeatureTypes(1); Assert.assertTrue(routeSearchParameters.hasAvoidFeatures()); }
### Question: RouteSearchParameters { public int[] getAvoidCountries() { return avoidCountries; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getAvoidCountries() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getAvoidCountries()); }
### Question: RouteSearchParameters { public void setAvoidCountries(int[] avoidCountries) { this.avoidCountries = avoidCountries; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setAvoidCountries() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidCountries(new int[1]); Assert.assertArrayEquals(new int[1], routeSearchParameters.getAvoidCountries()); }
### Question: RouteSearchParameters { public boolean hasAvoidCountries() { return avoidCountries != null && avoidCountries.length > 0; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void hasAvoidCountries() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidCountries()); routeSearchParameters.setAvoidCountries(new int[1]); Assert.assertTrue(routeSearchParameters.hasAvoidCountries()); }
### Question: RouteSearchParameters { public boolean hasAvoidBorders() { return avoidBorders != BordersExtractor.Avoid.NONE; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void hasAvoidBorders() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidBorders()); routeSearchParameters.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); Assert.assertTrue(routeSearchParameters.hasAvoidBorders()); }
### Question: RouteSearchParameters { public void setAvoidBorders(BordersExtractor.Avoid avoidBorders) { this.avoidBorders = avoidBorders; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setAvoidBorders() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); Assert.assertEquals(BordersExtractor.Avoid.CONTROLLED, routeSearchParameters.getAvoidBorders()); }
### Question: RouteSearchParameters { public BordersExtractor.Avoid getAvoidBorders() { return avoidBorders; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getAvoidBorders() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(BordersExtractor.Avoid.NONE, routeSearchParameters.getAvoidBorders()); }
### Question: RouteSearchParameters { public Boolean getConsiderTurnRestrictions() { return considerTurnRestrictions; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getConsiderTurnRestrictions() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.getConsiderTurnRestrictions()); }
### Question: RouteSearchParameters { public void setConsiderTurnRestrictions(Boolean considerTurnRestrictions) { this.considerTurnRestrictions = considerTurnRestrictions; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setConsiderTurnRestrictions() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setConsiderTurnRestrictions(true); Assert.assertTrue(routeSearchParameters.getConsiderTurnRestrictions()); }
### Question: RouteSearchParameters { public int getVehicleType() { return vehicleType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getVehicleType() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(HeavyVehicleAttributes.UNKNOWN, routeSearchParameters.getVehicleType()); }
### Question: EncodeUtils { public static byte[] longToByteArray(long longValue) { ByteBuffer longToByteBuffer = ByteBuffer.allocate(Long.BYTES); longToByteBuffer.putLong(longValue); return longToByteBuffer.array(); } private EncodeUtils(); static byte[] longToByteArray(long longValue); static long byteArrayToLong(byte[] byteArray); }### Answer: @Test public void longToByteArrayTest() { long value = 1234L; byte[] byteValue = EncodeUtils.longToByteArray(value); assertEquals(8, byteValue.length); assertEquals(-46, byteValue[7]); assertEquals(4, byteValue[6]); }
### Question: RouteSearchParameters { public void setVehicleType(int vehicleType) { this.vehicleType = vehicleType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setVehicleType() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setVehicleType(HeavyVehicleAttributes.AGRICULTURE); Assert.assertEquals(HeavyVehicleAttributes.AGRICULTURE, routeSearchParameters.getVehicleType()); }
### Question: RouteSearchParameters { public String getOptions() { return options; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getOptions() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getOptions()); }
### Question: RouteSearchParameters { public boolean hasParameters(Class<?> value) { if (profileParams == null) return false; return profileParams.getClass() == value; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void hasParameters() throws Exception { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasParameters(routeSearchParameters.getClass())); routeSearchParameters.setProfileType(2); routeSearchParameters.setOptions("{\"profile_params\":{\"weightings\":{\"green\":{\"factor\":0.8}}}}"); Assert.assertTrue(routeSearchParameters.hasParameters(VehicleParameters.class)); }
### Question: RouteSearchParameters { public ProfileParameters getProfileParameters() { return profileParams; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getProfileParameters() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getProfileParameters()); }
### Question: RouteSearchParameters { public boolean getFlexibleMode() { return flexibleMode; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getFlexibleMode() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.getFlexibleMode()); }
### Question: RouteSearchParameters { public void setFlexibleMode(boolean flexibleMode) { this.flexibleMode = flexibleMode; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setFlexibleMode() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setFlexibleMode(true); Assert.assertTrue(routeSearchParameters.getFlexibleMode()); }
### Question: RouteSearchParameters { public double[] getMaximumRadiuses() { return maxRadiuses; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getMaximumRadiuses() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getMaximumRadiuses()); }
### Question: RouteSearchParameters { public void setMaximumRadiuses(double[] maxRadiuses) { this.maxRadiuses = maxRadiuses; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setMaximumRadiuses() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setMaximumRadiuses(new double[0]); Assert.assertNotNull(routeSearchParameters.getMaximumRadiuses()); Assert.assertSame(routeSearchParameters.getMaximumRadiuses().getClass(), double[].class); Assert.assertEquals(0, routeSearchParameters.getMaximumRadiuses().length); }
### Question: RouteSearchParameters { public WayPointBearing[] getBearings() { return bearings; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void getBearings() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getBearings()); }
### Question: RouteSearchParameters { public void setBearings(WayPointBearing[] bearings) { this.bearings = bearings; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; }### Answer: @Test public void setBearings() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setBearings(new WayPointBearing[]{}); Assert.assertArrayEquals(new WayPointBearing[]{}, routeSearchParameters.getBearings()); }
### Question: EncodeUtils { public static long byteArrayToLong(byte[] byteArray) { ByteBuffer byteToLongBuffer = ByteBuffer.allocate(Long.BYTES); byte[] storageBytes = {0,0,0,0,0,0,0,0}; int differenceInSize = storageBytes.length - byteArray.length; for(int i = byteArray.length-1; i >= 0; i--) { if(differenceInSize + i >= 0) storageBytes[differenceInSize + i] = byteArray[i]; } byteToLongBuffer.put(storageBytes); byteToLongBuffer.flip(); return byteToLongBuffer.getLong(); } private EncodeUtils(); static byte[] longToByteArray(long longValue); static long byteArrayToLong(byte[] byteArray); }### Answer: @Test public void byteArrayToLongTest() { byte[] byteArr = {0,0,0,0,73,-106,2,-46}; long value = EncodeUtils.byteArrayToLong(byteArr); assertEquals(1234567890, value); byte[] byteArr2 = {-24,106,4,-97}; long value2 = EncodeUtils.byteArrayToLong(byteArr2); assertEquals(3899262111L, value2); byte[] byteArr3 = {124,0,0,12,-45,76,-8,-96,1}; long value3 = EncodeUtils.byteArrayToLong(byteArr3); assertEquals(14101668995073L, value3); }
### Question: GeomUtility { public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } } private GeomUtility(); static LineString createLinestring(Coordinate[] coords); static BBox calculateBoundingBox(PointList pointList); static BBox generateBoundingFromMultiple(BBox[] boundingBoxes); static double getLength(Geometry geom, boolean inMeters); static double metresToDegrees(double metres); static double getArea(Geometry geom, boolean inMeters); static double calculateMaxExtent(Geometry geom); }### Answer: @Test public void calculateBoundingBox() { BBox bbox3D = GeomUtility.calculateBoundingBox(pointList3D); BBox bbox2D = GeomUtility.calculateBoundingBox(pointList2D); BBox bbox_fallback = GeomUtility.calculateBoundingBox(emptyPointList); Assert.assertEquals(-35.507813,bbox3D.minLon, 0.000009); Assert.assertEquals(38.408203,bbox3D.maxLon, 0.0000009); Assert.assertEquals(-12.897489,bbox3D.minLat, 0.000009); Assert.assertEquals(50.958427,bbox3D.maxLat, 0.0000009); Assert.assertEquals(113.0,bbox3D.minEle, 0.09); Assert.assertEquals(409.0,bbox3D.maxEle, 0.09); Assert.assertEquals(-35.507813,bbox2D.minLon, 0.000009); Assert.assertEquals(38.408203,bbox2D.maxLon, 0.000009); Assert.assertEquals(-12.897489,bbox2D.minLat, 0.000009); Assert.assertEquals(50.958427,bbox2D.maxLat, 0.000009); Assert.assertEquals(0f,bbox_fallback.minLon, 0.000009); Assert.assertEquals(0f,bbox_fallback.maxLon, 0.000009); Assert.assertEquals(0f,bbox_fallback.minLat, 0.000009); Assert.assertEquals(0f,bbox_fallback.maxLat, 0.000009); }
### Question: GeomUtility { public static BBox generateBoundingFromMultiple(BBox[] boundingBoxes) { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for(BBox bbox : boundingBoxes) { minLon = Math.min(minLon, bbox.minLon); maxLon = Math.max(maxLon, bbox.maxLon); minLat = Math.min(minLat, bbox.minLat); maxLat = Math.max(maxLat, bbox.maxLat); if(!Double.isNaN(bbox.minEle)) minEle = Math.min(minEle, bbox.minEle); if(!Double.isNaN(bbox.maxEle)) maxEle = Math.max(maxEle, bbox.maxEle); } if(minEle != Double.MAX_VALUE && maxEle != Double.MAX_VALUE) return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); else return new BBox(minLon, maxLon, minLat, maxLat); } private GeomUtility(); static LineString createLinestring(Coordinate[] coords); static BBox calculateBoundingBox(PointList pointList); static BBox generateBoundingFromMultiple(BBox[] boundingBoxes); static double getLength(Geometry geom, boolean inMeters); static double metresToDegrees(double metres); static double getArea(Geometry geom, boolean inMeters); static double calculateMaxExtent(Geometry geom); }### Answer: @Test public void generateBBoxFromMultiple() { BBox[] bboxes = { new BBox(1.5, 2.5, -1.5, 1.5, 10, 20), new BBox(2.6, 8.5, -0.5, 1.7, 5, 25) }; BBox bbox = GeomUtility.generateBoundingFromMultiple(bboxes); Assert.assertEquals(-1.5, bbox.minLat, 0); Assert.assertEquals(1.7, bbox.maxLat, 0); Assert.assertEquals(1.5, bbox.minLon, 0); Assert.assertEquals(8.5, bbox.maxLon, 0); Assert.assertEquals(5, bbox.minEle, 0); Assert.assertEquals(25, bbox.maxEle, 0); }