bool IndoorAtlasLocationService::GetLocation(Eegeo::Space::LatLong& latLong)
                {
                    if(std::abs(m_latLong.GetLatitude()) > 0 || std::abs(m_latLong.GetLongitude()) > 0)
                    {
                        latLong.SetLatitude(m_latLong.GetLatitude());
                        latLong.SetLongitude(m_latLong.GetLongitude());
                    }
                    else
                    {
                        m_defaultLocationService.GetLocation(latLong);
                    }

                    return true;
                }
void CameraTransitionExample::Transition()
{
	const float interestPointDistanceMetres = 1800.f;
	if (m_firstPoint)
	{
		Eegeo::Space::LatLong transitionDestinationLatLong = Eegeo::Space::LatLong::FromDegrees(37.718739, -122.500771);
		m_transitioner.StartTransitionTo(transitionDestinationLatLong.ToECEF(), interestPointDistanceMetres, false);
	}
	else
	{
		Eegeo::Space::LatLong transitionDestinationLatLong = Eegeo::Space::LatLong::FromDegrees(37.779547, -122.398805);
		m_transitioner.StartTransitionTo(transitionDestinationLatLong.ToECEF(), interestPointDistanceMetres, false);
	}
	m_firstPoint = !m_firstPoint;
}
void ControlCityThemeExample::FindThemeByPointInPolygon()
{
	Eegeo::Space::LatLong osaka = Eegeo::Space::LatLong::FromDegrees(34.700131,135.478884);
	Eegeo::v2 osakav2(static_cast<float>(osaka.GetLatitudeInDegrees()), static_cast<float>(osaka.GetLongitudeInDegrees()));

	// enumerate all of the themes in the theme repository
	int numberOfThemes = m_themeRepository.GetNumberOfThemes();
	for (int i=0; i<numberOfThemes; ++i)
	{
		const Eegeo::Resources::CityThemes::CityThemeData& themeData = m_themeRepository.GetCityThemeAt(i);
		if (themeData.PolygonBounds.size() > 0) // there are points in the bounding polygon
		{
			std::vector<Eegeo::v2> polygon;
			VectorLatLonToV2(themeData.PolygonBounds, polygon);
			if (PointInPolygon(polygon, osakav2))
			{
				EXAMPLE_LOG("This theme contains the Osaka point: %s\n", themeData.Name.c_str());
				return;
			}
		}
	}
	EXAMPLE_LOG("No theme found that contains the Osaka point\n");
}
    void MobileExampleApp::Update(float dt)
    {
        Eegeo::EegeoWorld& eegeoWorld(World());
        
        Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsModule = eegeoWorld.GetMapModule().GetInteriorsPresentationModule();
        Eegeo::Resources::Interiors::Camera::InteriorsCameraController& interiorsCameraController = interiorsModule.GetCameraController();
        
        m_pCurrentTouchController = interiorsModule.GetCameraController().IsEnabled()
            ? &interiorsModule.GetTouchController()
            : m_pCameraTouchController;

        eegeoWorld.EarlyUpdate(dt);

        m_pGlobeCameraController->Update(dt);
        m_pCameraTransitionController->Update(dt);
        
        if(interiorsCameraController.IsEnabled())
        {
            interiorsCameraController.Update(dt);
        }

        Eegeo::Camera::CameraState cameraState(interiorsCameraController.IsEnabled()
                                               ? interiorsCameraController.GetCameraState()
                                               : m_pGlobeCameraController->GetCameraState());
        
        Eegeo::Camera::RenderCamera renderCamera(interiorsCameraController.IsEnabled()
                                                 ? interiorsCameraController.GetRenderCamera()
                                                 : m_pGlobeCameraController->GetRenderCamera());
        
        Eegeo::dv3 ecefInterestPoint(cameraState.InterestPointEcef());

        m_pPoiRingModule->GetPoiRingController().Update(dt, renderCamera, ecefInterestPoint);

        Eegeo::EegeoUpdateParameters updateParameters(dt,
                cameraState.LocationEcef(),
                cameraState.InterestPointEcef(),
                cameraState.ViewMatrix(),
                cameraState.ProjectionMatrix(),
                GetUpdatedStreamingVolume(cameraState, renderCamera),
                m_screenProperties);

        eegeoWorld.Update(updateParameters);

        m_pSearchModule->GetSearchRefreshService().TryRefreshSearch(dt, ecefInterestPoint);

        m_pPinsModule->GetController().Update(dt, renderCamera);

        if(!eegeoWorld.Initialising())
        {
            WorldPinsModule().GetWorldPinsScaleController().Update(dt, renderCamera);
            CompassModule().GetCompassUpdateController().Update(dt);
            CompassModule().GetCompassUpdateController().Update(dt);
            m_pGpsMarkerModule->GetGpsMarkerController().Update(dt, renderCamera);
            
            if (m_interiorsEnabled)
            {
                Eegeo_ASSERT(m_pInteriorsEntitiesPinsModule != NULL);
                
                m_pInteriorsEntitiesPinsModule->GetPinsModule().Update(dt, renderCamera);
                m_pInteriorsEntitiesPinsModule->GetInteriorsEntitiesPinsController().Update(dt);
            }
            
            InitialExperience::SdkModel::IInitialExperienceModel& initialExperienceModel = m_initialExperienceModule.GetInitialExperienceModel();
            if(!initialExperienceModel.HasCompletedInitialExperience() && IsLoadingScreenComplete())
            {
                InitialExperience::SdkModel::IInitialExperienceController& initialExperienceController = m_initialExperienceModule.GetInitialExperienceController();
                initialExperienceController.Update(dt);
            }
  
            if (!m_setMetricsLocation)
            {
                Eegeo::dv3 gpsLocation;
                if(m_pNavigationService->TryGetGpsLocationOnTerrain(gpsLocation))
                {
                    Eegeo::Space::LatLong ll = Eegeo::Space::LatLong::FromECEF(gpsLocation);
                    m_metricsService.SetPosition(ll.GetLatitudeInDegrees(), ll.GetLongitudeInDegrees(), 0.f, 0.f);
                    m_setMetricsLocation = true;
                }
            }
        }

        m_pNavigationService->Update(dt);

        UpdateLoadingScreen(dt);
    }
        const std::array<AutomatedScreenshotController::SceneSetupFunction, AutomatedScreenshotController::NumScenes> AutomatedScreenshotController::States() const
        {
            return {{
                [this]() {
                    const PlaceJumps::View::PlaceJumpModel London(
                            "London",
                            Eegeo::Space::LatLong::FromDegrees(51.512179, -0.080664),
                            162.2f,
                            1780.1f,
                            "");

                    m_placeJumpController.JumpTo(London);
                    m_weatherController.SetTime("Day");
                    m_weatherController.SetTheme("Summer");

                    return WaitMs(8000);
                },

                [this]() {
                    const long long WaitMsForInteriorToLoad = 4000;
                    const long long MsToWaitForCameraToEnterInterior = 3000;
                    const Eegeo::Resources::Interiors::InteriorId WestportHouseInteriorId("westport_house");
                    const Eegeo::Space::LatLong location(Eegeo::Space::LatLong::FromDegrees(56.460108, -2.978094));
                    const float distanceFromInterest = 200.f;
                    const PlaceJumps::View::PlaceJumpModel WestportHouse(
                            "WestportHouse",
                            location,
                            312.8f,
                            distanceFromInterest,
                            "");

                    m_placeJumpController.JumpTo(WestportHouse);

                    return Seq(WaitMs(WaitMsForInteriorToLoad),
                               Act([=]() { m_interiorSelectionModel.SelectInteriorId(WestportHouseInteriorId); }),
                               WaitMs(MsToWaitForCameraToEnterInterior),
                               Act([=]() {
                                   m_cameraTransitionService.StartTransitionTo(location.ToECEF(), distanceFromInterest, WestportHouseInteriorId, 2, true);
                               }),
                               WaitForCameraTransition(&m_cameraTransitionService),
                               Act([=]() {
                                   m_searchQueryPerformer.PerformSearchQuery("General", true, true);
                               }),
                               WaitMs(8000),
                               Act([=]() {
                                   m_searchQueryPerformer.RequestClear();
                                   m_searchQueryPerformer.RemoveSearchQueryResults();
                               })
                    );
                },

                [this]() {
                    return IsLandscapeLayout(m_screenProperties)
                            ? TabletVASceneSetup(true)
                            : PhoneNYCSceneSetup(true);
                },

                [this]() {
                    return IsLandscapeLayout(m_screenProperties)
                           ? TabletVASceneSetup(false)
                           : PhoneNYCSceneSetup(false);
                },
                
                [this]() {
                    return IsLandscapeLayout(m_screenProperties)
                           ? SelectedPinSceneSetup("Victoria and Albert Museum", 2)
                           : SelectedPinSceneSetup("Empire State Building", 0);
                },

                [this]() {
                    static const std::string LightThemesManifestUrlDefault  = "https://cdn-resources.wrld3d.com/mobile-themes-new/v883/ambientwhite/manifest.bin.gz";
                    const long long MsToWaitForSearchQueryToClear = 3000;
                    const long long MsToWaitForThemeToLoad = 3000;
                    const PlaceJumps::View::PlaceJumpModel SanFran(
                            "SanFran",
                            Eegeo::Space::LatLong::FromDegrees(37.742448, -122.446477),
                            27.2f,
                            1914.3f,
                            "");
                    
                    m_messageBus.Publish(ClosePoiMessage());
                    m_messageBus.Publish(SearchMenu::OpenSearchMenuMessage(false));
                    m_placeJumpController.JumpTo(SanFran);
                    m_cityThemeLoader.LoadThemes(LightThemesManifestUrlDefault, "Summer", "DayDefault");

                    return Seq(WaitMs(MsToWaitForSearchQueryToClear),
                               Act([=]() {
                        m_searchQueryPerformer.RemoveSearchQueryResults(); }),
                               WaitForStreaming(&m_cityThemeLoader),
                               WaitMs(MsToWaitForThemeToLoad));
                },

                [this]() {
                    static const std::string SciFiThemesManifestUrlDefault = "https://cdn-resources.wrld3d.com/mobile-themes-new/v883/scifi/manifest.bin.gz";
                    const long long MsToWaitForSearchResultsToClearAndThemeToLoad = 3000;
                    const PlaceJumps::View::PlaceJumpModel LA(
                            "LA",
                            Eegeo::Space::LatLong::FromDegrees(34.051624, -118.254724),
                            187.6f,
                            1885.8f,
                            "");

                    m_placeJumpController.JumpTo(LA);
                    m_searchQueryPerformer.RemoveSearchQueryResults();
                    m_cityThemeLoader.LoadThemes(SciFiThemesManifestUrlDefault, "Summer", "DayDefault");

                    return Seq(WaitForStreaming(&m_cityThemeLoader),
                               WaitMs(MsToWaitForSearchResultsToClearAndThemeToLoad));
                }
            }};
        }