[Gfoss] visualizzazione qgis e st_makeline postgis

Benedetto Porfidia benedetto.porfidia a isprambiente.it
Gio 1 Dic 2011 17:18:59 CET


Salve a tutti,
non riesco a far caricare a qgis delle tables che creo su postgis.
Mi spiego meglio: ho delle tabelle di punti di vertci di linee con le 
loro geometrie e l'identificativo della linea; voglio creare le linee 
direttamente su db utilizzando st_makeline.
Eseguo il seguente [1] codice e sul db va tutto liscio.
Quando vado a visualizzarle come layer su qgis, mi da l'errore del 
cursore perso e se provo ad aprire la tabella va in crash tutto qgis.

ps. La query mi restituisce 3800 e spicci records di linee da oltre 140 
mila punti; le prime 4 linee risultano a lunghezza zero (1 solo vertice)

Se provo ad esportare la tabella di linee direttamente pgsql2shp mi dice:



C:\Programmi\PostgreSQL\8.4\bin>pgsql2shp.exe -h 10.16.232.93 -u 
postgres -P pos
tgres -r -b -f linee.shp geofisica public.nav
Initializing... Done (postgis major version: 1).
Output shape: PolyLine
Dumping: XRecordFetch: ERROR:  geometry requires more points

Idem se cancello le prime 4 linee che hanno lunghezza zero

Se visualizzo le geometrie con AsText mi dice che è tutto ok.

Scusate la lunghezza

questo è l'sql che eseguo
[1]

>
> CREATE SEQUENCE public.nav_gid_seq
>   INCREMENT 1
>   MINVALUE 1
>   MAXVALUE 9223372036854775807
>   START 146590
>   CACHE 1;
> ALTER TABLE public.nav_gid_seq
>   OWNER TO postgres;
>
> CREATE TABLE public.nav
> (
>   gid integer NOT NULL DEFAULT nextval('nav_gid_seq'::regclass),
>   nome character varying(20),
>   length double precision,
>   nfix integer,
>   the_geom geometry,
>   CONSTRAINT nav_pkey PRIMARY KEY (gid ),
>   CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2),
>   CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'LINESTRING'::text OR the_geom IS NULL),
>   CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 32633)
> )
> WITH (
>   OIDS=FALSE
> );
> ALTER TABLE public.nav
>   OWNER TO postgres;
>
> INSERT INTO nav(
>             nome, nfix, length, the_geom)
>    select nome, max(nfix), length(st_makeline (the_geom)), st_makeline (the_geom) as the_geom from
 >
>  (SELECT  ismar_mono_totale.nomelinea AS nome, ismar_mono_totale.fix AS nfix, transform(ismar_mono_totale.the_geom, 32633) AS the_geom
>    FROM ismar_mono_totale
>
>   ORDER BY ismar_mono_totale.nomelinea)
>   as foo
>   GROUP BY nome
>   ORDER BY max;
>
>
>



Maggiori informazioni sulla lista Gfoss