Donate using PayPal

CycleStreets blog

News from CycleStreets

Archive for the ‘Developers’ Category

CycleHack Cambridge 2016

Sunday, April 10th, 2016

CycleHack is a 48-hour event aiming to make cities cycle-friendly through reducing the barriers to cycling and prototyping new ideas to improve the cycling experience and encourage more and safer cycling. More than 40 other cities around the world have signed up to host CycleHack events in their communities over the weekend of 24 to 25 June, 2016.

Cyclehack

Cambridge, home of CycleStreets, will be joining cities around the world for a weekend-long CycleHack event, which will be held at Anglia Ruskin University and other locations where specialist equipment may be required. Participants will be encouraged to test their ideas and prototypes around town during the event.

CycleHack was launched in 2014 in Glasgow and has since grown to a global event. In 2015 CycleHack had more than 600 participants from over 25 countries across five continents. 67% of participants were inspired to cycle more. In 2016 the event is set to be even bigger with more than 40 cities already registered.

Cyclehack CambridgeCycleHack Cambridge is hoping to attract a whole range of people from developers, makers and data scientists to non-technical artists, designers and those who are interested in cycling and have some great ideas. We also want to include representation from all corners of our diverse cycling community and want to see lots of students and young people taking part. This event will bring together the key elements of our Cambridge culture: cycling, innovation and technology.

The event encourages participants to prototype and test their ideas during the weekend to see how they will work in their intended context. Solutions can fall into one of the five CycleHack categories; digital, physical, policy, local plan, event/campaign. Hacks will be loaded to the online open source catalogue to show how the ideas can be replicated. Prizes will be awarded to the best hacks.

CycleStreets is one of the partners organising the event. We’ll be on hand to help out and give advice to people considering doing a digital hack. Perhaps you’ve never used an API (a data interface – like the CycleStreets API for instance) before or don’t know what it is? We can help you get started.

Cambridge Cycling Campaign is the main organiser of the event. Other partners include the Smart Cambridge Programme (Cambridge County Council) and CoDE Research Institute at Anglia Ruskin University.

There are more details on the Facebook event page about the event, and you can register online.

Students: Get paid to write code for CycleStreets/OpenStreetMap this summer with GSOC 2016

Saturday, March 19th, 2016

GSOC 2016Each year, Google runs a summer programme called Google Summer of Code (GSOC), where students get involved in coding for open source projects like ours and are paid for their time.

We (CycleStreets) have created a project ideas list, which would be undertaken under the umbrella of the OpenStreetMap organisation, and are willing to mentor a student or students on these.

By way of background, CycleStreets is a social enterprise based in Cambridge, UK. We run the cycle journey planner website at www.cyclestreets.net, provide a leading bicycle routing API data interface used by a range of third-party apps and websites, and run a number of projects in the field of cycling advocacy. Many of our projects are open source.

openstreetmaplogoWe use open data from OpenStreetMap (sometimes referred to as a kind of ‘wikipedia for maps’). OSM is a community/ecosystem doing a lot of leading-edge work in the area of open geo data, and there are many fields within it that could interest computer science students, engineering students, and others.

As well as our own project list, there are are other project ideas from elsewhere within the OpenStreetMap community that we’d also strongly encourage students to consider too.

Students must apply via the GSOC website by Friday 25th March, 7pm GMT, but it’s very important to work via the process given in the OpenStreetMap GSOC 2016 page.

Please note that GSOC is a highly competitive process, and only those students who come up with the best proposals that will assist OpenStreetMap are likely to be accepted.

We’d be very happy to meet in central Cambridge (UK) (or via Skype if you’re not based here) to discuss potential projects, and/or to provide some background to OpenStreetMap, whether you are thinking about one of our (CycleStreets) projects or another project listed on the OSM project ideas page. Please do get in touch with us in the first instance.

Patrick reports back

Thursday, October 1st, 2015

Back in July we introduced our summer intern, Patrick. Here, he reports back on his achievements over the three-month period.

Patrick

This summer I worked for Cyclestreets as a paid intern for three months. During this time, I became acquainted with the large codebase the site runs on, and made several structural changes to the organisation of the code. After my work at Cyclestreets I feel much more comfortable working with sizeable codebases, and the focus on refactoring and identifying optimisable code has made a huge change in the way I approach coding my own projects.

One of my main tasks as intern was to refactor the existing codebase into an MVC-style layout. Building on a similar structure designed into Ruby on Rails, we set out to create classes with distinct personalities; views, models and controllers. Establishing rules that govern class content contributes to building a strong framework that isolates code into functioning categories. Once an MVC structure has been implemented, crosstalk between classes can easily be analysed and anomalies can be identified.

Cyclestreets runs two main environments (contexts) – a GUI environment and an API environment. These two systems had become merged over time due to feature development, so re-establishing the functional dichotomy between these entities became a priority. This was a long process, as a long period of development had led to a proliferation of technical debt in the codebase.

The concept of refactoring, or changing code structure without altering the code function, reverses this process. It is risky, as refactoring can introduce subtle bugs. It is also very easy, as I found out on several occasions, to dig yourself into a hole as one alteration leads to another, and another, until it is extremely hard to finalise the series of sequential refactorings. To avoid this, refactoring must be done systematically.

Design patterns can be identified that provide targets for refactoring, and over the summer I became familiar with identifying duplicated code, contrived complexity, over-large classes, and long methods, to name a few of the ‘bad smells’ I learned to identify in the code.

Rolling out my changes to the main servers was always a nail-biting moment. I didn’t want to be “that guy” that brought down the system while users in London were relying on the excellent CycleStreets app to get to work during the Underground strikes that went on during summer. [Ed.: Don’t worry, we deploy in dev first :) ]

The team at CycleStreets were extremely supportive, and I thank them for the time they took to broaden my knowledge of PHP and good coding practices. It was a very enjoyable summer, one I will look back on fondly as in the years to come I design my own apps and come across the issues I learned to rectify during this internship. Thank you Martin and Simon!

Martin and Simon thank you back, Patrick – the codebase has moved forward significantly over the summer, with several long-running problems resolved. You were a pleasure to work with, arguing your case well when there were difficult decisions to take in the code, and taking on feedback.

Beautiful new galleries page unveiled

Monday, July 27th, 2015

We are pleased to unveil the new Galleries front page, which brings your beautiful photos and content to the front and centre. Galleries is a really neat feature to group cycling-related media for presentation or campaigning.

There is also a lot more flexibility available while adding a new gallery – you can now navigate away from the Create Gallery form to find more photos to add, and when you return all the fields will be exactly as you left them. You can even close your browser window and come back later, and the gallery creation form will still show your data as you left it.

As well as the graphical front end, our intern Patrick has been busy developing a new Galleries API for developers, which enables API calls to list and show the content of Galleries, and create and update Galleries.

We hope you enjoy browsing and adding to the Galleries.

Screen Shot 2015-07-27 at 17.13.12

Moving to Leaflet.js

Sunday, July 27th, 2014

This is a tech post mainly for our OpenStreetMap and techie users!

During recent months we’ve quietly been working on a major change behind the scenes in preparation for some large-changes to our web interface (which has long been in need of upgrading) and to prepare for a more mobile-friendly experience:

We’ve moved the large amount of our mapping code from OpenLayers 2 to Leaflet. This is the part of the site you see whenever you come across a map that you can drag around – the ‘slippy maps’. Last Monday, our commit “Removed OpenLayers” landed.

This has been quite a major undertaking, and a rather painful one at that. It has meant not only rewriting every bit of map javascript code, but also creating a new, second-generation API (data feed) using GeoJSON, as that is the native format that makes working with Leaflet so easy. In creating the V2 API, we’ve also had to keep every part of the old V1 API running perfectly so as not to break third-party mobile apps and sites that rely on it.

We had to rewrite Javascript modules for the every one of the types of slippy map used around on the site:

The V2 API (the technical interface to the underlying data that gets shown on the maps) emits data in the easily-parsable GeoJSON format. The V2 API, to be made public soon, is something we’ve wanted to do anyway for a while now. As we’ve moved to GeoJSON, we’ve found that throwing objects of all kinds onto a map is far easier compared to generating GML using XML DOM structures and writing Javascript to handle that.

When we launched CycleStreets back in 2009, GML was in vogue, and OpenLayers was the only real choice available. In fact, in 2009, many of the wonderful tools like Leaflet, jQuery, and autocomplete were either not available or were in their infancy. Now these tools are available, we no longer have to deal with the pain of generating XML DOM (for GML) structures and that is a very welcome relief.

It’s fair to say that we’ve always struggled with OpenLayers 2. OpenLayers is a very powerful map framework, basically letting you do almost anything on top of a map canvas, and with a very ‘correct’ object-orientated style. But with things like a standard web projection and GeoJSON standardisation now the norm for web mapping, the swiss-army-knife approach has not been ideal for us.

The force-point came for us when we ran into an intractable problem where a clickable layer of shop icons, used on a journey planner we run for a third party, had the odd behaviour that one of the two start/finish itinerary waypoint markers could not be moved if an icon had been clicked. We spent two days trying to debug this, even going as far as picking through the OpenLayers source code. Long ago we had learnt which of the five popup types to use, but we simply could not work out the mechanism for changing focus between layers. So we changed tack, generating GeoJSON for the icon layer and got a prototype working in Leaflet pretty quickly, and it ‘just worked’. From that point our V2 API project really got going.

It’s great to see that a new version of OpenLayers, OpenLayers 3, is in the works, which will undoubtedly take that very respected project forward. But for us, for now, Leaflet is where we plan to put our development focus.

PS The V2 API is going live shortly. All of our site is running from it and documentation is in place – we’ve just resolving the remaining few format issues now.

Our debugging view, now running from a GeoJSON data endpoint in our V2 API

Our debugging view, now running from a GeoJSON data endpoint in our V2 API.

The redesign upgrade project, of which the above work is part, has been possible thanks to part-funding from the Cambridge City Council Cycling & Walking Grants scheme, helping get more people cycling in Cambridge. We are most grateful to them for their support.

Scripting CycleStreets setup (Tech post)

Thursday, January 31st, 2013

This is a tech post, so if you’re not a techy person, feel free to stop reading now!

We’ve been reorganising the CycleStreets codebase to get ready for open-sourcing the remainder of our software.

This has been a challenging task involving learning how to write scripts that automate the installation of the CycleStreets website. The job has taken rather longer than expected, but has resulted in a much clearer structure to the highest level of the CycleStreets system and given us greater control of how the system is deployed.

It is fair to say that this aspect of our system had become rather complex with a lot of hidden dependencies. This would have been a real barrier for new coders to our project and so it had to be sorted out. The work now allows our codebase to separate out into these scenarios:

  • Live deployment – provides the main CycleStreets website
  • Failover deployment – holds a replicated copy of all CycleStreets data that can be used, should the live site fail for some reason
  • Import – processes the latest OpenStreetMap extracts into a routing system

An immediate benefit of the work will be that we can much more easily deploy each of these roles. So for instance we could have multiple import machines, and each could be configured to serve different regions of the world.

We still have a little further work to clean and clarify the codebase before we can open the core code. This has been our main priority for the last few months, and will remain so for the next few weeks. It won’t be perfect, but we’ve aimed to get rid of the really bad dependency gremlins.

We’ve also been doing various cleanups, such as removing this blog installation from the main repository, daemonizing the routing process (optionally), and adding SMS monitoring.

The ongoing work on the scripts part of our system can be viewed at our public CycleStreets setup repository.

CycleStreets android app now with offline maps

Thursday, July 5th, 2012

We’re pleased to announce a major new version of the CycleStreets Android App (version 1.4), our fourth update in just over a year. It brings a great new feature … Offline maps!

 Download the app update and install the map pack now!

   

Up until now, the CycleStreets app has had to download maps as it needed them. As you move around the map, or zoom in and out, the downloads new parts of the map – the tiles – as it goes. The different map styles it offers are provided by simply downloading the tiles from different servers. Generally, this works fine. But if you’re on you’re out and about and have a poor signal, or want to try and eke out your battery life, it can be a problem.

This new update provides a solution – a free downloadable map pack covering the whole of Great Britain and Ireland. The map pack is available from Google Play as a separate download, and once installed, you need never download another tile again. All the map data CycleStreets needs is there, on your phone, and it will render the maps it needs as it needs them. (Routing itself still uses the network, but this is a tiny amount of data by comparison.)

To set up the offline maps download the app update and install the map pack. Start the map pack app and it will set up the offline maps automatically. You can always switch between online and offline maps using the Settings screen.

Plan cycle-friendly routes from A to B, via C, anywhere in the UK!

  • Plans routes through the full street and path network, including Sustrans routes and other networks
  • Innovative & quick “three taps” system: Set current location, tap the map to set destination, and plan!
  • Or search for any location in the UK, including full postcode support and local/national placefinder
  • Choice of map styles (including the great OpenCycleMap showing contours, and Ordnance Survey Street View, and offline style)
  • Downloadable maps for offline use
  • Turn-by-turn itinerary view
  • Choose from different types of routing – fastest/quietest/balanced/shortest
  • Easily switch between route types (e.g. quietest to fastest) having planned a route
  • Takes account of hills automatically
  • Routes automatically saved for later use
  • UK-wide (NB some areas of OpenStreetMap are better than others)
  • Share your route by Twitter, Facebook, or email

CycleStreets for Android is an open source project and the code is available on GitHub. If you’d like to get involved with the code – and Android development is easier than you might imagine – do get in touch.

Please do add a review of the app too!

– Jez

Open sourcing update

Friday, June 22nd, 2012

We’re making good progress on this, after a stalled attempt to sort things out back in March when a busy period then struck. Our previous update has some background on this overall initiative.

Firstly, we’re planning a Developer Day in late summer – more news soon.

The last month or so has seen significant refactoring of some of the least clean parts of the codebase. In particular:

  • The XML API generation framework has been tidied considerably, with a long-standing and obstructive dependency finally removed. There is more to be done later.
  • The Photomap code has been restructured. For a long time it has been shackled by a wrong class hierarchy that saw all access (e.g. viewing photos, adding them, browsing on the map) going through an overarching class that really should just have been a resource class. Over a several-day refactoring this class hierarchy was reversed.
  • The code for addition of photos in particular has been rather a mess for a while because there are many different GUIs writing to it. Work to move the model-related code to a separate model class is seeing this cleaned up, and various lurking bugs have been removed in the process.

Some of the work has been very difficult even for us as the original authors(!), with some of it quite painful due to the age of the code and the number of hacks it had acquired. It is code areas like these which we know would have put people off even considering helping because the risk of breakage was very high to an unfamiliar author.

A Git server has just been installed (thanks Wookey!), so we are about – at long last – to move away from SVN which will enable us to move to a multi-branch model and, more importantly, then to move to GitHub.

We’ve thought long and hard about whether to retain the SVN history during the migration to Git. I’m pleased to say that we do intend to retain this (unless any big problems arise), with over 9,000 commits therefore being carried forward into the new Git repo to be created. In coming to this conclusion we took the view that, despite presenting some risks, it means that the history of the development of the system – which is effectively its documentation – is retained. This is particularly important because of the code was never designed with unit tests in mind (unlike our new Cyclescape codebase).

We’ve identified most of the sensitive strings such as passwords and API keys that will be stripped out as part of this process.

Initially we planned to split out the split the codebase into around 7 separate repositories (e.g. Journey planner, Photomap, common, API launcher, etc.), but in retrospect we think this would cause more problems than it solves in terms of ease of installation. So instead we are planning to split the sections of the code more simply into directories at the top-level, and do this after putting the code on GitHub.

Stay tuned for imminent updates!

We’re having an Android Hack Day!

Friday, February 10th, 2012

We’re holding a CycleStreets for Android Hack Day on Saturday 25th February 2012. Come along, because it’ll be fun.

Dive in

So what might you do with the Android app? Well, anything you like, but here are some suggestions – export a CycleStreets route as GPX, integrate a vector mapping library like MapsForge, add speech output, or simply poke around in the code and see what catches your eye. Learn some new things, ask questions, maybe have a beer in the evening.

What you’ll need

  • A Laptop. Linux, Windows, or Mac, whatever your preference.
  • The CycleStreets for Android source code. The source code lives up on GitHub, so grab a copy by forking it. If you don’t already have a Github account, you will need to create one. You’ll also need need a copy of Git itself. If you’re unfamiliar with Git, don’t worry because we’ll give you a primer. If you’re unfamiliar with source code control in general, you still don’t need to worry, we’ll teach you a valuable life skill.
  • The Android SDK. To build the code, you’ll need the Android SDK. Strictly speaking the SDK and a text editor are more or less all you need, but you will probably find this a little easier using it with the Eclipse IDE. The integration with Eclipse is very good, the code completion support will help you work your way through an unfamiliar API, and the debugging support is excellent. See the image below for the components you’ll need.
  • An Android device. Actually this is optional, as the Android SDK supports Virtual Devices you can run on your laptop, but it’s quicker and easier to run your code on a real device.
  • 3G dongle if you have one – there’ll be internet, but bring a dongle just in case we have problems.

What you won’t need

  • Previous Android Experience. Programming for Android is actually pretty straightforward, so you don’t need any specific experience. Familiarity with event-driven user interfaces is helpful, but if you’re keen you should be able to pick it up pretty easily.
  • Java Expertise. The language of Android is Java, but you don’t need deep, deep Java expertise. You can get by with a smattering.

When and where?

Saturday 25th February 2012 from 12 noon – 10pm.

Ross Street Community Centre. [Map showing the route from Cambridge station – green route is best.]

It’d be great if you could let us know if you can come so we can order enough fresh pizza!

The bits of the Android SDK that you need, shown ticked (click to enlarge):

 

Upgraded hosting for CycleStreets (Technical post)

Saturday, October 29th, 2011

We’ve recently completed a switch over of the whole CycleStreets system to upgraded hosting. Our previous primary server has been extremely reliable and, having just checked, I find it has been up for 795 days, and has only been rebooted once in the last two-and-a-half years.

The new primary server is needed to support expansion of the journey planner, to handle the growing amount of data we manage in the CycleStreets system and to provide increased reliability of our services,  as well as for our new project, Cyclescape. We now also have additional redundancy.

The switchover has turned out to be a rather more complex procedure than expected as there are quite a number of different components that are required to make CycleStreets all work smoothly. This recent switchover it has helped to tighten up a number of areas. This will make future switchovers easier to handle, and a major benefit has been a restructuring of our documentation.

We have tighted up how we handle file permissions and this means that developers no longer need sudo access to rollout code onto the live server. The structure we’ve got for that feels a lot cleaner and has improved the security of the system.

The hardest part of all this was the moment of switchover itself. As the system is live and being used to generate thousands of routes per day we aimed to have as little downtime as possible. The data on both systems was synchronised before turning off the live server and switching over the DNS. This was done in the small hours and because of careful prepartion was completed in about 15 minutes. When the new server became live it was impossible to tell that anything had changed. Only a few things were missed out in the switchover – the automatic tweeting of our photo-of-the-day, and the updating of a missed DNS record – but both of these are now fixed.

The system does feel more responsive now, and we’ve noticed that some of our scripts run twice as quick as previously.

We are very grateful to our hosts, Mythic Beasts, for their continued support and technical advice.

Funding for this upgrade has been partly helped by a grant from Cycling Scotland and from donations.

Cycling Scotland

We welcome your feedback, especially to report bugs or give us route feedback.

My comments relate to: *






Your comments: *
URL of page: * https://www.cyclestreets.net/footer.html
How did you find out about CycleStreets?:
Your name:
Our ref: Please leave blank - anti-spam measure

* Items marked with an asterisk [*] are required fields and must be fully completed.