-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bba163c
commit 50e1c9e
Showing
11 changed files
with
14,860 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
.settings | ||
.settings | ||
.hg | ||
*.iml | ||
.idea | ||
.DS_Store | ||
bin | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
(function (angular) { | ||
'use strict'; | ||
|
||
angular.module('tw').controller('SelectPlaceCtrl', function($scope) { | ||
angular.module('tw').controller('SelectPlaceCtrl', function($scope, $http) { | ||
$scope.cities = Object.keys(tw.data.locations); | ||
$scope.getDistrictsOfCity = function(city) { | ||
var cityObject = tw.data.locations[city]; | ||
$scope.districts = Object.keys(cityObject); | ||
} | ||
$scope.$on('location', function(event, latLon) { | ||
$http.get('http://localhost:8012/geocode?lat=' + latLon.lat + '&lon' + latLon.lon).success(function(data) { | ||
console.log(data); | ||
}) | ||
}) | ||
}); | ||
|
||
})(angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function (angular) { | ||
angular.module('tw').directive('geocodeAddress', function () { | ||
return { | ||
restrict: 'A', | ||
link: function (scope, elem) { | ||
var autocomplete = new google.maps.places.Autocomplete(elem[0]); | ||
google.maps.event.addListener(autocomplete, 'place_changed', function () { | ||
console.log(autocomplete.getPlace()); | ||
}); | ||
} | ||
} | ||
}); | ||
})(angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(function (angular) { | ||
angular.module('tw').directive('locateMeButton', function () { | ||
return { | ||
restrict: 'A', | ||
link: function (scope, elem) { | ||
elem.on('click', function () { | ||
scope.$emit('location', {lat: 1, lon: 2}); | ||
}); | ||
} | ||
} | ||
}); | ||
})(angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var process = require('process'); | ||
var mongoSetup = require('./mongo-setup'); | ||
var heilbronnPlaces = require('./hn-streets.json'); | ||
var zones = require('./zones.json'); | ||
|
||
var GeoJSON = require('mongoose-geojson-schema'); | ||
var mongoose = require('mongoose'); | ||
|
||
mongoose.connect('mongodb://localhost/tapwater'); | ||
|
||
var Location = mongoose.model('Location', new mongoose.Schema({ | ||
name: String, | ||
zone: String, | ||
geometry: GeoJSON.Geometry | ||
})); | ||
var Zone = mongoose.model('Zone', { | ||
name: String, | ||
calcium: Number, | ||
kalium: Number | ||
}); | ||
|
||
|
||
var convertCoordinatesArray = function (coordinates) { | ||
var convertedCoordinates = []; | ||
coordinates.forEach(function (coordinate) { | ||
if (Array.isArray(coordinate[0])) { | ||
convertedCoordinates.push(convertCoordinatesArray(coordinate)); | ||
} else { | ||
convertedCoordinates.push([coordinate[1], coordinate[0]]); | ||
} | ||
}); | ||
return convertedCoordinates; | ||
}; | ||
|
||
heilbronnPlaces.features.forEach(function (feature) { | ||
var location = new Location({ | ||
name: feature.properties.name, | ||
zone: "Heilbronn " + feature.properties.haertegrad, | ||
geometry: { | ||
"type": feature.geometry.type, | ||
"coordinates": convertCoordinatesArray(feature.geometry.coordinates) | ||
} | ||
}); | ||
location.save(function(e) { | ||
console.log(e); | ||
}); | ||
}); | ||
|
||
Object.keys(zones).forEach(function (zoneName) { | ||
var zone = new Zone({ | ||
name: zoneName, | ||
calcium: zones[zoneName].calcium, | ||
kalium: zones[zoneName].kalium | ||
}); | ||
zone.save(); | ||
}); | ||
|
||
process.exit(); |
Oops, something went wrong.