Overlap Ground stations

Hi everyone,
I’m working with a ground stations network, and I wanted to compute the duration of time when the satellite is saw from two different stations at the same time. How can I do?
This is my Visibility handler
private static class VisibilityHandler implements EventHandler {
private AbsoluteDate start = null;
public Action eventOccurred(final SpacecraftState s, final ElevationDetector detector,
final boolean increasing) {

        if (increasing) {
         	 start = s.getDate();
        } else if(start !=null)  {
            double duration = s.getDate().durationFrom(start);
        	System.out.println(" Visibility on " + detector.getTopocentricFrame().getName()+
        			 " from " + start + " to " + s.getDate() +
                     ", duration = " + duration + " s");
return Action.CONTINUE ;


Thank you in advance

Hi @mosenich,

You should probably combine two ElevationDetector with a logical AND using the static method BooleanDetector.andCombine.
You’ll need to add your VisibilityHandler (and tweak it a bit) to the new EventDetector created by the call to the andCombine method.

Hope this helps,

1 Like

You can use BooleanDetector.andCombine to combine the detectors of both stations.
the combined detector will be triggered when both stations have visibility.


Thank you @MaximeJ and @luc,
I tried to use BooleanDetector.andCombine, but I don’t understand how to modify the handler to see the overlap properly, because eventOccurred admit only one detector. What I’m doing wrong? What do you suggest?
I’m sorry, probably these are stupid questions, but I’m a student and this is my first approach to these problems.

The event handler should be set on the boolean detector (using BooleanDetector.andCombine(d1, d2).withHandler(myHandler), not on the underlying detectors. The handlers of the raw detectors are in fact ignored by the boolean combination.

The handler will therefore get only a reference to the boolean detector when eventOccurred is called, therefore if you need your handler to know about the stations themselves, you need to pass the data at construction using something like BooleanDetector.andCombine(d1, d2).withHandler(new MyDualHandler(d1, d2))).

Thank you so much for the answer,
Now I have understand. I used this handler and it looks to work.

private static class MyHandler implements EventHandler{
private AbsoluteDate start = null;
public Action eventOccurred(final SpacecraftState s, final BooleanDetector bdetector, boolean bob) {

		if(bob) {
			start = s.getDate();
			System.out.println("overlap between india and thailand.   start"+ s.getDate());
		}else if(start !=null)  {
            double duration = s.getDate().durationFrom(start);
        	System.out.println(" duration = " + duration + " s");
		return Action.CONTINUE;