Skip to content

Commit

Permalink
remove dead and unneeded console.logs, disable incident and call map …
Browse files Browse the repository at this point in the history
…scrolls, and add emergency shelter section to both SpotFax and SpotSafety
  • Loading branch information
kmcurry committed Feb 7, 2019
1 parent 5ef6b23 commit 43f01d7
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 58 deletions.
3 changes: 2 additions & 1 deletion locations/Virginia/VirginiaBeach.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ var VirginiaBeach = {
boundary: "https://gismaps.vbgov.com/arcgis/rest/services/Basemaps/Administrative_Boundaries/MapServer/0/",
council: "https://gismaps.vbgov.com/arcgis/rest/services/Basemaps/VotingDistricts/MapServer/2/",
neighborhoods: "https://gismaps.vbgov.com/arcgis/rest/services/Basemaps/PropertyInformation_VBgov/MapServer/13/",
shelters: "https://gismaps.vbgov.com/arcgis/rest/services/Public_Safety/Emergency_Preparedness/MapServer/0/",
subdivisions: "https://gismaps.vbgov.com/arcgis/rest/services/Basemaps/PropertyInformation_VBgov/MapServer/23/",
zipCodes: "https://gismaps.vbgov.com/arcgis/rest/services/Basemaps/Administrative_Boundaries/MapServer/1/",

property: {
AICUZ: "https://gismaps.vbgov.com/arcgis/rest/services/Basemaps/AICUZ/MapServer/3/",
sales: "https://data.vbgov.com/resource/p3zb-bkwc.json",
Expand Down
9 changes: 6 additions & 3 deletions locations/template.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var LocationName = {

boundary: "",
neighborhoods: "",
representatives: "",
council: "",
evacuation: "",

neighborhoods: "",
shelters: "",
subdivisions: "",
zipCodes: "",

property: {
AICUZ: "",
FIRM: "",
Expand Down
8 changes: 8 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ body {
background: #ffb3ec;
}

.emergency-shelter {
background: #d9f9a8;
}

.evacuation {
background: #d9b7f1;
}

.flood {
background: #C1ECFA;
padding-left: 2px !important;
Expand Down
19 changes: 5 additions & 14 deletions public/js/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function getAddress(searchPosition) {
if (request.readyState == 4) {
if (request.status == 200) {
var data = JSON.parse(request.responseText);
//console.log(data);
var address = data.results[0];
resolve(address);
} else {
Expand Down Expand Up @@ -90,8 +89,7 @@ function getFeaturesForLocation(address, position) {
getClosestThing(DataDirectory.recreation.centers, ll, "recreation-center");
getNearbyNeighborhoods(DataDirectory.neighborhoods, ll, 1, "neighborhoods")
getCouncilDistrict(DataDirectory.council, ll);
getEvacuationZone(locations[statePath].evacuation, ll);


//getCountWithinDays(DataDirectory.police.calls, ll, 1, 30, "police-calls");
getCountWithinDays(DataDirectory.property.code_enforcement, ll, 1, 30, "code-enforcement");
getPropertySales(DataDirectory.property.sales, address);
Expand Down Expand Up @@ -151,8 +149,6 @@ function getAverageResponseTime(url, ll, d, type) {
var msg = getAverageTime(data, ll);
//var z = "<p>" + data.length + "</p>";

//console.log(data);

msg += "<a title='Call or Incident reports within 1 mile. Average response time based on " + data.length + " records.' href=''>*</a>";

d3.select("#" + type + "-response-avg").html(msg);
Expand Down Expand Up @@ -185,6 +181,9 @@ function getClosestThing(url, ll, thing, units) {

console.log(closest.item[0].properties);

// TODO: filter attributes that contain substring 'name'
var name = closest.item[0].properties.stop_name ? closest.item[0].properties.stop_name : closest.item[0].properties.NAME;

var msg = "";

if (!closest.item || parseInt(closest.distance) === 9999) {
Expand Down Expand Up @@ -212,7 +211,7 @@ function getClosestThing(url, ll, thing, units) {

mapUrl += closest.item[0].properties.ADDRESS;

var html = "<a href='" + mapUrl + "'>" + msg + "</a>"
var html = "<a href='" + mapUrl + "'>" + msg + "</a><br/>" + name;


d3.select("#closest-" + thing).html(html);
Expand Down Expand Up @@ -288,8 +287,6 @@ function getCountWithinDays(url, ll, dist, days, type) {

url += "?$where=within_circle(" + locField + "," + ll[1] + "," + ll[0] + "," + dist + encodeURIComponent(") and " + dateField + " > '") + encodeURIComponent(checkDate) + encodeURIComponent("'");

console.log(url);

d3.request(url)
.mimeType("application/json")
.response(function (xhr) {
Expand Down Expand Up @@ -481,7 +478,6 @@ function getRepresentation(url, address) {
var offices = data.offices;

$(offices).each(function (index, office) {
//console.log(office);
msg += "<p style='background-color:LightBlue'>" + office.name + "</p>";


Expand Down Expand Up @@ -725,7 +721,6 @@ function getClosestItem(features, ll) {

$(features).each(function () {
var f = $(this);
//console.log(f[0]);
if (f && f[0]) {
if (f[0].geometry.coordinates[0].length) {
if (f[0].geometry.coordinates[0][0].length) {
Expand All @@ -738,7 +733,6 @@ function getClosestItem(features, ll) {
}
dist = d3.geoDistance(coords, ll); // distance in radians
if (dist < closest.distance) {
//console.log(dist);
closest.distance = dist;
closest.item = f;
}
Expand All @@ -749,8 +743,6 @@ function getClosestItem(features, ll) {
closest.distance = closest.distance != 9999 ? parseFloat(closest.distance) * 3959 : 9999; // 3959 is Earth radius in miles
closest.distance = closest.distance.toFixed(2);

console.log(closest.distance);

coords = null;
dist = null;

Expand All @@ -776,7 +768,6 @@ function getItemsForFeatures(features, ll, d) {
var dist = d3.geoDistance(coords, ll);
var max = d / 3959;
if (dist <= max) {
//console.log(f[0]);
return f[0];
}
}
Expand Down
2 changes: 1 addition & 1 deletion public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function geolocate() {
center: geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
//autocomplete.setBounds(circle.getBounds());
});
}
}
Expand Down
5 changes: 1 addition & 4 deletions public/js/prices/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ $(document).ready(function () {
geoCoderKey = $("#geoCoderKey").val();
GApisKey = $("#GApisKey").val();

//console.log(locations);
searchPosition = $("#searchPosition").val();
//console.log(searchPosition);
searchPosition = searchPosition.split(',');

$(document).tooltip();
console.log("DOCUMENT IS READY");


getAddress(searchPosition)
.then(function (address) {
var addr = address;
Expand Down
3 changes: 0 additions & 3 deletions public/js/property/mapCodeEnforcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var map = L.map('codeEnforcementMap').setView([36.78, -76.00], 11);
var zipCode_boundary = null;

var locations = $("#locations").val();
//console.log(locations);
locations = JSON.parse(locations);

if (locations['Virginia']) {
Expand All @@ -24,7 +23,6 @@ function getColor(d) {
}

function style(feature) {
console.log(feature.properties.enforcements.length);
return {
fillColor: getColor(feature.properties.enforcements.length),
weight: 2,
Expand Down Expand Up @@ -118,7 +116,6 @@ $.ajax({
$(data.features).each(function (key, data) {
var enforcementsInZipCode = $(enforcements).filter(function(index) {
//return enforcements[index].zip_code.startsWith(data.properties.ZIP_CODE);
//console.log(enforcements[index].sub_division);
return enforcements[index].sub_division == data.properties.SUBD_DESC;
})
data.properties.enforcements = enforcementsInZipCode;
Expand Down
3 changes: 0 additions & 3 deletions public/js/property/mapPropertySales.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var map = L.map('propertySalesMap').setView([36.78, -76.00], 10);
var zipCode_boundary = null;

var locations = $("#locations").val();
//console.log(locations);
locations = JSON.parse(locations);

if (locations['Virginia']) {
Expand All @@ -24,7 +23,6 @@ function getColor(d) {
}

function style(feature) {
console.log(feature.properties.sales.length);
return {
fillColor: getColor(feature.properties.sales.length),
weight: 2,
Expand Down Expand Up @@ -117,7 +115,6 @@ $.ajax({
if (sales) {
$(data.features).each(function (key, data) {
var salesInZipCode = $(sales).filter(function(index) {
//console.log(sales[index].zip_code);
if(sales[index].zip_code) {
return sales[index].zip_code.startsWith(data.properties.ZIP_CODE);
}
Expand Down
5 changes: 1 addition & 4 deletions public/js/safety/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ $(document).ready(function () {
geoCoderKey = $("#geoCoderKey").val();
GApisKey = $("#GApisKey").val();

//console.log(locations);
searchPosition = $("#searchPosition").val();
//console.log(searchPosition);
searchPosition = searchPosition.split(',');

$(document).tooltip();
console.log("DOCUMENT IS READY");


getAddress(searchPosition)
.then(function (address) {
var addr = address;
Expand Down
3 changes: 2 additions & 1 deletion public/js/safety/mapCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var mapCalls = L.map('callsMap').setView([36.78, -76.00], 10);
var patrol_zone_boundary_calls = null;

var locations = $("#locations").val();
//console.log(locations);
locations = JSON.parse(locations);

if (locations['Virginia']) {
Expand Down Expand Up @@ -123,6 +122,8 @@ $.ajax({
onEachFeature: onEachCallsFeature
});
patrol_zone_boundary_calls.addTo(mapCalls);

mapCalls.scrollWheelZoom.disable();
}
});
}
Expand Down
2 changes: 0 additions & 2 deletions public/js/safety/mapCallsSubdivision.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var map = L.map('callsMap').setView([36.78, -76.00], 11);
var subdivision_boundary = null;

var locations = $("#locations").val();
//console.log(locations);
locations = JSON.parse(locations);

if (locations['Virginia']) {
Expand All @@ -24,7 +23,6 @@ function getColor(d) {
}

function style(feature) {
console.log(feature.properties.calls.length);
return {
fillColor: getColor(feature.properties.calls.length),
weight: 2,
Expand Down
4 changes: 3 additions & 1 deletion public/js/safety/mapIncidents.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ $.ajax({
success: function (data) {

var locations = $("#locations").val();
//console.log(locations);
locations = JSON.parse(locations);

if (locations['Virginia']) {
Expand All @@ -123,6 +122,9 @@ $.ajax({
onEachFeature: onEachFeature
});
patrol_zone_boundary_incidents.addTo(mapIncidents);

mapIncidents.scrollWheelZoom.disable();

}
});
}
Expand Down
29 changes: 12 additions & 17 deletions public/js/safety/safety.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@ function getSafetyData(DataDirectory, ll) {
getAverageResponseTime(DataDirectory.medical.emergency.calls, ll, 1, "ems");
getAverageResponseTime(DataDirectory.police.calls, ll, 1, "police");
getCrashes(DataDirectory.police.crashes, ll, 1, 30);
getEvacuationZone(locations[statePath].evacuation, ll);
getClosestThing(DataDirectory.shelters, ll, "emergency-shelter", "miles");

//getClosestThing(DataDirectory.fire.hydrants.public, ll, "hydrant-public", "feet");
// getClosestThing(DataDirectory.fire.hydrants.private, ll, "hydrant-private", "feet");

setTimeout(
function(){
$('#police-incidents-table').DataTable({
paging:false
});
$('#police-calls-table').DataTable({
paging:false
});
$('#police-crash-table').DataTable({
paging:false
});
}, 1000);
}

function getEvacuationZone(url, ll) {
Expand Down Expand Up @@ -94,6 +84,9 @@ function getCrashes(crashes, ll, dist, days) {
html += "</tbody>"
$("#police-crash-table").append(html);
crashes = null;
$('#police-crash-table').DataTable({
paging:false
});
} else {
console.log("No Data from getCountWithinDays")
}
Expand All @@ -105,7 +98,6 @@ function getPoliceCalls(calls, ll, dist, days) {

getCountWithinDays(calls, ll, dist, days, "police-calls").then(function (calls) {
if (calls) {
// console.log("Police Incidents")
calls = calls.sort(function (a, b) {
return new Date(b.call_date_time) - new Date(a.call_date_time);
});
Expand Down Expand Up @@ -162,6 +154,9 @@ function getPoliceCalls(calls, ll, dist, days) {
html += "</tbody>"
$("#police-calls-table").append(html);
calls = null;
$('#police-calls-table').DataTable({
paging:false
});
} else {
console.log("No Data from getCountWithinDays")
}
Expand All @@ -174,7 +169,6 @@ function getPoliceIncidents(incidents, ll, dist, days) {

getCountWithinDays(incidents, ll, dist, days, "police-incidents").then(function (incidents) {
if (incidents) {
// console.log("Police Incidents")
incidents = incidents.sort(function (a, b) {
return new Date(b.date_occured) - new Date(a.date_occured);
});
Expand Down Expand Up @@ -229,6 +223,9 @@ function getPoliceIncidents(incidents, ll, dist, days) {
html += "</tbody>";
$("#police-incidents-table").append(html);
incidents = null;
$('#police-incidents-table').DataTable({
paging:false
});
} else {
console.log("No Data from getCountWithinDays")
}
Expand All @@ -254,7 +251,6 @@ function getPolicePatrolZone(url, ll) {
}

if (data && data.features && data.features[0]) {
//console.log(data.features[0]);
var patrolZone = data.features[0].properties.BEAT ? data.features[0].properties.BEAT : data.features[0].properties.Car_Sector;
d3.select("#police-patrol").html(patrolZone); //+ "<a href=''>Zone Map</a>");
} else {
Expand Down Expand Up @@ -286,7 +282,6 @@ function getPolicePrecinct(url, ll) {
}

if (data && data.features && data.features[0]) {
//console.log(data.features[0]);
var precinct = data.features[0].properties.PRECINCT ? data.features[0].properties.PRECINCT : data.features[0].properties.Precinct;
d3.select("#police-precinct").html(precinct); //+ "<a href=''>Zone Map</a>");
} else {
Expand Down
5 changes: 1 addition & 4 deletions public/js/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ $(document).ready(function () {
geoCoderKey = $("#geoCoderKey").val();
GApisKey = $("#GApisKey").val();

//console.log(locations);
searchPosition = $("#searchPosition").val();
//console.log(searchPosition);
searchPosition = searchPosition.split(',');

$(document).tooltip();
console.log("DOCUMENT IS READY");


getAddress(searchPosition)
.then(function (address) {
var addr = address;
Expand Down
10 changes: 10 additions & 0 deletions public/views/safety.pug
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ body
div(class="col-xs-6 col-sm-6 col-md-6 col-lg-6")
div(id="address") ...
div(name="safety" id="safety")
div(class="row evacuation")
div(class="col-xs-6 col-sm-6 col-md-6 col-lg-6")
<span class="fa fa-life-ring"></span> Evacuation Zone
div(class="col-xs-6 col-sm-6 col-md-6 col-lg-6")
div(id="evacuation")
div(class="row emergency-shelter")
div(class="col-xs-6 col-sm-6 col-md-6 col-lg-6")
<span class="fa fa-building"></span> Emergency Shelter
div(class="col-xs-6 col-sm-6 col-md-6 col-lg-6")
div(id="closest-emergency-shelter")
div(class="row ems")
div(class="col-xs-6 col-sm-6 col-md-6 col-lg-6")
<span class="fa fa-ambulance"></span> Response Time
Expand Down
Loading

0 comments on commit 43f01d7

Please sign in to comment.