[GraphHopper] custom flagencoder
Peter
graphhopper at gmx.de
Fri Jul 3 07:58:32 UTC 2015
Hi Fred,
please avoid duplicate postings
Regarding your problem: you have to use the same settings for the import
too.
So do the import with your custom flagencoder e.g. via tmpHopp.importOrLoad
deploy the created files to android and it'll work.
Regards,
Peter
On 03.07.2015 09:49, Fred Laurent wrote:
> hello ,
> excuse me, I have a really problem to create My customer Flag encoder
> this is my class MyFlagEncoder
>
> I run My app with :
> GraphHopper tmpHopp = new GraphHopper().forMobile();
> tmpHopp.setEncodingManager(new EncodingManager(new
> MyFlagEncoder(5,5,0))); // Or (new MyFlagEncoder());
>
> I have Error : Graphhopper config:
> Mycar|speedFactor=5.0|speedBits=5|turnCosts=false|version=1
> Graph:
> car|speedFactor=5.0|speedBits=5|turnCosts=false|version=1,foot|speedFactor=1.0|speedBits=4|turnCosts=false|version=1,bike|speedFactor=2.0|speedBits=4|turnCosts=false|version=1,
> dir:/storage/sdcard0/graphhopper/maps/XXX-gh/
> Thank you All,
>
> 2015-07-02 14:47 GMT+02:00 Peter <graphhopper at gmx.de
> <mailto:graphhopper at gmx.de>>:
>
> 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>
>>>
>>> ______
>>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20150703/9ddd0a69/attachment.html>
More information about the GraphHopper
mailing list