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