How to use the turf.featureCollection function in turf

To help you get started, we’ve selected a few turf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osmlab / osmlint / validators / filterNHS / map.js View on Github external
var osmlint = '01_dir_template';
  var result = [];
  for (var i = 0; i < layer.features.length; i++) {
    var val = layer.features[i];

    //writeData(JSON.stringify(val) + '\n');
    //here comes all your code to validate the data
    // val.properties._osmlint = osmlint;
    // result.push(val);
    if (val.properties.FULLNAME && val.properties.FULLNAME ==='US Hwy 1'){
  result.push(val);
    }
  }

  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / missingUTurn / map.js View on Github external
}
      }
      // Check the outputs
      if (_.size(nearRoads.evalRoad) > 0 && _.size(nearRoads.paralled) > 0 && _.size(nearRoads.output) > 0 && _.size(nearRoads.intersecCoord) > 0) {
        for (var type in nearRoads) {
          for (var feature in nearRoads[type]) {
            output[feature] = nearRoads[type][feature];
          }
        }
      }
    }
  }

  var result = _.values(output);
  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / bridgeOnNode / map.js View on Github external
module.exports = function(tileLayers, tile, writeData, done) {
  var layer = tileLayers.osm.osm;
  var result = layer.features.filter(function(val) {
    if (val.properties.bridge && (val.geometry.type === 'Point')) {
      val.properties._osmlint = 'bridgeonnode';
      return true;
    }
  });

  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / junctionYMotorway / map.js View on Github external
var overlapCoords = overlapObj.geometry.coordinates;
          if (_.intersection(coords, overlapCoords).length === 2 && (
              valueHighway.properties['turn:lanes:backward'] ||
              valueHighway.properties['turn:lanes:forward'] ||
              valueHighway.properties['turn:lanes'])) {
            output[valueHighway.properties['@id']] = valueHighway;
            output[overlap[4].id] = overlapObj;
          }
        }
      }
    }
  }

  var result = _.values(output);
  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / filterMajorHighways / map.js View on Github external
'motorway_link': true,
    'trunk_link': true,
    'primary_link': true,
    'secondary_link': true,
    'tertiary_link': true
  };
  var result = [];
  for (var i = 0; i < layer.features.length; i++) {
    var val = layer.features[i];
    if (majorRoads[val.properties.highway]) {
      val.properties._osmlint = osmlint;
      result.push(val);
    }
  }
  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }
  done(null, null);
};
github osmlab / osmlint / validators / filterDate / map.js View on Github external
module.exports = function(tileLayers, tile, writeData, done) {
  var layer = tileLayers.osm.osm;
  var result = layer.features.filter(function(obj) {
    return (obj.properties['@timestamp'] >= today);
  });

  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / wikiDataNoEnglishName / map.js View on Github external
module.exports = function(tileLayers, tile, writeData, done) {
  var layer = tileLayers.osm.osm;
  var osmlint = 'wikidatanoenglishname';
  var result = [];

  for (var i = 0; i < layer.features.length; i++) {
    var val = layer.features[i];
    if (val.geometry.type === 'Point' && val.properties.place && val.properties.wikidata && !val.properties['name:en']) {
      val.properties._osmlint = osmlint;
      result.push(val);
    }
  }

  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / userNameMatch / map.js View on Github external
var highways = [];

  for (var i = 0; i < layer.features.length; i++) {
    var val = layer.features[i];
    if (val.properties.highway &&
      val.properties.name &&
      (val.properties.name.indexOf(' ' + val.properties['@user']) > -1 || val.properties.name.indexOf(val.properties['@user'] + ' ') > -1 ||
        levenshtein.get(val.properties.name, val.properties['@user']) < 2)) {
      val.properties._osmlint = osmlint;
      highways.push(val);
    }
  }

  var result = _.values(highways);
  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }
  done(null, null);
};
github osmlab / osmlint / validators / getYLanes / map.js View on Github external
var overlapObj = motorwayJunction[overlap[4].id];
        if (overlapObj && valueHighway.properties['@id'] !== overlapObj.properties['@id'] && overlapObj.properties.highway === 'motorway_junction') {
          var coords = _.flatten(valueHighway.geometry.coordinates);
          var overlapCoords = overlapObj.geometry.coordinates;
          if (_.intersection(coords, overlapCoords).length === 2) {
            output[valueHighway.properties['@id']] = valueHighway;
            output[overlap[4].id] = overlapObj;
          }
        }
      }
    }
  }

  var result = _.values(output);
  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};
github osmlab / osmlint / validators / noName / map.js View on Github external
module.exports = function(tileLayers, tile, writeData, done) {
  var layer = tileLayers.osm.osm;
  var osmlint = 'noname';
  var result = [];
  for (var i = 0; i < layer.features.length; i++) {
    var val = layer.features[i];

    if (val.properties.highway && val.properties.name && val.properties.name.replace(/\s/g, '').replace(/-/g, '').toLowerCase().indexOf('noname') > -1) {
      val.properties._osmlint = osmlint;
      result.push(val);
    }
  }

  if (result.length > 0) {
    var fc = turf.featureCollection(result);
    writeData(JSON.stringify(fc) + '\n');
  }

  done(null, null);
};