Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
poi.features.forEach((feat, idx) => {
let coords = feat.geometry.type !== 'Point'
? centerOfMass(feat).geometry.coordinates
: feat.geometry.coordinates;
// The response will be converted to a feature on the client.
// This way we reduce the response size by a lot.
response.push({
// feature id.
i: idx,
// Coordinates.
c: [parseInt(coords[0] * 1e5) / 1e5, parseInt(coords[1] * 1e5) / 1e5]
});
});
const origins = features.map(feat => {
const coordinates = feat.geometry.type === 'Point'
? feat.geometry.coordinates
: centerOfMass(feat).geometry.coordinates;
// Will be flattened later.
// The array is constructed in this way so we can match the index of the
// results array and attribute the correct id.
const featureIndicators = indicators.map(ind => ({
key: ind.key,
label: ind.label,
value: parseInt(feat.properties[ind.key])
}));
originsIndicators.push(featureIndicators);
return {
project_id: projId,
name: feat.properties[getPropInsensitive(feat.properties, 'name')] || 'N/A',
coordinates: JSON.stringify(coordinates)
};
? data.map(d =>
centerOfMass(d.geometry, { properties: { ...d.properties } })
)
const features = poisData[key].features.map(feat => {
return {
...feat,
properties: {
...feat.properties,
ram_poi_type: key
},
geometry: feat.geometry.type !== 'Point'
? centerOfMass(feat).geometry
: feat.geometry
};
});
return acc.concat(features);