summaryrefslogtreecommitdiff
path: root/create-data.js
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-06-16 23:19:18 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-06-16 23:19:18 +0100
commit8fbbb84bb82f1858571c959af6cf4b3ba5941f12 (patch)
treec363c91fb64679788f8fca7c896a6fcf6da87fcb /create-data.js
parentf654f4af526ef4288cb8298217051523135c4c2c (diff)
downloadleaflet-soton-8fbbb84bb82f1858571c959af6cf4b3ba5941f12.tar
leaflet-soton-8fbbb84bb82f1858571c959af6cf4b3ba5941f12.tar.gz
Add doors to the map
Diffstat (limited to 'create-data.js')
-rwxr-xr-xcreate-data.js51
1 files changed, 46 insertions, 5 deletions
diff --git a/create-data.js b/create-data.js
index 7f062a0..ff86e81 100755
--- a/create-data.js
+++ b/create-data.js
@@ -535,11 +535,23 @@ function createBuildingParts(buildings, callback) {
mergeUniversityDataWithBuildingParts(buildingParts, buildingPartsByURI, buildings, function(err) {
- console.log("finishing createBuildingParts");
- callback(err, {
- type: "FeatureCollection",
- features: buildingParts
- }, workstations);
+ async.eachSeries(buildingParts, function(buildingPart, callback) {
+ if (buildingPart.properties.buildingpart === "room") {
+ getDoors(buildingPart, function(err, doors) {
+ console.log(JSON.stringify(doors, null, 4));
+ buildingParts.push.apply(buildingParts, doors);
+ callback();
+ });
+ } else {
+ callback();
+ }
+ }, function(err) {
+ console.log("finishing createBuildingParts");
+ callback(err, {
+ type: "FeatureCollection",
+ features: buildingParts
+ }, workstations);
+ });
});
}
);
@@ -561,6 +573,35 @@ function getBuildingPartMemberRefs(levelRelation, callback) {
callback(null, partRefs);
}
+function getDoors(room, callback) {
+
+ var query = "select osm_id, ST_AsGeoJSON(ST_Transform(way, 4326), 10) as point from planet_osm_point where (select nodes from planet_osm_ways where id=" + room.id + ") @> ARRAY[osm_id];";
+
+ pg.query(query, function(err, results) {
+ if (err) {
+ console.error("Query: " + query);
+ console.error(err);
+ callback(err);
+ return;
+ }
+
+ console.log(JSON.stringify(results, null, 4));
+
+ async.map(results.rows, function(part, callback) {
+ var feature = {type: "Feature", id: part.osm_id};
+ console.log(JSON.stringify(part, null, 4));
+ feature.geometry = JSON.parse(part.point);
+
+ feature.properties = { level: room.properties.level };
+
+ console.log("got door");
+ console.log(JSON.stringify(feature, null, 4));
+
+ callback(null, feature);
+ }, callback);
+ });
+}
+
function getBuildingParts(callback) {
var query = "select ST_AsGeoJSON(ST_Transform(way, 4326), 10) as polygon,ST_AsText(ST_Transform(ST_Centroid(way), 4326)) as center,osm_id,name,buildingpart,\"buildingpart:verticalpassage\",ref,uri,amenity,unisex,male,female from planet_osm_polygon where buildingpart is not null";