code: @Override
      public int analyzeRoutes(String client) {
          RouteGpsCoordinates lastRouteCoordinates = findLastRouteCoordinates(client);
          GpsCoordinates lastCoordinates = null;
          if (lastRouteCoordinates == null) {
              LOG.info("No GPS coordinates assigned to routes for client {}", client);
          } else {
              lastCoordinates = mongoTemplate.findById(lastRouteCoordinates.getCoordinatesId(), GpsCoordinates.class, GpsCoordinates.class.getSimpleName());
          }
  
          Query query = new Query();
          query.addCriteria(where("client").is(client));
          if (lastRouteCoordinates != null) {
              query.addCriteria(where("_id").gt(new ObjectId(lastRouteCoordinates.getCoordinatesId())));
          }
          query.limit(routeAnalysisBatchSize);
          query.with(new Sort(ASC, "_id"));
          List<GpsCoordinates> coordinatesToAnalyze = mongoTemplate.find(query, GpsCoordinates.class, GpsCoordinates.class.getSimpleName());
          for (GpsCoordinates coordinates : coordinatesToAnalyze) {
              String routeId;
              if (lastCoordinates == null || (TimeUnit.MILLISECONDS.toMinutes(coordinates.getTimestamp().getTime() - lastCoordinates.getTimestamp().getTime()) > 5)) {
                  Route newRoute = createNewRoute(client);
                  routeId = documentDriver.save(collectionName(newRoute.getClass()), pojoToMap(newRoute));
              } else {
                  routeId = lastRouteCoordinates.getRouteId();
              }
  
              lastRouteCoordinates = new RouteGpsCoordinates(null, routeId, coordinates.getId(), client);
              mongoTemplate.save(lastRouteCoordinates, collectionName(RouteGpsCoordinates.class));
              lastCoordinates = coordinates;
          }
          return coordinatesToAnalyze.size();
      }
docs: Overridden