Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from doug-martin/localhost-changes

Localhost changes
  • Loading branch information...
commit 535593c0a771b89c4cca66da6d638d6c2c84f46d 2 parents 0a4e851 + 7724cae
@doug-martin doug-martin authored
View
6 node/server/config.js
@@ -1,6 +1,6 @@
exports = module.exports = {
MONGO_URL:"mongodb://localhost:27017/safeomaha",
- HOST:"localhost",
- PORT:8088,
+ HOST:"www.safeomaha.org",
+ PORT:80,
DEFAULT_RADIUS : 0.5
-}
+}
View
6 node/server/lib/models/SafeItem.js
@@ -22,7 +22,7 @@ SafeItemSchema.statics.categories = function (type, cb) {
SafeItemSchema.statics.getItems = function (opts, includeMeta, cb) {
var q = comb.merge({}, opts);
- opts.loc && (q.loc = { $near:opts.loc, $spherical:true, $maxDistance:(opts.radius || config.DEFAULT_RADIUS) / 6378 });
+ opts.loc && (q.loc = { $near:opts.loc, $maxDistance:(opts.radius || config.DEFAULT_RADIUS) / 6378 });
opts.box && (q.loc = {"$within":{"$box":opts.box}});
delete q.radius;
delete q.box;
@@ -33,7 +33,7 @@ SafeItemSchema.statics.getItems = function (opts, includeMeta, cb) {
SafeItemSchema.statics.topOfficers = function (opts, cb) {
var q = comb.merge({}, opts);
- opts.loc && (q.loc = { $near:opts.loc, $spherical:true, $maxDistance:(opts.radius || config.DEFAULT_RADIUS) / 6378 });
+ opts.loc && (q.loc = { $near:opts.loc, $maxDistance:(opts.radius || config.DEFAULT_RADIUS) / 6378 });
opts.box && (q.loc = {"$within":{"$box":opts.box}});
delete q.radius;
delete q.box;
@@ -78,7 +78,7 @@ SafeItemSchema.statics.topOfficers = function (opts, cb) {
SafeItemSchema.statics.topCrimes = function (opts, cb) {
var q = comb.merge({}, opts);
- opts.loc && (q.loc = { $near:opts.loc, $spherical:true, $maxDistance:(opts.radius || config.DEFAULT_RADIUS) / 6378 });
+ opts.loc && (q.loc = { $near:opts.loc, $maxDistance:(opts.radius || config.DEFAULT_RADIUS) / 6378 });
opts.box && (q.loc = {"$within":{"$box":opts.box}});
delete q.radius;
delete q.box;
View
2  node/server/lib/routes.js
@@ -8,11 +8,11 @@ var connected = false;
var connect = function (cb) {
var ret = new comb.Promise();
if (!connected) {
+ connected = true;
mongoose.connect(config.MONGO_URL, function (err) {
if (err) {
ret.errback(err);
} else {
- connected = true;
ret.callback();
}
});
View
13 web/css/style.css
@@ -24,13 +24,24 @@ body {padding:0; height:100%; margin:0px auto 0px auto; background:url(../images
#navbar #foursquare:hover {opacity:0.95}
#controls {overlow:auto; background:#dcd2aa; -webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px; float:left}
- #slider-container {float:left; vertical-align:top; width:244px;height:450px; margin:5px 0px 0px 5px; -webkit-border-top-left-radius: 2px; -webkit-border-bottom-left-radius: 2px; -moz-border-radius-topleft: 2px; -moz-border-radius-bottomleft: 2px; border-top-left-radius: 2px; border-bottom-left-radius: 2px; background:url(../images/sidebar-bg.png) repeat-y #f6f4f4; background-position:top right}
+ #slider-container {float:left; vertical-align:top; width:244px;height:450px; overflow-x: auto; margin:5px 0px 0px 5px; -webkit-border-top-left-radius: 2px; -webkit-border-bottom-left-radius: 2px; -moz-border-radius-topleft: 2px; -moz-border-radius-bottomleft: 2px; border-top-left-radius: 2px; border-bottom-left-radius: 2px; background:url(../images/sidebar-bg.png) repeat-y #f6f4f4; background-position:top right}
#slider-container h2 {margin:15px 10px 0px 10px; padding:6px 6px 18px 6px; color:#000; line-height:15px; font-weight:normal; background:url(../images/sidebar-divider.png) no-repeat; background-position:bottom}
#slider-container ul {list-style: none; margin:-5px 10px 5px 10px; color:#000; font-size:15px; padding:0px 6px 21px 6px; line-height:15px; font-weight:normal; background:url(../images/sidebar-divider.png) no-repeat; background-position:bottom}
#map_canvas {color:#37341F; float:left; margin:5px 5px 5px 0px; overflow:hidden; height:450px; width:706px}
#footer {width:960px; margin:0px auto 0px auto; text-align:center; font-size:13px; color:#605c43; padding:40px 0px 40px 0px; overflow:hidden}
+
+#crime-facts,
+#cops-facts {
+ display: block;
+ font-size: 8pt;
+ background: wheat;
+ border-radius: 9px;
+ overflow: auto;
+ max-height: 287px;
+}
+
.infowindow {
text-transform:capitalize;
max-height: 80px;
View
4 web/foursquare/oauth2.html
@@ -95,8 +95,8 @@
});
</script>
</head>
-<body>
- <a href="https://foursquare.com/oauth2/authenticate?client_id=MFHWM4ODQS5CMN5FQLP5JKTBYXLC50EZCUCL5Y3XBVQRFCIQ&response_type=token&redirect_uri=http://safeomaha.org/foursquare/oauth2.html">Link your Foursquare</a>
+<body>
+ <a href="https://foursquare.com/oauth2/authenticate?client_id=MFHWM4ODQS5CMN5FQLP5JKTBYXLC50EZCUCL5Y3XBVQRFCIQ&response_type=token&redirect_uri=http://www.safeomaha.org/foursquare/oauth2.html">Link your Foursquare</a>
<div id="map_canvas" style="width:1000px;height:400px;"></div>
View
8 web/index.html
@@ -61,12 +61,16 @@
<li>
<h4 id="crime-toggler">Crime</h4>
<input type="range" id="crimeSlider" min="0" max="4" step="1" value="2" onChange="onRatingChange(event,'crime')" />
- <div id="crime-facts"></div>
+ <div id="crime-title">Top Crimes</div>
+ <div id="crime-facts">
+ </div>
</li>
<li>
<h4 id="cops-toggler">Cops</h4>
<input type="range" id="policeSlider" min="0" max="4" step="1" value="2" onChange="onRatingChange(event,'police')" />
- <div id="cops-facts"></div>
+ <div id="cops-title">Top Arrests</div>
+ <div id="cops-facts">
+ </div>
</li>
<li>
<h4 id="accidents-toggler">Accidents</h4>
View
290 web/js/map.js
@@ -2,192 +2,190 @@ var geocoder;
var map;
var infowindow;
var baseurl = '';
-$.ajaxSetup ({
- cache: false
-});
+$.ajaxSetup({
+ cache:false
+});
function initialize() {
- var myOptions = {
- center: new google.maps.LatLng(41.25917,-95.93386),
- zoom: 12,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
-
- geocoder = new google.maps.Geocoder();
- map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
-
- infowindow = new google.maps.InfoWindow({"maxWidth":175});
-
- google.maps.event.addListener(map, 'click', function(event) {
- // call web service here to get data about this point
-
- // add a marker here, and load data about this location
- infowindow.close();
- infowindow.setContent("<center><img src='/images/ajax-loader.gif'></center>");
- infowindow.setPosition(event.latLng);
- infowindow.open(map);
-
- fetchEvents(event.latLng.lat(),event.latLng.lng());
- //console.log(event.latLng.lat(),event.latLng.lng());
- });
-
- listenForBoundsChange();
-
+ var myOptions = {
+ center:new google.maps.LatLng(41.25917, -95.93386),
+ zoom:12,
+ mapTypeId:google.maps.MapTypeId.ROADMAP
+ };
+
+ geocoder = new google.maps.Geocoder();
+ map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+
+ infowindow = new google.maps.InfoWindow({"maxWidth":175});
+
+ $("#crime-title").hide();
+ $("#cops-title").hide();
+ google.maps.event.addListener(map, 'click', function (event) {
+ // call web service here to get data about this point
+
+ // add a marker here, and load data about this location
+ infowindow.close();
+ infowindow.setContent("<center><img src='/images/ajax-loader.gif'></center>");
+ infowindow.setPosition(event.latLng);
+ infowindow.open(map);
+
+ fetchEvents(event.latLng.lat(), event.latLng.lng());
+ //console.log(event.latLng.lat(),event.latLng.lng());
+ });
+
+ listenForBoundsChange();
+
map.overlayMapTypes.insertAt(0, new google.maps.ImageMapType({
- getTileUrl: function (tile, zoom) {
- var sliderData = getSliderData();
+ getTileUrl:function (tile, zoom) {
+ var sliderData = getSliderData();
var base = '/heatmap';
map_name = 'goodCrime';
color_scheme = 'classic';
- url = base +'/'+ map_name +'/' +
- sliderData["crimeSlider"] + '/' +
- sliderData["policeSlider"] + '/' +
- sliderData["accidentSlider"] + '/' +
- color_scheme +'/'+ zoom +'/'
- url += tile.x +','+ tile.y +'.png';
+ url = base + '/' + map_name + '/' +
+ sliderData["crimeSlider"] + '/' +
+ sliderData["policeSlider"] + '/' +
+ sliderData["accidentSlider"] + '/' +
+ color_scheme + '/' + zoom + '/'
+ url += tile.x + ',' + tile.y + '.png';
return url;
},
- tileSize: new google.maps.Size(256, 256),
- isPng: true
+ tileSize:new google.maps.Size(256, 256),
+ isPng:true
}));
-
- // load data
-
- //fetchData();
-
- map_foursquare_points();
+
+ // load data
+
+ //fetchData();
+
+ map_foursquare_points();
}
-function listenForBoundsChange()
-{
- google.maps.event.addListenerOnce(map, 'bounds_changed', function(){
- google.maps.event.addListenerOnce(map, 'idle', function(){
- updateStats();
- listenForBoundsChange();
- });
- });
+function listenForBoundsChange() {
+ google.maps.event.addListenerOnce(map, 'bounds_changed', function () {
+ google.maps.event.addListenerOnce(map, 'idle', function () {
+ updateStats();
+ listenForBoundsChange();
+ });
+ });
}
-function updateStats()
-{
- var bounds = map.getBounds();
- // pass extent to service
- var minX = bounds.getSouthWest().lng(); // minX = SW x
- var minY = bounds.getSouthWest().lat(); // minY = SW y
- var maxX = bounds.getNorthEast().lng(); // maxX = NE x
- var maxY = bounds.getNorthEast().lat(); // maxY = NE y
-
- var urlParams = "minX=" + minX + "&minY=" + minY + "&maxX=" + maxX + "&maxY=" + maxY;
- $.getJSON(baseurl + '/node/stats?' + urlParams, function(data) {
- //crime-facts
- //cops-facts
- // ol
-
- var i = 0;
- var crimes = data.topCrimes.items;
- var officers = data.topOfficers.items;
-
- var topCrimesContent = "<ol>";
- for (i = 0; i < crimes.length; i++)
- {
- var crimeData = crimes[i];
- topCrimesContent += "<li>" + crimeData.crime + ": " + crimeData.count + "</li>";
- console.log(topCrimesContent);
- }
- topCrimesContent += "</ol>";
-
- var topOfficersContent = "<ol>";
- for (i = 0; i < officers.length; i++)
- {
- var officerData = officers[i];
- topOfficersContent += "<li>Badge #" + officerData.officer + ": " + officerData.count + "</li>";
- console.log(topOfficersContent);
- }
- topOfficersContent += "</ol>";
-
- $("#crime-facts").html(topCrimesContent);
- $("#cops-facts").html(topOfficersContent);
-
- console.info("Update stats complete. " + data);
- });
-
- console.info("Update stats based on map extent minX: " + minX + ", minY: " + minY + ", maxX: " + maxX + ", maxY: " + maxX );
+function updateStats() {
+ var bounds = map.getBounds();
+ // pass extent to service
+ var minX = bounds.getSouthWest().lng(); // minX = SW x
+ var minY = bounds.getSouthWest().lat(); // minY = SW y
+ var maxX = bounds.getNorthEast().lng(); // maxX = NE x
+ var maxY = bounds.getNorthEast().lat(); // maxY = NE y
+
+ var urlParams = "minx=" + minX + "&miny=" + minY + "&maxx=" + maxX + "&maxy=" + maxY;
+ $.getJSON(baseurl + '/node/stats?' + urlParams, function (data) {
+ //crime-facts
+ //cops-facts
+ // ol
+
+ var i = 0;
+ var crimes = data.topCrimes.items;
+ var officers = data.topOfficers.items;
+
+ var topCrimesContent = "<ol>";
+ for (i = 0; i < crimes.length; i++) {
+ var crimeData = crimes[i];
+ topCrimesContent += "<li>" + crimeData.crime + ": " + crimeData.count + "</li>";
+ console.log(topCrimesContent);
+ }
+ topCrimesContent += "</ol>";
+
+ var topOfficersContent = "<ol>";
+ for (i = 0; i < officers.length; i++) {
+ var officerData = officers[i];
+ topOfficersContent += "<li>Badge #" + officerData.officer + ": " + officerData.count + "</li>";
+ console.log(topOfficersContent);
+ }
+ topOfficersContent += "</ol>";
+
+ $("#crime-facts").html(topCrimesContent);
+ $("#cops-facts").html(topOfficersContent);
+
+ console.info("Update stats complete. " + data);
+ });
+
+ console.info("Update stats based on map extent minX: " + minX + ", minY: " + minY + ", maxX: " + maxX + ", maxY: " + maxX);
}
function drawMarkers(data) {
-console.log(data);
- dataSet = data.items;
- var markers = new Array();
- for (var i = 0; i < dataSet.length; i++) {
- //console.log('Will place marker at ' + dataSet[i].loc[0] + ' ' + dataSet[i].loc[1])
- markers[i] = new google.maps.Marker({
- position: new google.maps.LatLng(dataSet[i].loc[1], dataSet[i].loc[0]),
- title: dataSet[i].type,
- map: map
- });
-
- if (markerImages[dataSet[i].type])
- markers[i].setIcon(markerImages[dataSet[i].type]);
-
- google.maps.event.addListener(markers[i], 'click', (function(marker,dataSetRow) {
- return function () {
- infowindow.setContent(makeInfoWindowContent(dataSetRow));
- infowindow.open(map, marker);
- };
- })(markers[i],dataSet[i]));
-
- }
+ console.log(data);
+ dataSet = data.items;
+ var markers = new Array();
+ for (var i = 0; i < dataSet.length; i++) {
+ //console.log('Will place marker at ' + dataSet[i].loc[0] + ' ' + dataSet[i].loc[1])
+ markers[i] = new google.maps.Marker({
+ position:new google.maps.LatLng(dataSet[i].loc[1], dataSet[i].loc[0]),
+ title:dataSet[i].type,
+ map:map
+ });
+
+ if (markerImages[dataSet[i].type])
+ markers[i].setIcon(markerImages[dataSet[i].type]);
+
+ google.maps.event.addListener(markers[i], 'click', (function (marker, dataSetRow) {
+ return function () {
+ infowindow.setContent(makeInfoWindowContent(dataSetRow));
+ infowindow.open(map, marker);
+ };
+ })(markers[i], dataSet[i]));
+
+ }
}
function updateHeatmap(sliderData) {
- console.log('sliders updated, will update map now.');
+ console.log('sliders updated, will update map now.');
//map.setCenter(map.getBounds().getCenter());
var zoom = map.getZoom();
map.setZoom(zoom + 1);
map.setZoom(zoom);
- google.maps.event.trigger(map,'resize');
+ google.maps.event.trigger(map, 'resize');
}
function makeInfoWindowContent(dataSetRow) {
- var html = '<div class="infowindow">';
- html += dataSetRow.category + '<br>' + dataSetRow.date + '<br>';
- //console.log(dataSetRow);
- //html += 'Offense: ' + dataSetRow.meta.crimeOffenseWithXy[0].offensedes;
- html += '</div>';
- return html.toLowerCase();
+ var html = '<div class="infowindow">';
+ html += dataSetRow.category + '<br>' + dataSetRow.date + '<br>';
+ //console.log(dataSetRow);
+ //html += 'Offense: ' + dataSetRow.meta.crimeOffenseWithXy[0].offensedes;
+ html += '</div>';
+ return html.toLowerCase();
}
function fetchData() {
- // place holder function. This will fetch data later
+ // place holder function. This will fetch data later
- $.getJSON(baseurl + '/node/ACCIDENT?meta=true', function(data) {
- drawMarkers(data);
- });
+ $.getJSON(baseurl + '/node/ACCIDENT?meta=true', function (data) {
+ drawMarkers(data);
+ });
}
-function fetchEvents(lat,lng) {
- console.log('fetchEvents called.');
- $.getJSON(baseurl + '/node/CRIME?x=' + lng + '&y=' + lat + '&radius=25&meta=true', handleEvents);
- }
+function fetchEvents(lat, lng) {
+ console.log('fetchEvents called.');
+ $.getJSON(baseurl + '/node/CRIME?x=' + lng + '&y=' + lat + '&radius=25&meta=true', handleEvents);
+}
function handleEvents(data) {
- var html = '';
- for (var i = 0; i < data.items.length; i++) {
- html += '<p><b>' + data.items[i].category + '</b><br>' +
- data.items[i].meta.crimeOffenseWithXy[0].occuradd +
- '</p>';
- }
-
- var finalHtml = "<div class='infowindow'>" + html + "</div>";
- infowindow.setContent(finalHtml.toLowerCase());
+ var html = '';
+ for (var i = 0; i < data.items.length; i++) {
+ html += '<p><b>' + data.items[i].category + '</b><br>' +
+ data.items[i].meta.crimeOffenseWithXy[0].occuradd +
+ '</p>';
+ }
+
+ var finalHtml = "<div class='infowindow'>" + html + "</div>";
+ infowindow.setContent(finalHtml.toLowerCase());
}
// define images for different types of data (http://jg.org/mapping/icons.html)
var markerImages = {
- "CRIME": "http://labs.google.com/ridefinder/images/mm_20_red.png",
- "SCHOOL": "http://labs.google.com/ridefinder/images/mm_20_white.png"
+ "CRIME":"http://labs.google.com/ridefinder/images/mm_20_red.png",
+ "SCHOOL":"http://labs.google.com/ridefinder/images/mm_20_white.png"
};
View
6 web/js/run.js
@@ -10,10 +10,16 @@ require({
'dojo/domReady!'
], function () {
$('#crime-toggler').css({ cursor:'pointer',textDecoration:'underline' }).bind('click', function () {
+ $("#crime-title").hide();
$('#crime-facts').toggle('slow');
+ $("#cops-title").hide();
+ $('#cops-facts').hide('slow');
});
$('#cops-toggler').css({ cursor:'pointer',textDecoration:'underline' }).bind('click', function () {
+ $("#cops-title").hide();
$('#cops-facts').toggle('slow');
+ $("#crime-title").hide();
+ $('#crime-facts').hide('slow');
});
$('#accidents-toggler').bind('click', function () {
$('#accidents-facts').toggle('slow');
Please sign in to comment.
Something went wrong with that request. Please try again.