{"id":1620,"date":"2017-07-11T11:57:38","date_gmt":"2017-07-11T11:57:38","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/webteam\/?p=1620"},"modified":"2017-07-12T09:42:04","modified_gmt":"2017-07-12T09:42:04","slug":"1620","status":"publish","type":"post","link":"https:\/\/blog.soton.ac.uk\/webteam\/2017\/07\/11\/1620\/","title":{"rendered":"Open Data Internship &#8211; Week 2 &#8211; Dusting off old skills"},"content":{"rendered":"<p style=\"text-align: left\"><em>He ran his fingers across the dust console leaving a trail of clear glass showing the controls beneath. He paused. It had been quite some time since he had last flow this ship, so he took a moment to try and remember the controls. Gingerly he tapped some of the buttons. An explosion echoed through the ship and an alert displayed on the console, &#8220;Uncaught TypeError: Cannot read property &#8216;id&#8217; of undefined&#8221;. &#8220;Hmm, how about this?&#8221; he mused tapping the console again, this time the bridge came to life.<\/em><\/p>\n<p>This week has seen me dusting off my JavaScript skills in the aid of making a route finding map prototype for campus. So in its simplest terms this is a graph traversal problem. But before I jumped into coding a graph traversal algorithm I needed to find some way to represent the map. The form I decided on was reasonably simple, I only modelled the nodes and these nodes had the properties of a unique numerical ID, a label for describing the location, a geometric point, and a list of nodes to which it was connected. I decided upon this because it allowed for one-way edges which could represent exit only doors.<\/p>\n<p>Next came the implementation of the graph traversal. The method I used was a modified Breadth-First search which instead of enqueuing newly explored nodes to end a queue, I instead inserted them into an array which was ordered by cost (distance) travelled, and the least travelled node was expanded next.<\/p>\n<p>The underlying data I was using was a list of university building entrances, but this list was incomplete and also didn\u2019t help with navigation as just drawing a line from one door to another will not help anyone navigate anywhere unless they can fly. So I manually created intermediate nodes on paths and crossings, typically where the path forked or crossed a road. As I was only making this data for a prototype I did it sporadically and just arbitrarily picking a spot on the route I was trying to add and working from there, but on I decided\u00a0 this was not a good way to move forward once the main program was working so I spent time using GIMP2 to simplify a university map down to the elements I needed to see to decide where to place nodes.<\/p>\n<p>I started with this Map:<\/p>\n<p><a href=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1621 aligncenter\" src=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map1-300x285.png\" alt=\"A map of the University\" width=\"300\" height=\"285\" srcset=\"https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map1-300x285.png 300w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map1-768x730.png 768w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map1.png 839w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Then spent time reducing the colour of the image, primarily using tools such as Posterize, which reduces the number of colours in an image, and the &#8216;Select by Colour Tool&#8217;, which I would use to select an all a specific colour on the map and recolour it all. After several hours of this and some manual cleaning up of the image I produced this three colour Map:<\/p>\n<p><a href=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1623 aligncenter\" src=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map2-300x285.png\" alt=\"Three colour map of the Univercity\" width=\"300\" height=\"285\" srcset=\"https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map2-300x285.png 300w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map2-768x730.png 768w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map2.png 839w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Here we see roads in white, paths\/paved areas as grey and impassible areas (grass and buildings) in black.<\/p>\n<p>Now it was a matter of adding nodes to the map, I started by adding blue dots to represent doors and then added red dots for forks in paths and road crossing. Finally I connected these nodes with green lines to represent traversable paths. This gave me this map:<\/p>\n<p><a href=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1624 aligncenter\" src=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map3-300x285.png\" alt=\"3 colour university map with simplified overlay.\" width=\"300\" height=\"285\" srcset=\"https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map3-300x285.png 300w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map3-768x730.png 768w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map3.png 839w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now that I had the graph I could remove the underlying map and see the graph I had created:<\/p>\n<p><a href=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1625 aligncenter\" src=\"http:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map4-300x285.png\" alt=\"A graph representation of campus\" width=\"300\" height=\"285\" srcset=\"https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map4-300x285.png 300w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map4-768x730.png 768w, https:\/\/blog.soton.ac.uk\/webteam\/files\/2017\/07\/map4.png 839w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Which I personally think looks quite nice, but more importantly will allow me to expand upon the data in my prototype in a logical and well thought out way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>He ran his fingers across the dust console leaving a trail of clear glass showing the controls beneath. He paused. It had been quite some time since he had last flow this ship, so he took a moment to try and remember the controls. Gingerly he tapped some of the buttons. An explosion echoed through [&hellip;]<\/p>\n","protected":false},"author":99281,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[352,4224,6481,364],"tags":[],"class_list":["post-1620","post","type-post","status-publish","format-standard","hentry","category-data","category-geo-2","category-javascript","category-programming"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/1620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/users\/99281"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/comments?post=1620"}],"version-history":[{"count":5,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/1620\/revisions"}],"predecessor-version":[{"id":1630,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/1620\/revisions\/1630"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/media?parent=1620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/categories?post=1620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/tags?post=1620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}