[Gfoss] pmapper editing di punti

kassandraxxx at libero.it kassandraxxx at libero.it
Tue Dec 26 04:27:30 CET 2006


Ho provato a mettere echo "<p>Sql = '$sql'"; ma praticamente non mi da nessun risultato per quella variabile...nè per quella nè per altre in questo file..
il campo the_geom e' il campo geometry...l'unico altro campo che è menzionato di diverso e' imgxy che penso faccia parte dello script per individuare il punto selezionato sulla carta.
I due file che vanno modificati sono digitize.php e digitizedlg.phtml..gli altri che trovate anche nello zip sono solo da copiare...vi metto anche la parte del file .map

-------------------------------------------------------------
il file completo e' digitize.php

<?php 
require_once ("DB.php");
session_start();
require_once("common.php");



function DB_addPoint($imgxy, $nome, $datazione, $funzione, $quota)
{   
    $db_host = "localhost";  
    $db_type = "pgsql";
    $db_name = "postgres";
    $db_user = "postgres";
    $db_pwd  = "pass";
    
    $dsn = "$db_type://$db_user:$db_pwd@$db_host/$db_name";
    
    // CONVERT PIXEL X/Y TO MAP UNITS
    $imgxy_arr = explode(" ", $imgxy);
    $x_pix = $imgxy_arr[0];
    $y_pix = $imgxy_arr[1];
        
    $GEOEXT = $_SESSION["GEOEXT"];
    $geoDeltaX = $GEOEXT["maxx"] - $GEOEXT["minx"];
    $geoDeltaY = $GEOEXT["maxy"] - $GEOEXT["miny"];
    
    $mapW = $_SESSION["mapwidth"];
    $mapH = $_SESSION["mapheight"];
    
    $x_geo = round($GEOEXT["minx"] + (($x_pix/$mapW)*$geoDeltaX));
    $y_geo = round($GEOEXT["maxy"] - (($y_pix/$mapH)*$geoDeltaY)); 

    
        
    
    // CONNECT TO DB AND RUN QUERY
    $the_geom = "GeomFromText('POINT($x_geo $y_geo)',26591)";  
    $sql = "INSERT INTO liguri(the_geom,nome,datazione,funzione,quota) 
            VALUES($the_geom, 
                   $nome, 
                   $datazione, 
                   $funzione, 
                   $quota)";
    //error_log ($sql);
	
  
  
    $dbh = dbConnect($dsn);
    $result = $dbh->query($sql);

    // Check that $result is not an error
    if (DB::isError($result)) {
        $dbh->disconnect();
        return ($result->getMessage());
    } else {
        $dbh->disconnect();
        return 1;
    }
     
}


function dbConnect($dsn)
{
    $dbh = DB::connect($dsn);
    if (DB::isError($dbh)) {
        die ($dbh->getMessage());
        return NULL;
    } else {
        return $dbh;
    }
}
echo "<p>Sql = '$sql'";

?>

-----------------------------------------------------------
il file completo che mostra la tabella di inserimento è digitizedlg.phtml

<?php
require_once("incphp/digitize.php");
require_once("incphp/common.php");
require_once("incphp/globals.php");

//==============================================


$definepoint = $_GET['definepoint'];
if ($definepoint) {
    $imgxy = $_GET['imgxy'];
} else {
    $imgxy = $_POST['imgxy'];
    $addpoint = $_POST['addpoint'];
}

if ($addpoint) {
    $nome      = $_POST['nome'];
    $datazione  = $_POST['datazione'];
    $funzione = $_POST['funzione'];
    $quota   = $_POST['quota'];
    
    // Write to DB
    $dbreturn = DB_addPoint($imgxy, $nome, $datazione, $funzione, $quota);
}

?>
<HTML>
<HEAD>
<link rel="stylesheet" href="templates/scheda_siti.css" type="text/css">
<title>Inserimento dei siti archeologici</title>
</HEAD>
<BODY  leftmargin="3" topmargin="3" marginwidth="3" onLoad="window.focus()" >
<!-- onUnload="opener.parent.mapFrame.removeSymPoints('digitize')" -->
<table width="100%" class="BGCHEADFOOT"><tr><td>SCHEDA SITO</td></tr></table>
<p>

<?php
  if ($definepoint):
?>
<FORM action="digitizedlg.phtml"  method="POST">
 <table class="DIGITIZE">
  <tr>
   <td>nome</td>
   <td><input type="text" name="nome" size="15"></td>
  </tr>
  <tr>
   <td>datazione</td>
   <td><input type="text" name="datazione" size="11"></td>
  </tr>
    <tr>
   <td>funzione</td>
   <td><input type="text" name="funzione" size="55"></td>
  </tr>
  <tr>
   <td>quota</td>
   <td><input type="integer" name="quota" size="23"></td>
  </tr>
</table> 
 <p>
 <input type="button" onClick="submit();opener.parent.mapFrame.removeSymPoints('digitize')" name="ok" value="OK" size="30">
 <input type="button" onClick="self.close();opener.parent.mapFrame.removeSymPoints('digitize')" name="cancel" value="Annulla" size="30"><FONT COLOR="#b1bbc5">________________________________________</FONT><a href="http://localhost/pmapper-3.0.0-beta1/help.html" target="_blank"><FONT COLOR="#0000ff">HELP</FONT></a>

 <input type="hidden" name="imgxy" value="<? echo $imgxy ?>">
 <input type="hidden" name="addpoint" value="1">
</FORM>

<?php
  else:
    if ($dbreturn == 1):  
?>

Il dato e' stato inserito <br>
nel database: <p>
<table>
  <tr>
   <td>nome</td>
   <td><? echo $nome ?></td>
  </tr>
  <tr>
   <td>datazione</td>
   <td><? echo $datazione ?></td>
  </tr>
  <tr>
   <td>funzione</td>
   <td><? echo $funzione ?></td>
  </tr>
  <tr>
   <td>quota</td>
   <td><? echo $quota ?></td>
  </tr>
 
 
 </table>
 
 <form>
   <input type="button" value="Chiudi" onClick="self.close()">
 </form>


<?php
    else:
      echo ("<h3>ERROR</h3> \n");
      echo ("Il dato non e' stato inserito nel database. <p> inserimento fallito: <br>\n");
      echo $dbreturn;
    endif;  
endif;
?>


</BODY>
</HTML>


-----------------------------------------------------------
file .map

LAYER # 
    NAME        liguri
    CONNECTIONTYPE POSTGIS
    CONNECTION "dbname=postgres host=localhost user=postgres password=pass port=5432"
    #DATA "the_geom from liguri USING UNIQUE gid"
	DATA "the_geom from (select gid,the_geom,nome,datazione,funzione,quota from liguri) as newtable using unique gid" 
    STATUS       OFF
    TYPE         POINT
    PROJECTION
      "init=epsg:26591"
    END 
    METADATA 
       "DESCRIPTION" "liguri"
       "RESULT_FIELDS" "nome,datazione,funzione,quota"
       "RESULT_HEADERS" "nome,datazione,funzione,quota"
    END  # Metadata 
    CLASS
    Name 'liguri'
    COLOR 255 0 0 
    SYMBOL 'square' 
    SIZE 9
    OUTLINECOLOR 0 0 0
    TEMPLATE void
  END  # Class
END  # Layer


ci sto divendando pazza....




------------------------------------------------------
Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
http://click.libero.it/infostrada26dic06





More information about the Gfoss mailing list