diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | 1.osm | 7 | ||||
-rw-r--r-- | 25.osm | 19 | ||||
-rw-r--r-- | 32.osm | 7 | ||||
-rw-r--r-- | 36.osm | 27 | ||||
-rw-r--r-- | 58.osm | 23 | ||||
-rw-r--r-- | 59.osm | 23 | ||||
-rw-r--r-- | data.yaml | 202 | ||||
-rwxr-xr-x | process.js | 66 |
9 files changed, 174 insertions, 202 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a9a84c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +~* +data.json @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='UTF-8'?> +<osm version='0.6' upload='true' generator='JOSM'> + <node id='-19233' action='modify' visible='true' lat='50.937612555621854' lon='-1.3960995445710553'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811742195' /> + </node> +</osm> @@ -0,0 +1,19 @@ +<?xml version='1.0' encoding='UTF-8'?> +<osm version='0.6' upload='true' generator='JOSM'> + <node id='-19251' action='modify' visible='true' lat='50.93490257593572' lon='-1.3934960590766836'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811689323' /> + </node> + <node id='-19250' action='modify' visible='true' lat='50.93480931508163' lon='-1.3933156500545465'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811640704' /> + </node> + <node id='-19249' action='modify' visible='true' lat='50.93481141083323' lon='-1.393544278999651'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811643297' /> + </node> + <node id='-19248' action='modify' visible='true' lat='50.93479726450819' lon='-1.393570051717099'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811640709' /> + </node> +</osm> @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='UTF-8'?> +<osm version='0.6' upload='true' generator='JOSM'> + <node id='-10919' action='modify' visible='true' lat='50.9360999403971' lon='-1.3957865775373284'> + <tag k='level' v='3' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1812956311' /> + </node> +</osm> @@ -0,0 +1,27 @@ +<?xml version='1.0' encoding='UTF-8'?> +<osm version='0.6' upload='true' generator='JOSM'> + <node id='-14' action='modify' visible='true' lat='50.93486483047066' lon='-1.3957888588783323'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811689072' /> + </node> + <node id='-12' action='modify' visible='true' lat='50.93485412231365' lon='-1.3957487475953605'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811689064' /> + </node> + <node id='-10' action='modify' visible='true' lat='50.93487817177759' lon='-1.3957796667093179'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811643313' /> + </node> + <node id='-8' action='modify' visible='true' lat='50.93486763916717' lon='-1.3957403910780746'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811689058' /> + </node> + <node id='-6' action='modify' visible='true' lat='50.934859564164235' lon='-1.3957704745403035'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811689068' /> + </node> + <node id='-4' action='modify' visible='true' lat='50.93487308101619' lon='-1.395761003820713'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811689061' /> + </node> +</osm> @@ -0,0 +1,23 @@ +<?xml version='1.0' encoding='UTF-8'?> +<osm version='0.6' upload='true' generator='JOSM'> + <node id='-19196' action='modify' visible='true' lat='50.93645607975658' lon='-1.39851904914466'> + <tag k='level' v='2' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811675031' /> + </node> + <node id='-19177' action='modify' visible='true' lat='50.93643459905807' lon='-1.3986520696218114'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811643322' /> + </node> + <node id='-19176' action='modify' visible='true' lat='50.93657186578985' lon='-1.3983560990601491'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811643646' /> + </node> + <node id='-19175' action='modify' visible='true' lat='50.93667193402978' lon='-1.398418452408814'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811643303' /> + </node> + <node id='-19174' action='modify' visible='true' lat='50.93672799310674' lon='-1.3985015902070337'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811643275' /> + </node> +</osm> @@ -0,0 +1,23 @@ +<?xml version='1.0' encoding='UTF-8'?> +<osm version='0.6' upload='true' generator='JOSM'> + <node id='-9901' action='modify' visible='true' lat='50.937363963459404' lon='-1.3977679578670272'> + <tag k='level' v='3' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811652107' /> + </node> + <node id='-9900' action='modify' visible='true' lat='50.93722376433564' lon='-1.3977351648573628'> + <tag k='level' v='3' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1812950344' /> + </node> + <node id='-9899' action='modify' visible='true' lat='50.937222143534065' lon='-1.3977557408634267'> + <tag k='level' v='3' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1811637593' /> + </node> + <node id='-9898' action='modify' visible='true' lat='50.93735748027226' lon='-1.397667006837277'> + <tag k='level' v='3' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1812968313' /> + </node> + <node id='-9862' action='modify' visible='true' lat='50.93729466663912' lon='-1.3977179921826415'> + <tag k='level' v='1' /> + <tag k='uri' v='http://id.southampton.ac.uk/mfd/1812968319' /> + </node> +</osm> diff --git a/data.yaml b/data.yaml deleted file mode 100644 index 92f26ad..0000000 --- a/data.yaml +++ /dev/null @@ -1,202 +0,0 @@ -# This file contains the location of multi-function devices - -## Building 1 - -# PR_B01_C1009_M01 -http://id.southampton.ac.uk/mfd/1811742195: - level: '1' - coordinates: - - -1.3961015 - - 50.9376083 - comment: - Near entrance in far left corner - -## EScience Building - -# PR_B25_R1007_M01 -http://id.southampton.ac.uk/mfd/1811689323: - level: '1' - coordinates: - - -1.3934958 - - 50.9348978 - comment: - Right of entrance in to 1007 - -# PR_B25_R1009_M01 -http://id.southampton.ac.uk/mfd/1811643297: - level: '1' - coordinates: - - -1.3935384 - - 50.9348132 - comment: - Right side of room 1009 - -# PR_B25_R1009_M02 -http://id.southampton.ac.uk/mfd/1811640704: - level: '1' - coordinates: - - -1.3933223 - - 50.9348058 - comment: - Rear of room 1009 - -# PR_B25_R1011_M01 -http://id.southampton.ac.uk/mfd/1811640709: - level: '1' - coordinates: - - -1.3935674 - - 50.9347941 - comment: - Corner of room 1011 - -## Zepler (59) - -# PR_B59_C1730_M01 -http://id.southampton.ac.uk/mfd/1812968319: - level: '1' - coordinates: - - -1.3977322 - - 50.9372873 - comment: - Just outside the rapid prototyping lab - -# PR_B59_R3218_M01 -http://id.southampton.ac.uk/mfd/1812968313: - level: '3' - coordinates: - - -1.3976627 - - 50.9373496 - comment: - Middle of the main corridor on level 3 - -# PR_B59_R3207_M01 -http://id.southampton.ac.uk/mfd/1812950344: - level: '3' - coordinates: - - -1.3977299 - - 50.9372259 - comment: - South end of the Undergraduate Computing Labs, on the left - -# PR_B59_R3237_M01 -http://id.southampton.ac.uk/mfd/1811637593: - level: '3' - coordinates: - - -1.3977482 - - 50.937225 - comment: - South end of the Undergraduate Computing Labs, on the right - - -# PR_B59_R3237_M02 -http://id.southampton.ac.uk/mfd/1811652107: - level: '3' - coordinates: - - -1.3977665 - - 50.9373547 - comment: - Middle of the Undergraduate Computing Labs - -## Library (36) - -# PR_B36_LVL02_M01 -http://id.southampton.ac.uk/mfd/1811643313: - level: '2' - coordinates: - - -1.3957815 - - 50.9348748 - comment: Print room, far right - -# PR_B36_LVL02_M02 -http://id.southampton.ac.uk/mfd/1811689061: - level: '2' - coordinates: - - -1.3957612 - - 50.9348692 - comment: Print room, middle right - -# PR_B36_LVL02_M03 -http://id.southampton.ac.uk/mfd/1811689058: - level: '2' - coordinates: - - -1.395739 - - 50.9348633 - comment: Print room, near right - -# PR_B36_LVL02_M04 -http://id.southampton.ac.uk/mfd/1811689064: - level: '2' - coordinates: - - -1.39575 - - 50.9348476 - comment: Print room, near left - -# PR_B36_LVL02_M05 -http://id.southampton.ac.uk/mfd/1811689068: - level: '2' - coordinates: - - -1.3957726 - - 50.9348536 - comment: Print room, middle right - -# PR_B36_LVL02_M06 -http://id.southampton.ac.uk/mfd/1811689072: - level: '2' - coordinates: - - -1.3957927 - - 50.93486 - comment: Print room, far right - -## Building 32 - -# PR_B32_C3049_M01 -http://id.southampton.ac.uk/mfd/1812956311: - level: '3' - coordinates: - - -1.3958056 - - 50.9361012 - comment: - In the open space, at the south end of level 3 - -## Murray (58) - -# PR_B58_R2126_M01 -http://id.southampton.ac.uk/mfd/1811675031: - level: '2' - coordinates: - - -1.3985114 - - 50.9364605 - comment: In the corridor in the southmost corner of the building - -# PR_B58_R1049_M01 -http://id.southampton.ac.uk/mfd/1811643275: - level: '1' - coordinates: - - -1.3985098 - - 50.9367144 - comment: Named like in room 1049, but actually in room 1043 - -# PR_B58_R1045_M01 -http://id.southampton.ac.uk/mfd/1811643303: - level: '1' - coordinates: - - -1.3984117 - - 50.9366692 - comment: In room 1045 near the partition - -# PR_B58_R1047_M01 -http://id.southampton.ac.uk/mfd/1811643646: - level: '1' - coordinates: - - -1.3983556 - - 50.9365553 - comment: Against the outside wall - -# PR_B58_R1053_M01 -http://id.southampton.ac.uk/mfd/1811643322: - level: '1' - coordinates: - - -1.3986478 - - 50.9364296 - comment: - Against the far outside wall diff --git a/process.js b/process.js new file mode 100755 index 0000000..4054106 --- /dev/null +++ b/process.js @@ -0,0 +1,66 @@ +#!/usr/bin/env nodejs + +fs = require('fs') +osmtogeojson = require('osmtogeojson'); + +DOMParser = require('xmldom').DOMParser; + +if (!String.prototype.endsWith) { + Object.defineProperty(String.prototype, 'endsWith', { + value: function (searchString, position) { + var subjectString = this.toString(); + if (position === undefined || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + } + }); +} + +fs.readdir('.', function(err, files) { + var features = []; + + files.forEach(function(name) { + if (name.endsWith(".osm")) { + buildingId = name.slice(0, -4); + + data = fs.readFileSync(name, 'utf8'); + + var doc = new DOMParser().parseFromString(data); + + var geojson = osmtogeojson(doc, { + flatProperties: true + }); + + geojson.features.forEach(function(feature) { + delete feature.id + delete feature.properties.id + + features.push(feature); + }); + } + }); + + var byURI = {}; + + features.forEach(function(feature) { + if (feature.properties.uri in byURI) { + console.error("duplicate uri " + feature.properties.uri); + } else { + byURI[feature.properties.uri] = feature; + } + }); + + featureCollection = { + type: "FeatureCollection", + features: features + }; + + var stream = fs.createWriteStream("./data.json"); + stream.once('open', function(fd) { + stream.write(JSON.stringify(featureCollection, null, 4)); + stream.end(); + }); +}); |