Heads-I-Lose

Check-in [6912ce6208]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | origin/master
Files: files | file ages | folders
SHA3-256: 6912ce6208fd6f682c3b228d50dc2336e451036f2e0f8e14d08df77800061e14
User & Date: base@atomicules.co.uk 2014-11-30 11:02:39
Context
2014-12-05
20:43
Housekeeping: Formatting, variable naming consistency, etc - Get rid of the mixed up mess of CamelCase, underscores, prefixes, suffixes, abbreviations, full names, etc. - Make indenting of lists:map functions consistent - Remove spurious whitespace check-in: 301914a6a1 user: base@atomicules.co.uk tags: trunk, origin/master
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to headsilose.erl.

206
207
208
209
210
211
212
213
214
215
216
217


218

219
220
221
222
223
224
225
	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).







|
<
|
|
|
>
>
|
>







206
207
208
209
210
211
212
213

214
215
216
217
218
219
220
221
222
223
224
225
226
227
	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),
	[Headw, Sidew, Tailw] = lists:map(fun(Wind_group) ->

		lists:filter(fun({_Distance, Wind_type}) ->
			Wind_type == Wind_group end,
			List_of_distances_and_wind) end,
		[headwind, sidewind, tailwind]),
	[Sum_of_Headw, Sum_of_Sidew, Sum_of_Tailw] = lists:map(fun(Windg) ->
		lists:foldl(fun({Distance2, _Wind}, Sum) -> Distance2 + Sum end, 0, Windg) end,
		[Headw, Sidew, Tailw]).
	%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).