{"action":"created","comment":{"url":"https://api.github.com/repos/glob3mobile/g3m/pulls/comments/55987811","id":55987811,"diff_hunk":"@@ -0,0 +1,162 @@\n+//\n+//  PyramidElevationDataProvider.cpp\n+//  G3MiOSSDK\n+//\n+//  Created by Sebastian Ortega Trujillo on 4/3/16.\n+//\n+//\n+\n+#import \"PyramidElevationDataProvider.hpp\"\n+#include \"PyramidElevationDataProvider_BufferDownloadListener.hpp\"\n+#include \"IJSONParser.hpp\"\n+#include \"DownloadPriority.hpp\"\n+#include \"JSONObject.hpp\"\n+#include \"JSONInteger.hpp\"\n+#include \"JSONDouble.hpp\"\n+#include \"JSONArray.hpp\"\n+#include \"G3MContext.hpp\"\n+#include \"TimeInterval.hpp\"\n+#include <sstream>\n+\n+class PyramidElevationDataProvider::MetadataListener : public IBufferDownloadListener {\n+public:\n+    MetadataListener(std::vector<PyramidComposition>* itself): _itself(itself) {}\n+    \n+    void onDownload(const URL& url,\n+                    IByteBuffer* buffer,\n+                    bool expired) {\n+        \n+        const std::string str = buffer->getAsString();\n+        \n+        IJSONParser* parser = IJSONParser::instance();\n+        const JSONArray* array = parser->parse(str)->asObject()->getAsArray(\"sectors\");\n+        \n+        for (unsigned int i=0; i<array->size(); i++){\n+            _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i)));\n+        }\n+    }\n+    void onError(const URL& url) {}\n+    void onCancel(const URL& url) {}\n+    \n+    void onCanceledDownload(const URL& url,\n+                            IByteBuffer* data,\n+                            bool expired) {}\n+    \n+private:\n+    std::vector<PyramidComposition>* _itself;\n+    const G3MContext *_context;\n+    \n+    double getUpperLat(const JSONArray *array, int index){\n+        JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject(\"sector\")->getAsObject(\"upper\")->getAsNumber(\"lat\");\n+        return doble->value();\n+    }\n+    \n+    double getLowerLat(const JSONArray *array, int index){\n+        JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject(\"sector\")->getAsObject(\"lower\")->getAsNumber(\"lat\");\n+        return doble->value();\n+    }\n+    \n+    double getUpperLon(const JSONArray *array, int index){\n+        JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject(\"sector\")->getAsObject(\"upper\")->getAsNumber(\"lon\");\n+        return doble->value();\n+    }\n+    \n+    double getLowerLon(const JSONArray *array, int index){\n+        JSONDouble *doble = (JSONDouble*)array->getAsObject(index)->getAsObject(\"sector\")->getAsObject(\"lower\")->getAsNumber(\"lon\");\n+        return doble->value();\n+    }\n+    \n+    int getLevel(const JSONArray *array,int index){\n+        JSONInteger *integer = (JSONInteger *) array->getAsObject(index)->getAsNumber(\"pyrLevel\");\n+        return integer->intValue();\n+    }\n+};\n+\n+PyramidElevationDataProvider::PyramidElevationDataProvider(const std::string &layer, const Sector& sector,\n+                                                           bool isMercator,double deltaHeight): _sector(sector), _layer(layer){\n+    _pyrComposition = new std::vector<PyramidComposition>();\n+    _deltaHeight = deltaHeight;\n+    _isMercator = isMercator;\n+}\n+\n+PyramidElevationDataProvider::~PyramidElevationDataProvider(){\n+    _pyrComposition->clear();\n+    delete _pyrComposition;\n+    _pyrComposition = NULL;\n+    \n+}\n+\n+void PyramidElevationDataProvider::getMetadata() const{\n+    \n+    _downloader->requestBuffer(URL(requestMetadataPath(),false), DownloadPriority::HIGHER, TimeInterval::fromDays(30), true, new MetadataListener(_pyrComposition), true);\n+}\n+\n+void PyramidElevationDataProvider::initialize(const G3MContext* context ){\n+    _downloader = context->getDownloader();\n+    getMetadata();\n+}\n+\n+const long long PyramidElevationDataProvider::requestElevationData(const Sector &sector, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener){\n+    //This requester is not necessary, but we are forced to implement it, so -1.\n+    return -1;\n+}\n+\n+const long long PyramidElevationDataProvider::requestElevationData(const Sector &sector, int level, int row, int column, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener){\n+    \n+    if ((_downloader == NULL) || (aboveLevel(sector, level))){\n+        return -1;\n+    }\n+    \n+    std::string path = requestStringPath(_layer,level,row,column);\n+    \n+    return _downloader->requestBuffer(URL(path,false), DownloadPriority::HIGHEST - level, TimeInterval::fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent, listener, autodeleteListener, _deltaHeight), true );\n+}\n+\n+std::string PyramidElevationDataProvider::requestStringPath(const Sector &sector, const Vector2I &extent){\n+    // TODO: Esta en principio no debería usarse, pero ...\n+    ILogger::instance()->logError(\"BAD STRING PATH REQUESTED!\");\n+    return \"\";\n+}\n+\n+std::string PyramidElevationDataProvider::requestStringPath(const std::string & layer, int level, int row, int column){\n+    std::ostringstream strs;\n+    strs << _layer << level << \"/\" << column << \"/\" << row << \".json\"; //\".bil\";\n+    std::string res = strs.str();\n+    //ILogger::instance()->logInfo(res);\n+    return res;\n+}\n+\n+std::string PyramidElevationDataProvider::requestMetadataPath() const{\n+    return _layer + \"meta.json\";\n+}\n+\n+void PyramidElevationDataProvider::cancelRequest(const long long requestId){\n+    _downloader->cancelRequest(requestId);\n+}\n+\n+std::vector<const Sector*> PyramidElevationDataProvider::getSectors() const{\n+    std::vector<const Sector*> sectors;\n+    sectors.push_back(&_sector);\n+    return sectors;\n+}\n+\n+const Vector2I PyramidElevationDataProvider::getMinResolution() const{\n+    //    int WORKING_JM;\n+    return Vector2I::zero();\n+}\n+","path":"iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp","position":147,"original_position":147,"commit_id":"b959387f3ed00fca27298693d97848483e6b26fa","original_commit_id":"b959387f3ed00fca27298693d97848483e6b26fa","user":{"login":"DiegoGomezDeck","id":1429156,"avatar_url":"https://avatars.githubusercontent.com/u/1429156?v=3","gravatar_id":"","url":"https://api.github.com/users/DiegoGomezDeck","html_url":"https://github.com/DiegoGomezDeck","followers_url":"https://api.github.com/users/DiegoGomezDeck/followers","following_url":"https://api.github.com/users/DiegoGomezDeck/following{/other_user}","gists_url":"https://api.github.com/users/DiegoGomezDeck/gists{/gist_id}","starred_url":"https://api.github.com/users/DiegoGomezDeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DiegoGomezDeck/subscriptions","organizations_url":"https://api.github.com/users/DiegoGomezDeck/orgs","repos_url":"https://api.github.com/users/DiegoGomezDeck/repos","events_url":"https://api.github.com/users/DiegoGomezDeck/events{/privacy}","received_events_url":"https://api.github.com/users/DiegoGomezDeck/received_events","type":"User","site_admin":false},"body":"What is it?","created_at":"2016-03-14T11:38:40Z","updated_at":"2016-03-14T11:38:40Z","html_url":"https://github.com/glob3mobile/g3m/pull/176#discussion_r55987811","pull_request_url":"https://api.github.com/repos/glob3mobile/g3m/pulls/176","_links":{"self":{"href":"https://api.github.com/repos/glob3mobile/g3m/pulls/comments/55987811"},"html":{"href":"https://github.com/glob3mobile/g3m/pull/176#discussion_r55987811"},"pull_request":{"href":"https://api.github.com/repos/glob3mobile/g3m/pulls/176"}}},"pull_request":{"url":"https://api.github.com/repos/glob3mobile/g3m/pulls/176","id":62409285,"html_url":"https://github.com/glob3mobile/g3m/pull/176","diff_url":"https://github.com/glob3mobile/g3m/pull/176.diff","patch_url":"https://github.com/glob3mobile/g3m/pull/176.patch","issue_url":"https://api.github.com/repos/glob3mobile/g3m/issues/176","number":176,"state":"open","locked":false,"title":"Str-elevs client","user":{"login":"ChanoOT","id":6318394,"avatar_url":"https://avatars.githubusercontent.com/u/6318394?v=3","gravatar_id":"","url":"https://api.github.com/users/ChanoOT","html_url":"https://github.com/ChanoOT","followers_url":"https://api.github.com/users/ChanoOT/followers","following_url":"https://api.github.com/users/ChanoOT/following{/other_user}","gists_url":"https://api.github.com/users/ChanoOT/gists{/gist_id}","starred_url":"https://api.github.com/users/ChanoOT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChanoOT/subscriptions","organizations_url":"https://api.github.com/users/ChanoOT/orgs","repos_url":"https://api.github.com/users/ChanoOT/repos","events_url":"https://api.github.com/users/ChanoOT/events{/privacy}","received_events_url":"https://api.github.com/users/ChanoOT/received_events","type":"User","site_admin":false},"body":"A client class to read DEM pyramids is added (PyramidElevationDataProvider).\r\nChanges in ElevationData and ShortBufferElevationData are done to save extra data from a DEM pyramid input file.\r\nA new requestElevationData() method is added to make petitions based on tile information. Default behaviour redirects to the original method, the new class uses this implementation.\r\nMinor changes in PlanetTileTesselator are done to make tile mesh resolution variable, according to the incoming elevationData. Default resolution is still the one given by TilesRenderParameters.\r\nMinor changes in TileElevationDataRequest are introduced to call the new requestElevationData() method.\r\nMinor changes in Tile are introduced to cancel elevation requests which are no longer needed.\r\nDemo examples are introduced for every platform.","created_at":"2016-03-10T15:46:59Z","updated_at":"2016-03-14T11:38:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7ca9cc73baa153fc1abee2bdf1402ff2eaf7d86","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/glob3mobile/g3m/pulls/176/commits","review_comments_url":"https://api.github.com/repos/glob3mobile/g3m/pulls/176/comments","review_comment_url":"https://api.github.com/repos/glob3mobile/g3m/pulls/comments{/number}","comments_url":"https://api.github.com/repos/glob3mobile/g3m/issues/176/comments","statuses_url":"https://api.github.com/repos/glob3mobile/g3m/statuses/b959387f3ed00fca27298693d97848483e6b26fa","head":{"label":"glob3mobile:str-elevs","ref":"str-elevs","sha":"b959387f3ed00fca27298693d97848483e6b26fa","user":{"login":"glob3mobile","id":5470097,"avatar_url":"https://avatars.githubusercontent.com/u/5470097?v=3","gravatar_id":"","url":"https://api.github.com/users/glob3mobile","html_url":"https://github.com/glob3mobile","followers_url":"https://api.github.com/users/glob3mobile/followers","following_url":"https://api.github.com/users/glob3mobile/following{/other_user}","gists_url":"https://api.github.com/users/glob3mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/glob3mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glob3mobile/subscriptions","organizations_url":"https://api.github.com/users/glob3mobile/orgs","repos_url":"https://api.github.com/users/glob3mobile/repos","events_url":"https://api.github.com/users/glob3mobile/events{/privacy}","received_events_url":"https://api.github.com/users/glob3mobile/received_events","type":"Organization","site_admin":false},"repo":{"id":12868151,"name":"g3m","full_name":"glob3mobile/g3m","owner":{"login":"glob3mobile","id":5470097,"avatar_url":"https://avatars.githubusercontent.com/u/5470097?v=3","gravatar_id":"","url":"https://api.github.com/users/glob3mobile","html_url":"https://github.com/glob3mobile","followers_url":"https://api.github.com/users/glob3mobile/followers","following_url":"https://api.github.com/users/glob3mobile/following{/other_user}","gists_url":"https://api.github.com/users/glob3mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/glob3mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glob3mobile/subscriptions","organizations_url":"https://api.github.com/users/glob3mobile/orgs","repos_url":"https://api.github.com/users/glob3mobile/repos","events_url":"https://api.github.com/users/glob3mobile/events{/privacy}","received_events_url":"https://api.github.com/users/glob3mobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/glob3mobile/g3m","description":"The multiplatform advanced visualization framework","fork":false,"url":"https://api.github.com/repos/glob3mobile/g3m","forks_url":"https://api.github.com/repos/glob3mobile/g3m/forks","keys_url":"https://api.github.com/repos/glob3mobile/g3m/keys{/key_id}","collaborators_url":"https://api.github.com/repos/glob3mobile/g3m/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/glob3mobile/g3m/teams","hooks_url":"https://api.github.com/repos/glob3mobile/g3m/hooks","issue_events_url":"https://api.github.com/repos/glob3mobile/g3m/issues/events{/number}","events_url":"https://api.github.com/repos/glob3mobile/g3m/events","assignees_url":"https://api.github.com/repos/glob3mobile/g3m/assignees{/user}","branches_url":"https://api.github.com/repos/glob3mobile/g3m/branches{/branch}","tags_url":"https://api.github.com/repos/glob3mobile/g3m/tags","blobs_url":"https://api.github.com/repos/glob3mobile/g3m/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/glob3mobile/g3m/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/glob3mobile/g3m/git/refs{/sha}","trees_url":"https://api.github.com/repos/glob3mobile/g3m/git/trees{/sha}","statuses_url":"https://api.github.com/repos/glob3mobile/g3m/statuses/{sha}","languages_url":"https://api.github.com/repos/glob3mobile/g3m/languages","stargazers_url":"https://api.github.com/repos/glob3mobile/g3m/stargazers","contributors_url":"https://api.github.com/repos/glob3mobile/g3m/contributors","subscribers_url":"https://api.github.com/repos/glob3mobile/g3m/subscribers","subscription_url":"https://api.github.com/repos/glob3mobile/g3m/subscription","commits_url":"https://api.github.com/repos/glob3mobile/g3m/commits{/sha}","git_commits_url":"https://api.github.com/repos/glob3mobile/g3m/git/commits{/sha}","comments_url":"https://api.github.com/repos/glob3mobile/g3m/comments{/number}","issue_comment_url":"https://api.github.com/repos/glob3mobile/g3m/issues/comments{/number}","contents_url":"https://api.github.com/repos/glob3mobile/g3m/contents/{+path}","compare_url":"https://api.github.com/repos/glob3mobile/g3m/compare/{base}...{head}","merges_url":"https://api.github.com/repos/glob3mobile/g3m/merges","archive_url":"https://api.github.com/repos/glob3mobile/g3m/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/glob3mobile/g3m/downloads","issues_url":"https://api.github.com/repos/glob3mobile/g3m/issues{/number}","pulls_url":"https://api.github.com/repos/glob3mobile/g3m/pulls{/number}","milestones_url":"https://api.github.com/repos/glob3mobile/g3m/milestones{/number}","notifications_url":"https://api.github.com/repos/glob3mobile/g3m/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/glob3mobile/g3m/labels{/name}","releases_url":"https://api.github.com/repos/glob3mobile/g3m/releases{/id}","deployments_url":"https://api.github.com/repos/glob3mobile/g3m/deployments","created_at":"2013-09-16T13:35:11Z","updated_at":"2016-03-03T17:50:58Z","pushed_at":"2016-03-14T10:56:42Z","git_url":"git://github.com/glob3mobile/g3m.git","ssh_url":"git@github.com:glob3mobile/g3m.git","clone_url":"https://github.com/glob3mobile/g3m.git","svn_url":"https://github.com/glob3mobile/g3m","homepage":"http://www.glob3mobile.com/","size":539689,"stargazers_count":85,"watchers_count":85,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":29,"forks":41,"open_issues":29,"watchers":85,"default_branch":"purgatory"}},"base":{"label":"glob3mobile:purgatory","ref":"purgatory","sha":"bd29e1c2f5afbedd70da8f24ce9f5671a5d66250","user":{"login":"glob3mobile","id":5470097,"avatar_url":"https://avatars.githubusercontent.com/u/5470097?v=3","gravatar_id":"","url":"https://api.github.com/users/glob3mobile","html_url":"https://github.com/glob3mobile","followers_url":"https://api.github.com/users/glob3mobile/followers","following_url":"https://api.github.com/users/glob3mobile/following{/other_user}","gists_url":"https://api.github.com/users/glob3mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/glob3mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glob3mobile/subscriptions","organizations_url":"https://api.github.com/users/glob3mobile/orgs","repos_url":"https://api.github.com/users/glob3mobile/repos","events_url":"https://api.github.com/users/glob3mobile/events{/privacy}","received_events_url":"https://api.github.com/users/glob3mobile/received_events","type":"Organization","site_admin":false},"repo":{"id":12868151,"name":"g3m","full_name":"glob3mobile/g3m","owner":{"login":"glob3mobile","id":5470097,"avatar_url":"https://avatars.githubusercontent.com/u/5470097?v=3","gravatar_id":"","url":"https://api.github.com/users/glob3mobile","html_url":"https://github.com/glob3mobile","followers_url":"https://api.github.com/users/glob3mobile/followers","following_url":"https://api.github.com/users/glob3mobile/following{/other_user}","gists_url":"https://api.github.com/users/glob3mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/glob3mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glob3mobile/subscriptions","organizations_url":"https://api.github.com/users/glob3mobile/orgs","repos_url":"https://api.github.com/users/glob3mobile/repos","events_url":"https://api.github.com/users/glob3mobile/events{/privacy}","received_events_url":"https://api.github.com/users/glob3mobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/glob3mobile/g3m","description":"The multiplatform advanced visualization framework","fork":false,"url":"https://api.github.com/repos/glob3mobile/g3m","forks_url":"https://api.github.com/repos/glob3mobile/g3m/forks","keys_url":"https://api.github.com/repos/glob3mobile/g3m/keys{/key_id}","collaborators_url":"https://api.github.com/repos/glob3mobile/g3m/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/glob3mobile/g3m/teams","hooks_url":"https://api.github.com/repos/glob3mobile/g3m/hooks","issue_events_url":"https://api.github.com/repos/glob3mobile/g3m/issues/events{/number}","events_url":"https://api.github.com/repos/glob3mobile/g3m/events","assignees_url":"https://api.github.com/repos/glob3mobile/g3m/assignees{/user}","branches_url":"https://api.github.com/repos/glob3mobile/g3m/branches{/branch}","tags_url":"https://api.github.com/repos/glob3mobile/g3m/tags","blobs_url":"https://api.github.com/repos/glob3mobile/g3m/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/glob3mobile/g3m/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/glob3mobile/g3m/git/refs{/sha}","trees_url":"https://api.github.com/repos/glob3mobile/g3m/git/trees{/sha}","statuses_url":"https://api.github.com/repos/glob3mobile/g3m/statuses/{sha}","languages_url":"https://api.github.com/repos/glob3mobile/g3m/languages","stargazers_url":"https://api.github.com/repos/glob3mobile/g3m/stargazers","contributors_url":"https://api.github.com/repos/glob3mobile/g3m/contributors","subscribers_url":"https://api.github.com/repos/glob3mobile/g3m/subscribers","subscription_url":"https://api.github.com/repos/glob3mobile/g3m/subscription","commits_url":"https://api.github.com/repos/glob3mobile/g3m/commits{/sha}","git_commits_url":"https://api.github.com/repos/glob3mobile/g3m/git/commits{/sha}","comments_url":"https://api.github.com/repos/glob3mobile/g3m/comments{/number}","issue_comment_url":"https://api.github.com/repos/glob3mobile/g3m/issues/comments{/number}","contents_url":"https://api.github.com/repos/glob3mobile/g3m/contents/{+path}","compare_url":"https://api.github.com/repos/glob3mobile/g3m/compare/{base}...{head}","merges_url":"https://api.github.com/repos/glob3mobile/g3m/merges","archive_url":"https://api.github.com/repos/glob3mobile/g3m/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/glob3mobile/g3m/downloads","issues_url":"https://api.github.com/repos/glob3mobile/g3m/issues{/number}","pulls_url":"https://api.github.com/repos/glob3mobile/g3m/pulls{/number}","milestones_url":"https://api.github.com/repos/glob3mobile/g3m/milestones{/number}","notifications_url":"https://api.github.com/repos/glob3mobile/g3m/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/glob3mobile/g3m/labels{/name}","releases_url":"https://api.github.com/repos/glob3mobile/g3m/releases{/id}","deployments_url":"https://api.github.com/repos/glob3mobile/g3m/deployments","created_at":"2013-09-16T13:35:11Z","updated_at":"2016-03-03T17:50:58Z","pushed_at":"2016-03-14T10:56:42Z","git_url":"git://github.com/glob3mobile/g3m.git","ssh_url":"git@github.com:glob3mobile/g3m.git","clone_url":"https://github.com/glob3mobile/g3m.git","svn_url":"https://github.com/glob3mobile/g3m","homepage":"http://www.glob3mobile.com/","size":539689,"stargazers_count":85,"watchers_count":85,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":29,"forks":41,"open_issues":29,"watchers":85,"default_branch":"purgatory"}},"_links":{"self":{"href":"https://api.github.com/repos/glob3mobile/g3m/pulls/176"},"html":{"href":"https://github.com/glob3mobile/g3m/pull/176"},"issue":{"href":"https://api.github.com/repos/glob3mobile/g3m/issues/176"},"comments":{"href":"https://api.github.com/repos/glob3mobile/g3m/issues/176/comments"},"review_comments":{"href":"https://api.github.com/repos/glob3mobile/g3m/pulls/176/comments"},"review_comment":{"href":"https://api.github.com/repos/glob3mobile/g3m/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/glob3mobile/g3m/pulls/176/commits"},"statuses":{"href":"https://api.github.com/repos/glob3mobile/g3m/statuses/b959387f3ed00fca27298693d97848483e6b26fa"}}}}