function filterData(data, crimeType, startDate, endDate) {
let lat, lng, block, type, info, date, results = [];
const dataFilter = arrow.predicate.custom(i => {
const date = toDate(data.getColumn('Date').get(i));
const primaryType = data.getColumn('PrimaryType').get(i);
return date >= startDate && date <= endDate &&
(crimeType === '' || primaryType === crimeType);
}, b => 1);
data.filter(dataFilter)
.scan((index) => {
results.push({
'lat': lat(index),
'lng': lng(index),
index
});
}, (batch) => {
lat = arrow.predicate.col('Latitude').bind(batch);
lng = arrow.predicate.col('Longitude').bind(batch);
}
);
return results;
}