@Test(expected = EmptyElementException.class) public void emptySkipSegments() throws StatusCodeException { List<Integer> skip_segments = new ArrayList<>(); request.setSkipSegments(skip_segments); new RouteRequestHandler().convertRouteRequest(request); }
public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCodeException { RoutingRequest routingRequest = new RoutingRequest(); boolean isRoundTrip = request.hasRouteOptions() && request.getRouteOptions().hasRoundTripOptions(); routingRequest.setCoordinates(convertCoordinates(request.getCoordinates(), isRoundTrip)); routingRequest.setGeometryFormat(convertGeometryFormat(request.getResponseType())); if (request.hasUseElevation()) routingRequest.setIncludeElevation(request.getUseElevation()); if (request.hasContinueStraightAtWaypoints()) routingRequest.setContinueStraight(request.getContinueStraightAtWaypoints()); if (request.hasIncludeGeometry()) routingRequest.setIncludeGeometry(convertIncludeGeometry(request)); if (request.hasIncludeManeuvers()) routingRequest.setIncludeManeuvers(request.getIncludeManeuvers()); if (request.hasIncludeInstructions()) routingRequest.setIncludeInstructions(request.getIncludeInstructionsInResponse()); if (request.hasIncludeRoundaboutExitInfo()) routingRequest.setIncludeRoundaboutExits(request.getIncludeRoundaboutExitInfo()); if (request.hasAttributes()) routingRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); for (APIEnums.ExtraInfo extra : request.getExtraInfo()) { if (extra.compareTo(APIEnums.ExtraInfo.COUNTRY_INFO) == 0) { routingRequest.setIncludeCountryInfo(true); } } } if (request.hasLanguage()) routingRequest.setLanguage(convertLanguage(request.getLanguage())); if (request.hasInstructionsFormat()) routingRequest.setInstructionsFormat(convertInstructionsFormat(request.getInstructionsFormat())); if (request.hasUnits()) routingRequest.setUnits(convertUnits(request.getUnits())); if (request.hasSimplifyGeometry()) { routingRequest.setGeometrySimplify(request.getSimplifyGeometry()); if (request.hasExtraInfo() && request.getSimplifyGeometry()) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*"); } } if (request.hasSkipSegments()) { routingRequest.setSkipSegments(processSkipSegments(request)); } if (request.hasId()) routingRequest.setId(request.getId()); if (request.hasMaximumSpeed()) { routingRequest.setMaximumSpeed(request.getMaximumSpeed()); } int profileType = -1; int coordinatesLength = request.getCoordinates().size(); RouteSearchParameters params = new RouteSearchParameters(); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); params.setExtraInfo(convertExtraInfo(request.getExtraInfo())); } if (request.hasSuppressWarnings()) params.setSuppressWarnings(request.getSuppressWarnings()); try { profileType = convertRouteProfileType(request.getProfile()); params.setProfileType(profileType); } catch (Exception e) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_PROFILE); } if (request.hasRoutePreference()) params.setWeightingMethod(convertWeightingMethod(request.getRoutePreference())); if (request.hasBearings()) params.setBearings(convertBearings(request.getBearings(), coordinatesLength)); if (request.hasMaximumSearchRadii()) params.setMaximumRadiuses(convertMaxRadii(request.getMaximumSearchRadii(), coordinatesLength, profileType)); if (request.hasUseContractionHierarchies()) { params.setFlexibleMode(convertSetFlexibleMode(request.getUseContractionHierarchies())); params.setOptimized(request.getUseContractionHierarchies()); } if (request.hasRouteOptions()) { params = processRouteRequestOptions(request, params); } if (request.hasAlternativeRoutes()) { if (request.getCoordinates().size() > 2) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_ALTERNATIVE_ROUTES, "(number of waypoints > 2)"); } RouteRequestAlternativeRoutes alternativeRoutes = request.getAlternativeRoutes(); if (alternativeRoutes.hasTargetCount()) { params.setAlternativeRoutesCount(alternativeRoutes.getTargetCount()); String paramMaxAlternativeRoutesCount = AppConfig.getGlobal().getRoutingProfileParameter(request.getProfile().toString(), "maximum_alternative_routes"); int countLimit = StringUtility.isNullOrEmpty(paramMaxAlternativeRoutesCount) ? 0 : Integer.parseInt(paramMaxAlternativeRoutesCount); if (countLimit > 0 && alternativeRoutes.getTargetCount() > countLimit) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_ALTERNATIVE_ROUTES, Integer.toString(alternativeRoutes.getTargetCount()), "The target alternative routes count has to be equal to or less than " + paramMaxAlternativeRoutesCount); } } if (alternativeRoutes.hasWeightFactor()) params.setAlternativeRoutesWeightFactor(alternativeRoutes.getWeightFactor()); if (alternativeRoutes.hasShareFactor()) params.setAlternativeRoutesShareFactor(alternativeRoutes.getShareFactor()); } if (request.hasMaximumSpeed()) { params.setMaximumSpeed(request.getMaximumSpeed()); } params.setConsiderTurnRestrictions(false); routingRequest.setSearchParameters(params); return routingRequest; }
RouteRequestHandler extends GenericHandler { public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCodeException { RoutingRequest routingRequest = new RoutingRequest(); boolean isRoundTrip = request.hasRouteOptions() && request.getRouteOptions().hasRoundTripOptions(); routingRequest.setCoordinates(convertCoordinates(request.getCoordinates(), isRoundTrip)); routingRequest.setGeometryFormat(convertGeometryFormat(request.getResponseType())); if (request.hasUseElevation()) routingRequest.setIncludeElevation(request.getUseElevation()); if (request.hasContinueStraightAtWaypoints()) routingRequest.setContinueStraight(request.getContinueStraightAtWaypoints()); if (request.hasIncludeGeometry()) routingRequest.setIncludeGeometry(convertIncludeGeometry(request)); if (request.hasIncludeManeuvers()) routingRequest.setIncludeManeuvers(request.getIncludeManeuvers()); if (request.hasIncludeInstructions()) routingRequest.setIncludeInstructions(request.getIncludeInstructionsInResponse()); if (request.hasIncludeRoundaboutExitInfo()) routingRequest.setIncludeRoundaboutExits(request.getIncludeRoundaboutExitInfo()); if (request.hasAttributes()) routingRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); for (APIEnums.ExtraInfo extra : request.getExtraInfo()) { if (extra.compareTo(APIEnums.ExtraInfo.COUNTRY_INFO) == 0) { routingRequest.setIncludeCountryInfo(true); } } } if (request.hasLanguage()) routingRequest.setLanguage(convertLanguage(request.getLanguage())); if (request.hasInstructionsFormat()) routingRequest.setInstructionsFormat(convertInstructionsFormat(request.getInstructionsFormat())); if (request.hasUnits()) routingRequest.setUnits(convertUnits(request.getUnits())); if (request.hasSimplifyGeometry()) { routingRequest.setGeometrySimplify(request.getSimplifyGeometry()); if (request.hasExtraInfo() && request.getSimplifyGeometry()) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*"); } } if (request.hasSkipSegments()) { routingRequest.setSkipSegments(processSkipSegments(request)); } if (request.hasId()) routingRequest.setId(request.getId()); if (request.hasMaximumSpeed()) { routingRequest.setMaximumSpeed(request.getMaximumSpeed()); } int profileType = -1; int coordinatesLength = request.getCoordinates().size(); RouteSearchParameters params = new RouteSearchParameters(); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); params.setExtraInfo(convertExtraInfo(request.getExtraInfo())); } if (request.hasSuppressWarnings()) params.setSuppressWarnings(request.getSuppressWarnings()); try { profileType = convertRouteProfileType(request.getProfile()); params.setProfileType(profileType); } catch (Exception e) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_PROFILE); } if (request.hasRoutePreference()) params.setWeightingMethod(convertWeightingMethod(request.getRoutePreference())); if (request.hasBearings()) params.setBearings(convertBearings(request.getBearings(), coordinatesLength)); if (request.hasMaximumSearchRadii()) params.setMaximumRadiuses(convertMaxRadii(request.getMaximumSearchRadii(), coordinatesLength, profileType)); if (request.hasUseContractionHierarchies()) { params.setFlexibleMode(convertSetFlexibleMode(request.getUseContractionHierarchies())); params.setOptimized(request.getUseContractionHierarchies()); } if (request.hasRouteOptions()) { params = processRouteRequestOptions(request, params); } if (request.hasAlternativeRoutes()) { if (request.getCoordinates().size() > 2) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_ALTERNATIVE_ROUTES, "(number of waypoints > 2)"); } RouteRequestAlternativeRoutes alternativeRoutes = request.getAlternativeRoutes(); if (alternativeRoutes.hasTargetCount()) { params.setAlternativeRoutesCount(alternativeRoutes.getTargetCount()); String paramMaxAlternativeRoutesCount = AppConfig.getGlobal().getRoutingProfileParameter(request.getProfile().toString(), "maximum_alternative_routes"); int countLimit = StringUtility.isNullOrEmpty(paramMaxAlternativeRoutesCount) ? 0 : Integer.parseInt(paramMaxAlternativeRoutesCount); if (countLimit > 0 && alternativeRoutes.getTargetCount() > countLimit) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_ALTERNATIVE_ROUTES, Integer.toString(alternativeRoutes.getTargetCount()), "The target alternative routes count has to be equal to or less than " + paramMaxAlternativeRoutesCount); } } if (alternativeRoutes.hasWeightFactor()) params.setAlternativeRoutesWeightFactor(alternativeRoutes.getWeightFactor()); if (alternativeRoutes.hasShareFactor()) params.setAlternativeRoutesShareFactor(alternativeRoutes.getShareFactor()); } if (request.hasMaximumSpeed()) { params.setMaximumSpeed(request.getMaximumSpeed()); } params.setConsiderTurnRestrictions(false); routingRequest.setSearchParameters(params); return routingRequest; } }
RouteRequestHandler extends GenericHandler { public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCodeException { RoutingRequest routingRequest = new RoutingRequest(); boolean isRoundTrip = request.hasRouteOptions() && request.getRouteOptions().hasRoundTripOptions(); routingRequest.setCoordinates(convertCoordinates(request.getCoordinates(), isRoundTrip)); routingRequest.setGeometryFormat(convertGeometryFormat(request.getResponseType())); if (request.hasUseElevation()) routingRequest.setIncludeElevation(request.getUseElevation()); if (request.hasContinueStraightAtWaypoints()) routingRequest.setContinueStraight(request.getContinueStraightAtWaypoints()); if (request.hasIncludeGeometry()) routingRequest.setIncludeGeometry(convertIncludeGeometry(request)); if (request.hasIncludeManeuvers()) routingRequest.setIncludeManeuvers(request.getIncludeManeuvers()); if (request.hasIncludeInstructions()) routingRequest.setIncludeInstructions(request.getIncludeInstructionsInResponse()); if (request.hasIncludeRoundaboutExitInfo()) routingRequest.setIncludeRoundaboutExits(request.getIncludeRoundaboutExitInfo()); if (request.hasAttributes()) routingRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); for (APIEnums.ExtraInfo extra : request.getExtraInfo()) { if (extra.compareTo(APIEnums.ExtraInfo.COUNTRY_INFO) == 0) { routingRequest.setIncludeCountryInfo(true); } } } if (request.hasLanguage()) routingRequest.setLanguage(convertLanguage(request.getLanguage())); if (request.hasInstructionsFormat()) routingRequest.setInstructionsFormat(convertInstructionsFormat(request.getInstructionsFormat())); if (request.hasUnits()) routingRequest.setUnits(convertUnits(request.getUnits())); if (request.hasSimplifyGeometry()) { routingRequest.setGeometrySimplify(request.getSimplifyGeometry()); if (request.hasExtraInfo() && request.getSimplifyGeometry()) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*"); } } if (request.hasSkipSegments()) { routingRequest.setSkipSegments(processSkipSegments(request)); } if (request.hasId()) routingRequest.setId(request.getId()); if (request.hasMaximumSpeed()) { routingRequest.setMaximumSpeed(request.getMaximumSpeed()); } int profileType = -1; int coordinatesLength = request.getCoordinates().size(); RouteSearchParameters params = new RouteSearchParameters(); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); params.setExtraInfo(convertExtraInfo(request.getExtraInfo())); } if (request.hasSuppressWarnings()) params.setSuppressWarnings(request.getSuppressWarnings()); try { profileType = convertRouteProfileType(request.getProfile()); params.setProfileType(profileType); } catch (Exception e) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_PROFILE); } if (request.hasRoutePreference()) params.setWeightingMethod(convertWeightingMethod(request.getRoutePreference())); if (request.hasBearings()) params.setBearings(convertBearings(request.getBearings(), coordinatesLength)); if (request.hasMaximumSearchRadii()) params.setMaximumRadiuses(convertMaxRadii(request.getMaximumSearchRadii(), coordinatesLength, profileType)); if (request.hasUseContractionHierarchies()) { params.setFlexibleMode(convertSetFlexibleMode(request.getUseContractionHierarchies())); params.setOptimized(request.getUseContractionHierarchies()); } if (request.hasRouteOptions()) { params = processRouteRequestOptions(request, params); } if (request.hasAlternativeRoutes()) { if (request.getCoordinates().size() > 2) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_ALTERNATIVE_ROUTES, "(number of waypoints > 2)"); } RouteRequestAlternativeRoutes alternativeRoutes = request.getAlternativeRoutes(); if (alternativeRoutes.hasTargetCount()) { params.setAlternativeRoutesCount(alternativeRoutes.getTargetCount()); String paramMaxAlternativeRoutesCount = AppConfig.getGlobal().getRoutingProfileParameter(request.getProfile().toString(), "maximum_alternative_routes"); int countLimit = StringUtility.isNullOrEmpty(paramMaxAlternativeRoutesCount) ? 0 : Integer.parseInt(paramMaxAlternativeRoutesCount); if (countLimit > 0 && alternativeRoutes.getTargetCount() > countLimit) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_ALTERNATIVE_ROUTES, Integer.toString(alternativeRoutes.getTargetCount()), "The target alternative routes count has to be equal to or less than " + paramMaxAlternativeRoutesCount); } } if (alternativeRoutes.hasWeightFactor()) params.setAlternativeRoutesWeightFactor(alternativeRoutes.getWeightFactor()); if (alternativeRoutes.hasShareFactor()) params.setAlternativeRoutesShareFactor(alternativeRoutes.getShareFactor()); } if (request.hasMaximumSpeed()) { params.setMaximumSpeed(request.getMaximumSpeed()); } params.setConsiderTurnRestrictions(false); routingRequest.setSearchParameters(params); return routingRequest; } RouteRequestHandler(); }
RouteRequestHandler extends GenericHandler { public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCodeException { RoutingRequest routingRequest = new RoutingRequest(); boolean isRoundTrip = request.hasRouteOptions() && request.getRouteOptions().hasRoundTripOptions(); routingRequest.setCoordinates(convertCoordinates(request.getCoordinates(), isRoundTrip)); routingRequest.setGeometryFormat(convertGeometryFormat(request.getResponseType())); if (request.hasUseElevation()) routingRequest.setIncludeElevation(request.getUseElevation()); if (request.hasContinueStraightAtWaypoints()) routingRequest.setContinueStraight(request.getContinueStraightAtWaypoints()); if (request.hasIncludeGeometry()) routingRequest.setIncludeGeometry(convertIncludeGeometry(request)); if (request.hasIncludeManeuvers()) routingRequest.setIncludeManeuvers(request.getIncludeManeuvers()); if (request.hasIncludeInstructions()) routingRequest.setIncludeInstructions(request.getIncludeInstructionsInResponse()); if (request.hasIncludeRoundaboutExitInfo()) routingRequest.setIncludeRoundaboutExits(request.getIncludeRoundaboutExitInfo()); if (request.hasAttributes()) routingRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); for (APIEnums.ExtraInfo extra : request.getExtraInfo()) { if (extra.compareTo(APIEnums.ExtraInfo.COUNTRY_INFO) == 0) { routingRequest.setIncludeCountryInfo(true); } } } if (request.hasLanguage()) routingRequest.setLanguage(convertLanguage(request.getLanguage())); if (request.hasInstructionsFormat()) routingRequest.setInstructionsFormat(convertInstructionsFormat(request.getInstructionsFormat())); if (request.hasUnits()) routingRequest.setUnits(convertUnits(request.getUnits())); if (request.hasSimplifyGeometry()) { routingRequest.setGeometrySimplify(request.getSimplifyGeometry()); if (request.hasExtraInfo() && request.getSimplifyGeometry()) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*"); } } if (request.hasSkipSegments()) { routingRequest.setSkipSegments(processSkipSegments(request)); } if (request.hasId()) routingRequest.setId(request.getId()); if (request.hasMaximumSpeed()) { routingRequest.setMaximumSpeed(request.getMaximumSpeed()); } int profileType = -1; int coordinatesLength = request.getCoordinates().size(); RouteSearchParameters params = new RouteSearchParameters(); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); params.setExtraInfo(convertExtraInfo(request.getExtraInfo())); } if (request.hasSuppressWarnings()) params.setSuppressWarnings(request.getSuppressWarnings()); try { profileType = convertRouteProfileType(request.getProfile()); params.setProfileType(profileType); } catch (Exception e) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_PROFILE); } if (request.hasRoutePreference()) params.setWeightingMethod(convertWeightingMethod(request.getRoutePreference())); if (request.hasBearings()) params.setBearings(convertBearings(request.getBearings(), coordinatesLength)); if (request.hasMaximumSearchRadii()) params.setMaximumRadiuses(convertMaxRadii(request.getMaximumSearchRadii(), coordinatesLength, profileType)); if (request.hasUseContractionHierarchies()) { params.setFlexibleMode(convertSetFlexibleMode(request.getUseContractionHierarchies())); params.setOptimized(request.getUseContractionHierarchies()); } if (request.hasRouteOptions()) { params = processRouteRequestOptions(request, params); } if (request.hasAlternativeRoutes()) { if (request.getCoordinates().size() > 2) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_ALTERNATIVE_ROUTES, "(number of waypoints > 2)"); } RouteRequestAlternativeRoutes alternativeRoutes = request.getAlternativeRoutes(); if (alternativeRoutes.hasTargetCount()) { params.setAlternativeRoutesCount(alternativeRoutes.getTargetCount()); String paramMaxAlternativeRoutesCount = AppConfig.getGlobal().getRoutingProfileParameter(request.getProfile().toString(), "maximum_alternative_routes"); int countLimit = StringUtility.isNullOrEmpty(paramMaxAlternativeRoutesCount) ? 0 : Integer.parseInt(paramMaxAlternativeRoutesCount); if (countLimit > 0 && alternativeRoutes.getTargetCount() > countLimit) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_ALTERNATIVE_ROUTES, Integer.toString(alternativeRoutes.getTargetCount()), "The target alternative routes count has to be equal to or less than " + paramMaxAlternativeRoutesCount); } } if (alternativeRoutes.hasWeightFactor()) params.setAlternativeRoutesWeightFactor(alternativeRoutes.getWeightFactor()); if (alternativeRoutes.hasShareFactor()) params.setAlternativeRoutesShareFactor(alternativeRoutes.getShareFactor()); } if (request.hasMaximumSpeed()) { params.setMaximumSpeed(request.getMaximumSpeed()); } params.setConsiderTurnRestrictions(false); routingRequest.setSearchParameters(params); return routingRequest; } RouteRequestHandler(); RouteResult[] generateRouteFromRequest(RouteRequest request); RoutingRequest convertRouteRequest(RouteRequest request); RouteSearchParameters processRequestOptions(RouteRequestOptions options, RouteSearchParameters params); @Override int convertRouteProfileType(APIEnums.Profile profile); }
RouteRequestHandler extends GenericHandler { public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCodeException { RoutingRequest routingRequest = new RoutingRequest(); boolean isRoundTrip = request.hasRouteOptions() && request.getRouteOptions().hasRoundTripOptions(); routingRequest.setCoordinates(convertCoordinates(request.getCoordinates(), isRoundTrip)); routingRequest.setGeometryFormat(convertGeometryFormat(request.getResponseType())); if (request.hasUseElevation()) routingRequest.setIncludeElevation(request.getUseElevation()); if (request.hasContinueStraightAtWaypoints()) routingRequest.setContinueStraight(request.getContinueStraightAtWaypoints()); if (request.hasIncludeGeometry()) routingRequest.setIncludeGeometry(convertIncludeGeometry(request)); if (request.hasIncludeManeuvers()) routingRequest.setIncludeManeuvers(request.getIncludeManeuvers()); if (request.hasIncludeInstructions()) routingRequest.setIncludeInstructions(request.getIncludeInstructionsInResponse()); if (request.hasIncludeRoundaboutExitInfo()) routingRequest.setIncludeRoundaboutExits(request.getIncludeRoundaboutExitInfo()); if (request.hasAttributes()) routingRequest.setAttributes(convertAttributes(request.getAttributes())); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); for (APIEnums.ExtraInfo extra : request.getExtraInfo()) { if (extra.compareTo(APIEnums.ExtraInfo.COUNTRY_INFO) == 0) { routingRequest.setIncludeCountryInfo(true); } } } if (request.hasLanguage()) routingRequest.setLanguage(convertLanguage(request.getLanguage())); if (request.hasInstructionsFormat()) routingRequest.setInstructionsFormat(convertInstructionsFormat(request.getInstructionsFormat())); if (request.hasUnits()) routingRequest.setUnits(convertUnits(request.getUnits())); if (request.hasSimplifyGeometry()) { routingRequest.setGeometrySimplify(request.getSimplifyGeometry()); if (request.hasExtraInfo() && request.getSimplifyGeometry()) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*"); } } if (request.hasSkipSegments()) { routingRequest.setSkipSegments(processSkipSegments(request)); } if (request.hasId()) routingRequest.setId(request.getId()); if (request.hasMaximumSpeed()) { routingRequest.setMaximumSpeed(request.getMaximumSpeed()); } int profileType = -1; int coordinatesLength = request.getCoordinates().size(); RouteSearchParameters params = new RouteSearchParameters(); if (request.hasExtraInfo()) { routingRequest.setExtraInfo(convertExtraInfo(request.getExtraInfo())); params.setExtraInfo(convertExtraInfo(request.getExtraInfo())); } if (request.hasSuppressWarnings()) params.setSuppressWarnings(request.getSuppressWarnings()); try { profileType = convertRouteProfileType(request.getProfile()); params.setProfileType(profileType); } catch (Exception e) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_PROFILE); } if (request.hasRoutePreference()) params.setWeightingMethod(convertWeightingMethod(request.getRoutePreference())); if (request.hasBearings()) params.setBearings(convertBearings(request.getBearings(), coordinatesLength)); if (request.hasMaximumSearchRadii()) params.setMaximumRadiuses(convertMaxRadii(request.getMaximumSearchRadii(), coordinatesLength, profileType)); if (request.hasUseContractionHierarchies()) { params.setFlexibleMode(convertSetFlexibleMode(request.getUseContractionHierarchies())); params.setOptimized(request.getUseContractionHierarchies()); } if (request.hasRouteOptions()) { params = processRouteRequestOptions(request, params); } if (request.hasAlternativeRoutes()) { if (request.getCoordinates().size() > 2) { throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_ALTERNATIVE_ROUTES, "(number of waypoints > 2)"); } RouteRequestAlternativeRoutes alternativeRoutes = request.getAlternativeRoutes(); if (alternativeRoutes.hasTargetCount()) { params.setAlternativeRoutesCount(alternativeRoutes.getTargetCount()); String paramMaxAlternativeRoutesCount = AppConfig.getGlobal().getRoutingProfileParameter(request.getProfile().toString(), "maximum_alternative_routes"); int countLimit = StringUtility.isNullOrEmpty(paramMaxAlternativeRoutesCount) ? 0 : Integer.parseInt(paramMaxAlternativeRoutesCount); if (countLimit > 0 && alternativeRoutes.getTargetCount() > countLimit) { throw new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, RouteRequest.PARAM_ALTERNATIVE_ROUTES, Integer.toString(alternativeRoutes.getTargetCount()), "The target alternative routes count has to be equal to or less than " + paramMaxAlternativeRoutesCount); } } if (alternativeRoutes.hasWeightFactor()) params.setAlternativeRoutesWeightFactor(alternativeRoutes.getWeightFactor()); if (alternativeRoutes.hasShareFactor()) params.setAlternativeRoutesShareFactor(alternativeRoutes.getShareFactor()); } if (request.hasMaximumSpeed()) { params.setMaximumSpeed(request.getMaximumSpeed()); } params.setConsiderTurnRestrictions(false); routingRequest.setSearchParameters(params); return routingRequest; } RouteRequestHandler(); RouteResult[] generateRouteFromRequest(RouteRequest request); RoutingRequest convertRouteRequest(RouteRequest request); RouteSearchParameters processRequestOptions(RouteRequestOptions options, RouteSearchParameters params); @Override int convertRouteProfileType(APIEnums.Profile profile);  }