Пример #1
0
 /**
  * Returns all layers found in a mapfile
  *
  *  $file [string] : file path
  */
 public function parseFile($file)
 {
     if (is_file($file)) {
         if (substr($file, -4) == '.map') {
             //create a map object
             try {
                 $projLib = getenv("PROJ_LIB");
                 $mapFileContent = $this->fopen_file_get_contents($file);
                 $mapFileContent = preg_replace('/(\\n|^)\\s*MAP\\s*(\\n|#)/', "\$0\nCONFIG PROJ_LIB {$projLib}\n", $mapFileContent, 1);
                 $oMap = ms_newMapObjFromString($mapFileContent, dirname($file));
             } catch (Exception $e) {
                 $error = ms_getErrorObj();
                 throw new Exception($error->message);
                 exit;
             }
             $map = new Map($oMap);
             $m = array();
             $mapMetaData = array("wms_onlineresource");
             $mapParameters = array("projection");
             foreach ($mapMetaData as $metaData) {
                 $m[$metaData] = $map->getMeta($metaData);
             }
             foreach ($mapParameters as $parameter) {
                 $m[$parameter] = $map->getParam($parameter);
             }
             $layers = $map->parseLayers();
             return $this->formatParsingOutput($m, $layers);
         } else {
             throw new Exception("Le fichier spécifié n'est pas un mapfile valide.");
         }
     } else {
         throw new Exception("Le fichier n'existe pas.");
     }
 }
     unlink($dirmap . "/" . $nomePrefixo . ".prj");
     unlink($dirmap . "/" . $nomePrefixo . ".shx");
     unlink($dirmap . "/" . $nomePrefixo . ".dbf");
     unlink($dirmap . "/" . $nomePrefixo . ".shp");
     exit;
 }
 $arqshp = $dir_tmp . "/" . $nomePrefixo . ".shp";
 //pega os parametros de conexao
 include "classe_metaestat.php";
 $m = new Metaestat();
 $conexao = $m->listaConexao($_POST["i3GEOuploadcodigoconexao"], true);
 //array(5) { ["codigo_estat_conexao"]=> string(1) "1" ["bancodedados"]=> string(8) "geosaude" ["host"]=> string(9) "localhost" ["porta"]=> string(4) "5432" ["usuario"]=> string(8) "postgres" }
 //pega as colunas do shapefile
 $shapefileObj = ms_newShapefileObj($arqshp, -1);
 $numshapes = $shapefileObj->numshapes;
 $mapObj = ms_newMapObjFromString("MAP END");
 $layer = ms_newLayerObj($mapObj);
 $layer->set("data", $arqshp);
 if (file_exists($dir_tmp . "/" . $nomePrefixo . ".prj")) {
     $layer->setprojection("AUTO");
 }
 $layer->open();
 $colunasTemp = $layer->getItems();
 $colunas = array();
 foreach ($colunasTemp as $c) {
     //abaixo gid e forcado a entrar
     if (!is_numeric($c) && strtolower($c) != "gid") {
         $colunas[] = $c;
     }
 }
 echo "<br>Numshapes existentes no SHP: " . $numshapes;
Пример #3
0
         if (file_exists($szPlatformMapfile)) {
             $modifyPaths = true;
             $oMap = ms_newMapObj($szPlatformMapfile);
             $szMapFile = $szPlatformMapfile;
         }
     } else {
         $mapGen = new Map($platformContext, substr($szMapFile, 10));
         if ($mapGen->Exists()) {
             $result = $mapGen->Save();
             if ($result->IsOk()) {
                 $sMapFileContents = $result->Get('MAPDATA');
             } else {
                 echo var2json($result);
                 die;
             }
             $oMap = ms_newMapObjFromString($sMapFileContents);
         }
     }
     /*
      */
 } else {
     if (file_exists($szMapFile)) {
         $modifyPaths = true;
         $oMap = ms_newMapObj($szMapFile);
     }
 }
 /* optionally move the mapfile to the session */
 if ($moveToSession) {
     //path to map file in the session is used by the client
     $mapId = getSessionSavePath() . $oMap->name . ".map";
     //modify various paths if necessary