Пример #1
0
 public static function PolygonToGeoJson($poly)
 {
     $str = '[';
     $extRing = $poly->GetExteriorRing();
     if ($extRing != null) {
         $coords = $extRing->GetCoordinates();
         $str .= MgGeoJsonWriter::CoordsToGeoJson($coords);
     }
     $count = $poly->GetInteriorRingCount();
     if ($count > 0) {
         if ($extRing != null) {
             $str .= ",";
         }
         for ($i = 0; $i < $count; $i++) {
             $ring = $poly->GetInteriorRing($i);
             $coords = $ring->GetCoordinates();
             $str .= MgGeoJsonWriter::CoordsToGeoJson($coords);
             if ($i < $count - 1) {
                 $str .= ",";
             }
         }
     }
     $str .= "]";
     return $str;
 }