January 19th, 2009 — 4:53pm
I’ve just finished the interface for browsing the work day by day. It took much more time then anticipated. This was because as soon as I jumped to another day the program started slowing down to an unacceptable level. I had to figure out why that happened before I could carry on. Finding that out and fixing it took me about five hours!
I finally discovered that a drawing new heart-beat graph slowed down the program because it got bigger with every new day you clicked. This graph is build up from thousands of dots and lines. To make the animation go faster I had to remove those first. But I put them in the wrong place so I couldn’t remove them. I had to rewrite the code for building the graph so I knew where all the lines and dots were and then I could remove them. Now with every day you pick the old graph is removed and a new one is drawn and the speed stays the same.
On the net I found this really nice code for adding listeners to the seven buttons in a dynamic way:
addEventListener(MouseEvent.CLICK, mouse_click);
function mouse_click(event:MouseEvent):void {
var object_name=String(event.target.name);
for (var i:int = 0; i < 7; i++){
if (object_name == day_btn_array[i])
{
get_day_data(event);
}
}
}
So instead of writing all the listeners by hand I now only have three eventlisteners (only one is shown here.) With every click the function finds out what button was clicked. It calls the appropriate function and passes the original click event. In the called function I again retrieve the name of the button from that event using event.target.name again.
Comment » | Uncategorized
January 8th, 2009 — 5:38pm
Yesterday I discovered something very disturbing. The XML file with the GPS track was missing 40 tracks in the log for the fourth. Not at the beginning or end but just, somewhere…?! This file has thousands of nodes and is almost 1 Mb big. A node looks likes this:
<trkpt lat=”52.387110000″ lon=”4.909017000″>
<ele>48,5</ele>
<time>2009-01-05T07:46:35Z</time>
</trkpt>
That’s very easy for a computer to read but not for a human.

screen dump of compare_times output
I had to come up with a way to pinpoint the gaps. So I started to write a program called compare_times. I wanted a way to compare the times logged by the Suunto watch to the times stored by the GPS logger. Usually I don’t need the time node of a GPS track but now I could use it to see if the times weren’t matching at places. I output the times side by side to a file so I could compare them. And yes indeed, at some point they were not matching anymore.

Times in the GPS log that need my attention
So now I had to enhance my program so that it would point out to me exactly where things were going wrong. It’s impossible for a human to see for example two tracks missing at say 17:48:13 and 17:48:23 on a whole day. I decided that I would count the tracks in every minute. If there weren’t six tracks (logs) in one minute something was wrong. It sounds easy but it wasn’t all that easy to program. But I worked it out and ended up with a clean list of attention points so I knew where to look.
Mending the data was more work then writing the program. This was especially true for the log of the fifth. There 200 tracks were missing! Sometimes six minutes of data were just not there. Now I’ve got the day data of day 1 to 4. I hope the other days won’t be as bad.
Comment » | Uncategorized
December 10th, 2008 — 2:16pm

Custom marker in Google maps for Flash
Yesterday I continued with my Flash web app. I’d already done some tests with part of the application. For example displaying a map inside Flash. Only recently Google maps have released an API for working with Google maps inside Flash. This makes it very easy to include (interactive) maps inside your Flash app. Of course when you want different things it’s harder
I want to display two maps, one for Amsterdam and one for Breda. On the map you can follow me around for two weeks. I wanted to use a fitting icon to display where I have been. So I designed a heart to indicate where it was beating at a certain time. I thought it would be simple to display my custom marker. But I could only find difficult and not so logical examples explaining how this is done. So with a fresh mind in the morning I took a new look at the documentation and worked it out. As it took me quite some time to work this simple code out I’ll just repeat it here for those interested:
function onMapaReady(event:Event):void {
map_a.setCenter(new LatLng(b_line_array[2],b_line_array[3]), 14, MapType.NORMAL_MAP_TYPE);
var a_icon:Marker = new Marker( new LatLng(b_line_array[2],b_line_array[3]),
new MarkerOptions({
icon: new my_icon()
})
);
map_a.addOverlay(a_icon);
}
So in my library I have a movie clip called (linkage) my_icon. I use this for the Amsterdam and the Breda map, except that it’s called b_icon there, the rest of the code is the same. Make sure you import the marker classes:
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
And add the overlay, then you’re done.
Comment » | Uncategorized
December 5th, 2008 — 7:00pm
Today I finished my program for combining data from different files. There will be three different files at the end of a day. A text file with lines and tab separated data containing all the data recorded by the Suunto watch. A gpx file that contains GPS data in xml format. And a text file with lines and tab separated data which holds time and activity data.
I placed myself for the daunting task of combining these different files and formats into one tab separated text file. As Flash can’t output a text file I chose Processing for the job. It appeared the capabilities to work with strings are rather limited compared to ActionScript or PHP. But they do have a very convenient XML element class. It was actually the first time I worked with an XML file in this way (that is extracting attributes from an XML node). The loadStrings function is very handy for loading external data and putting it into an array at the same time. In one big loop I cycle through all the files, add a concatenated line at the end of every loop. The result is a tidy text file with only the necessary data in a structured format.
A day well spend 

Merging three files into one (day_data.txt)
2 comments » | Uncategorized
December 4th, 2008 — 9:15pm

Flash Lite app with Shuriken component
Part of the data I want to log and show are my activities. I’ve wrecked my brain trying to think of an easy but digital way of keeping track of my activities during the day. That data should consist of a time stamp and of course my activity. I imagined an application which would run either on my PDA or on my mobile phone. I would have to be really easy to work with as I’ll be using it for two whole weeks on a constant basis. I was thinking of a drop-down menu or combo-box which would hold all my possible activities (hmm, is that possible). Once I’d have selected an activity it would be stored on the device together with a time stamp indicating the current time. The next morning I would download the data from the device and integrate it with other data collected the previous day. Sounds simple right?
My first thought was Excel, as this is an easy way to store structured data and output it in different formats. But the power of my pocket Excel is limited and after some time I realized that you can’t use VB Script so that solution went down the drain.
By chance I realized that Flash (dear Flash) can also store persistent data. This wasn’t something I had worked with before but it sounded promising and I could use it on my Nokia. At first I developed a desktop version. When I got that working (sorting the collected data proved to be the most difficult task) I discovered that I couldn’t use the combo-box component on my Nokia, it wasn’t supported. But thankfully there are geniuses out there who made custom components for handheld devices! After I’d finally set them up other parts of my AS3 code weren’t working on Flash Lite, which supports AS2. But after a about a days work I can’t get the application to really store all the data. The sorting again is a problem (1, 10, 11, 2) pfffff. So this afternoon I made the very uncharacteristic decision to give up this application. Time is pressing. I still have to build… everything really.
So now I feel quite relieved and have decided I’ll use pencil, paper and my watch to collect my activities.
Comment » | Uncategorized