miribsystematics-co-il-esridist

Sequence property of AGSStopGraphic does not seem to influence

Discussion created by miribsystematics-co-il-esridist Employee on May 5, 2011
Latest reply on May 12, 2011 by miribsystematics-co-il-esridist
Hi,

I'm trying to use the new AGSRouteTask in ver. 1.8.
My routeTaskParameters are:
// the next 3 lines will cause the task to find the
// best route regardless of the stop input order
self.routeTaskParams.findBestSequence = NO;
self.routeTaskParams.preserveFirstStop = YES;
self.routeTaskParams.preserveLastStop = YES;

// since we used "findBestSequence" we need to
// get the newly reordered stops
self.routeTaskParams.returnStopGraphics = YES;

This is because I want to control the order of the stops.

I have two addresses between which I want to find a route. Since it runs asynchronously, sometimes it calculates first the To address and then the From address. Anyway I give the From AGSStopGraphic a sequence of 1 and the To AGSStopGraphic a sequence of 2. I can control the symbols numbers but when I look at the directions, it still shows the reverse order.

I reproduced the same thing in the AGSRouteTask sample by changing:
RouteBtnClicked - from line 610:

// the next 3 lines will cause the task to find the
// best route regardless of the stop input order
self.routeTaskParams.findBestSequence = NO;
self.routeTaskParams.preserveFirstStop = YES;
self.routeTaskParams.preserveLastStop = YES;

// since we used "findBestSequence" we need to
// get the newly reordered stops
self.routeTaskParams.returnStopGraphics = YES;

RoutingSampleViewController.m, from line 473 (addStopOrBarrier):

NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
AGSSymbol *symbol;
AGSStopGraphic *stopGraphic;

switch (AGSGeometryTypeForGeometry(geometry)) {
  //Stop
  case AGSGeometryTypePoint:
            _numStops++;
   if (_numStops == 1)
   {
    symbol = [self stopSymbolWithNumber:_numStops + 1];
    stopGraphic = [AGSStopGraphic graphicWithGeometry:geometry
                    symbol:symbol
                   attributes:attributes
               infoTemplateDelegate:self];
    stopGraphic.sequence = (_numStops + 1);
   }
   else //2
   {
    symbol = [self stopSymbolWithNumber:_numStops - 1];
    stopGraphic = [AGSStopGraphic graphicWithGeometry:geometry
                 symbol:symbol
                attributes:attributes
            infoTemplateDelegate:self];
    stopGraphic.sequence = (_numStops - 1);
   }
   //You can set additional properties on the stop here
   //refer to the conceptual helf for Routing task
   [self.graphicsLayer addGraphic:stopGraphic];
   [self.graphicsLayer dataChanged];
   break;

Finally, in RoutingSampleViewController.m, from line 203(didSolveWithResult):

       // remove the stop graphics from the graphics layer
        // careful not to attempt to mutate the graphics array while
        // it is being enumerated
  NSMutableArray *graphics = [[self.graphicsLayer.graphics mutableCopy] autorelease];
  for (AGSGraphic *g in graphics) {
   if ([g isKindOfClass:[AGSStopGraphic class]]) {
    [self.graphicsLayer removeGraphic:g];
    [self.graphicsLayer addGraphic:g];
   }
  }
 
  /*
        // add the returned stops...it's possible these came back in a different order
        // because we specified findBestSequence
  for (AGSStopGraphic *sg in self.routeResult.stopGraphics) {
           
            // get the sequence from the attribetus
   NSInteger sequence = [[sg.attributes valueForKey:@"Sequence"] integerValue];
           
            // create a composite symbol using the sequence number
   sg.symbol = [self stopSymbolWithNumber:sequence];
           
            // add the graphic
   [self.graphicsLayer addGraphic:sg];
  }
        */


Then I add two points and try to route them. I see that it reverses the number of symbols (as I asked) but the route looks as if I made no change.

I put it also under ftp.plm.co.il/mirie
user:systematics
password: System2030

Am I right?

I tried it also with:
self.routeTaskParams.returnStopGraphics = NO;
but it didn't help. It looks like the stops input ignores already the sequence I give.

Thanks a lot,
Miri

Outcomes