Tripal Plant PopGen Submit
accession_coordinates.inc
Go to the documentation of this file.
1 <?php
2 
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 }
32 
45 function tpps_get_coordinates($row, array &$options) {
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)
tpps_get_coordinates($row, array &$options)
tpps_file_iterator($fid, $function, array &$options=array())
tpps_accession_coordinates()