Driving Time

Jun 2, 2009 at 9:09 AM

Hello,

 

It would be nice to be able to get the driving time from a route.

Thanks a lot.

 

Nicolas Pernoud.

Coordinator
Jun 2, 2009 at 11:25 AM

check now first marker of route tooltip text in demos

Jun 3, 2009 at 7:51 AM

Hello,

 

That's neat. How can I get it to a string or double ?

 

Thanks,

 

Nicolas Pernoud.

Coordinator
Jun 3, 2009 at 7:54 AM

it's string allready, but in html, somehow need to convert to normal string... ;/

Jun 3, 2009 at 9:04 AM
Edited Jun 3, 2009 at 9:17 AM

It is manageable to get the time from the html string, yet, it would be nice to be able to get it as a propertie : as Distance.

Jun 3, 2009 at 9:16 AM

Actually, the nicer would be to get a double or interger (number of seconds !?) so that we can do math upon it !

 

Thanks a lot, and congratulations for you tremendous work !

Coordinator
Jun 3, 2009 at 9:19 AM

can you help me this time? ;}

Jun 3, 2009 at 10:08 AM

that should do ; at least for french and english languages...

 

private static int ConvertHTMLDistanceToInt(string aller)
        {
            string temps;

            temps = aller.Split('/')[1];

            int hourEndPosition = temps.IndexOf("h", 0) - 1;
            int minutesEndPosition = temps.IndexOf("min", 0) - 1;
            int secondsEndPosition = temps.IndexOf("sec", 0) - 1;

            int hourStartPosition = hourEndPosition - 1;
            while (hourStartPosition > 1 && temps.Substring(hourStartPosition, 1) != " ")
            {
                hourStartPosition--;
            }
            int minutesStartPosition = minutesEndPosition - 1;

            while (minutesStartPosition > 1 && temps.Substring(minutesStartPosition, 1) != " ")
            {
                minutesStartPosition--;
            }

            int secondsStartPosition = secondsEndPosition - 1;
            while (secondsStartPosition > 1 && temps.Substring(secondsStartPosition, 1) != " ")
            {
                secondsStartPosition--;
            }

            int seconds = 0;

            if (hourStartPosition > 0)
            {
                seconds += int.Parse(temps.Substring(hourStartPosition, hourEndPosition - hourStartPosition)) * 3600;
            }
            if (minutesStartPosition > 0)
            {
                seconds += int.Parse(temps.Substring(minutesStartPosition, minutesEndPosition - minutesStartPosition)) * 60;
            }
            if (secondsStartPosition > 0)
            {
                seconds += int.Parse(temps.Substring(secondsStartPosition, secondsEndPosition - secondsStartPosition));
            }
            return seconds;
        }