Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch refs/stash Excluding Merge-Ins
This is equivalent to a diff from 0c4224822a to 6463b2f68f
2014-12-26
| ||
22:15 |
Add basic implementation for selecting between route geometries
Not a great implementation, but it works. If no route geometry choice is | |
12:40 | WIP on osrm: 2a14782 Add basic implementation for selecting between route geometries Leaf check-in: 6463b2f68f user: base@atomicules.co.uk tags: refs/stash, trunk | |
12:40 | index on osrm: 2a14782 Add basic implementation for selecting between route geometries check-in: 8438b5c356 user: base@atomicules.co.uk tags: refs/stash, trunk | |
2014-12-17
| ||
22:46 |
Add basic implementation for selecting between route geometries
Not a great implementation, but it works. If no route geometry choice is | |
2014-12-14
| ||
21:54 | Remove some redundant comments check-in: 0c4224822a user: base@atomicules.co.uk tags: origin/master, trunk | |
21:53 | Update README to suit osrm branch check-in: ee1cd9e7e0 user: base@atomicules.co.uk tags: origin/master, trunk | |
Changes to README.md.
︙ | ︙ | |||
14 15 16 17 18 19 20 | 6. Run `erl -run headsilose headsilose <location id> -noshell` to get the result. Since I wrote this to be semi-useful for me, the result returned depends on the time of the day. If it's run before 8am it looks for the 6am weather data (since data is in 3 hour periods) and assumes the route is being traversed normally, run between 8am and 7pm it looks for the 6pm data for going home and therefore also traverses the saved route in reverse, and run after that time it looks again for the 6am data, but for the next day, and thus the route is back to being traversed in the normal direction. _Hint:_ I have a shell function defined as follows: function headsilose { | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 6. Run `erl -run headsilose headsilose <location id> -noshell` to get the result. Since I wrote this to be semi-useful for me, the result returned depends on the time of the day. If it's run before 8am it looks for the 6am weather data (since data is in 3 hour periods) and assumes the route is being traversed normally, run between 8am and 7pm it looks for the 6pm data for going home and therefore also traverses the saved route in reverse, and run after that time it looks again for the 6am data, but for the next day, and thus the route is back to being traversed in the normal direction. _Hint:_ I have a shell function defined as follows: function headsilose { erl -pa /home/simon/Code/github/atomicules/heads-I-lose /home/simon/Code/github/atomicules/heads-I-lose/ebin -run headsilose headsilose XXXXXX alternative_geometries -noshell; } So I can just call headsilose Which will result in something like the following being printed out: |
︙ | ︙ |
Changes to headsilose.erl.
1 2 3 4 5 | -module(headsilose). -export([get_locations/0, get_locations/1, headsilose/1]). -include_lib("xmerl/include/xmerl.hrl"). -import(weather_types, [weather_type/1]). -import(polyline, [decode/1]). | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | -module(headsilose). -export([get_locations/0, get_locations/1, headsilose/1]). -include_lib("xmerl/include/xmerl.hrl"). -import(weather_types, [weather_type/1]). -import(polyline, [decode/1]). -import(osrm, [read_route/1]). %Supply a direction and location and work out if head wind or not %For now "know the location id" upfront, but ideally need to search for it at some point or present a choice. %Initially based on: http://pragdave.pragprog.com/pragdave/2007/04/a_first_erlang_.html -define(BASE_URL, |
︙ | ︙ | |||
227 228 229 230 231 232 233 | sidewind; Tailwind -> tailwind end. %Something like that? | > > > > > | > > > > | | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | sidewind; Tailwind -> tailwind end. %Something like that? %First two for command line usage headsilose([Location]) -> headsilose_(Location); headsilose([Location, Route_choice]) -> headsilose_(Location, Route_choice). headsilose_(Location) -> %If route choice not specified default to default! %The other choice is "alternative_geometries", for now I think there is only ever one alternative so pick this first. headsilose_(Location, "route_geometry"). headsilose_(Location, Route_choice) -> Date_today = erlang:localtime(), { Date_formatted, Rep } = date_and_rep(Date_today), {Direction, Speed, Gust, Weather, Temperature} = get_weather(Location, { Date_formatted, Rep }), Weather_type = weather_types:weather_type(erlang:list_to_integer(Weather)), [Headwinds, Sidewinds, Tailwinds] = build_list_of_wind_directions(Direction), {_Checksum, Polyline} = osrm:read_route(Route_choice), Polyline_decoded = polyline:decode(Polyline), Distances_and_headings_list = convert_lats_longs_to_distance_heading(Polyline_decoded), %A better representation than 360 or 1080 would be better now this is used here as well. Journey = if Rep =:= "360" -> journey(Distances_and_headings_list); Rep =:= "1080" -> reverse_journey(Distances_and_headings_list) |
︙ | ︙ |
Changes to osrm.erl.
1 | -module(osrm). | | | 1 2 3 4 5 6 7 8 9 | -module(osrm). -export([get_route/1, get_route/2, read_route/1]). -import(polyline, [decode/1]). %https://github.com/Project-OSRM/osrm-backend/wiki/Server-api %For now, get weather for one location (probably good enough as relatively short distances weather wise; ultimately consider time as well?) %To get lats and longs could also do a query for here: http://www.uk-postcodes.com/ (json again) -define(BASE_URL, |
︙ | ︙ | |||
34 35 36 37 38 39 40 | io:format("API Might be down~n"), Reason after maybe_quit() end. | | > | > > > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | io:format("API Might be down~n"), Reason after maybe_quit() end. read_route(Route_choice) -> {_Status, Route} = file:read_file(os:getenv("HOME") ++ "/.headsilose_route"), %Use jiffy %http://www.snip2code.com/Snippet/51463/how-to-support-chinese-in-http-request-b/ { Props } = jiffy:decode(Route), Route_geometry = if Route_choice =:= "route_geometry" -> proplists:get_value(binary:list_to_bin(Route_choice), Props); Route_choice =:= "alternative_geometries" -> %hd only if alternative though! %for now I think there is only ever one alternative so that is why we pick hd hd(proplists:get_value(binary:list_to_bin(Route_choice), Props)) end, %That is all for now? Because... %And these don't seem to actually be returned, hence having to go down the route of polyline decoding %Route_Instructions = proplists:get_value(<<"route_instructions">>, Props), %Total_Distance = proplists:get_value(<<"total_distance">>, proplists:get_value(<<"route_summary">>, Props)), %And need to figure out how to get nested values. I.e like xpath. Just nest the queries? Nope that doesn't work %Like so: {Hint_data} = proplists:get_value(<<"hint_data">>, Props), |
︙ | ︙ |