{"action":"created","comment":{"url":"https://api.github.com/repos/iTowns/itowns/pulls/comments/142098102","pull_request_review_id":66410451,"id":142098102,"diff_hunk":"@@ -0,0 +1,130 @@\n+import { Vector3 } from 'three';\n+import Extent from '../../Geographic/Extent';\n+import OGCWebServiceHelper from './OGCWebServiceHelper';\n+import Fetcher from './Fetcher';\n+\n+// select the smallest image entirely covering the tile\n+function selectBestImageForExtent(images, extent) {\n+    let selection;\n+    for (const entry of images) {\n+        if (extent.isInside(entry.extent)) {\n+            if (!selection) {\n+                selection = entry;\n+            } else {\n+                const d = selection.extent.dimensions();\n+                const e = entry.extent.dimensions();\n+                if (e.x <= d.x && e.y <= d.y) {\n+                    selection = entry;\n+                }\n+            }\n+        }\n+    }\n+    return selection;\n+}\n+\n+\n+/**\n+ * This provider uses no protocol but instead download static images directly.\n+ *\n+ * It uses as input 'image_filename: extent' values and then tries to find the best image\n+ * for a given tile using the extent property.\n+ */\n+export default {\n+    preprocessDataLayer(layer) {\n+        if (!layer.extent) {\n+            throw new Error('layer.extent is required');\n+        }\n+\n+        if (!(layer.extent instanceof Extent)) {\n+            layer.extent = new Extent(layer.projection, ...layer.extent);\n+        }\n+\n+        layer.options = {};\n+        layer.canTileTextureBeImproved = this.canTileTextureBeImproved;\n+        layer.url = new URL(layer.url, window.location);\n+        return Fetcher.json(layer.url.href).then((metadata) => {\n+            layer.images = [];\n+            // eslint-disable-next-line guard-for-in\n+            for (const image in metadata) {\n+                const extent = new Extent(layer.projection, ...metadata[image]);\n+                layer.images.push({\n+                    image,\n+                    extent,\n+                });\n+            }\n+        });\n+    },\n+\n+    tileInsideLimit(tile, layer) {\n+        if (!layer.images) {\n+            return false;\n+        }\n+        for (const entry of layer.images) {\n+            if (tile.extent.isInside(entry.extent)) {\n+                return true;\n+            }\n+        }\n+\n+        return false;\n+    },\n+\n+    canTileTextureBeImproved(layer, tile) {\n+        const s = selectBestImageForExtent(layer.images, tile.extent);\n+        if (!s) {\n+            return false;\n+        }\n+        const mat = tile.material;\n+        const idx = mat.getLayerTextureOffset(layer.id);\n+        const currentTexture = mat.textures[1][idx];\n+        if (!currentTexture.file) {\n+            return true;\n+        }\n+        return currentTexture.file != s.image;\n+    },\n+\n+    getColorTexture(tile, layer) {","path":"src/Core/Scheduler/Providers/StaticProvider.js","position":85,"original_position":85,"commit_id":"3329a1b7e3852815cf3d776e783c2fa03896876a","original_commit_id":"3329a1b7e3852815cf3d776e783c2fa03896876a","user":{"login":"peppsac","id":2198295,"avatar_url":"https://avatars3.githubusercontent.com/u/2198295?v=4","gravatar_id":"","url":"https://api.github.com/users/peppsac","html_url":"https://github.com/peppsac","followers_url":"https://api.github.com/users/peppsac/followers","following_url":"https://api.github.com/users/peppsac/following{/other_user}","gists_url":"https://api.github.com/users/peppsac/gists{/gist_id}","starred_url":"https://api.github.com/users/peppsac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peppsac/subscriptions","organizations_url":"https://api.github.com/users/peppsac/orgs","repos_url":"https://api.github.com/users/peppsac/repos","events_url":"https://api.github.com/users/peppsac/events{/privacy}","received_events_url":"https://api.github.com/users/peppsac/received_events","type":"User","site_admin":false},"body":"Correct. I'll fix this.","created_at":"2017-10-02T09:57:59Z","updated_at":"2017-10-02T09:57:59Z","html_url":"https://github.com/iTowns/itowns/pull/451#discussion_r142098102","pull_request_url":"https://api.github.com/repos/iTowns/itowns/pulls/451","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/iTowns/itowns/pulls/comments/142098102"},"html":{"href":"https://github.com/iTowns/itowns/pull/451#discussion_r142098102"},"pull_request":{"href":"https://api.github.com/repos/iTowns/itowns/pulls/451"}},"in_reply_to_id":141953712},"pull_request":{"url":"https://api.github.com/repos/iTowns/itowns/pulls/451","id":135325444,"html_url":"https://github.com/iTowns/itowns/pull/451","diff_url":"https://github.com/iTowns/itowns/pull/451.diff","patch_url":"https://github.com/iTowns/itowns/pull/451.patch","issue_url":"https://api.github.com/repos/iTowns/itowns/issues/451","number":451,"state":"open","locked":false,"title":"feature: add StaticProvider","user":{"login":"peppsac","id":2198295,"avatar_url":"https://avatars3.githubusercontent.com/u/2198295?v=4","gravatar_id":"","url":"https://api.github.com/users/peppsac","html_url":"https://github.com/peppsac","followers_url":"https://api.github.com/users/peppsac/followers","following_url":"https://api.github.com/users/peppsac/following{/other_user}","gists_url":"https://api.github.com/users/peppsac/gists{/gist_id}","starred_url":"https://api.github.com/users/peppsac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peppsac/subscriptions","organizations_url":"https://api.github.com/users/peppsac/orgs","repos_url":"https://api.github.com/users/peppsac/repos","events_url":"https://api.github.com/users/peppsac/events{/privacy}","received_events_url":"https://api.github.com/users/peppsac/received_events","type":"User","site_admin":false},"body":"Sometimes it's handy to be able to use a single image as a layer (mainly want you\r\nwant to quick test without the hassle of setting up a wms server for instance).\r\n\r\nThis provider is really simple, and just compute the offset in the image to use\r\nto match the tile extent.\r\n\r\nExample usage:\r\n```js\r\n    view.addLayer({\r\n        url: 'http://localhost:8080/foo.png',\r\n        networkOptions: { crossOrigin: 'anonymous' },\r\n        type: 'color',\r\n        protocol: 'image',\r\n        id: 'myimage',\r\n    });\r\n```","created_at":"2017-08-11T12:31:12Z","updated_at":"2017-10-02T09:57:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"48359d82b4fae3aeff52147451bfaa1d0e463083","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/iTowns/itowns/pulls/451/commits","review_comments_url":"https://api.github.com/repos/iTowns/itowns/pulls/451/comments","review_comment_url":"https://api.github.com/repos/iTowns/itowns/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iTowns/itowns/issues/451/comments","statuses_url":"https://api.github.com/repos/iTowns/itowns/statuses/3329a1b7e3852815cf3d776e783c2fa03896876a","head":{"label":"iTowns:single_image","ref":"single_image","sha":"3329a1b7e3852815cf3d776e783c2fa03896876a","user":{"login":"iTowns","id":14266889,"avatar_url":"https://avatars2.githubusercontent.com/u/14266889?v=4","gravatar_id":"","url":"https://api.github.com/users/iTowns","html_url":"https://github.com/iTowns","followers_url":"https://api.github.com/users/iTowns/followers","following_url":"https://api.github.com/users/iTowns/following{/other_user}","gists_url":"https://api.github.com/users/iTowns/gists{/gist_id}","starred_url":"https://api.github.com/users/iTowns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iTowns/subscriptions","organizations_url":"https://api.github.com/users/iTowns/orgs","repos_url":"https://api.github.com/users/iTowns/repos","events_url":"https://api.github.com/users/iTowns/events{/privacy}","received_events_url":"https://api.github.com/users/iTowns/received_events","type":"Organization","site_admin":false},"repo":{"id":43068275,"name":"itowns","full_name":"iTowns/itowns","owner":{"login":"iTowns","id":14266889,"avatar_url":"https://avatars2.githubusercontent.com/u/14266889?v=4","gravatar_id":"","url":"https://api.github.com/users/iTowns","html_url":"https://github.com/iTowns","followers_url":"https://api.github.com/users/iTowns/followers","following_url":"https://api.github.com/users/iTowns/following{/other_user}","gists_url":"https://api.github.com/users/iTowns/gists{/gist_id}","starred_url":"https://api.github.com/users/iTowns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iTowns/subscriptions","organizations_url":"https://api.github.com/users/iTowns/orgs","repos_url":"https://api.github.com/users/iTowns/repos","events_url":"https://api.github.com/users/iTowns/events{/privacy}","received_events_url":"https://api.github.com/users/iTowns/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iTowns/itowns","description":"A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data","fork":false,"url":"https://api.github.com/repos/iTowns/itowns","forks_url":"https://api.github.com/repos/iTowns/itowns/forks","keys_url":"https://api.github.com/repos/iTowns/itowns/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iTowns/itowns/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iTowns/itowns/teams","hooks_url":"https://api.github.com/repos/iTowns/itowns/hooks","issue_events_url":"https://api.github.com/repos/iTowns/itowns/issues/events{/number}","events_url":"https://api.github.com/repos/iTowns/itowns/events","assignees_url":"https://api.github.com/repos/iTowns/itowns/assignees{/user}","branches_url":"https://api.github.com/repos/iTowns/itowns/branches{/branch}","tags_url":"https://api.github.com/repos/iTowns/itowns/tags","blobs_url":"https://api.github.com/repos/iTowns/itowns/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iTowns/itowns/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iTowns/itowns/git/refs{/sha}","trees_url":"https://api.github.com/repos/iTowns/itowns/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iTowns/itowns/statuses/{sha}","languages_url":"https://api.github.com/repos/iTowns/itowns/languages","stargazers_url":"https://api.github.com/repos/iTowns/itowns/stargazers","contributors_url":"https://api.github.com/repos/iTowns/itowns/contributors","subscribers_url":"https://api.github.com/repos/iTowns/itowns/subscribers","subscription_url":"https://api.github.com/repos/iTowns/itowns/subscription","commits_url":"https://api.github.com/repos/iTowns/itowns/commits{/sha}","git_commits_url":"https://api.github.com/repos/iTowns/itowns/git/commits{/sha}","comments_url":"https://api.github.com/repos/iTowns/itowns/comments{/number}","issue_comment_url":"https://api.github.com/repos/iTowns/itowns/issues/comments{/number}","contents_url":"https://api.github.com/repos/iTowns/itowns/contents/{+path}","compare_url":"https://api.github.com/repos/iTowns/itowns/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iTowns/itowns/merges","archive_url":"https://api.github.com/repos/iTowns/itowns/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iTowns/itowns/downloads","issues_url":"https://api.github.com/repos/iTowns/itowns/issues{/number}","pulls_url":"https://api.github.com/repos/iTowns/itowns/pulls{/number}","milestones_url":"https://api.github.com/repos/iTowns/itowns/milestones{/number}","notifications_url":"https://api.github.com/repos/iTowns/itowns/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iTowns/itowns/labels{/name}","releases_url":"https://api.github.com/repos/iTowns/itowns/releases{/id}","deployments_url":"https://api.github.com/repos/iTowns/itowns/deployments","created_at":"2015-09-24T13:24:26Z","updated_at":"2017-09-26T08:02:48Z","pushed_at":"2017-09-30T14:10:37Z","git_url":"git://github.com/iTowns/itowns.git","ssh_url":"git@github.com:iTowns/itowns.git","clone_url":"https://github.com/iTowns/itowns.git","svn_url":"https://github.com/iTowns/itowns","homepage":"http://www.itowns-project.org","size":5241,"stargazers_count":59,"watchers_count":59,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":71,"forks":36,"open_issues":71,"watchers":59,"default_branch":"master"}},"base":{"label":"iTowns:master","ref":"master","sha":"e43e059248a803350480a646051bf10e5530b286","user":{"login":"iTowns","id":14266889,"avatar_url":"https://avatars2.githubusercontent.com/u/14266889?v=4","gravatar_id":"","url":"https://api.github.com/users/iTowns","html_url":"https://github.com/iTowns","followers_url":"https://api.github.com/users/iTowns/followers","following_url":"https://api.github.com/users/iTowns/following{/other_user}","gists_url":"https://api.github.com/users/iTowns/gists{/gist_id}","starred_url":"https://api.github.com/users/iTowns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iTowns/subscriptions","organizations_url":"https://api.github.com/users/iTowns/orgs","repos_url":"https://api.github.com/users/iTowns/repos","events_url":"https://api.github.com/users/iTowns/events{/privacy}","received_events_url":"https://api.github.com/users/iTowns/received_events","type":"Organization","site_admin":false},"repo":{"id":43068275,"name":"itowns","full_name":"iTowns/itowns","owner":{"login":"iTowns","id":14266889,"avatar_url":"https://avatars2.githubusercontent.com/u/14266889?v=4","gravatar_id":"","url":"https://api.github.com/users/iTowns","html_url":"https://github.com/iTowns","followers_url":"https://api.github.com/users/iTowns/followers","following_url":"https://api.github.com/users/iTowns/following{/other_user}","gists_url":"https://api.github.com/users/iTowns/gists{/gist_id}","starred_url":"https://api.github.com/users/iTowns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iTowns/subscriptions","organizations_url":"https://api.github.com/users/iTowns/orgs","repos_url":"https://api.github.com/users/iTowns/repos","events_url":"https://api.github.com/users/iTowns/events{/privacy}","received_events_url":"https://api.github.com/users/iTowns/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iTowns/itowns","description":"A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data","fork":false,"url":"https://api.github.com/repos/iTowns/itowns","forks_url":"https://api.github.com/repos/iTowns/itowns/forks","keys_url":"https://api.github.com/repos/iTowns/itowns/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iTowns/itowns/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iTowns/itowns/teams","hooks_url":"https://api.github.com/repos/iTowns/itowns/hooks","issue_events_url":"https://api.github.com/repos/iTowns/itowns/issues/events{/number}","events_url":"https://api.github.com/repos/iTowns/itowns/events","assignees_url":"https://api.github.com/repos/iTowns/itowns/assignees{/user}","branches_url":"https://api.github.com/repos/iTowns/itowns/branches{/branch}","tags_url":"https://api.github.com/repos/iTowns/itowns/tags","blobs_url":"https://api.github.com/repos/iTowns/itowns/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iTowns/itowns/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iTowns/itowns/git/refs{/sha}","trees_url":"https://api.github.com/repos/iTowns/itowns/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iTowns/itowns/statuses/{sha}","languages_url":"https://api.github.com/repos/iTowns/itowns/languages","stargazers_url":"https://api.github.com/repos/iTowns/itowns/stargazers","contributors_url":"https://api.github.com/repos/iTowns/itowns/contributors","subscribers_url":"https://api.github.com/repos/iTowns/itowns/subscribers","subscription_url":"https://api.github.com/repos/iTowns/itowns/subscription","commits_url":"https://api.github.com/repos/iTowns/itowns/commits{/sha}","git_commits_url":"https://api.github.com/repos/iTowns/itowns/git/commits{/sha}","comments_url":"https://api.github.com/repos/iTowns/itowns/comments{/number}","issue_comment_url":"https://api.github.com/repos/iTowns/itowns/issues/comments{/number}","contents_url":"https://api.github.com/repos/iTowns/itowns/contents/{+path}","compare_url":"https://api.github.com/repos/iTowns/itowns/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iTowns/itowns/merges","archive_url":"https://api.github.com/repos/iTowns/itowns/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iTowns/itowns/downloads","issues_url":"https://api.github.com/repos/iTowns/itowns/issues{/number}","pulls_url":"https://api.github.com/repos/iTowns/itowns/pulls{/number}","milestones_url":"https://api.github.com/repos/iTowns/itowns/milestones{/number}","notifications_url":"https://api.github.com/repos/iTowns/itowns/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iTowns/itowns/labels{/name}","releases_url":"https://api.github.com/repos/iTowns/itowns/releases{/id}","deployments_url":"https://api.github.com/repos/iTowns/itowns/deployments","created_at":"2015-09-24T13:24:26Z","updated_at":"2017-09-26T08:02:48Z","pushed_at":"2017-09-30T14:10:37Z","git_url":"git://github.com/iTowns/itowns.git","ssh_url":"git@github.com:iTowns/itowns.git","clone_url":"https://github.com/iTowns/itowns.git","svn_url":"https://github.com/iTowns/itowns","homepage":"http://www.itowns-project.org","size":5241,"stargazers_count":59,"watchers_count":59,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":71,"forks":36,"open_issues":71,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iTowns/itowns/pulls/451"},"html":{"href":"https://github.com/iTowns/itowns/pull/451"},"issue":{"href":"https://api.github.com/repos/iTowns/itowns/issues/451"},"comments":{"href":"https://api.github.com/repos/iTowns/itowns/issues/451/comments"},"review_comments":{"href":"https://api.github.com/repos/iTowns/itowns/pulls/451/comments"},"review_comment":{"href":"https://api.github.com/repos/iTowns/itowns/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iTowns/itowns/pulls/451/commits"},"statuses":{"href":"https://api.github.com/repos/iTowns/itowns/statuses/3329a1b7e3852815cf3d776e783c2fa03896876a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"peppsac"}}