tinyows
tinyows copied to clipboard
json output for custom types
create type texture as (url text,uv float[][]); create table textured_geometry (gid serial primary key, geom geometry('MULTIPOLYGONZ',3946,3), name text, tex texture);
insert into textured_geometry(geom, name, tex) values ('SRID=3946;MULTIPOLYGON Z (((0 0 0,6 0 0,0 0 12,0 0 0)),((0 0 12,6 0 0,6 0 12,0 0 12)))'::geometry, 'toto', ROW('http://localhost/textures/building-texture1.jpg','{{0,0},{.7,.0},{0,1},{0,0},{0,1},{.7,.0},{.7,1},{0,1}}'));
When requesting JSON as outputFormat, the result is:
..."tex": "(http://localhost/textures/building-texture1.jpg,\"{{0,0},{0.7,0},{0,1},{0,0},{0,1},{0.7,0},{0.7,1},{0,1}}\")"}...
It would be better to have something like the output of TO_JSON instead:
select to_json(tex) from textured_geometry;
{"url":"http://localhost/textures/building-texture1.jpg","uv":[[0,0],[0.7,0],[0,1],[0,0],[0,1],[0.7,0],[0.7,1],[0,1]]}