void TwitterFeedService::HandleAuthResponse(Eegeo::Web::IWebResponse& webResponse)
 {
     m_pCurrentAuthRequest = NULL;
     
     if(webResponse.GetHttpStatusCode() != 200)
     {
         m_currentServiceState = OFFLINE;
         
         ClearAccountNameQueue();
         
         return;
     }
     
     size_t resultSize = webResponse.GetBodyData().size();
     std::string serialized(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize);
     
     rapidjson::Document document;
     
     document.Parse<0>(serialized.c_str());
     
     Eegeo_ASSERT(!document.HasParseError(), "Error parsing auth response");
     Eegeo_ASSERT(document.HasMember(AccessTokenKey.c_str()), "Auth response doesn't contain access code: %s", serialized.c_str());
     
     m_accessToken = std::string(document[AccessTokenKey.c_str()].GetString());
     
     LoadNextTimeLine();
 }
void EegeoSearchQuery::OnWebResponseReceived(Eegeo::Web::IWebResponse& webResponse)
{
    if(webResponse.IsSucceeded())
    {
        size_t resultSize = webResponse.GetBodyData().size();
        m_responseString = std::string(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize);
        m_isSuccess = true;
    }

    m_completionCallback();
}
                void YelpBusinessQuery::HandleWebResponseComplete(Eegeo::Web::IWebResponse& webResponse)
                {
                    Eegeo_ASSERT(!webResponse.IsCancelled());
                    
                    size_t resultSize = webResponse.GetBodyData().size();
                    const std::string& responseString = resultSize > 0 ? std::string(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize) : "<empty>";

                    bool parseSuccess = false;
                    Search::SdkModel::SearchResultModel result;
                    
                    if (webResponse.IsSucceeded())
                    {
                        parseSuccess = m_yelpBusinessParser.TryParse(responseString, result);
                    }
                    else
                    {
                        Eegeo_TTY("YelpBusinessQuery failed: %s", responseString.c_str());
                    }
                    
                    const Search::SdkModel::IdentitySearchCallbackData& callbackData = parseSuccess
                        ? Search::SdkModel::IdentitySearchCallbackData::CreateSucceeded(result)
                        : Search::SdkModel::IdentitySearchCallbackData::CreateFailed(result);

                    m_completionCallback(callbackData);

                    Eegeo_DELETE this;
                }
 void TwitterFeedService::HandleTimeLineResponse(Eegeo::Web::IWebResponse& webResponse)
 {
     m_pCurrentTimeLineRequest = NULL;
     
     if(webResponse.GetHttpStatusCode() != 200)
     {
         m_currentServiceState = OFFLINE;
         
         ClearAccountNameQueue();
         
         return;
     }
     
     size_t resultSize = webResponse.GetBodyData().size();
     std::string serialized(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize);
     
     rapidjson::Document document;
     
     document.Parse<0>(serialized.c_str());
     
     Eegeo_ASSERT(!document.HasParseError(), "Error parsing timeline request response")
     Eegeo_ASSERT(document.IsArray(), "Timeline request response unrecognised: %s", serialized.c_str());
     
     std::map<std::string, TweetRepository*>::iterator repositoryIt = m_repositoryMap.find(m_accountNameQueue.front());
     
     if(repositoryIt == m_repositoryMap.end())
     {
         repositoryIt = m_repositoryMap.insert(std::pair<std::string, TweetRepository*>(m_accountNameQueue.front(), Eegeo_NEW(TweetRepository)())).first;
     }
     
     TweetRepository* currentRepository = (*repositoryIt).second;
     
     for(rapidjson::SizeType i = 0; i < document.Size(); ++i)
     {
         currentRepository->AddItem(TweetModel::GetNewTweetModelFromJsonDocument(document, i));
     }
     
     m_feedLoadedCallbacks.ExecuteCallbacks(m_accountNameQueue.front(), *currentRepository);
     
     m_accountNameQueue.pop();
     
     LoadNextTimeLine();
 }
 void StencilAreaExample::HandleRequest(Eegeo::Web::IWebResponse& webResponse)
 {
     m_pendingWebRequestsContainer.RemoveRequest(webResponse);
     
     if (!webResponse.IsSucceeded())
     {
         Eegeo_ASSERT(m_pAlertBoxDismissedHandler == NULL, "AlertBoxDismissedHandler not NULL");
         
         m_pAlertBoxDismissedHandler = Eegeo_NEW(Eegeo::UI::NativeAlerts::TSingleOptionAlertBoxDismissedHandler<StencilAreaExample>(this, &StencilAreaExample::HandleAlertBoxDismissed));
         
         m_nativeUIFactories.AlertBoxFactory().CreateSingleOptionAlertBox("Unabled to Retrieve Stencil Data",
                                                                          "Ensure network connection is enabled and retry the example",
                                                                          *m_pAlertBoxDismissedHandler);
         
         return;
     }
     
     size_t resultSize = webResponse.GetBodyData().size();
     std::string json( reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize );
     
     const std::string document(json);
     TDistricts districtOutlines;
     
     // Parse polygons in GeoJSON to vector of LatLongAltitudes
     Eegeo::Data::GeoJSON::GeoJSONDocument geoJsonDocument(document);
     const Eegeo::Data::GeoJSON::GeoJSONObject& obj = geoJsonDocument.Parse();
     const Eegeo::Data::GeoJSON::FeatureCollection& featureCollection = obj.AsFeatureCollection();
     for (int i = 0; i < featureCollection.GetNumFeatures(); ++i)
     {
         const Eegeo::Data::GeoJSON::Feature& feature = featureCollection.GetFeatureAt(i);
         const Eegeo::Data::GeoJSON::MultiPolygon& multiPolygon = feature.GetGeometry().AsMultiPolygon();
         
         for (int j = 0; j < multiPolygon.GetNumPolygons(); ++j)
         {
             const Eegeo::Data::GeoJSON::PolygonData& polygonData = multiPolygon.GetPolygonAt(j);
             ConvertToDistrict(polygonData, districtOutlines);
         }
     }
     
     // outlineAltitudeOffsets are terrain heights (from ITerrainHeightLookup) at outline centroids
     const float outlineAltitudeOffsets[] = {4.6849f, 43.7334f, 2.6585f, 90.3125f, 75.8662f, 102.4601f, 44.9174f, 66.8289f, 75.8662f, 114.1066f, 133.8441f, 133.8441f, 62.8317f, 114.9324f, 118.5516f, 95.9089f, 95.5290f, 74.7607f, 51.2341f, 75.5237f, 25.9373f, 73.1260f, 25.9373f, 150.2888f, 89.1085f, 51.5655f, 114.1066f, 100.2126f, 70.4457f, 97.8528f, 20.2937f, 60.0656f, 85.6781f, 104.2594f, 99.6410f, 116.9411f, 214.2081f, 96.4998f, 210.9473f, 253.4782f, 153.0558f, 83.6688f, 96.4998f, 201.9720f, 131.3402f, 179.9836f, 253.4782f, 71.6693f, 103.3735f, 97.8528f, 182.9989f, 198.2886f, 198.2886f, 210.7315f, 214.2081f, 68.3862f, 180.9597f, 95.9089f, 114.9324f, 89.3736f, 46.2380f, 46.2380f, 9.2913f, 38.6931f, 66.5644f, 68.5033f, 59.7500f, 87.9804f, 87.3458f, 180.5154f, 31.2882f, 85.6422f, 29.3151f, 86.2003f, 84.5633f, 24.2386f, 68.4895f, 67.2186f, 65.6160f, 93.8255f, 65.5967f, 93.8255f, 49.4197f, 102.0758f, 48.5513f, 32.5650f, 32.5650f, 18.5832f, 15.9373f, 65.6160f, 145.7743f, 153.0558f, 24.2386f, 83.5538f, 21.3396f, 102.0758f, 84.0589f, 45.1286f, 18.5832f, 60.8095f, 65.5967f, 78.1820f, 64.3211f, 84.5633f, 87.0487f, 27.0241f, 38.6449f, 9.0000f, 87.9804f, 68.0252f, 78.8772f, 86.1506f, 10.5388f, 50.2124f, 63.0208f, 24.9978f, 68.6975f, 34.0320f, 81.3867f, 73.4589f, 99.1616f, 74.4662f, 29.0826f, 67.2422f, 24.4150f, 37.3627f, 74.5852f, 51.0264f, 7.7920f, 58.2490f, 57.2189f, 65.7713f, 86.5244f, 3.9804f, 28.7383f, 38.1068f, 57.2189f, 50.3965f, 74.5852f, 31.1714f, 3.9804f, 6.0546f, 99.1616f, 18.1432f, 104.0983f, 17.7228f, 16.0400f, 63.0100f, 13.3495f, 21.9093f, 16.0400f, 38.7216f, 86.5244f, 68.5033f, 54.6419f, 67.0218f, 24.3175f, 15.2920f, 50.4095f, 10.6337f, 51.0376f};
     
     const float heightOfStencilAreaInM = 250.f;
     
     // Create stencil area extrusions for each district polygon, assigning to a random color palette.
     int districtCount = 0;
     for (TDistricts::iterator it = districtOutlines.begin(); it != districtOutlines.end(); ++it)
     {
         int randomPalette = int((rand() % m_palettes.size()));
         const Eegeo::Data::StencilArea::StencilAreaPaletteModel& paletteModel = *(m_palettes[randomPalette]);
         const std::vector<Eegeo::Space::LatLongAltitude>& outline = *it;
         Eegeo::Data::StencilArea::StencilAreaModel* pModel = Eegeo::Data::StencilArea::StencilAreaModel::StencilAreaBuilder("stencil_area",
                                                                                                                             paletteModel,
                                                                                                                             outline,
                                                                                                                             Eegeo::Rendering::StencilMapLayerMask::Buildings,
                                                                                                                             outlineAltitudeOffsets[districtCount]+heightOfStencilAreaInM)
         .Build();
         m_outlines.push_back(pModel);
         m_controller.Add(*pModel);
         ++districtCount;
     }
 }
 void MyPinsWebService::WebRequestCompleteCallback(Eegeo::Web::IWebResponse& webResponse)
 {
     size_t resultSize = webResponse.GetBodyData().size();
     std::string responseString = resultSize > 0 ? std::string(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize) : "<empty>";
     Eegeo_TTY("Web Request Completed, code: %d response: %s\n", webResponse.GetHttpStatusCode(), responseString.c_str());
 }