src/sidebar/Sidebar.js
// Gets call from Buffer and sends data to MainMap and Layer
Gets call from Buffer and sends data to MainMap and Layer
Gets call from Buffer and sends data to MainMap and Layer
function callBuffer(buffer_radius, geojson_file_key) {
  var layer_position = find_called_geojson(geojson_file_key)
  var selected_layer_geojson = collect_called_geojson(layer_position)
  var selected_layer_name = this.state.layer_list[layer_position][0]
  var buffered = turf.buffer(selected_layer_geojson, buffer_radius, {units: 'meters'});
  var buffer_dissolved = buffered.features[0]
  for (var i = 1; i < buffered.features.length; i++) {
    buffer_dissolved = turf.union(buffer_dissolved, buffered.features[i])
  }
  if (buffer_dissolved.geometry.type == 'MultiPolygon') {
    var multipolygon = {"type":"FeatureCollection","features": [buffer_dissolved]};
    final_buffer = geojsonMultiPolygonToPolygon(multipolygon)
  } else {
    var final_buffer = {"type":"FeatureCollection","features": [buffer_dissolved]};
  }
  const buffer_layer_key = generateKey()
  get_newgeojson(final_buffer, buffer_layer_key)
  createLayer(selected_layer_name+' '+buffer_radius+' m buffer', buffer_layer_key, final_buffer)
}
function callBuffer ( buffer_radius , geojson_file_key ) { var layer_position = find_called_geojson ( geojson_file_key ) var selected_layer_geojson = collect_called_geojson ( layer_position ) var selected_layer_name = this . state . layer_list [ layer_position ] [ 0 ] var buffered = turf . buffer ( selected_layer_geojson , buffer_radius , { units : 'meters' } ) ; var buffer_dissolved = buffered . features [ 0 ] for ( var i = 1 ; i < buffered . features . length ; i ++ ) { buffer_dissolved = turf . union ( buffer_dissolved , buffered . features [ i ] ) } if ( buffer_dissolved . geometry . type == 'MultiPolygon' ) { var multipolygon = { "type" : "FeatureCollection" , "features" : [ buffer_dissolved ] } ; final_buffer = geojsonMultiPolygonToPolygon ( multipolygon ) } else { var final_buffer = { "type" : "FeatureCollection" , "features" : [ buffer_dissolved ] } ; } const buffer_layer_key = generateKey ( ) get_newgeojson ( final_buffer , buffer_layer_key ) createLayer ( selected_layer_name + ' ' + buffer_radius + ' m buffer' , buffer_layer_key , final_buffer ) }
Gets call from Buffer and sends data to MainMap and Layer
Gets call from Buffer and sends data to MainMap and Layer
// Runs dissolve on the buffer, so we don't get overlapping buffer zones. // Cleans the returned dissolve data.