Sunday 5 February 2012

Garmin Communicator Plugin

I've been intending to write about this for sometime but Blogger has been uncooperative and would never let me make a new post. I suppose I could have drafter it in Libre Office but I didn't and hence I forgot what I was going to say.

Something about my latest squirrel project, not so secret if I am going to tell you about it here. I use Linux, do you ? Ubuntu 11.04 actually with some tests on Mint Felica. Mostly Ubuntu though, I am trying to use Windows as little as possible at home. The only things I use Windows XP for is my GPS and route/track making software (& remoting into work). I use MapSource for my GPS and MS Autoroute to help me generate tracks. I wrote some software a year or so ago to take the output from Autoroute and generate a track, I really must reuse that. I've been working on a web application to do part of what MapSource does with respect to tracks. In particular what I want is to be able to download the track log, clean up the crap tracks and view it on a map, a Google Map actually. I can do most of that with my application. The difficult part was getting the data from the GPS. Easier on Windows with the Garmin Communicator Plugin but sadly it doesn't work on Linux. Andreas Diesner has written a Linux version, (http://www.andreas-diesner.de/garminplugin/doku.php?id=start) which sadly doesn't work with my GPS type, a Garmin Vista C. It's quite old. Well it does now, I have modified the original code. Not only can it read the track log but also send tracks, waypoints and routes to the GPS using gpsbabel as an intermediary. I've modified gpsbabel also to use the Garmin Track Extension to colour the track on the device using the colour defined in the GPX file.

Get in touch if you want to know more. At some point I'll donate my work back to the original projects, I've been in touch with Andreas so far to do just that.

I'd like to remove the dependency on gpsbabel to make install easier, if I ever publish the whole package, so far this has proven difficult due to my lack of C on Linux experience.

Sunday 18 September 2011

New Washer



Bought from Boots Kitchen Appliances, delivered and fitted and working in less than 24 hours from ordering, on a Sunday too !

Saturday 27 August 2011

Coast & Castles

Coast & Castles

I never thought I'd do a tour like this, don't really know why, this route never really appealed to me so why did I do it ? Because I was invited to, that's all. It's good enough reason.

I was contacted by an old school friend a few months ago, someone whom I'd not seen for about 25 years, we met up and had a short ride with two other people from our home town and they invited me to join them on the Coast and Castles route in August. The route goes from Edinburgh to Tynemouth mostly down the coast of Northumbria and passes many castles en route, we decided to extend it to ride all the way to Hartlepool, our home town.

So we made our plans, Moore booked the B&Bs, we booked our trains to Edinburgh and arranged to meet on the train at Newcastle Central Station. We rendezvoused again in the centre of Edinburgh because my ticket was to Haymarket and not Waverley because it was cheaper.

On the road and soon out of the city; it was busy with tourists and festival people, we got onto the bike track that took us far from the madding crowd in a non direct way, it was mostly downhill and smooth which was nice. It rained before we got to Dalkeith, heavily. I knew Dalkeith, my route would have taken us there more directly but with more traffic, this was better but it felt slow. More heavy rain in Dalkeith. The exit from the town was via a different road to what I am used to, it took us to the same long hill, one which on clear day affords nice views of the Firth of Forth, not today though, drizzly and misty. No traffic, not wind. We rode up steadily and summited more or less together, no one forced the pace, we had plenty of time for our planned distance. Pretty soon on the descent we rode away from the rain and into sunshine, the five mile descent pleased us, particularly the other three chaps who'd not been here before. We kept good pace to Innerleithen where we stopped for a late lunch at the cyclist friendly Whistle Stop cafe. Cyclist friendly ? They loaned us a bike lock to lock our bikes to the metal rings embedded in the wall.

Off again, bound for Kelso. Not difficult cycling, plenty of time to spend messing around on the bike tracks that are part of the route. Had I been alone I'd have probably used the roads but this wasn't my tour, I was just a passenger and it was after all old school touring, just cycling with friends. A bit more rain, heavy, the obligatory Sustrans get lost in an urban area but it's par for the course. The river side path was very nice, quiet, stress free riding, pretty good surface and fairly direct.

We arrived at Kelso around 17:30, fine. Found the B&B OK, The Abbeyside B&B I think it was called. Very nice, the proprietors stored our bikes in the garage and took our wet things to a place to dry them overnight. Rooms were nice, en suite, breakfast was great. We ate at a pub and had some pints. A good day.

No rain the next day, our destination was Seahouses on the East Coast of England. Not a particularly difficult days riding. Meandering along the Tweed towards Berwick we crossed the Scotland-England border three times on traffic light roads. I felt irritated in Berwick with the traffic and people. After lunch we headed down the coast. Now here is where my criticisim of Route 1 really starts, too much on off road paths on the edge of the beach. We all did OK, even me on 25mm road tyres but it was stressful at times. The seaviews were great, it was a bright sunny day and of course no traffic on the paths, except some walkers, cyclists and cows ! We didn't see any UXBs or quicksand despite the warnings. It was a hot day, we were all flagging a bit in the heat, we stopped near the A1, the noise of the traffic was deafening, we pushed on and stopped again in a hamlet on a hill. All downhill from here back to the coast. Budle Bay was nice, Bamburgh Castle was nice and finally we arrived at Seashouses for our overnight. The last mile seemed much longer, the headwind made it harder and our group broke apart. Not for long though. The B&B was very nice. Malabar House. Dinner was in a pub with some nice beer and we chatted mostly about people we knew from school.

A reasonably early start for our longest day, about 90 miles to our homelands, all down the coast with some tricky parts through coastal towns and river crossings to negotiate. We made a short detour to Craster to get some kippers. Pretty soon after Amble we split the group, slower and faster. I was a faster rider. So Moore, my old mate, and I pressed on into the headwind. Once again on the off road path around Duridge Bay. It's very very nice, well worth a visit. Some crappy industrial bits around Newbiggin and Blyth were not so nice though. It took us ages to get past Blyth, huge busy roads that we wanted to avoid meant we found ourselves doubling back and going through estates. Eventually we made it through and back to the coast, it seemed to take us ages though. I was getting a bit irritated by this, it was hot and we had a headwind too. Down the coast to Whitley Bay was more straightforward, it was busy there, as was Cullercoats so we stopped only for a sit down. Tynemouth was busy too but we did eat here. It was nice to sit in the shade and cool down and relax properly. Only about 30 miles to go from here.

We rolled along the north bank of the Tyne to the Sheilds Ferry where we had to wait for 10 minutes or so. Once on the otherside of the river we made pretty good progress on another Sustrans route as far as Sunderland. From here it was plain sailing to our hometown.

It was a good three day tour, relaxing and easy. Old skool touring.

Sunday 12 June 2011

Compress Filter

A simple Java servlet Filter to compress the returned pages

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
PrintWriter out = response.getWriter();

// Create a wrapper to catch the output of the next Filter/Servlet in
// the chain
HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(
(HttpServletResponse) response) {
private CharArrayWriter output = new CharArrayWriter();;

public String toString() {
return output.toString();
}

public PrintWriter getWriter() {
return new PrintWriter(output);
}
};
// pass the request along the filter chain
chain.doFilter(request, wrapper);

String html = wrapper.toString();

HtmlCompressor compressor = new HtmlCompressor();
compressor.setCompressJavaScript(true);
compressor.setRemoveComments(false);
compressor.setSimpleDoctype(true);

String compressedHtml;
try {
compressedHtml = compressor.compress(html);
CharArrayWriter caw = new CharArrayWriter();
caw.write(compressedHtml);
response.setContentLength(caw.toString().getBytes().length);
out.write(caw.toString());
out.close();
} catch (Exception e) {
logger.error(e.getMessage());
out.write(html);
out.close();
}
}

Friday 31 December 2010

OS DEM, why why why ?

With 20 odd years experience in IT, well it wasn’t called IT in the early days, I have plenty of experience in reading data files. One must read from the top to the bottom of the file and generally one processes the first things one reads first and tries to avoid reading and processing any data item more than once. If data is stored in a matrix of rows and columns, the first row read usually becomes row zero and the first column usually column zero.

The OS DEM ASCII data isn’t like that. I am not suggesting it’s wrong or bad, though I was cursing it when I was trying to load it, but the flimsy accompanying document leaves a lot to be desired. That’s quite common though for technical documents, technicians generally make poor communicators, they fail to realise or maybe forget how much prior knowledge they actually have and hence how much the audience might not have. One documents go public the knowledge level of the audience tumbles.

Back to the OS DEM ASCII data; each ASCII file represents a 20x20km square part of the 100x100km grid square denoted by a 2 character code such as SE. Thus there are up to 25 files for each 100km square arranged in five rows of five and they are named to represent their position in the 100km square and hence the data they contain. Using square SE as an example, because I live in that square, file se00.asc is at the bottom left, se20.asc to its right and se02.asc above it. See how the first numerical digit represents the column (eastings) and the second the row (northings). Notice that there are no odd numbers, that’s because the files represent 20 x 20km squares or tiles. The data contained in each one is referenced from the bottom left hand corner of the matrix , the header rows contain the Grid Reference of this point, for example, tile se00 starts at 400000, 400000 and contains data for 20km in the east and north directions sampled every 50 m so we have 401 points in each direction and hence contains data for 400000-420000 in each direction. If you are still thinking at this point you’ll notice that 400000-420000 at 50m intervals will give 401 points and that the adjacent tile to the right/east and above/north starts at 420000 and 420000 respectively giving a one row/column overlap.

Now the data itself seems to be arranged in rows with CR/LF at the end of each row and with 401 data rows, 5 header rows which are not very useful given the meaning file names. Each row contains 401 data values representing the elevation for each point along the x (easterly) axis. So if one printed the document, don’t, it’s huge, one would see the matrix of elevation values for each 50m x 50m square. I wish they’d told me this up front, with such large datasets, manual checking of retrieved values is difficult. So, if you need to calculate the matrix cell for a grid reference make sure you reference it from the bottom left and make sure you placed the first line that you read on the top row and subsequent line beneath it.

The ASCII format is very efficient, only data that cannot be derived is stored, it’s not too difficult in Java to read it into memory in an efficient way either. I read it as a character stream and once I encounter the delimiters, space, CR/LF I convert the number to an int, none of the decimal values of the data are anything other than zero it seems, not in the sample I looked at anyway and for my application accuracy to the nearest metre is good enough. I read 100km squares on demand, that’s 25 files, even if I only need one point. My application will need thousands of points at a time but hopefully all in the same or a few 100km squares. To speed things up in the future I have then serialized my 100km square object into a single file. Subsequent invocations of my application can then load the entire square in about one eighth of the time, less than 500ms on my computer. The data size on disk is slightly larger but with serialized objects we have the opportunity to compress them into a jar file and use the class loader to locate and load them. This adds only a small amount of time to the load of uncompressed file and presents a neat method of transporting and storing static data. To keep things simple, each tile object maintains a map of data, each element in the map represent the data from one of the ASCII files. Accessing it is simply a question of using the Grid Reference to determine first which 100km square then which 20km subdivision and finally which cell within it. In other words I have an object for a 100km square then each of these has a map which has a 2 dimensional array of int to store the elevation data for each cell.

Saturday 27 November 2010

R T F M

RTFM. Google it. Some dude might as well have said that to me when I asked for help with his software. "It works for me" - he said. Great, but that's no help what so ever to me. Since this isn't Chad Valley software I am working with I do presume it's well tested and actually works. I don't always make that assumption. Thus I assume I have made some error in my configuration, that's why I am asking for help. I have read the manual, diligently worked through the tutorial and the software doesn't do what it should do. It works, it works properly but wouldn't permit it to be used in the advertised manner and in the way I want to use it. An error message would have been more helpful, you, the owner, could have been more helpful instead of telling me to RTFM twice. I know it's Open Source and free and you can't give all your time for free helping people use the stuff you have create, I understand, I make a living in IT Support. But you do have a forum with the title " productname Support" and if you want to have people adopt this stuff and pay for consultency and support they need to get a good impression of it from the start. First impressions last. Faultering on the tutorial leaves a bad taste.

Wednesday 3 November 2010

Dark Peak

It was getting colder as we approached the start, the thermometer in the car was reading 0 degrees Celsius. Outside, cyclists were wearing shorts though some were properly muffled up. It was relatively early, the sun was still low in the sky and we were in the shade, the day would surely warm up.

Steve’s front tyre was flat on unloading the car, broken valve. He replaced his tube while I sat in the car keeping warm. Finally about 30 minutes later than planned we started ‘Dark Peak’ with a long climb to Hade Edge, I think. The day was warming up, in the sunshine with the northerly wind behind us it was very pleasant. The air was cool still, it’s October in northern England. Up we went passing two other riders on the climb. On the top we could see that it was going to be a special day. Blue sky, clear and a superb view over the north Peak District with the leaves changing colour as autumn advances. We were heading towards Langsett and then over Strines Road towards the A57. I’ve been on this road before, a few years ago but in the opposite direction. I knew it was hilly, it’s a hilly route in the Peak District after all. Today though, with the recent weather and cold, the roads, particularly the descents were very difficult. The thawing frost was still damp, the fallen leaves were accumulating in the sheltered parts and compressed leaves make for slippery surfaces. Riding into the Sun with no peak on my hat, in and out of shade made actually seeing the road very difficult; coupled with my crashes in the last few years which were with similar road conditions I descended very very gingerly. I was glad of the climbs, non of which were too troublesome. Most were challenging but the speed we rode made them doable.

The first part of the day wasn’t one for hurrying. Super views, little traffic, sunshine, many other cyclists, made it one of those days when you are glad you came out. Lunch in Edale after 50km approximately half way. We missed a turn before this though, just after Derwent Resevoir, probably did about 1km before realising and doubling back. The dark glasses the sunshine and the National Park made it damn nigh impossible to see my track on my GPS. The National Park ? Well, I make my tracks green as they usually show up best. My GPS shades National Parks green too, green on green isn’t very visible and it was hard to see the track with a quick glance which is all I could afford at the speed we were travelling at this point !! At last a flat bit, from Hope to Edale.

The cafe was busy, we arrived at the same time as a group of muddy mountain bikers. They had their coffee outside and soon after we arrived the place was quiet again. Out on the road, the easy pedalling continued for a short while, then the road went up again, for a long time, to take us out of Edale and back into the Hope Valley. There is probably a name for this climb, it was quite spectacular with great views to where we’d been then narrowing until the road cut through a gap in the hill to pop out the other side. It marked the transition to a new landscape, a downhill one out of the hills for a while. Steve enjoyed the main road descent too much and missed a turn, I waited, thankfully he realised very soon that I had stopped and u turned to come back to me. Right, and up another hill then down down down to New Mill. Heavier traffic to Marple but wide roads meant it wasn’t too troublesome. Quick control in Marple. 25km or so to go, only two or three big climbs.

It all seemed much easier to me now, often does in the second half of a ride. The wind that assisted us when heading south wasn’t having much effect when we were heading north. I think the south side of the hills were sheltered but even on the summit of Holme Moss it didn’t seem that windy. It was still sunny and not too cold. After a very long climb out or Marple or was it Glossop we joined the road high up the side of Longendale overlooking the Woodhead road. This is one of my favourite views, seems like a foreign land, the wooded sides of the valley in their autumn colours, the cars on the road so far below us, silent, the barren tops of the hills. We stopped in a car park on the Trans Pennine Trail for the toilets and some water then headed for the last climb of the day, Holme Moss from the easier, Derbyshire side. I’d been up here a month or so earlier, today it seemed easier than then. I’d not spent all day riding into a headwind this time. We cruised up steadily not beaking any records, we kept together and had a brief stop at the top to admire the view. Last time I was here my GPS registered 3m higher than the sign said, 524m, today it was 8m higher, it’s well known that elevation on GPS devices are not very accurate!! It’s all downhill from here, the tarmac had a very thin cover of rain, we’d just missed a shower so we descended carefully and made it to the town about 20 seconds after the Tourist Info. closed – it would been nice to have them stamp out card for the final control. These places justify their existence by the number of callers, I like to support them as I think they add something to a town.

A good ride, challenging but not too difficult to spoil the enjoyment. A nice route made great by the weather conditions on the day. Mostly hilly, 2300m of altitude gain for 106km route, 2.25 AAA points, not much flat but some nice long fast downhills. Some very tricky and dangerous ones too though which on a dry day will be easier.