<commit_before>// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include "TwitterFeedTourStateMachineFactory.h"

#include <vector>
#include "ITourRepository.h"
#include "TwitterFeedShowTweetState.h"
#include "TourModel.h"
#include "TourStateMachine.h"
#include "TourStateModel.h"
#include "TweetRepository.h"


namespace ExampleApp
{
    namespace Tours
    {
        namespace SdkModel
        {
            namespace TourInstances
            {
                namespace TwitterFeed
                {
                    TwitterFeedTourStateMachineFactory::TwitterFeedTourStateMachineFactory(Camera::IToursCameraTransitionController& toursCameraTransitionController,
                                                                                           Camera::IToursCameraController& toursCameraController,
                                                                                           WorldPins::SdkModel::IWorldPinsService& worldPinsService,
                                                                                           Eegeo::Resources::Interiors::InteriorController& interiorController,
                                                                                           InteriorsExplorer::SdkModel::InteriorVisibilityUpdater& interiorVisibilityUpdater,
                                                                                           const Eegeo::Resources::Interiors::InteriorSelectionModel& interiorSelectionModel,
                                                                                           const std::string& userId,
                                                                                           const std::map<std::string, TweetStateData>& tweetStateDataMap,
                                                                                           Metrics::IMetricsService& metricsService,
                                                                                           ExampleAppMessaging::TMessageBus& messageBus)
                    : m_toursCameraController(toursCameraController)
                    , m_toursCameraTransitionController(toursCameraTransitionController)
                    , m_worldPinsService(worldPinsService)
                    , m_interiorController(interiorController)
                    , m_interiorVisibilityUpdater(interiorVisibilityUpdater)
                    , m_interiorSelectionModel(interiorSelectionModel)
                    , m_userId(userId)
                    , m_tweetStateDataMap(tweetStateDataMap)
                    , m_metricsService(metricsService)
                    , m_messageBus(messageBus)
                    {
                        
                    }
                    
                    TwitterFeedTourStateMachineFactory::~TwitterFeedTourStateMachineFactory()
                    {
                        
                    }
                    
                    States::ITourStateMachine* TwitterFeedTourStateMachineFactory::CreateTourStateMachine(const TourModel& tourModel)
                    {
                        std::vector<States::ITourStateMachineState*> stateMachineStates;
                        std::string tourTwitterBaseUserName = tourModel.TwitterBaseUserName();
                        
                        for (int i = 0; i < tourModel.StateCount(); ++i)
                        {
                            if(!tourModel.States()[i].IsTweet())
                            {
                                Eegeo_ASSERT(false, "Non Tweet TourStateModel in twitter only factory");
                                continue;
                            }
                            
                            const Social::TwitterFeed::TweetModel& tweet = *(tourModel.States()[i].Tweet());
                            std::string nextTourName = tweet.GetUserScreenName();
                            
                            if(tweet.GetUserName() == tourTwitterBaseUserName)
                            {
                                nextTourName = "";
                            }
                            
                            const TweetStateData* tweetStateData = NULL;
                            
                            std::map<std::string, TweetStateData>::const_iterator tweetStateIt = m_tweetStateDataMap.find(tweet.GetUserScreenName());
                            
                            if(tweetStateIt == m_tweetStateDataMap.end())
                            {
                                // use the current tour's state data
                                tweetStateIt = m_tweetStateDataMap.find(m_userId);
                                
                                Eegeo_ASSERT(tweetStateIt != m_tweetStateDataMap.end(), "Couldn't find state data for tour: %s", m_userId.c_str());
                                
                                tweetStateData = &((*tweetStateIt).second);
                            }
                            else
                            {
                                // use the current state's state data
                                tweetStateData = &((*tweetStateIt).second);
                            }
                            
                            const float cameraRotationDeltaRad = Eegeo::Math::Deg2Rad(10.0f);
                            
                            std::string placename = !tweet.GetPlaceName().empty() ? tweet.GetPlaceName() : tweet.GetUserName();
                            
                            Eegeo::Space::LatLong location = tweet.HasCoordinates() ? tweet.GetCoordinates() : Eegeo::Space::LatLong::FromECEF(tweetStateData->m_ecefTarget);
                            
                            bool isInterior = false;
                            WorldPins::SdkModel::WorldPinInteriorData worldPinInteriorData;
                            if( !tweet.HasCoordinates() )
                            {
                                isInterior = tweetStateData->m_isInterior;
                                worldPinInteriorData = tweetStateData->m_interiorData;
                            }
                            else if(tweetStateData->m_useBounds)
                            {
                               if(location.GetLatitude() < tweetStateData->m_minBounds.GetLatitude() ||
                                  location.GetLongitude() < tweetStateData->m_minBounds.GetLongitude() ||
                                  location.GetLatitude() > tweetStateData->m_maxBounds.GetLatitude() ||
                                  location.GetLongitude() > tweetStateData->m_maxBounds.GetLongitude())
                               {
                                   isInterior = tweetStateData->m_isInterior;
                                   worldPinInteriorData = tweetStateData->m_interiorData;
                                   location = Eegeo::Space::LatLong::FromECEF(tweetStateData->m_ecefTarget);
                               }
                            }
                            
                            stateMachineStates.push_back(Eegeo_NEW(TwitterFeedShowTweetState(tourModel.States()[i],
                                                                                             m_toursCameraTransitionController,
                                                                                             m_worldPinsService,
                                                                                             isInterior,
                                                                                             worldPinInteriorData,
                                                                                             m_interiorController,<commit_msg>Updated Twitter Tour camera rotation to 15 degrees per card instead of 10 degrees. Pair Francisco<commit_after>// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include "TwitterFeedTourStateMachineFactory.h"

#include <vector>
#include "ITourRepository.h"
#include "TwitterFeedShowTweetState.h"
#include "TourModel.h"
#include "TourStateMachine.h"
#include "TourStateModel.h"
#include "TweetRepository.h"


namespace ExampleApp
{
    namespace Tours
    {
        namespace SdkModel
        {
            namespace TourInstances
            {
                namespace TwitterFeed
                {
                    TwitterFeedTourStateMachineFactory::TwitterFeedTourStateMachineFactory(Camera::IToursCameraTransitionController& toursCameraTransitionController,
                                                                                           Camera::IToursCameraController& toursCameraController,
                                                                                           WorldPins::SdkModel::IWorldPinsService& worldPinsService,
                                                                                           Eegeo::Resources::Interiors::InteriorController& interiorController,
                                                                                           InteriorsExplorer::SdkModel::InteriorVisibilityUpdater& interiorVisibilityUpdater,
                                                                                           const Eegeo::Resources::Interiors::InteriorSelectionModel& interiorSelectionModel,
                                                                                           const std::string& userId,
                                                                                           const std::map<std::string, TweetStateData>& tweetStateDataMap,
                                                                                           Metrics::IMetricsService& metricsService,
                                                                                           ExampleAppMessaging::TMessageBus& messageBus)
                    : m_toursCameraController(toursCameraController)
                    , m_toursCameraTransitionController(toursCameraTransitionController)
                    , m_worldPinsService(worldPinsService)
                    , m_interiorController(interiorController)
                    , m_interiorVisibilityUpdater(interiorVisibilityUpdater)
                    , m_interiorSelectionModel(interiorSelectionModel)
                    , m_userId(userId)
                    , m_tweetStateDataMap(tweetStateDataMap)
                    , m_metricsService(metricsService)
                    , m_messageBus(messageBus)
                    {
                        
                    }
                    
                    TwitterFeedTourStateMachineFactory::~TwitterFeedTourStateMachineFactory()
                    {
                        
                    }
                    
                    States::ITourStateMachine* TwitterFeedTourStateMachineFactory::CreateTourStateMachine(const TourModel& tourModel)
                    {
                        std::vector<States::ITourStateMachineState*> stateMachineStates;
                        std::string tourTwitterBaseUserName = tourModel.TwitterBaseUserName();
                        
                        for (int i = 0; i < tourModel.StateCount(); ++i)
                        {
                            if(!tourModel.States()[i].IsTweet())
                            {
                                Eegeo_ASSERT(false, "Non Tweet TourStateModel in twitter only factory");
                                continue;
                            }
                            
                            const Social::TwitterFeed::TweetModel& tweet = *(tourModel.States()[i].Tweet());
                            std::string nextTourName = tweet.GetUserScreenName();
                            
                            if(tweet.GetUserName() == tourTwitterBaseUserName)
                            {
                                nextTourName = "";
                            }
                            
                            const TweetStateData* tweetStateData = NULL;
                            
                            std::map<std::string, TweetStateData>::const_iterator tweetStateIt = m_tweetStateDataMap.find(tweet.GetUserScreenName());
                            
                            if(tweetStateIt == m_tweetStateDataMap.end())
                            {
                                // use the current tour's state data
                                tweetStateIt = m_tweetStateDataMap.find(m_userId);
                                
                                Eegeo_ASSERT(tweetStateIt != m_tweetStateDataMap.end(), "Couldn't find state data for tour: %s", m_userId.c_str());
                                
                                tweetStateData = &((*tweetStateIt).second);
                            }
                            else
                            {
                                // use the current state's state data
                                tweetStateData = &((*tweetStateIt).second);
                            }
                            
                            const float cameraRotationDeltaRad = Eegeo::Math::Deg2Rad(15.0f);
                            
                            std::string placename = !tweet.GetPlaceName().empty() ? tweet.GetPlaceName() : tweet.GetUserName();
                            
                            Eegeo::Space::LatLong location = tweet.HasCoordinates() ? tweet.GetCoordinates() : Eegeo::Space::LatLong::FromECEF(tweetStateData->m_ecefTarget);
                            
                            bool isInterior = false;
                            WorldPins::SdkModel::WorldPinInteriorData worldPinInteriorData;
                            if( !tweet.HasCoordinates() )
                            {
                                isInterior = tweetStateData->m_isInterior;
                                worldPinInteriorData = tweetStateData->m_interiorData;
                            }
                            else if(tweetStateData->m_useBounds)
                            {
                               if(location.GetLatitude() < tweetStateData->m_minBounds.GetLatitude() ||
                                  location.GetLongitude() < tweetStateData->m_minBounds.GetLongitude() ||
                                  location.GetLatitude() > tweetStateData->m_maxBounds.GetLatitude() ||
                                  location.GetLongitude() > tweetStateData->m_maxBounds.GetLongitude())
                               {
                                   isInterior = tweetStateData->m_isInterior;
                                   worldPinInteriorData = tweetStateData->m_interiorData;
                                   location = Eegeo::Space::LatLong::FromECEF(tweetStateData->m_ecefTarget);
                               }
                            }
                            
                            stateMachineStates.push_back(Eegeo_NEW(TwitterFeedShowTweetState(tourModel.States()[i],
                                                                                             m_toursCameraTransitionController,
                                                                                             m_worldPinsService,
                                                                                             isInterior,
                                                                                             worldPinInteriorData,
                                                                                             m_interiorController,
{'fraction_non_alphanumeric': 0.0611579754601227, 'fraction_numerical': 0.0019171779141104294, 'mean_word_length': 0.9255567860219023, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 128, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2657551', 'n_tokens_mistral': 3106, 'n_tokens_neox': 2908, 'n_words': 396}