Heads-I-Lose

Timeline
Login

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

50 most recent check-ins

2018-06-05
10:56
Formatting Leaf check-in: 64b10ac7d9 user: noreply@github.com tags: master, trunk
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
made it defaults to the default "route_geometry". If
"alternative_geometries" is specified it uses the first one of the
alternatives (because as far as I can tell there is only ever one
alternative? I supposed at some point I could extend if needed, perhaps
use a tuple argument: {"alternative_geomtries", 1}). Leaf check-in: 9c81571ac3 user: base@atomicules.co.uk tags: origin/master, trunk

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
made it defaults to the default "route_geometry". If
"alternative_geometries" is specified it uses the first one of the
alternatives (because as far as I can tell there is only ever one
alternative? I supposed at some point I could extend if needed, perhaps
use a tuple argument: {"alternative_geomtries", 1}). check-in: 6807958aad user: base@atomicules.co.uk tags: refs/stash, trunk

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
2014-12-12
12:49
Bug fix - Forgetting than list indexes start at 1

Which means I also need to wrap around the list if I get 16 segments.
I.e. both 0 rads and 2*Pi rads are valid.

This means I probably could have just simply added Pi (previous commit)
to reverse the journey as I can just keep wrapping around. Oh well. check-in: 598ec92c32 user: base@atomicules.co.uk tags: origin/master, trunk

12:49
Commit in haste: Repent at leisure. Fix reverse journey

Had not actually tried out my changes, or, it seems, used my brain at all
in making them.

- Can't simply just add Pi on, need to keep it within 2*Pi limit
- Also forgot to get compass direction check-in: 3022ce9541 user: base@atomicules.co.uk tags: origin/master, trunk

2014-12-11
22:37
Handle the reverse route

I don't want to have to query OSRM for th ereverse route - it's
pointless. Instead reverse the route we already have - because I don't
actually need a properly ordered reverse route, just a list of
directions and distances.

In order to do this made sense to re-jig some of the functions a bit:

- Need date and time at top level, not buried in get_weather since
reverse route or normal route is also dependent on time of day
- Don't convert to distances and compass directions in one swoop since
it is easier to reverse the heading angles rather than compass points check-in: 935d1fbeae user: base@atomicules.co.uk tags: origin/master, trunk

2014-12-05
23:51
Calculate wind-type percentages and use to determine win/lose

In other words: done for now. Those are pretty much the changes I
wanted to do. Sure they will be much room for improvements to the code,
but it works! check-in: c4d0b2bbec user: base@atomicules.co.uk tags: origin/master, trunk

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: origin/master, trunk

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: origin/master, trunk

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: origin/master, trunk

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: origin/master, trunk

17:34
Bug fix - nth_wrap didn't work for last items in a list

I only noticed this just recently, which means it has been wrong for
about a year! I think it's just luck I'd never come across an issue with
it not working.

I don't know if I'd got half way through writing this and forgot to
finish it off, or whether I was just being an imbecile: If the remainder
is 0 then that should return the last item in a list, not just the
number 1. Leaf check-in: 76eac348fc user: base@atomicules.co.uk tags: trunk, v1.1.0

2014-11-28
21:29
Make use of atan2 unsigned

Hadn't realised it returns negative numbers. check-in: 0fe524de48 user: base@atomicules.co.uk tags: origin/master, trunk

21:03
Do head | tail properly

Wasn't thinking straight when I first wrote that, obviously check-in: 5c494abd30 user: base@atomicules.co.uk tags: origin/master, trunk

20:12
WIP - 1st attempt at bringing together polyline and OSRM functionality

Compiles, but doesn't yet run.

The general principle is that it will get a previously saved polyline
and convert this into a list of compass headings and distances. It will
then sum up the distances of head, side and tail winds to see which
wins.

For the time being I'm focusing on summing up headwinds only.

Adds the following functions:

- build_list_of_wind_directions

Previously this didn't exist as a standalone function, rather it was
built into the main headsilose routine. Before it was fed with a
direction of travel and based on this it would work out which 16 point
compass headings were head, side or tail winds. Now it needs to work a
bit in reverse (although I haven't made the necessary changes yet - I
don't think1) and instead feed it with the actual wind direction and
it will use this to build the list of head, side and tail winds.

- get_compass_direction_for

Convert an angle into a 16-point compass direction

- head_side_or_tail_wind

Decided whether, for a given direction of heading, it is a head, side
or tailwind. Uses the lists from build_list_of_wind_directions.
check-in: 3a98087e88 user: base@atomicules.co.uk tags: origin/master, trunk
2014-11-27
19:12
Rename function to something more sensible check-in: 47dd9b33c8 user: base@atomicules.co.uk tags: origin/master, trunk
2014-11-24
22:27
First commit of OSRM API bit to get route geometry

Commiting this in a back-to-front way as I actually first started with
this file before doing the polyline branch. But it was as doing this
that I realised I was going to need a polyline decoder after all because
the API didn't actually return the route instructions and so I'd have to
use the route geometry instead.

So this is just a "works enough to develop further" commit so I can work
on the changes to headsilose.erl next. check-in: a0c2266624 user: base@atomicules.co.uk tags: origin/master, trunk

2014-10-23
10:40
Extend to decode a full example polyline (multiple points instead of single)

As per the Encoded Polyline Algorithm Format page:
https://developers.google.com/maps/documentation/utilities/polylinealgorithm

- Previously the decoder only worked with a single point (baby steps and
all that) and was tested with the example point of `~oia@
- This commit extends it to work with the example of
_p~iF~ps|U_ulLnnqC_mqNvxq`@
- Probably still to do is figure out decoding an unsigned value and the
bit about string literals.

Basically alter functions to use a list of lists approach:

- Adds split_up_six_bits which does what it says on the tin and looks
for the absence of the 0x20 bit and creates a list of lists of each
point's bit chunks.
- five_bit_chunks is now called six_bit_chunks since the groups of
chunks have to be split up at the six bit stage.
- Similarly, five_bit_chunk is now called six_bit_chunk; it is otherwise
exactly the same except from not "un-or-ing" the 0x20 bit to go from
six bits to five bits. Still padding to six bits, but I wonder if this
is entirely unnecessary and I can use this to determine the absence of
the 0x20 bit and thus where to split up the chunks into groups?
- five_bit_chunks now does the "un-or-ing" by mapping over the list of
lists. Perhaps this could be bundled in with the rest of the big
lists:map in the top level decode function?
- most of what was in the top level decode function remains the same,
but is just mapped over a list now. These should probably be at least
pulled out as separate functions that are mapped over. Need to decide
which approach to go for: functions that map or mapping functions.
- Changes to reversing, specifically the un-reversing of the five bit
chunks. This was bundled in with the five_bit_chunks function and the
un-reversing was achieved by simply not doing lists:reverse since the
function naturally reversed it. Now, to follow the algorithm backwards
step by step, there is now a lists:reverse at the end of
six_bit_chunks which then has to be undone by including a
lists:reverse in five_bit_chunks.
- Add in algorithm step numbers to comments. Leaf check-in: 8d51987b6f user: base@atomicules.co.uk tags: polyline, trunk

2014-10-17
20:17
Fixes for non-negative numbers

But confusingly fixed by fixing the negative numbers which already
worked, but just not the way I thought they were working.

I.e. I forgot bin_flip returns a string so the If statement I had which
just returned Shifted_binary in the case of non-negative numbers would
then fall over on the following steps because it wasn't a string.

Change so this bit just deals in numbers and not strings.

There will be lots of bitslike this where things can be simplified by me
not following the algorithm quite so literally. check-in: 9356c1341b user: base@atomicules.co.uk tags: polyline, trunk

2014-10-16
22:04
Finish decoding as per the algorithm example steps 11 back to 1

Certainly inefficient and definitely not pretty. But decodes the
example on the Google algorithm page. Yet to test with a full example
where I'm sure I will find bugs. check-in: 916a5d5dcb user: base@atomicules.co.uk tags: polyline, trunk

2014-10-15
11:47
Make decoder work back from step 11 to 3

Practically there. Adds in decoding steps 5 to 3. Not sure yet if
checking for last bit being 1 is the correct way to assess if a negative
number (steps 5 and 3), but can investigate that later.

There is also a lot of redundancy I'm sure i can remove. I.e. continual
conversion between binary numbers and the string representation of that
binary number. Some of this may not actually be necessary. check-in: 9af5aeb4b8 user: base@atomicules.co.uk tags: polyline, trunk

2014-10-13
21:04
Corrections to make decoder work for step 11 back to 5

- eight_bit_chunks expects a list of chunks not a continuous string,
rename variables to suit...
- but then does get flattened into a string for the eight_bit_chunks_
sub-function. Makes more sense this way. Maybe
- Fix reversing everywhere (ish, probably could still improve this) to
suit algorithm requirements
- Add padding function to add zeros to front of binary numbers as
required to get the correct chunk length
- nthtail usuage was off by one because I didn't realise it starts from
n+1 check-in: fc13512bf0 user: base@atomicules.co.uk tags: polyline, trunk

2014-10-04
20:29
First commit of polyline decoder work, still WIP

This compiles and the functions work so it'll do as a baseline / first
commit, but it is some way off being finished and it is not at all
elegant. check-in: 81d2c007ea user: base@atomicules.co.uk tags: polyline, trunk

2014-03-11
14:43
Merge branch 'master' of github.com:atomicules/heads-I-lose check-in: 736cabe83d user: base@atomicules.co.uk tags: trunk
14:41
Better error handling when run from command line

The main problem I had was if the API was down it would catch the error
as intended, but still crash out (and create a crash dump file) because
of the use of `init stop` on the command line; it was crashing because
it was trying to stop something that wasn't running!

So I've changed my command line call and now call `init stop` wih the
script itself.

HOWEVER

I didn't want that to mean an erl shell would be exited if an error
occured (that's not going to help debugging) so I had to check how the
code was being run (from command line or in a shell) and do the
appropriate thing.

Also decided to catch everything, not just errors (also exits, etc) and
export the `get_weather` function for more useful debugging in the
shell. check-in: 2a1ffd0bc9 user: base@atomicules.co.uk tags: trunk, v1.0.4

2014-02-11
12:21
Add license check-in: e71cd8520c user: atomicules@users.noreply.github.com tags: trunk
2013-12-21
01:07
Retabbing again only check-in: 3eda6df559 user: base@atomicules.co.uk tags: trunk
01:04
Re-tab only

(Yes, I should probably stop using tabs) check-in: b4f1b3ddfd user: base@atomicules.co.uk tags: trunk

00:58
More fun with mapping

No reduction in lines, but does remove some of the repetitive code. check-in: b034bf9b3e user: base@atomicules.co.uk tags: trunk

00:39
Minor update to README todo list check-in: 8550bc71d0 user: base@atomicules.co.uk tags: trunk
00:37
Report out temperature as well check-in: 5539b4fd26 user: base@atomicules.co.uk tags: trunk, v1.0.3
00:28
Add support for reporting out weather types check-in: 40a75bd38c user: base@atomicules.co.uk tags: trunk
2013-12-19
14:33
Remove repetitive lines by using mapping function over list

Arguably make it less readable in the process, but ho-hum. check-in: 454402e1f7 user: base@atomicules.co.uk tags: trunk

2013-12-17
14:07
Add in basic error handling of timeouts (and badmatches in XML)

but still let fatal errors, etc occur. Just trying to be tidier when API
is down/slow or is up, but is returning a response saying it is down! check-in: 0c24f44076 user: base@atomicules.co.uk tags: trunk, v1.0.2

2013-12-13
10:52
Add hint to readme about adding a shell function to run it check-in: bdde3f7671 user: base@atomicules.co.uk tags: trunk
2013-12-12
12:52
Report out actual direction, speed and gust to make more useful

Still could do with intepreting weather type, etc to know if raining.
And take into account the actual speeds check-in: 69547fc18e user: base@atomicules.co.uk tags: trunk, v1.0.1

2013-12-03
15:18
Make get_locations ok from command line, tidy up, update README

For initial "release"

- Integrate start and headsilose. Silly me, don't need a a function with
a separate name, just separate arguments
- Make get_locations work from the command line with a search term
- Tidy up the export of functions
- Finally tidy up the unused variable warning on Status when reading the
API key

In the README

- Remove done todo, add new ones
- Much more detail into usage section
- Add credits check-in: c55cd91138 user: base@atomicules.co.uk tags: trunk, v1.0.0

14:12
Correct ref link in comment check-in: 0427608d2b user: base@atomicules.co.uk tags: trunk
13:04
Add basic search/filtering of locations via XPath

Won't help with cass/capitalisation issues, but is better than nothing check-in: e185b7b72f user: base@atomicules.co.uk tags: trunk

09:31
Format output of get_locations instead of dumping XML

Still could do with adding in some kind of search, etc check-in: 9e99dc8440 user: base@atomicules.co.uk tags: trunk

2013-12-02
13:08
Make suitable for command line usage

- Add `start` function to split out Args
- Add instructions on uages to README check-in: 6c403e3238 user: base@atomicules.co.uk tags: trunk

11:54
Add in sidewinds and Merge headsilose and get_weather functions

Also:

- Correctly format date string for leading zeroes check-in: 413a10ab29 user: base@atomicules.co.uk tags: trunk

2013-11-28
13:05
Much nicer construction of opposites using map check-in: 672c5aaab9 user: base@atomicules.co.uk tags: trunk
2013-11-27
13:12
Basic functionality all working now!

For a given location and heading (direction of travel) will tell me
whether heads_i_lose (headwind) or tails_i_win (tailwind).

Since wind direction is the from direction and heading (as far as I'm
concerned) is the to direction, a head wind is defined as anything 2
compass points either side (on a 16-point compass). A tailwind is
anything else - which isn't true, but I didn't say I was finished yet.

Needs lots of tarting up as well. check-in: 24f0fa2f55 user: base@atomicules.co.uk tags: trunk

13:10
Set xpath correctly depending on time of day func is run check-in: 4e5197c3fb user: base@atomicules.co.uk tags: trunk
13:09
Add .gitignore check-in: e094ab13db user: base@atomicules.co.uk tags: trunk