[Gfoss] insert polygon - p.mapper

Fabio D'Ovidio fabiodovidio a gmail.com
Gio 22 Maggio 2008 11:02:13 CEST


Ciao Salvatore,
credo di si...
Se vuoi puoi vedere un'esempio nel codice di cartoweb3, precisamente nel 
plugin Edition che fa più o meno la stessa cosa...

Facci sapere.

-- 
Ing. Fabio D'Ovidio

INOVA Open Solutions s.r.l.
Web : http://www.inovaos.it
Tel.: 081 197 57 600
mail: fabiodovidio a gmail.com




Salvator*eL*arosa ha scritto:
> Salve a tutti,
>
> Secondo voi è possibile modificare questa funzione
> per far inserire un poligono all'interno del DB da p.mapper:
>
> function DB_addPoint($imgxy, $stato, $uso)
> {   
>     $db_host = "localhost";  
>     $db_type = "pgsql";
>     $db_name = "cms";
>     $db_user = "postgres";
>     $db_pwd  = "";
>     
>     $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];   //"per esempio: se aumento l'array 
>                                        //come posso modificare l'SQL per
> l'inserimento"
>         
>     $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
>     $geometry = "GeomFromText('POINT($x_geo $y_geo)',3004)";  
>     $sql = "INSERT INTO domande(stato,uso,geom)
> VALUES('$stato','$uso',$geometry)";
>     //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;
>     }
>     
>     
> }
>
> Questa è relativa all'inserimento di un punto!
>
> Grazie
>
> -----
> Salvatore Larosa
> GPG: 0xE504BBE2 (FP: D9B2 CA87 81CD 1B91 E24D 3B42 D0F7 FA01 E504 BBE2)
>   




Maggiori informazioni sulla lista Gfoss