array(), "unique_id_array" => array(), "name_array" => array(), "latitude_array" => array(), "longitude_array" => array(), "coord_accuracy_array" => array(), "begin_date_array" => array(), "end_date_array" => array() ); private $point_count = 0; private $date = ""; private $input_DOM; private $trackpoint_elements; private $trackpoint_element; private $time_elements; private $time_element; private $time_stamp; // function point_array_from_gpx // returns: an array of arrays containing the coordinates and the associated // times (dates) from the gpx, as well as accuracy indications for // both these entities public function readPointsfromGPXFile($input_file_path) { $this->point_count = 0; // read GML input file $this->input_DOM = new DOMDocument(); $this->input_DOM->load("$input_file_path"); // We specifically search only gml:Point occurences // Other types of points ( in other namespaces) are NOT supported $this->trackpoint_elements = $this->input_DOM->getElementsByTagName("trkpt"); foreach ($this->trackpoint_elements as $this->trackpoint_element) { if ($this->trackpoint_element->hasAttribute("lat")) { $this->points_array["latitude_array"][$this->point_count] = $this->trackpoint_element->getAttribute ("lat" ); } if ($this->trackpoint_element->hasAttribute("lon")) { $this->points_array["longitude_array"][$this->point_count] = $this->trackpoint_element->getAttribute ("lon" ); } // TODO : search for SRS in gpx (is that defined ?? ) // as for now, we always assume WGS84 // Within a gml:Point object, the srs could be attached to a different // namespace : so we just search for the tag without specifying namespace //if ($point->hasAttribute("srsName")) { //echo (" srsName=" . $point->getAttribute ("srsName" ) . "
" ); //} $this->time_elements = $this->trackpoint_element->getElementsByTagName("time"); foreach ($this->time_elements as $this->time_element) { $this->time_stamp = $this->time_elements->nodeValue; $this->date = substr($this->time_stamp,0,10); $this->points_array["begin_date_array"][$this->point_count] = $this->date; $this->points_array["end_date_array"][$this->point_count] = $this->date; // TODO : search for id in the GPX first (??) // if no id is given, we give one ourselves $this->points_array["id_array"][$this->point_count] = 'id'. $this->point_count; } // foreach time_element $this->point_count++; } // foreach point return($this->points_array); } //public function readPointsfromGPXFile //public function writePointsToGPXFile($points_array,$output_file_path) { // } } // class GPX_Module ?>