Finding closest line segment intersecting rays
You'll need two data structures - for vertical rays and for horizontal rays. I'll describe a data structure for vertical rays. Draw a vertical line through each segment end - you'll get a set of vertical slabs. Each of these slabs will be divided by pieces of original segments into trapezoids (possibly infinite ones).

Number of these slabs will not exceed $2n$, and number of trapezoids in each slab will not exceed $n$. In order to find a segment, closest to the query point along a vertical ray (going up or down), you need to use binary search to find a slab at first, and then - another binary search to find a trapezoid inside the found slab. Upper and lower boundary of this trapezoid will give you the answer. These two binary searches will take $O(log(n))$ time.
The data structure for horizontal rays is similar - the only difference is that slabs should be horizontal.