[GraphHopper] customer flagencoder
Peter
graphhopper at gmx.de
Thu Jul 2 12:47:55 UTC 2015
Do
new EncodingManager(yourCustomFlagEncoder)
where yourCustomFlagEncoder is not a string but your encoder:
new EncodingManager(new MyCustomFlagEncoder())
Also I've changed the subject - please do so yourself next time before
re-using unrelated threads!
Peter
On 02.07.2015 14:43, Fred Laurent wrote:
> Sorry ,
> thank you , Yes , i see :
> I make : Graphhopper g = new Graphhopper ().forMobile();
> g.setEncodingManager(new EncodingManager("car2"));
>
> I have error : an error happend while creating graph : in encoder
> list not supportef car2
> I don't understand
> Thank you
>
> 2015-07-02 14:27 GMT+02:00 Peter <graphhopper at gmx.de
> <mailto:graphhopper at gmx.de>>:
>
> 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 <fredlaurent31 at gmail.com
>> <mailto:fredlaurent31 at gmail.com>>:
>>
>> Yes .. multiple alternate routes calculation. Ok I 'll wait
>> the answer of Peter.
>> Thank you..
>>
>> 2015-07-01 14:22 GMT+02:00 Emux <devemux86 at gmail.com
>> <mailto:devemux86 at gmail.com>>:
>>
>> 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
> GraphHopper at openstreetmap.org <mailto:GraphHopper at openstreetmap.org>
> https://lists.openstreetmap.org/listinfo/graphhopper
>
>
>
>
> _______________________________________________
> GraphHopper mailing list
> GraphHopper at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/graphhopper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20150702/639cd307/attachment.html>
More information about the GraphHopper
mailing list