Hi Fred, no need to extend from EncodingManager - just use it like: new EncodingManager(yourCustomFlagEncoder)
Also customizing an existing flagencoder will be easier soon :) ! Kind Regards, Peter On 02.07.2015 14:09, Fred Laurent wrote: > Hello.. > Can you explain me the problem .. I create MyFlagEncoder (I read : > https://github.com/graphhopper/graphhopper/blob/master/docs/core/create-new-flagencoder.md) > > and I override toString method , I put "car2" > I create class Myencoder extends EncodingManager { > public static final String CAR2 = "car2"; > > public MyEncoder(String car2) { > super(car2); > } > static List<FlagEncoder> parseEncoderString( String encoderList ) > { > if (encoderList.contains(":")) > throw new IllegalArgumentException("EncodingManager does > no longer use reflection instantiate encoders directly."); > > String[] entries = encoderList.split(","); > List<FlagEncoder> resultEncoders = new ArrayList<FlagEncoder>(); > > for (String entry : entries) > { > entry = entry.trim().toLowerCase(); > if (entry.isEmpty()) > continue; > > String entryVal = ""; > if (entry.contains("|")) > { > entryVal = entry; > entry = entry.split("\\|")[0]; > } > PMap configuration = new PMap(entryVal); > > AbstractFlagEncoder fe; > > > else if (entry.equals(CAR2)) > fe = new MyFlagEncoder(configuration); > > else > throw new IllegalArgumentException("entry in encoder > list not supported " + entry); > > if (configuration.has("version")) > { > if (fe.getVersion() != configuration.getInt("version", > -1)) > { > throw new IllegalArgumentException("Encoder " + > entry + " was used in version " > + configuration.getLong("version", -1) + > ", but current version is " + fe.getVersion()); > } > } > > resultEncoders.add(fe); > } > return resultEncoders; > } > In MyActivity i put : > > GHRequest request = new GHRequest(step2); > > request.setVehicle(MyEncoder.CAR2).setAlgorithm(AlgorithmOptions.ASTAR_BI); > > I run My application and in my log I have error : [java.lang. > IllegalArgumentException: Vehicle car2 unsupported. > Supported are:car] > I must create graph car2?.... > thank you > > 2015-07-01 14:38 GMT+02:00 Fred Laurent <[email protected] > <mailto:[email protected]>>: > > Yes .. multiple alternate routes calculation. Ok I 'll wait the > answer of Peter. > Thank you.. > > 2015-07-01 14:22 GMT+02:00 Emux <[email protected] > <mailto:[email protected]>>: > > Do you mean multiple alternate routes calculation? > > Peter can answer better, but I think this is work in progress > currently in GraphHopper. > > -- > Emux > Cruiser <http://wiki.openstreetmap.org/wiki/Cruiser> - Atlas > > <http://wiki.openstreetmap.org/wiki/Atlas_%28navigation_application%29> > > ______ >
_______________________________________________ GraphHopper mailing list [email protected] https://lists.openstreetmap.org/listinfo/graphhopper
