There are times when we want to use preformatted text instead of code blocks:
With that said, there is an issue with preformatted text. When I copy code from an IDE (such as SQL Developer), the indents get stripped out:
--https://community.esri.com/t5/arcgis-enterprise-questions/pl-sql-code-review-set-polyline-m-values-to/td-p/1159398
with
function pythagoras(x1 in number, y1 in number, x2 in number, y2 in number) return number is
begin
return round(sqrt( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)), 2); -- Power is a slow function
end;
function m_as_length(shape in sde.st_geometry) return varchar2
is
result varchar2(32767);
vertex_set varchar2(32767);
oldX number;
oldY number;
newX number;
newY number;
line_len number := 0;
begin
for vPartIndex in 1..sde.st_geometry_operators.st_numgeometries_f(shape)
loop
vertex_set := null;
for vPointIndex in 1..sde.st_geometry_operators.st_numpoints_f(sde.st_geometry_operators.ST_GeometryN_f(shape,vPartIndex))
loop
newX := sde.st_geometry_operators.st_x_f(sde.st_geometry_operators.st_pointn_f(sde.st_geometry_operators.st_geometryn_f(shape,vPartIndex),vPointIndex));
newY := sde.st_geometry_operators.st_y_f(sde.st_geometry_operators.st_pointn_f(sde.st_geometry_operators.st_geometryn_f(shape,vPartIndex),vPointIndex));
if vPointIndex <> 1 then
line_len := line_len + pythagoras(oldX, oldY, newX, newY);
end if;
oldX := newX;
oldY := newY;
vertex_set := vertex_set || newX || ' ' || newY || ' ' || line_len || ', ';
end loop;
result := result || '(' || rtrim((vertex_set),', ') || '),';
end loop;
return 'MULTILINESTRING M (' || rtrim((result),',') || ')';
end;
select
m_as_length(shape)
from
polyline
(That happens, even though the indents are literal spaces in SQL Developer, not tabs.)
That's not what we want. For example, if I were to copy my code elsewhere (such as Stack Overflow), and then paste it from S.O. as preformatted text, then the indents will be preserved:
--https://community.esri.com/t5/arcgis-enterprise-questions/pl-sql-code-review-set-polyline-m-values-to/td-p/1159398 with function pythagoras(x1 in number, y1 in number, x2 in number, y2 in number) return number is begin return round(sqrt( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)), 2); -- Power is a slow function end; function m_as_length(shape in sde.st_geometry) return varchar2 is result varchar2(32767); vertex_set varchar2(32767); oldX number; oldY number; newX number; newY number; line_len number := 0; begin for vPartIndex in 1..sde.st_geometry_operators.st_numgeometries_f(shape) loop vertex_set := null; for vPointIndex in 1..sde.st_geometry_operators.st_numpoints_f(sde.st_geometry_operators.ST_GeometryN_f(shape,vPartIndex)) loop newX := sde.st_geometry_operators.st_x_f(sde.st_geometry_operators.st_pointn_f(sde.st_geometry_operators.st_geometryn_f(shape,vPartIndex),vPointIndex)); newY := sde.st_geometry_operators.st_y_f(sde.st_geometry_operators.st_pointn_f(sde.st_geometry_operators.st_geometryn_f(shape,vPartIndex),vPointIndex)); if vPointIndex <> 1 then line_len := line_len + pythagoras(oldX, oldY, newX, newY); end if; oldX := newX; oldY := newY; vertex_set := vertex_set || newX || ' ' || newY || ' ' || line_len || ', '; end loop; result := result || '(' || rtrim((vertex_set),', ') || '),'; end loop; return 'MULTILINESTRING M (' || rtrim((result),',') || ')'; end; select m_as_length(shape) from polyline
So, we can see that the preformatted text is capable of handling pasted indents, in some cases.
Idea:
Could preformatted text be enhanced so that pasted indents are always preserved?
(even when pasting from IDEs like SQL Developer)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.