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

aperi2007 aperi2007 at gmail.com
Fri Oct 28 13:33:45 PDT 2011


declaring the view using the bad code:

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

give this result

dbtopo=> \d v_elemento_divisorio
          View "gb.v_elemento_divisorio"
    Column   |          Type          | Modifiers
------------+------------------------+-----------
  oid        | integer                |
  coddivisor | character varying(35)  |
  codtipo    | character varying(128) |
  codlinea   | character varying(35)  |
  codlineass | character varying(35)  |
  geom       | geometry               |

instead declaring the view using the good code:

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

give this result

dbtopo=> \d v_elemento_divisorio
            View "gb.v_elemento_divisorio"
    Column   |           Type            | Modifiers
------------+---------------------------+-----------
  oid        | integer                   |
  coddivisor | character varying(35)     |
  codtipo    | character varying(128)    |
  codlinea   | character varying(35)     |
  codlineass | character varying(35)     |
  geom       | geometry(LineString,3003) |


Seem that postgis try to define it an else condition assigning it a 
unknown "geometry" ?

Andrea.


Il 28/10/2011 20:21, Sandro Santilli ha scritto:
>
> I guess PostgreSQL can't assume the columns is
> geometry(LINESTRING, 3003)
> if one of the fields is possibly an unspecified
> geometry() ?
>
> See also \d theview, it should tell you the field type
> including geometry type (typmod).
>
> --strk;
>
>    ()   Free GIS&  Flash consultant/developer
>    /\   http://strk.keybit.net/services.html
>




More information about the postgis-devel mailing list