helper_functions/polygonsCenters/polygonsCenters.js
/**
 * Generates a GeoJson file that icludes feature' centers coords
 * 
 * @param {string} oldFile input geojson file path 
 * @param {number} precision - round centers to given places after comma
 * @param {string} newFile output geojson filename
 * @param {string} fileToGenerate choose between 'full-with-centers' or 'minified'
 */
Generates a GeoJson file that icludes feature' centers coords

@param {string} oldFile input geojson file path
@param {number} precision - round centers to given places after comma
@param {string} newFile output geojson filename
@param {string} fileToGenerate choose between 'full-with-centers' or 'minified'
Generates a GeoJson file that icludes feature ' centers coords @param { string } oldFile input geojson file path @param { number } precision - round centers to given places after comma @param { string } newFile output geojson filename @param { string } fileToGenerate choose between ' full - with - centers ' or ' minified '
function generateNewGeoJson(oldFile, newFile, precision, fileToGenerate) {
    const coords = JSON.parse(fs.readFileSync(oldFile, { encoding: 'utf8', flag: 'r' }));
    let newCoords;
    if (fileToGenerate === 'full-with-centers') {
        newCoords = generateFeaturesWithCenters(coords, precision);
    }
    else if (fileToGenerate === 'minified') {
        newCoords = generateMinifiedFeatures(coords, precision);
    }
    else {new Error('Incorrect fileToGenerate type')}
    fs.writeFile(`${newFile}.json`, JSON.stringify(newCoords), (err) => err ? console.log(err) : null);
}
function generateNewGeoJson ( oldFile , newFile , precision , fileToGenerate ) { const coords = JSON . parse ( fs . readFileSync ( oldFile , { encoding : 'utf8' , flag : 'r' } ) ) ; let newCoords ; if ( fileToGenerate === 'full-with-centers' ) { newCoords = generateFeaturesWithCenters ( coords , precision ) ; } else if ( fileToGenerate === 'minified' ) { newCoords = generateMinifiedFeatures ( coords , precision ) ; } else { new Error ( 'Incorrect fileToGenerate type' ) } fs . writeFile ( ` ${ newFile } ` , JSON . stringify ( newCoords ) , ( err ) => err ? console . log ( err ) : null ) ; }
Generates a GeoJson file that icludes feature' centers coords
Generates a GeoJson file that icludes feature ' centers coords
// Choose between geojson with full data and centers properties // and geojson without ISO3166-1-Alpha-3