I had a quiet week at work and had time to make this: www.sheffieldaircadets.uk
It will find the closest squadron to a given postcode, not just as the crow flies, but by realistic driving time (including traffic using the unit’s actual parade times) and public transport route plans.
You might even call it over-engineered but that’s what I do when I’ve got time on my hands!
I’ve included some sample Sheffield postcodes below so you can see some realistic results.
S5 7WP
S6 3EB
S7 1HA
S10 3ED
S13 9BB
S35 4JU
If you use other postcodes then you might run into problems until midnight tonight. I’ve been testing and developing it today and I’ve used up most of the free quota on my public transport API.
All feedback appreciated!
1 Like
I’d love to be able to develop applications like this.
Any resources you’d recommend looking at for an EE?
What’s an EE? Experienced enthusiast? Electrical engineer? They’re my best two guesses!
It’s built using PHP and Javascript.
In a nutshell, the information for each squadron is held in a PHP array. The list and map are generated from that array when the page first loads.
When you run a search, it first checks the cache database to see if a similar search has recently been performed. If it has, it retrieves the result directly from the database. If it hasn’t, it sends requests out to MapQuest (for driving directions) and TransportAPI (for public transport) and waits for a response. This usually takes around 10 seconds. When you search for a postcode there is over 10,000 lines of information returned! Most of this is a series of co-ordinates for drawing the journey plans onto a map, but this information isn’t currently used.
The return information from MapQuest and TransportAPI is in a text-based format called JSON. On the main search page, this JSON is interpreted in Javascript. Travel times are pulled out and inserted onto layout elements which are then made visible, and a marker is placed on the map to show ‘You are here’.
Once you click through to see the journey plans, the request is repeated (but as it’s just been performed once, it’ll always come back very quickly from the cache). Then PHP is used to interpret the JSON response. This time, the squadrons are sorted by average travel time. For driving, the closest squadron and any within 5 minutes of that are shown. For public transport, the closest squadron and any within 10 minutes of that are shown.
You’ll notice I’ve said ‘closest’ every time but I actually mean ‘shortest travel time’. There’s no non-wordy way of saying that, and it’s phrased as ‘closest’ on the website as well. If anyone can think of a more accurate phrase that would clear a niggle from my mind.
Ahhh I mean Electronic Engineer (well student), hmmm might have to try learning php and JavaScript then. cheers
Not sure if this was overlooked during the move to Discourse, but any feedback would be appreciated. If anyone else is based in a city where there are many units and catchment areas can overlap, let me know, as it should be very easy to make versions for other cities.