Using Iterator from sortRequests in plan() skip requests

Issue #104 duplicate
William Bourque created an issue

In plan() of DefaultConstellationPlannerImpl, near the line 116, the request list is sorted:

SortedSet<AbstractConstellationRequest> sortedRequests = sortRequests(getConstellationRequestsList().getConstellationRequests());

This iterator is then used to loop on request below; something like the following (added debug to illustrate the issue):

Iterator<AbstractConstellationRequest> requests = sortedRequests.iterator();
System.out.println("NUMBER OF REQUESTS: " + getConstellationRequestsList().getConstellationRequests().size() );
while (requests.hasNext()){
        System.out.println("REQUEST: " + request.getUid());
        AbstractConstellationRequest request = requests.next();
        //...
}

It seems there is something wrong with this iterator: Although "NUMBER OF REQUESTS" is 81 in my case, only the first 3 are printed".

Example output:

!ENTRY ca.gc.asc_csa.apogy.examples.satellite 1 0 2016-03-04 14:53:10.704
!MESSAGE Constellation Planner started
NUMBER OF REQUESTS: 81
REQUEST: ca.gc.asc_csa.apogy.examples.satellite.impl.StringUIDImpl@3b75b7b4 (id: TARGET01)

!ENTRY ca.gc.asc_csa.apogy.examples.satellite 1 0 2016-03-04 14:53:22.489
!MESSAGE Constellation Planner found 0 passes
REQUEST: ca.gc.asc_csa.apogy.examples.satellite.impl.StringUIDImpl@731a5a39 (id: TARGET03)

!ENTRY ca.gc.asc_csa.apogy.examples.satellite 1 0 2016-03-04 14:53:30.820
!MESSAGE Constellation Planner found 5 passes
REQUEST: ca.gc.asc_csa.apogy.examples.satellite.impl.StringUIDImpl@119cd026 (id: TARGET02)

!ENTRY ca.gc.asc_csa.apogy.examples.satellite 1 0 2016-03-04 14:53:39.278
!MESSAGE Constellation Planner found 4 passes

!ENTRY ca.gc.asc_csa.apogy.examples.satellite 1 0 2016-03-04 14:53:39.279
!MESSAGE Constellation Planner completed

By removing the sort, it loops on the 81 requests as it should. The following was used:

//SortedSet<AbstractConstellationRequest> sortedRequests = sortRequests(getConstellationRequestsList().getConstellationRequests());
List<AbstractConstellationRequest> sortedRequests = getConstellationRequestsList().getConstellationRequests();

Comments (3)

  1. Log in to comment