Can we think of a one one function from ${Q\cap[0,1]}\times {Q\cap[0,1]} \rightarrow \mathbb R$ which has and additional property that it maintains distances order?
What i mean is that if we write $f(x_i,y_i) = c_i$, then
$$\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}<\sqrt{(x_3-x_4)^2+(y_3-y_4)^2} \Rightarrow |c_1-c_2|<|c_3-c_4|.$$
What this will help is to completely get rid of the distance function in finding the shortest part through a messy calculation and directly using the difference operation.
There is no one-to-one continuous function from $\mathbb{R}\times\mathbb{R}$ into $\mathbb R$. While this doesn't completely answer your question, it makes it hard to belive that a function such as the one that you are interested in exists and it is computationaly useful.