msg := msg || 'and extent of ' || extent;
IF
- metadata.skewx::numeric(16, 10) <> 0::numeric(16, 10) OR
- metadata.skewy::numeric(16, 10) <> 0::numeric(16, 10)
+ round(metadata.skewx::numeric, 10) <> round(0::numeric, 10) OR
+ round(metadata.skewy::numeric, 10) <> round(0::numeric, 10)
THEN
msg := 'Skewed ' || overlay(msg placing 'r' from 1 for 1);
END IF;
CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rasttable name, rastcolumn name, axis char)
RETURNS double precision AS $$
SELECT
- replace(replace(split_part(split_part(s.consrc, ' = ', 2), '::', 1), ')', ''), '(', '')::double precision
+ replace(
+ replace(
+ replace(
+ replace(
+ split_part(
+ split_part(s.consrc, ' = ', 2),
+ '::', 1
+ ),
+ 'round(', ''
+ ),
+ ')', ''
+ ),
+ '(', ''
+ ),
+ ' ', ''
+ )::double precision
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
AND c.relname = $2
sql := 'ALTER TABLE ' || fqtn
|| ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (st_scale' || $4 || '('
+ || ' CHECK (round(st_scale' || $4 || '('
|| quote_ident($3)
- || ')::numeric(25,10) = (' || attr || ')::numeric(25,10))';
+ || ')::numeric, 10) = round(' || attr || '::numeric, 10))';
RETURN _add_raster_constraint(cn, sql);
END;
$$ LANGUAGE 'plpgsql' VOLATILE STRICT
CREATE OR REPLACE FUNCTION _raster_constraint_info_nodata_values(rastschema name, rasttable name, rastcolumn name)
RETURNS double precision[] AS $$
SELECT
- trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::double precision[]
+ trim(both '''' from
+ split_part(
+ replace(
+ replace(
+ split_part(s.consrc, ' = ', 2),
+ ')', ''
+ ),
+ '(', ''
+ ),
+ '::', 1
+ )
+ )::double precision[]
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
AND c.relname = $2
COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_nodata_values(rast raster)
- RETURNS double precision[] AS
- $$ SELECT array_agg(nodatavalue)::double precision[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
+ RETURNS numeric[] AS
+ $$ SELECT array_agg(round(nodatavalue::numeric, 10))::numeric[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION _add_raster_constraint_nodata_values(rastschema name, rasttable name, rastcolumn name)
fqtn text;
cn name;
sql text;
- attr double precision[];
+ attr numeric[];
max int;
BEGIN
fqtn := '';
sql := 'ALTER TABLE ' || fqtn
|| ' ADD CONSTRAINT ' || quote_ident(cn)
|| ' CHECK (_raster_constraint_nodata_values(' || quote_ident($3)
- || ')::numeric(16,10)[] = ''{';
+ || ')::numeric[] = ''{';
FOR x in 1..max LOOP
IF attr[x] IS NULL THEN
sql := sql || 'NULL';
sql := sql || ',';
END IF;
END LOOP;
- sql := sql || '}''::numeric(16,10)[])';
+ sql := sql || '}''::numeric[])';
RETURN _add_raster_constraint(cn, sql);
END;