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() ); // symbol used to separate components within // a tuple or coordinate string, "cs" in GML private $component_separator = ","; // "decimal" in GML private $decimal_separator = "."; // symbol used to separate tuples or coordinate strings, "ts" in GML private $tuple_separator = " "; // point counter private $point_count = 0; private $input_DOM; private $pos_elements; private $pos_element; private $pos_element_string; private $coords_atomised; private $coordinates_element; private $coordinate_element; // function point_array_from_gml // returns: an array of arrays containing the coordinates and (if provided) // the associated begin- and end-date from the GML public function readPointsFromGMLFile($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->point_elements = $this->input_DOM->getElementsByTagNameNS("http://www.opengis.net/gml","Point"); foreach ($this->point_elements as $this->point_element) { if ($this->point_element->hasAttributeNS("http://www.opengis.net/gml","id")) { $this->points_array["id_array"][$this->point_count] = $this->point_element->getAttributeNS ( "http://www.opengis.net/gml","id" ); } else { // if no id is given, we give one ourselves $this->points_array["id_array"][$this->point_count] = 'id'. $this->point_count; } // TODO : parse for SRS // 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 ($this->point_element->hasAttribute("srsName")) { // echo (" srsName=" . $this->point_element->getAttribute ("srsName" ) . "
" ); // } $this->pos_elements = $this->point_element->getElementsByTagNameNS("http://www.opengis.net/gml","pos"); foreach ($this->pos_elements as $this->pos_element) { // pos in GML is given as latitude (space) longitude $this->pos_element_string = $this->pos_element->nodeValue; $this->coords_atomised = explode(" ", $this->pos_element_string); $this->points_array["latitude_array"][$this->point_count] = $this->coords_atomised[0]; $this->points_array["longitude_array"][$this->point_count] = $this->coords_atomised[1]; } // the "coordinates" tag is deprecated in GML 3.1.0, still supported here // for backward compatibility. More specifically because the ogr2ogr // tools write out older GML versions $this->coordinates_element = $this->point_element->getElementsByTagNameNS("http://www.opengis.net/gml","coordinates"); foreach ($this->coordinates_element as $this->coordinate_element) { // coordinates in GML is given as latitude (space) longitude $this->pos_element_string = $this->coordinate_element->nodeValue; $this->coords_atomised = explode(",", $this->pos_element_string); $this->points_array["longitude_array"][$this->point_count] = $this->coords_atomised[0]; $this->points_array["latitude_array"][$this->point_count] = $this->coords_atomised[1]; } $this->point_count++; } // foreach ($this->point_elements as $this->point_element) return($this->points_array); } //public function readPointsFromGMLFile //public function writePointsToGMLFile ($points_array,$output_file_path) { // } } // class GML_Module ?>