You are here

function farm_area_generate_form_preview in farmOS 7

Farm area generator form preview.

1 string reference to 'farm_area_generate_form_preview'
farm_area_generate_form in modules/farm/farm_area/farm_area_generate/farm_area_generate.module
Area generator form.

File

modules/farm/farm_area/farm_area_generate/farm_area_generate.module, line 295
Farm area generate module.

Code

function farm_area_generate_form_preview(&$form, &$form_state) {

  // If the area and polygon was not stored in validation, bail.
  if (empty($form_state['storage']['area']) || empty($form_state['storage']['polygon'])) {
    return;
  }

  // Get all the necessary variables from the form state.
  $polygon = $form_state['storage']['polygon'];
  $count = $form_state['values']['count'];
  $orientation = $form_state['values']['orientation'];

  // Generate child area geometries.
  $geometries = farm_area_generate_geometries($polygon, $count, $orientation);
  if (!empty($geometries)) {
    $collection = new GeometryCollection($geometries);
    $form_state['storage']['wkt'] = $collection
      ->asText();
  }

  // Rebuild the form if WKT was generated.
  if (!empty($form_state['storage']['wkt'])) {
    $form_state['rebuild'] = TRUE;
  }
}