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 WildmanSoftware.com or on iTunes.

October 19th, 2012

  A few months ago while looking for an arborist my wife listed the job on NoCowboys.co.nz, 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: http://www.nocowboys.co.nz/jobs/myjobs/XXXX/overview-v2 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. http://www.nocowboys.co.nz/edit-my-rating/XXXX.

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.

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

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.

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.

map.events.register('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;

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');



February 7th, 2012

See the update at the end of the article

By now most people in New Zealand are probably aware of the Health Sponsorship Council’s decision to edit their “Smoking not our future” ad, or as the New Zealand Herald put it “Piri Weepu’s baby bottle advert ban” (for further reading check the links at the bottom). Though the article did say that breastfeeding support group La Leche League‘s opinion was canvassed (among others) it also incorrectly attributed an email campaign to them and left the general populace with the incorrect assumptions that LLL were butting in where they weren’t welcome, had started a campaign and banned the advert. In reality they merely provided feedback when asked that resulted in 2 seconds of film being removed while still maintaining the message of positive male parenting through a smoke free environment. The 2 second clip featured Piri Weepu, a hugely popular All Black after his incredible kicking efforts during Rugby World Cup 2011, bottle feeding his daughter. The Ministry of Health is actively trying to increase New Zealand’s low breastfeeding rate so the feedback from all the groups was to remove the clip and thus try to prevent undermining an important government funded health campaign. There was never any comment that Piri and his partner should be breastfeeding, there was no criticism of them at all, only that the images this ad may have contained would work against other ads. But alas this was lost in translation into eye catching headlines. On most Herald articles there is link to send a link out via Twitter and a link to see who had already done so. Today I followed that link and immediately saw someone who had got the wrong end of the stick and thought I could perhaps correct them. It didn’t work, and I got labelled a troll, spam and an ass for trying to stand up for reality. Here is the transcript of the back and forth with @kchawkings:

KH: Hell to the yes! Go Piri! “They are my kids, I’m not going to have anyone tell me how to raise me kids.” http://nzh.tw/10783857 via @nzherald

CS: @KCHawking ….said the man in the how to raise your kids advert to the people not telling him anything about raising his kids.

KH: @craigstanton dude, do you have nothing better to do than hunt down every mention of that article on twitter?

CS: @KCHawkings @NZHerarld linked to all the tweets at the top of article, I’m just doing what I can to correct a massive misunderstanding.

KH: @craigstanton And again I ask: Do you have nothing better to do? @NZHerarld

CS: @KCHawkings Do you have nothing better to do that comment on the article to start with? Maybe spend some time looking into the facts first.

KH: @craigstanton I commented because I support Piri being a great role model for fathers everywhere. Did they not stop to think that the benefits of the images would outweigh the negatives? That’s not to mention the numerous reasons a baby may not be able to drink from the breast. A fair amount of the people who follow me subscribe to the same beliefs, judging by the positive response I’ve received. As far as I’m concerned there is nothing wrong with Piri bottle feeding his daughter, and in my opinion it’s PC bullshit gone mad. It should never have been an issue in the first place. Now get off your high horse and go SPAM someone else, because that’s all your tweets are: Short Pointless Annoying Messages.

CS: @KCHawkings The benefits existed in all the other shots in that ad. They made no comment at all about whether or not he should bottle feed. I made that comment in support of a wonderful volunteer organisation who were asked and gave their opinion.

KH: Come on Kate, there’s no need to feed the trolls. Just because some guy is being an ass doesn’t mean you need to reply. Just block him.

CS: @KCHawkings I’m not being an ass, read what really happened, you’re dumping on a great bunch of people because the NZHerald misinformed you

There seemed no hope of getting the message across that LLL had not told Piri or any other parent what to do within the confines of Twitter, so as a last ditch attempt I have emailed her directly and await a reply, though I honestly don’t expect one.

I’m sorry if I came across as an ass to you, that was never my intention. Nor to troll nor spam. If you’re willing to hear what I have to say about how the NZHerald has twisted what happened then please read on. If you’re already reaching for the delete key then you can at least be sure that I won’t try to contact you again.

I’m glad you’re still reading. I read the Herald article and saw the link to tweets that mentioned it so I went to see what people thought. I was really surprised at how many people thought that the breastfeeding group, particularly La Leche League had criticized Piri in some way. They definitely didn’t. They have no knowledge of his situation and even then I’ve never known them to criticize people for their choices, they just provide support for people who have made the choice to breastfeed. Despite the headlines of “ban” and “protest” etc etc what actually happened was very simple. The Health Sponsorshop Council made an ad to promote the non-smoking message. They consulted with multiple breastfeeding groups and received the same feedback from all, that the bottle feeding scene would go against another government funded health message trying to make breastfeeding more acceptable. It was not an attempt to degrade the value of bottle feeding, they have been very clear on that. The HSC edited out 2 seconds of footage from the ad and maintained their message that a loving, caring dad looks after his children in a non-smoking environment, with absolutely no comment on how he chooses to feed them. If it ended there the ad would have gone to air and no-one would have any anything to worry about. But then the Herald ran a piece that many people misunderstood to mean that these groups wanted the whole ad banned, and that they were having a go at Piri when then really weren’t.

So why do I care? Well I know a lot of people involved with one of the groups that were asked for feedback. They are wonderful mums giving so much time to a volunteer organisation that is saddens me to see so many people calling them names like Nazis and Breastapo. Some of them even bottle feed their children, but are still on hand to offer advice on breastfeeding when it is sought. They were simple asked their opinion and gave it, then New Zealand replied with an outpouring of hate. It was a matter of keeping New Zealand health messages on target and not contradicting each other. Akin to making sure no-one in a sober driving ad is smoking. Your tweet seemed be based on what I thought would be a simple to correct misunderstanding about what the groups said (or in fact didn’t say) about Piri’s parenting. I had hoped that if I could point you towards the facts of the case you might see that you were mislead and that there would be one less voice denigrating the work these ladies do.

With all that said I really am sorry if you felt harassed on Twitter, or if this email is too much. Your website has a Contact Me button so I figured you’d be open to listening to random strangers from the internet. I won’t bother you again.

Craig, proud father to be, T minus 10.5 weeks and counting :-)

Further reading:

NZ Herald feedback page
La Leche League’s press release about the ad
La Leche League FAQ about supplementing milk supply, note there is no judgement in the words “…recommending a specific infant formula is beyond the scope of La Leche League. Please consult with your health care provider.”

Health Sponsorship Council’s response to the Positive Men group on Facebook when asked to reinstate the footage

Thank you for your interest in the Smoking Not Our Future ad.

As part of a standard post-production process we identified the (two-second) bottle-feeding shot as one for possible re-editing two weeks ago. As a result we asked for comment from La Leche League NZ and Plunket NZ. After receiving feedback a decision was made last Wednesday (1 February) to replace the shot with one that continues to show Piri in his role as a loving father, providing a smokefree home and car for his whanau.

The advert will go to air Sunday 12 February as planned.


Update Sept 6th: 2012
The Press Council has upheld a complaint by La Leche League about the NZHerald’s coverage of the story. A few important points are:

  • The League did not mention Piri Weepu or comment on his fathering skills.
  • The Council notes that the newspaper is now willing to make a correction, but the claim as published was a serious one, it did cast a slur on La Leche, and the Council finds no evidence that the League called Weepu’s role as a dad into question.
  • That this was not the image at the centre of the controversy should have been made clear to readers.
  • It did seem to the Council that at times the La Leche League was being pilloried for things they did not say or believe.
  • The Council does not believe that the use of the word censorship is warranted. The League made a suggestion, the HSC considered the suggestion and willingly removed the image from their own advertisement. This is not censorship.

Unfortunately the Herald was not so keen on publishing the correction. Relegating it to page 34 and not putting it front and center like they did with their original inflammatory articles. So, Miss Hawkings, if you’d like to apologize the door is wide open.

October 19th, 2011

Hey there uncles, aunts and cousins,
I’m happy to now be able to tell you about a new project I am managing. As you know I partnered with a developer (Tania McBeth) late last year and we’ve just passed the alpha stage with Version 2. Now that we’re in beta I can announce it publicly and start sharing screen shots (attached). It’s a self-funded start-up venture with an expected ROI of approximately 30 years. The central processing unit is up and running with basic motor control established. If everything goes to plan we’ll have a release candidate in autumn and will be going gold master on April 20th 2012.

~Craig, and Tania, and version 2.0

P.S. Right now I’m under sedation from a wisdom teeth operation so I’m explicitly forbidden from driving and “making important decisions” so the talk about product branding will have to wait a few days.

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.

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.

> gdalcopyproj.py 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).

>gdal2tiles.py 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.