[postgis-devel] How define a view that use a case operator for geometry field

aperi2007 aperi2007 at gmail.com
Fri Oct 28 10:11:18 PDT 2011


Il 28/10/2011 18:51, Sandro Santilli ha scritto:
> On Fri, Oct 28, 2011 at 06:48:10PM +0200, aperi2007 wrote:
>
>> 	case
>> 		when a.codlinea<>'' then b.geom::geometry(LINESTRING,3003)
>> 		when a.codlineasoprasotto<>'' then c.geom::geometry(LINESTRING,3003)
>> 	end as geom
>
> ELSE ?
>
>> Is correct that geometry_columns don't report the geometry-type and
>> the srid of a view defined like this ?
>
> Try:
>
>   SELECT * FROM the_view WHERE ST_SRID(geom) = 0;

I try
SELECT * FROM v_elemento_divisorio WHERE ST_SRID(geom) = 0;
the result was an empty recordset.

(very strange for me)

After this I change (following your suggest) the view with:

...
case
   when a.codlinea<>'' then b.geom::geometry(LINESTRING,3003)
   else c.geom::geometry(LINESTRING,3003)
end as geom
...

And it work ! (wow)

Now qgis-identify work correctly no error. :)

Try-ing again the
SELECT * FROM the_view WHERE ST_SRID(geom) = 0;
it return again an empty recordset.

why the first view don't give any error ?





More information about the postgis-devel mailing list