Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(data, tile, writeData, done) {
var digiroadLayer = data.fonecta.fonecta;
var diffLayer = data.osm.osm;
var osmlint = 'digiroad';
var resultDiffLayer = 0;
var resultdDigiLayer = 0;
var limits = {
min_zoom: 12,
max_zoom: 12
};
var bbox = turf.bbox(digiroadLayer);
var bboxPolygon = turf.bboxPolygon(bbox);
var centroidPt = turf.centroid(bboxPolygon);
var tilePoly = cover.geojson(centroidPt.geometry, limits);
var newtile = cover.tiles(centroidPt.geometry, limits);
// digiroad
for (var i = 0; i < diffLayer.features.length; i++) {
var val = diffLayer.features[i];
if (val.geometry.type == 'LineString') {
var dist = turf.lineDistance(val, 'kilometers');
resultDiffLayer = resultDiffLayer + dist;
}
}
//digiroad layer
for (var i = 0; i < digiroadLayer.features.length; i++) {
var val = digiroadLayer.features[i];
if (val.geometry.type == 'LineString') {
var dist = turf.lineDistance(val, 'kilometers');
resultdDigiLayer = resultdDigiLayer + dist;
diffFc.features = Object.keys(runkeeperPixels).map(function(hash){
var tile = hash.split('/').map(parseFloat);
var poly = turf.centroid(turf.polygon(tilebelt.tileToGeoJSON(tile).coordinates));
poly.properties.count = runkeeperPixels[hash];
return poly;
});
diffFc.features = diffFc.features.filter(function(cell){
dim.push(0.0);
}
demand.push(dim);
}
var landmark_polygons_of_interest = {"JFK Airport": 0, "LaGuardia Airport": 0, "Grand Central": 0, "Port Authority Bus Terminal": 0, "Penn Station": 0};
var landmark_scalers = {"JFK Airport": 11000.0, "LaGuardia Airport": 9000.0, "Grand Central": 2000.0, "Port Authority Bus Terminal": 1000.0, "Penn Station": 2000.0};
for (landmark_index = 0; landmark_index < landmarks_data["features"].length; landmark_index++) {
var landmark = landmarks_data["features"][landmark_index];
var landmark_name = landmark["properties"]["name"];
if (landmark_name in landmark_polygons_of_interest) {
//console.log(landmark["geometry"]["coordinates"]);
var landmark_polygon = turf.polygon(landmark["geometry"]["coordinates"]);
landmark_polygons_of_interest[landmark_name] = landmark_polygon;
var landmark_centroid = turf.centroid(landmark_polygon);
console.log("Landmark "+landmark_name+" centroid in polygon: "+turf.inside(landmark_centroid, landmark_polygon));
}
}
console.log("Calculating centroids");
var centroids = [];
for (tract_index = 0; tract_index < data.features.length; tract_index++) {
var turf_centroid = turf.centroid(data.features[tract_index]);
//var tract_area = turf.area(turf_polygons[tract_index]);
centroids[tract_index] = turf_centroid;
}
console.log("Calculating voxels");
for (i = 0; i < voxels_dim; i++) {
var lat = lat_min + voxels_res_lat*i;
var atotal = aland + awater;
var scale_factor = 1.0 / (aland / atotal);
var population_scaled_for_land = record["POP10"] * scale_factor;
populations[record["GEOID"]] = population_scaled_for_land;
population_density[record["GEOID"]] = population_scaled_for_land/(record["ALAND"] * .0000003861);
if (population_scaled_for_land/(record["ALAND"] * .0000003861) > 1000.0) {
dense_enough += 1;
}
}
console.log(dense_enough + " of " + population_records.length + " tracts are dense enough for consideration");
console.log("Calculating centroids");
var centroids = [];
var water_centroids = [];
for (tract_index = 0; tract_index < census_data.features.length; tract_index++) {
var turf_centroid = turf.centroid(turf_polygons[tract_index]);
//var tract_area = turf.area(turf_polygons[tract_index]);
centroids[tract_index] = turf_centroid;
}
for (var w = 0; w < water_data.features.length; w++) {
var water_centroid = turf.centroid(water_data.features[w]);
water_centroids[w] = water_centroid;
}
var dggrids_with_overlap = 0;
var dggrids_queried = 0;
for (var j = 0; j < dggrid_data.features.length; j++) {
var feature = dggrid_data.features[j];
var landmark = landmarks_data["features"][landmark_index];
var landmark_name = landmark["properties"]["name"];
if (landmark_name in landmark_polygons_of_interest) {
//console.log(landmark["geometry"]["coordinates"]);
var landmark_polygon = turf.polygon(landmark["geometry"]["coordinates"]);
landmark_polygons_of_interest[landmark_name] = landmark_polygon;
var landmark_centroid = turf.centroid(landmark_polygon);
console.log("Landmark "+landmark_name+" centroid in polygon: "+turf.inside(landmark_centroid, landmark_polygon));
}
}
console.log("Calculating centroids");
var centroids = [];
for (tract_index = 0; tract_index < data.features.length; tract_index++) {
var turf_centroid = turf.centroid(data.features[tract_index]);
//var tract_area = turf.area(turf_polygons[tract_index]);
centroids[tract_index] = turf_centroid;
}
console.log("Calculating voxels");
for (i = 0; i < voxels_dim; i++) {
var lat = lat_min + voxels_res_lat*i;
for (j = 0; j < voxels_dim; j++) {
var lon = lon_min + voxels_res_lon*j;
var square = turf.bboxPolygon([lon, lat, lon+voxels_res_lon, lat+voxels_res_lat]);
var d = 0.0;
for (tract_index = 0; tract_index < data.features.length; tract_index++) {
var tract = data.features[tract_index];
var ct2010 = tract.properties.TRACTCE10;
var centroid = centroids[tract_index];
hail.features = paths.features.map(function(path, k){
var cent = turf.centroid(path);
cent.properties.y = path.properties.YR;
return cent;
});
var zoomedTiles = zoomedTiles.map(function(tile){
var centroid =
turf.centroid(
turf.bboxPolygon(
tilebelt.tileToBBOX(tile)
)
);
return tilebelt.pointToTile(
centroid.geometry.coordinates[0],
centroid.geometry.coordinates[1], zoom);
});
return zoomedTiles;
var dggrids_queried = 0;
for (var j = 0; j < dggrid_data.features.length; j++) {
var feature = dggrid_data.features[j];
var dggrid_polygon = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": feature.geometry.coordinates
}
};
var dggrid_centroid = turf.centroid(dggrid_polygon);
var wkt = 'POLYGON((';
for (var i = 0; i < feature["geometry"]["coordinates"][0].length; i++) {
var coordinate = feature["geometry"]["coordinates"][0][i];
wkt += coordinate[0];
wkt += ' ';
wkt += coordinate[1];
if (i < feature["geometry"]["coordinates"][0].length - 1) {
wkt += ', ';
} else {
wkt += '))';
}
}
var has_overlap = false;
var all_water = false;
.pipe(through(function toEs(row) {
var stream = this;
if(irisMap.get(row.COM)) {
var center = turf.centroid(irisMap.get(row.COM));
var data = {
geometry: irisMap.get(row.COM).geometry,
center: center.geometry.coordinates
}
Object.keys(toKeep).map(label => {
data[toKeep[label]] = row[label];
})
batch.push({index: {_index: 'iris', _type: 'iris'}});
batch.push(data)
}
if (batch.length === 1000) {
data[1].features = data[1].features.filter(feature =>
inside(centroid(feature), gapsCoverageExtent)
).forEach(feature => {