Heads-I-Lose

Check-in [289839a15d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Yay! Working prototype. Will sum up the distances of headwinds... ...for a polyline route. I'd made silly mistakes like forgetting which order the list of tuples were in. I.e {Distances, Wind} or {Wind, Distances}. It doesn't really matter which order I use, but I should back sure it is consistent and matches the variable naming. Now need to extend this to sum up all wind directions and check for other bugs (such as sum of distances making sense, headwinds are actually headwinds and not tailwinds, etc).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | origin/master
Files: files | file ages | folders
SHA3-256: 289839a15dc8ba8abcda246e2932e1e2aa17a273fb83be02a367c1d2ff5518dc
User & Date: base@atomicules.co.uk 2014-11-29 17:52:12
Context
2014-11-30
11:02
Extend functionality to sum up all wind directions by mapping. Need to tidy up formatting and make it consistent and sort out the naming of variables - it's such a mess. check-in: 6912ce6208 user: base@atomicules.co.uk tags: trunk, origin/master
2014-11-29
17:52
Yay! Working prototype. Will sum up the distances of headwinds... ...for a polyline route. I'd made silly mistakes like forgetting which order the list of tuples were in. I.e {Distances, Wind} or {Wind, Distances}. It doesn't really matter which order I use, but I should back sure it is consistent and matches the variable naming. Now need to extend this to sum up all wind directions and check for other bugs (such as sum of distances making sense, headwinds are actually headwinds and not tailwinds, etc). check-in: 289839a15d user: base@atomicules.co.uk tags: trunk, origin/master
17:42
Merge branch 'master' into osrm Noticed the nth_wrap problem whilst developing this osrm branch as building the list of winds would be incomplete. check-in: 915a1fb3d0 user: base@atomicules.co.uk tags: trunk, origin/master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to headsilose.erl.

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
	[Headwinds, Sidewinds, Tailwinds] = build_list_of_wind_directions(Direction),
	%Ok so now map this list over (like previous function) the headings list to get list of head, side, tail and distances?

	{_Checksum, Polyline} = osrm:read_route(),
	Polyline_decoded = polyline:decode(Polyline),
	List_of_distances_and_compass = convert_lats_longs_to_distance_heading(Polyline_decoded),
	%If now have a set of co-ords need to figure out distances and directions
	List_of_distances_and_wind = lists:map(fun({Compass, Distance}) ->
			Wind = head_side_or_tail_wind(Compass, [Headwinds, Sidewinds, Tailwinds]),
			{Wind, Distance}
		end,
		List_of_distances_and_compass),
	%lists:map to get distnaces only? Could also map each of the winds?
	%Figure out for headwinds only for now
	Headw = lists:filter(fun({Element, _}) ->
		Element == headwind end,
		List_of_distances_and_wind),
	Sum_of_Headw = lists:foldl(fun({_wind, Distance}, Sum) -> Distance + Sum end, 0, Headw),
	io:format(Sum_of_Headw).
	%io:format("Direction: ~s~nSpeed: ~s mph~nGust: ~s mph~nWeather type: ~s~nTemperature: ~s deg C~n", [Direction, Speed, Gust, Weather_type, Temperature]).


%Need to read API key from file
readapikey() ->
	{_Status, KeyB} = file:read_file(os:getenv("HOME") ++ "/.datapoint"),
	string:strip(erlang:binary_to_list(KeyB),right,$\n).







|

|




|
|

|
<







201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
	[Headwinds, Sidewinds, Tailwinds] = build_list_of_wind_directions(Direction),
	%Ok so now map this list over (like previous function) the headings list to get list of head, side, tail and distances?

	{_Checksum, Polyline} = osrm:read_route(),
	Polyline_decoded = polyline:decode(Polyline),
	List_of_distances_and_compass = convert_lats_longs_to_distance_heading(Polyline_decoded),
	%If now have a set of co-ords need to figure out distances and directions
	List_of_distances_and_wind = lists:map(fun({Distance, Compass}) ->
			Wind = head_side_or_tail_wind(Compass, [Headwinds, Sidewinds, Tailwinds]),
			{Distance, Wind}
		end,
		List_of_distances_and_compass),
	%lists:map to get distnaces only? Could also map each of the winds?
	%Figure out for headwinds only for now
	Headw = lists:filter(fun({_Distance, Wind_type}) ->
		Wind_type == headwind end,
		List_of_distances_and_wind),
	Sum_of_Headw = lists:foldl(fun({Distance2, _Wind}, Sum) -> Distance2 + Sum end, 0, Headw).

	%io:format("Direction: ~s~nSpeed: ~s mph~nGust: ~s mph~nWeather type: ~s~nTemperature: ~s deg C~n", [Direction, Speed, Gust, Weather_type, Temperature]).


%Need to read API key from file
readapikey() ->
	{_Status, KeyB} = file:read_file(os:getenv("HOME") ++ "/.datapoint"),
	string:strip(erlang:binary_to_list(KeyB),right,$\n).