@Paulo,
Da para fazer no PostGIS, em 3D ou em 2D
----------------------- ENTRADA com 4 pontyos, sendo um repetido
#### ST_3DLength()
psql dbmadeira -c "insert into esquema.pelo_ramal(from_id,to_id,geom) values (9999,9999,st_linefromtext('LINESTRING Z (751600.0 7935997.0 925.0, 751610.0 7935998.0 928.0, 751610.0 7935998.0 928.0,751620.0 7935990.0 928.0)',31983));"
psql dbmadeira -c "select ST_3DLength(geom) from esquema.pelo_ramal where from_id = 9999 and to_id = 9999;"
psql dbmadeira -c "select ST_NumPoints(geom) from esquema.pelo_ramal where from_id = 9999 and to_id = 9999;"
psql dbmadeira -c "select ST_astext(ST_RemoveRepeatedPoints(geom)) from esquema.pelo_ramal where from_id = 9999 and to_id = 9999;"
psql dbmadeira -c "select ST_NumPoints(ST_RemoveRepeatedPoints(geom)) from esquema.pelo_ramal where from_id = 9999 and to_id = 9999;"
psql dbmadeira -c "select ST_3DLength(ST_RemoveRepeatedPoints(geom)) from esquema.pelo_ramal where from_id = 9999 and to_id = 9999;"
---------------------------------------------------- SAIDA:
bash linha_3d.txt
st_3dlength
------------------
23.2943369565672
(1 registro)
st_numpoints
--------------
4
(1 registro)
st_astext
-------------------------------------------------------------------------
LINESTRING Z (751600 7935997 925,751610 7935998 928,751620 7935990 928)
(1 registro)
st_numpoints
--------------
3
(1 registro)
===============================================================