If you application is written in Java with the embedded API, then Neo4j
Spatial has all the tools you need because it makes use of JTS internally
and so you can perform any JTS query you want. However, to benefit from the
RTree index to make the query fast will require that you also limit the
search scope somewhat. If you have an idea of a maximum distance you wish
to search you could solve this in two ways:
- Either - do an initial distance search finding all geometries within the maximum distance, and then perform a refinement on the resulting dataset to get only geometries that intersect the line of sight.
- Or - create the LineString for the line of sight, with a length matching your max distance, then perform an intersections search for all geometries that intersect this LineString, and select the closest.
This second option would only work in the Java API, but would be the
fastest since the search will only consider objects along the line of sight
in the RTree, so the index search is more selective than the distance
search option (which will search in all directions).
If, instead, the application is going to use the REST API, then this would be much harder to do, since that API only allows searching of points. I would recommend creating an unmanaged extension and doing the work in Java and exposing your own REST endpoint for this function.