Tripal Plant PopGen Submit
accession_coordinates.inc File Reference

Go to the source code of this file.

Functions

 tpps_accession_coordinates ()
 
 tpps_get_coordinates ($row, array &$options)
 

Detailed Description

Defines Ajax callback for plant accession coordinates.

Definition in file accession_coordinates.inc.

Function Documentation

◆ tpps_accession_coordinates()

tpps_accession_coordinates ( )

Returns an array of standardized coordinates based on a file id number.

Definition at line 11 of file accession_coordinates.inc.

11  {
12  $params = drupal_get_query_parameters($_POST);
13 
14  if (!empty($params['fid']) and file_load($params['fid'])) {
15  $coordinates = array();
16  $columns = array(
17  'id_col' => $params['id_col'],
18  'lat_col' => $params['lat_col'],
19  'long_col' => $params['long_col'],
20  );
21 
22  $options = array(
23  'no_header' => $params['no-header'],
24  'columns' => $columns,
25  'coords' => &$coordinates,
26  );
27  tpps_file_iterator($params['fid'], 'tpps_get_coordinates', $options);
28 
29  drupal_json_output($coordinates);
30  }
31 }
tpps_file_iterator($fid, $function, array &$options=array())

◆ tpps_get_coordinates()

tpps_get_coordinates (   $row,
array &  $options 
)

This function processes a single row of a plant accession file.

This function populates the coords attribute of the options array with the standardized coordinates of each plant in the file. This function is meant to be used with tpps_file_iterator().

Parameters
mixed$rowThe item yielded by the TPPS file generator.
array$optionsAdditional options set when calling tpps_file_iterator().

Definition at line 45 of file accession_coordinates.inc.

45  {
46  $id_col = $options['columns']['id_col'];
47  $lat_col = $options['columns']['lat_col'];
48  $long_col = $options['columns']['long_col'];
49  $coordinates = &$options['coords'];
50 
51  // Only add coordinates to the standardized coordinates array if
52  // we can successfully standardsize them.
53  if (($coord = tpps_standard_coord("{$row[$lat_col]},{$row[$long_col]}"))) {
54  $pair = explode(',', $coord);
55  // Add the standardized coordinates.
56  array_push($coordinates, array(
57  "{$row[$id_col]}",
58  $pair[0],
59  $pair[1],
60  ));
61  }
62 }
tpps_standard_coord($raw_coordinate)