I couldn’t leave it alone this evening – 5 hours after I got home and I’ve done the 6 LAs on Scotland’s mid-east coast. The wee bit that was missing from Aberdeen has been restored. (I processed that dataset again and the missing points magically reappeared. So here it is in glorious technicolour:
The points are very close to the LA boundaries on OpenStreetMap tiles, which is quite encouraging. The dashed line is OpenStreetMap and the solid line is Leaflet’s rendering of the converted data.
Fife is a 4-part multipolygon, that is there are four polygons in the bits that represent Fife. I guess these are the Isle of May, Inchkeith and Inchcolm. Each part of a multi polygon requires separate processing via the hero of the hour(s), http://gridreferencefinder.com/batchConvert/batchConvert.php.
So I’m dreading doing Shetland, Orkney and the Western Isles. But perhaps they don’t need to be marked or coloured because they are clearly separate from the mainland.
Less heroic have been Mac TextEdit (no RegEx), TextMate (one successful RegEx, then fell over and won’t stop trying to process a long finished-with Angus file) and Word (it has done most of the heavy kiting but has fallen over at least 10 times). I’ll forgive Eclipse for chugging away with RegExes very slowly but I won’t forgive it for completing the RegEx then hanging so I can’t save the result.
The optimal process seems to be
- Open the original data file in Word.
- Find any sub-polygons, by replacing ] ], [ [ with multiple <new line>s.
- Grep ], [ with ,<new line>
- Get rid of the dross at the start and end of the of the file, so that I’m left with just sets of [number,number],<new line>[number,number], …[number,number],<new line>[number,number].
- Manually copy and paste the first set into the heroic web page, and tell it to convert. If it moans, there is more than one set in what I’ve copied, so go back and sort it out. At this point, Word will fall over – hence the multiple saves,
- When a clean data set is in the hero, it will convert the data to lines containing some unwanted blurb and the data in LatLong format.
- Copy that bit to a new TextEdit file called <LA-name>.js, then leave some spaces.
- Convert the next data set, i.e the next polygon in the multipolygon.
- Copy and paste that data into the TextEdit file.
- Repeat steps 8-12 until all polygons are in the TextEdit file. Save and close it.
- Open it in Eclipse. Do the RegEx to remove the unwanted blurb. (To play it safe, do a few hundred lines at a time, saving each time.
- Save and close the file – Eclipse is about to fall over.
- Open the file in Word again, then replace all multiple new lines with a suitable swearword.
- Replace all new lines with ], [
- Replace the swearwords with ], [
- Top and tail the file so that it has the format var <LAname> = [ [ [number, number], … [number, number] ], [ [number, number], … [number, number] ], … [ [number, number], … [number, number] ] ];
- Save it in the right place in the website data structure, add the necessary call to index.html’s head and the necessary Leaflet call to drawMap.js.
- Open the web page and draw the map.
- Fix the colours in drawMap.js
- Move on to the next LA!