The below is a concept only and I am not sure whether it would work, but I found it interesting to think about.
Do you have access to Oracle database with Spatial on it? If the job is a one-off and you don't have Oracle "in-house", maybe you could use Oracle's development virtual machine (http://www.oracle.com/technetwork/community/developer-vm/index.html) with all the bits already installed and ready to play with. I am not sure about the licenses though - you'd have to check.
Anyway, assuming that the points are in POINTS table and lines in LINES table, and both tables have ID and GEOM columns, the following query should return pairs of points parallel to the grey lines, together with the distance between the points.
select A.id, B.id, sdo_geom.sdo_distance(A.geom, B.geom, :T) as pts_dist
from points A, points B, lines L
where A.id <> B.id
and sdo_geom.sdo_distance(A.geom, L.geom, :T) = sdo_geom.sdo_distance(B.geom, L.geom, :T)
and sdo_geom.sdo_distance(A.geom, L.geom, :T) < :X
and not exists
(select 1 from lines L1
where sdo_geom.relate(L1.geom, 'ANYINTERACT',
mdsys.sdo_geometry(/* params to create a line between A and B */), :T)) = 'TRUE')
I haven't tested it at all. The result would still have to be processed, because you would get: a) two links for each pair of points - from A to B and from B to A; b) if there are 3 or more points along a grey line, you'd get links between all of them - I think the solution would be, for the given point A to choose the shortest link from this point and ignore/remove the rest (that's what the distance is for in the result).
The parameters used in this query: T - tolerance (e.g. 0.005); X - the max distance between the point and the grey line - parallel points positioned too far from the grey line would not be taken into account (for this line).
The query could be changed to compare the distance of A from the line and distance of B from the line with some "error buffer", so if two points are "almost" parallel, they still would be taken into the result.
The query is probably not optimal and might take quite long to execute. But again, its a concept only and if you decide to try it out, I am sure there is a lot to do.
Best Answer
Your task is directly related to the task of visualizing geodata and nothing else (the names of the tables are abstract).
There are many ways to solve this problem, my solution is as follows:
The initial data, if I correctly understand the statement of your problem, are presented in Figure 1
I have in the boundaries_exper2 table two objects of the LineString type gid1 line on the left and the gid2 line on the right, you have two separate layers (tables).
1) Having calculated the values of your distance from the main route, in pgAdmin run the query:
create table boundaries_exper3 as SELECT ST_OffsetCurve (geom, 0.001) geom FROM exper_linestrings WHERE gid = 1;
The result is a parallel line with an indented line from the line with gid = 1
For an example, see Figure 2
2) Next you need to define the intersection point of the created parallel line with the adjacent to the main line (the line on the left) in pgAdmin run the query:
create table boundaries_exper4 as SELECT ST_Intersection (boundaries_exper2.geom, boundaries_exper3.geom) geom FROM boundaries_exper2.geom, boundaries_exper3 WHERE ST_Crosses (boundaries_exper2.geom, boundaries_exper3.geom);
The result is shown in Figure 3.
3) Next from all your lines, create a point type from the line type, for this, run the following query in pgAdmin:
create table exper_line_to_poi as SELECT (ST_Dumppoints (geom)).geom FROM boundaries_exper2;
The result, see Figures 4 and 5 respectively4) In the mode of editing the point table exper_line_to_poi_paral, delete all points that lie in the left area, copy the intersection point from the boundaries_exper4 layer and add it to the layer of processed points and from them create the line with the following code:
create table exper_poi_to_line_paral as SELECT st_makeline (geom) geom FROM exper_line_to_poi_paral;
The result is shown in Figure 6.5) Create 2 more lines 1 of the two points, namely the intersection point and the starting point of the adjacent line and from the points of the adjacent line (reference lines), create the line with the following codes:
create table exper_line_to_poi5 as SELECT st_makeline (geom) geom FROM exper_poi3;
andcreate table exper_line_to_poi6 as SELECT st_makeline (geom) geom FROM exper_line_to_poi3;
The result should be as follows, see figure 76) Combine the three linear tables into one by running the code:
create table exper_line_union as SELECT * FROM exper_poi_to_line_paral UNION ALL SELECT * FROM exper_line_to_poi5 UNION ALL SELECT * FROM exper_line_to_poi6
and add the main route,The result is shown in Figure 8