<commit_before>var cover = require('tile-cover');
var tilebelt = require('tilebelt');
var turf = require('turf');
var fs = require('fs');

//data
var pga = JSON.parse(fs.readFileSync(__dirname+'/data/pga.geojson'));
var pgv = JSON.parse(fs.readFileSync(__dirname+'/data/pgv.geojson'));

var coveropts = {min_zoom: 15, max_zoom: 15};
var tiles = {};

//peak ground acceleration
pga.features.forEach(function(contour){
  var contourTiles = cover.tiles(contour.geometry, coveropts);
  contourTiles.forEach(function(tile){
    if(!tiles[id(tile)]){
      tiles[id(tile)] = {
        pga: 0,
        pgv: 0
      };
    }
    if(tiles[id(tile)].pga < contour.properties.PARAMVALUE) {
      tiles[id(tile)].pga = contour.properties.PARAMVALUE;
    }
  });
});

//peak ground velocity
pgv.features.forEach(function(contour){
  var contourTiles = cover.tiles(contour.geometry, coveropts);
  contourTiles.forEach(function(tile){
    if(!tiles[id(tile)]){
      tiles[id(tile)] = {
        pga: 0,
        pgv: 0
      };
    }
    if(tiles[id(tile)].pgv < contour.properties.PARAMVALUE) {
      tiles[id(tile)].pgv = contour.properties.PARAMVALUE;
    }
  });
});

var fc = turf.featurecollection([]);
Object.keys(tiles).forEach(function(tile){
  var poly = turf.polygon(tilebelt.tileToGeoJSON(tile.split('/').map(parseFloat)).coordinates);
  poly.properties = tiles[tile];
  fc.features.push(poly);
});

fs.writeFileSync(__dirname+'/data/tiles.geojson', JSON.stringify(fc));
fs.writeFileSync(__dirname+'/data/tiles.json', JSON.stringify(tiles));
console.log(Object.keys(tiles).length)
function id (tile){
  return tile[0] + '/' + tile[1] + '/' + tile[2];
}<commit_msg>index conflation<commit_after>var cover = require('tile-cover');
var tilebelt = require('tilebelt');
var turf = require('turf');
var fs = require('fs');

//data
var pga = JSON.parse(fs.readFileSync(__dirname+'/data/pga.geojson'));
var pgv = JSON.parse(fs.readFileSync(__dirname+'/data/pgv.geojson'));

var coveropts = {min_zoom: 15, max_zoom: 15};
var tiles = {};

//peak ground acceleration
pga.features.forEach(function(contour){
  var contourTiles = cover.tiles(contour.geometry, coveropts);
  contourTiles.forEach(function(tile){
    if(!tiles[id(tile)]){
      tiles[id(tile)] = {
        pga: 0,
        pgv: 0
      };
    }
    if(tiles[id(tile)].pga < contour.properties.PARAMVALUE) {
      tiles[id(tile)].pga = contour.properties.PARAMVALUE;
    }
  });
});

//peak ground velocity
pgv.features.forEach(function(contour){
  var contourTiles = cover.tiles(contour.geometry, coveropts);
  contourTiles.forEach(function(tile){
    if(!tiles[id(tile)]){
      tiles[id(tile)] = {
        pga: 0,
        pgv: 0
      };
    }
    if(tiles[id(tile)].pgv < contour.properties.PARAMVALUE) {
      tiles[id(tile)].pgv = contour.properties.PARAMVALUE;
    }
  });
});

var fc = turf.featurecollection([]);
Object.keys(tiles).forEach(function(tile){
  var poly = turf.polygon(tilebelt.tileToGeoJSON(tile.split('/').map(parseFloat)).coordinates);
  poly.properties = tiles[tile];
  fc.features.push(poly);
});

fs.writeFileSync(__dirname+'/data/tiles.geojson', JSON.stringify(fc));
fs.writeFileSync(__dirname+'/data/tiles.json', JSON.stringify(tiles));

function id (tile){
  return tile[0] + '/' + tile[1] + '/' + tile[2];
}
{'fraction_non_alphanumeric': 0.18356164383561643, 'fraction_numerical': 0.006697108066971081, 'mean_word_length': 4.142410015649452, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1261357', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1156, 'n_words': 174}