wkt, strpos($this->wkt, "(") + 1, -1); //s'agit-il d'un multi-polygon ? if (strpos($coords_string, "),(") !== false) $this->multiple = true; if ($this->multiple) { $coords_multiple_string = substr($coords_string, strpos($coords_string, "(") + 1, -1); $polygons = explode("),(", $coords_multiple_string); foreach ($polygons as $polygon) { $coords = explode(",", $polygon); $coords_polygon = array(); for ($i = 0; $i < count($coords); $i++) { $infos = array(); $coord = $coords[$i]; $infos = explode(" ", $coord); //on ne met pas la dernière coordonnée, c'est la même que la 1ere if (0 == $i || $coords[0] != $coords[$i]) { $coords_polygon[] = new map_coord($infos[0], $infos[1]); } } $this->coords[] = $coords_polygon; } } else { $coords_string = str_replace(array("(", ")"), "", $coords_string); $coords = explode(",", $coords_string); $this->coords = array(); for ($i = 0; $i < count($coords); $i++) { $infos = array(); $coord = $coords[$i]; $infos = explode(" ", $coord); //on ne met pas la dernière coordonnée if ($i < (count($coords) - 1)) { $this->coords[] = new map_coord($infos[0], $infos[1]); } } } $this->coords_uptodate = true; } protected function build_transcription() { $this->transcription = "("; if ($this->coords[0]->get_decimal_long() >= 0) $this->transcription.="E "; else $this->transcription.="W "; $this->transcription.=map_coord::convert_decimal_to_sexagesimal($this->coords[0]->get_decimal_long()); $this->transcription.=" - "; if ($this->coords[1]->get_decimal_long() >= 0) $this->transcription.="E "; else $this->transcription.="W "; $this->transcription.=map_coord::convert_decimal_to_sexagesimal($this->coords[1]->get_decimal_long()); $this->transcription.=" / "; if ($this->coords[2]->get_decimal_lat() >= 0) $this->transcription.="N "; else $this->transcription.="S "; $this->transcription.=map_coord::convert_decimal_to_sexagesimal($this->coords[2]->get_decimal_lat()); $this->transcription.=" - "; if ($this->coords[0]->get_decimal_lat() >= 0) $this->transcription.="N "; else $this->transcription.="S "; $this->transcription.=map_coord::convert_decimal_to_sexagesimal($this->coords[0]->get_decimal_lat()); $this->transcription.=")"; } protected function build_wkt() { $this->wkt = $this->get_hold_type() . "("; if ($this->multiple) { $tmp_wkt = ""; foreach ($this->coords as $polygon) { if ($tmp_wkt == "") $tmp_wkt = "("; else $tmp_wkt .= ",("; foreach ($polygon as $coord) { $tmp_wkt.= $coord->get_decimal_lat() . " " . $coord->get_decimal_long() . ","; } $tmp_wkt.= $polygon[0]->get_decimal_lat() . " " . $polygon[0]->get_decimal_long(); $tmp_wkt .= ")"; } $this->wkt .= $tmp_wkt; } else { $this->wkt .= "("; foreach ($this->coords as $coord) { $this->wkt.= $coord->get_decimal_lat() . " " . $coord->get_decimal_long() . ","; } $this->wkt.= $this->coords[0]->get_decimal_lat() . " " . $this->coords[0]->get_decimal_long() . ")"; } $this->wkt .= ")"; $this->wkt_uptodate = true; } } // end of map_hold_polygon