974 | | |
975 | | -- There is place for optimization here for a more efficient scanning method |
976 | | FOR x IN 1..width LOOP |
977 | | FOR y IN 1..height LOOP |
978 | | newx := ST_Raster2WorldCoordX(newrast, x, y); |
979 | | newy := ST_Raster2WorldCoordY(newrast, x, y); |
980 | | -- If pixel is the source point then Eculidean distance is zero |
981 | | IF THEN |
982 | | newval := 0; |
983 | | ELSE |
984 | | exesql := "SELECT ST_Distance(ST_GeomFromText('POINT(" || newx || " " || newy || ")'," || newsrid || "),ST_Transform(" || sourcegeomcolumn || "," || newsrid || ")) FROM " || sourcetable || " ORDER BY $1 <-> $2 LIMIT 1;"; |
985 | | newval := EXECUTE(exesql); |
986 | | END IF; |
987 | | newrast := ST_SetValue(newrast, band, x, y, newval); |
988 | | END LOOP; |
989 | | END LOOP; |
| 974 | |