Archive for the ‘Technology’ Category

Tiled Maps 2.0

Thursday, July 11th, 2013

TiledMaps iconAfter quite a lot of tinkering, and a quite a lot of distraction with real life adventures, Tiled Maps 2.0 is out. There’s been a substantial change under the hood so it should load a lot faster and handle many more maps, but there are new features too:

  • Displays GPX files so you can take your tracks, routes and waypoints anywhere you go
  • Drop pins on to the map to record points of interest
  • Adjust the transparency of maps so you can mix topographic and shaded relief layers together
  • Reorder maps to stack them how you wish
  • Resizes nicely on iPhone 5 screens (yes I know I’m late on that one, but did you see I’ve now got a son to look after?)

Here’s a comparison of a USGS Topo map with and without a semitransparent shaded relief layer

Shaded relief demo

There are still a few more features to come, specifically related to GPX files, so grab Tiled Maps while it is still only 99¢.
You can get more information over at or on iTunes.

NoCowboys security failure [updated x2] [fixed]

Friday, October 19th, 2012

  A few months ago while looking for an arborist my wife listed the job on, a New Zealand website for finding and rating businesses. Because of the way jobs are manually checked before appearing on the site there is a delay after submitting before you can tell if it worked. While I was trying to work out why the job hadn’t appeared on the site yet I happened upon a gaping hole in their security which enabled me to edit any other job on the site as well as see all the correspondence between clients and businesses. Most of the correspondence is either the client giving their address or the businesses providing a quote. Obviously giving out an address is not great, but the quote can be harmful too. While I couldn’t change what the quotes were, I’m sure businesses would find it useful to know what the competing quotes were before providing their own one. It’s also possible to reply on behalf of the job-lister, and thus turn down quotes to ensure yours was the only one that got through. But this is only half of the site. The other half is being a business. If they have the same lack of security on that side then it will be trivial to edit the quotes from your competitors and destroy their reputation by adding a few swear words here and there. I haven’t been able to verify if such edits are possible because it costs $299NZD to register and I’m not paying for the privilege of checking their security any more than I already have. Still, I’m prepared to assume that if it is the same developer across the site they’ll have made the same basic mistake everywhere.
; ; ;Before I explain what this mistake is I should point out that I emailed NoCowboys about this in July, and again in October. I told them exactly how to perform the hack and suggested the cause and a fix. I have heard nothing from them and they haven’t fixed it. Hopefully by putting this in the public domain they’ll take more notice. Who knows, maybe we’ll see a listing under their Computer and IT Security section.
; ; ;So finally, what is this hole then? It’s simple, staggeringly simple. You need to register first and then login. If you had listed a job you could go to the edit page, or use this URL as an example: except instead of XXXX you’d have a job number. All you need to do is change the job number to the one you want to spy on and you’ll have full write-access to that job. The only security check they do is that *someone* is logged in, they don’t check who is logged in. Authentication but not authorisation.

Update : Oct 20th
It gets worse. The whole point of NoCowboys is to see opinions and ratings from other customers of the business you’re looking at to decide if you want to use them. So it’s not good that businesses can edit any review on the site. All a business needs to do is use this URL as an example and fill in the review number they’d like to edit.

Update 2
NoCowboys have contacted me and are working on a fix. Apparently the contact email address wasn’t working so this was the first they heard of it :/

Update 3: Oct 21stNoCowboys have fixed the problems. That was pretty quick from when they first read my messages. If it hadn’t been for the faulty feedback form on their site they would have had enough time to fix it in private and the world would never have known.

Introducing Tiled Maps

Tuesday, October 16th, 2012

I’m proud to announce Tiled Maps has been accepted into the iTunes app store and now available for purchase. TiledMaps iconTiled Maps lets you take your maps with you where ever you go. The maps are stored on your iOS device so you’ll have access to them when you’re offline, which is great if you’re keen on taking long walks beyond cellphone coverage like I am. Tiled Maps is based on the TMS specification just like Google Maps and OpenLayers. Further information on how to prepare maps and load them into the app is available on the guide page.

Tiled Maps takes full advantage of what ever device it is on, meaning a specialized interface for iPhones and iPads, not just a stretched screen like some older map apps. The map can follow your location and even rotate the maps to match the way the device is facing if you prefer to be “in the map”.

TiledMaps iPad screenshot
TIledMaps in the app store now

Quickly recover images from an iPhone backup

Tuesday, August 14th, 2012

If you accidentally delete images from your iPhone (or in my case allow iPhoto to delete them after an import only to find the import corrupted them) you can easily recover the images using this method so long as:

  • You backup your iphone using iTunes
  • The backup is unencrypted
  • You haven’t backed-up (backuped?) the iPhone since the images were deleted

The first thing to do is find the backup folder on your harddrive. It should be in “~/Library/Application Support/MobileSync/Backup”. You’ll have a folder in there for every device you back up, finding out which one is for the current device is an exercise for the reader.
Inside your selected folder will be a lot of files. I have 6000+. The ones you are interested in vary according to which device and which camera (front or back) took the photo. You can guess the size of the standard jpegs your camera produces or just grab all the files between 1 and 6mb. Copy them to another folder and open a Terminal window there.
Now run this command in the terminal to give all the files a .jpg extension.

for i in *; do mv "$i" "${i}".jpg; done

Most of the files will now open in Preview so you can find your lost photo. The files that don’t open weren’t really jpegs. They might be pngs if they were screenshots, or they could be any other file from your device.

WMS GetFeatureInfo spanning the dateline in OpenLayers

Friday, July 27th, 2012

If you’re using OpenLayers to draw a WMS layer and calling GetFeatureInfo, you’re probably having trouble when looking across the antimeridian, where 180° longitude becomes -180°. This is because OpenLayers sends a bounding box to the WMS server (I’m only dealing with Geoserver 2.1.4 at the moment, not sure on other systems) that includes coordinates beyond the normal limit. If centered over New Zealand it might send a bounding box stretching from 160° to 190°. If your data is in normal (-180->180) space Geoserver won’t find any of the data beyond 180 and if you convert OpenLayers to sending rationalized coordinates (160° to -170°) Geoserver will complain that the minX is greater than the maxX. So what are we to do?
The solution I have come up with is to trim the box you are sending to the server so that it doesn’t cross the dateline. depending on where you were clicking in my example you’d either send 160° to 180° or -180° to -170°. The trick is to work out which side of the dateline you clicked on and which side your view is based on. If your view had been centered on the Chatham Islands OpenLayers would see those same boundaries as -200° to -170°.

Starting from the OpenGeo code to query a wms layer using OpenLayers I added come calculation to trim the bounding box and shift the X and Y values (which are the point the user clicked relative to the top left of the bounding box) if the left boundary has been moved.'click', map, function (e) {

bbox = map.getExtent();
width = map.size.w;
clickX = e.xy.x;

//Start dateline solution
clickRatio = e.xy.x/map.size.w;
fullMapWidth = Math.abs(map.getMaxExtent().left) + Math.abs(map.getMaxExtent().right);
if (bbox.right > map.getMaxExtent().right)
datelineRatio = (map.getMaxExtent().right-bbox.left)/(bbox.right-bbox.left);
if(datelineRatio < clickRatio)//Click was far side of dateline, normal bbox would not find data
bbox.left = map.getMaxExtent().left;
bbox.right -= fullMapWidth;
clickX -= width * datelineRatio;

width = width * (1-datelineRatio);
} else if (bbox.left < map.getMaxExtent().left){
datelineRatio = (map.getMaxExtent().left-bbox.left)/(bbox.right-bbox.left);
if(datelineRatio > clickRatio)//Click was far side of dateline, normal bbox would not find data
bbox.right = map.getMaxExtent().right;
bbox.left += fullMapWidth;
width = width * datelineRatio;
//end dateline solution

var url = wfsPath
+ "?REQUEST=GetFeatureInfo"
+ "&EXCEPTIONS=application/vnd.ogc.se_xml"
+ "&BBOX=" + bbox.toBBOX()
+ "&X=" + Math.round(clickX)
+ "&Y=" + Math.round(e.xy.y)
+ "&INFO_FORMAT=text/html"
+ "&QUERY_LAYERS=" + wfsLayer
+ "&LAYERS=" + wfsLayer
+ "&SRS=EPSG:900913"
+ "&STYLES="
+ "&WIDTH=" + Math.round(width)
+ "&HEIGHT=" + map.size.h;,

Making radio buttons deselectable, like checkboxes

Tuesday, April 10th, 2012

Here’s a quick hack to give a set of radio buttons the ability to each turn off like a checkbox would if clicked when already selected. It requires JQuery and you can see it in action on JSFiddle.

$('[id*=radio_]').click(function() {
previousValue = $(this).attr('currentValue');

if (previousValue == "ON")
$(this).attr('currentValue', 'OFF');
} else {
$(this).attr('currentValue', 'ON');

var currentId = $(this).attr('id');

if ($(this).attr('id') != currentId)
$(this).attr('currentValue', 'OFF');



Restore colour to iPhoto 9.1.5

Tuesday, July 12th, 2011

Apple has just released iPhoto 9.1.5 and has continued its trend towards dull grey icons, which I really don’t like. So I’ve bundled up the coloured icons from 9.1.4 and simple instructions for their installation. Someday I might automate the installation, but for now it’s just a manual copy (and authenticate).

Download iPhoto9ColuredIcons

Update 2012-01-22: I’ve tested this in iPhoto 9.2.1 and it seems to be working fine.
Update 2012-05-08: I’ve tested this in iPhoto 9.2.3 and it seems to be working fine.

Geotiffs: Stage 1 seamless USGS map tile sets

Tuesday, June 7th, 2011

For a little while now I’ve been manipulating the excellent USGS geotiffs to fed my PCT mapping fetish. Since I’ve worked out a good enough system I thought I might share it with the world.

First off you’ll need a bunch of stuff installed on your computer.

With those installed you’re ready to follow my process.

1. Remove the collar

The USGS maps that I’ve been using come with a ‘collar’, that bit around the outside of the actual map data that you’d have to cut off if you were printing them out and sticking them together.

USGS maps with collars

Before cutting the collar off make sure to keep a copy of the original tiff because most image editing programs will lose the geo data when you press Save. In Photoshop I had to convert the image to RGB mode so that I could make the outside part transparent. It’s important not to change the size of the image. The embedded coordinates are for the corner of the tiff even though the map doesn’t reach there. Save the image and get back to the command line for step 2.

USGS maps with collars

2. Restore the geospatial data

The new tiff you have just saved does not have the embedded coordinates that it started with. So long as you kept a copy of the original file you can reinstate the data using the following command and the gdalcopyproj program.

> original_file.tif new_file.tif

3. Create a Virtual Tile Set

If you’re combining multiple maps you’ll either need to merge them into one large file or create a virtual tile set like this

>gdalbuildvrt -srcnodata b4 -hidenodata merged.vrt *.tif

The “b4″ tells GDAL that band four of your images is the transparency layer, and the “hidenodata” tells it that when two maps overlap, hide the one that has no data (is transparent). Without that the transparent collars of the geotifs erase useful content from geotifs they join up with.

You can merge the files like this

> gdalwarp -co COMPRESS=LZW *.tif merged.tif

But it won’t do the compression until the end, so with USGS maps you’ll be generating files over 1GB even if you only have a few source maps. The virtual tile set method is definitely quicker and takes less disk space.

4. Cutting the tiles

The following command will take either your merged geotif file, or the virtual tile set as the first parameter and an output directory as the second (which will be created if it doesn’t exist).

> merged.vrt tiles

The process can take quite a while, but it starts with the most detailed layer and each one after that is about 4 times faster than the previous one. When it’s complete you’ll have a full TMS tile stack ready for use on web map systems such as Google Maps and OpenLayers and my iOS app Tiled Maps. Next time I’ll post the scripts I use to optimise a tile set down from ~1.7Gb to 700Mb.

Adding locations to iMovie ’09

Tuesday, March 10th, 2009

The latest incarnation of Apple’s iMovie has many cool new features and I’m coming around to using it rather than iMovie HD 6 that I’ve kept hold of all these years. Among them is an animated globe that draws a line Indiana Jones style.
Globe in iMovie '09 As great as that seems you’re stuck with the 1600 or so locations that Apple chose. You can rename them but not change the coordinates. That’s where iMovieLocationEditor comes in. It simply adds new locations along with the names you’ve chosen (can be changes within iMovie just like the originals). You can type in the coordinates in you know them but it’s much easier to find it in Google Earth and then press the big button to import it into iMovieLocationEditor.

Apple changed something in iMovie 8.0.1. If you’re not seeing the changes appear in iMovie download version 1.03 and give that a try. If you think you’ve corrupted your location list you can download my backup.

GPS track interpolation in iPhoto ’09?

Wednesday, February 18th, 2009

Anyone who would be interested has probably already heard about the Places feature of iPhoto ’09. Usinghidden tables in iPhoto database embedded Google Maps. Once you’ve done that you can browse photos by location and make some very nifty photo albums with maps. There’s more to it than that but I’d be about the millionth person to review the new features of iPhoto ’09 if I did so, so I won’t. Instead I’m going to tell you about a feature that is missing, but one that Apple have clearly been playing with.
My Geotagger program has been out for a few years now and people have been happily (and least I think so) geotagging their photos. If this is done before importing them to iPhoto everything is fine, but doing it once they are already in iPhoto’s database means that iPhoto doesn’t know about the change and consequentially won’t draw these photos on the nice new maps Apple have added. So to find a solution for this I’ve been digging around in iPhoto’s database file. It’s a simple SQLite database but I haven’t fully solved it that part of the equation yet.
The interesting thing I found, and the reason I’m telling you about this before I have finished an update to Geotagger, is that in the database I found two unused tables. For those of you that don’t know about database and tables pretend I said I just found two very interesting lists. The tables are called SqGpsTracks and GpsTracksEventsJoin. What this tells me is that Apple were working on the ability to link a GPS track with an iPhoto event for people that may have a GPS Datalogger and a camera as separate devices. iPhoto would then be able to match up the time a photo was taken with the GPS log and work out where the photo was taken. This process is pretty well documented already and I’ve been doing it for ages using Jeffrey Early’s excellent GPSPhotoLinker. It could also mean the display of routes on the embedded maps, but that can’t be proven at this stage.

Though I welcome this feature for the masses I have never fully trusted iPhoto to do any editing of my pictures. I”m quite happy doing all the editing and geotagging before hand and just using iPhoto to store and display pictures, but for those that want an integrated solution this would definitely be a step forward.

UPDATE: Others have been discovering similar things, Adam looked in the nib files and found more proof that Apple is working on interpolation.