Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var buildings = layer.features.filter(function(val) {
if (val.properties.building && val.geometry.type === 'Polygon') {
var flag = 0;
var buildingPoints = turf.explode(val);
var pointsWithin = turf.within(buildingPoints, buffer);
if (!pointsWithin.features.length) {
var props = {
"_osm_way_id": val.properties._osm_way_id,
"building": val.properties.building,
};
//area in m^2
props.area = parseFloat((turf.area(val)).toFixed(3));
// Convert the polygon to a line to find perimeter
val.geometry.type = 'LineString';
val.geometry.coordinates = val.geometry.coordinates[0];
// perimeter in meter
props.perimeter = parseFloat(((turf.lineDistance(val,'kilometers') * 1000)).toFixed(3));
data: turf.envelope(logo),
color: color()
},
{
name: 'Center',
data: turf.center(logo),
color: color()
},
{
name: 'Explode',
data: turf.explode(logo),
color: color()
},
{
name: 'TIN',
data: turf.tin(turf.explode(logo)),
color: color()
},
{
name: 'Convex',
data: turf.convex(logo),
color: color()
},
{
name: 'Flip',
data: turf.flip(logo),
color: color()
},
{
name: 'Random',
data: turf.random('points', 50),
color: color()
var updates = this.editFeatures(layers, function(gj, layer) {
if (gj.selected) {
var _gj = turf.explode(gj)
return _gj
} else return gj
})
LayerActions.updateList(updates)
data: logo,
color: color()
},
{
name: 'Envelope',
data: turf.envelope(logo),
color: color()
},
{
name: 'Center',
data: turf.center(logo),
color: color()
},
{
name: 'Explode',
data: turf.explode(logo),
color: color()
},
{
name: 'TIN',
data: turf.tin(turf.explode(logo)),
color: color()
},
{
name: 'Convex',
data: turf.convex(logo),
color: color()
},
{
name: 'Flip',
data: turf.flip(logo),
color: color()
data: turf.flip(logo),
color: color()
},
{
name: 'Random',
data: turf.random('points', 50),
color: color()
},
{
name: 'Hex',
data: turf.hex(turf.extent(logo), 10),
color: color()
},
{
name: 'Hex-Count',
data: turf.count(turf.hex(turf.extent(logo), 10), turf.explode(logo), 'count'),
color: color()
}
];
var optionsDiv = document.getElementById('options');
options.forEach(function(o) {
var link = optionsDiv.appendChild(document.createElement('a'));
link.innerHTML = o.name;
link.style.background = o.color;
link.onclick = function() {
selectData(o.data);
togglePanel();
};
});