{"action":"created","comment":{"url":"https://api.github.com/repos/agrc/wri-web/pulls/comments/33587143","id":33587143,"diff_hunk":"@@ -0,0 +1,163 @@\n+define([\n+  'app/config',\n+\n+  'dojo/_base/lang',\n+  'dojo/Deferred',\n+  'dojo/promise/all',\n+  'dojo/topic',\n+\n+  'esri/layers/FeatureLayer'\n+], function (\n+  config,\n+\n+  lang,\n+  Deferred,\n+  all,\n+  topic,\n+\n+  FeatureLayer\n+) {\n+    var obj = {\n+      // scaleTrigger: int\n+      // summary:\n+      //      the trigger value to where the centroids explode to featureSelected\n+      scaleTrigger:  8,\n+\n+      // override: bool\n+      // summary:\n+      //      override the trigger\n+      override: false,\n+\n+      // definitionExpression: String\n+      // summary:\n+      //      the expression used to hide the project being looked at or only show centroids\n+      //      for a certain collection of projects\n+      definitionExpression: '',\n+\n+      // centroidLayer: FeatureLayer\n+      // summary:\n+      //      the centroid feature layer\n+      centroidLayer: null,\n+\n+      // explodedLayer: FeatureLayer\n+      // summary:\n+      //      the exploded projects\n+      explodedLayer: {},\n+\n+      // enabled: boolean\n+      // summary:\n+      //      whether or not to care about this stuff\n+      enabled: true,\n+\n+      startup: function () {\n+          // summary:\n+          //      get everyting started and setup\n+          console.log('app.centroidSwitch::startup', arguments);\n+\n+          topic.subscribe(config.topics.projectIdsChanged, lang.hitch(this, 'switchLayersFromProject'));\n+          topic.subscribe(config.topics.map.extentChange, lang.hitch(this, 'switchLayersFromExtent'));\n+      },\n+      switchLayersFromProject: function (ids) {\n+          // summary:\n+          //      decides whether to show the centroids or not\n+          // ids\n+          console.log('app.centroidSwitch::switchLayersFromProject', arguments);\n+\n+          if (!ids || ids.length === 1) {\n+              this.enabled = false;\n+              return;\n+          }\n+\n+          this.enabled = true;\n+      },\n+      switchLayersFromExtent: function (extent) {\n+          // summary:\n+          //      decides whether to show the centroids or not\n+          // extent: https://developers.arcgis.com/javascript/jsapi/map-amd.html#event-extent-change\n+          console.log('app.centroidSwitch::switchLayersFromExtent', arguments);\n+\n+          if (!this.enabled) {\n+              return;\n+          }\n+\n+          // if they are just panning don't worry about it\n+          // if the delta is null, it is the first load so\n+          // we need to show the centroids\n+          if (!extent.levelChange && extent.delta) {\n+              return;\n+          }\n+\n+          this._loadLayers().then(lang.hitch(this, function () {\n+              if (this.override) {\n+                  this.centroidLayer.setVisibility(false);\n+                  this.explodedLayer.forEach(function (layer) {\n+                      layer.setVisibility(false);\n+                  });\n+                  return;\n+              }\n+\n+              this.centroidLayer.setVisibility(extent.lod.level < this.scaleTrigger);\n+              Object.keys(this.explodedLayer).forEach(function (key) {\n+                  var layer = this.explodedLayer[key];\n+                  layer.setVisibility(extent.lod.level >= this.scaleTrigger);\n+              }, this);\n+              // topic.publish(config.topics.layer.toggleVisibility, {\n+              //     centroids: extent.lod.level < this.scaleTrigger,\n+              //     projects: extent.lod.level >= this.scaleTrigger\n+              // });\n+          }));\n+      },\n+      _loadLayers: function () {\n+          // summary:\n+          //      adds the new layers if they haven't been yet\n+          console.log('app.centroidSwitch::_loadLayers', arguments);\n+\n+          if (Object.keys(this.explodedLayer) === 0 || !this.centroidLayer) {\n+              var li = config.layerIndices;\n+              var deferreds = [];\n+              var typesLookup = {\n+                  0: 'poly-exploded',\n+                  1: 'line-exploded',\n+                  2: 'point-exploded'\n+              };\n+\n+              [li.poly, li.line, li.point].forEach(function (layerIndex, i) {\n+                  var layer = new FeatureLayer(config.urls.mapService + '/' + layerIndex, {\n+                      id: typesLookup[i]\n+                  });\n+\n+                  var deferred = new Deferred();\n+\n+                  layer.on('load', function () {\n+                      deferred.resolve();\n+                  });\n+\n+                  deferreds.push(deferred);\n+\n+                  this.explodedLayer[typesLookup[i]] = layer;\n+              }, this);\n+\n+              this.centroidLayer = new FeatureLayer(config.urls.centroidService, {\n+                  id: 'Centroid'\n+              });\n+\n+              topic.publish(config.topics.layer.add, {\n+                  graphicsLayers: [this.explodedLayer['poly-exploded'],\n+                                   this.explodedLayer['line-exploded'],\n+                                   this.explodedLayer['point-exploded'],\n+                                   this.centroidLayer\n+                                 ]\n+              });\n+\n+              return all(deferreds);\n+          }\n+\n+          var d = new Deferred();","path":"src/app/centroidSwitch.js","position":155,"original_position":155,"commit_id":"36f755d698e562ad4efbb3da40603112d4c25131","original_commit_id":"36f755d698e562ad4efbb3da40603112d4c25131","user":{"login":"stdavis","id":1326248,"avatar_url":"https://avatars.githubusercontent.com/u/1326248?v=3","gravatar_id":"","url":"https://api.github.com/users/stdavis","html_url":"https://github.com/stdavis","followers_url":"https://api.github.com/users/stdavis/followers","following_url":"https://api.github.com/users/stdavis/following{/other_user}","gists_url":"https://api.github.com/users/stdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/stdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stdavis/subscriptions","organizations_url":"https://api.github.com/users/stdavis/orgs","repos_url":"https://api.github.com/users/stdavis/repos","events_url":"https://api.github.com/users/stdavis/events{/privacy}","received_events_url":"https://api.github.com/users/stdavis/received_events","type":"User","site_admin":false},"body":"This is unneeded. I believe that you can just return `true` or something and then change `then` on 90 to `when`.","created_at":"2015-06-30T15:39:51Z","updated_at":"2015-06-30T15:39:51Z","html_url":"https://github.com/agrc/wri-web/pull/13#discussion_r33587143","pull_request_url":"https://api.github.com/repos/agrc/wri-web/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/agrc/wri-web/pulls/comments/33587143"},"html":{"href":"https://github.com/agrc/wri-web/pull/13#discussion_r33587143"},"pull_request":{"href":"https://api.github.com/repos/agrc/wri-web/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/agrc/wri-web/pulls/13","id":38834203,"html_url":"https://github.com/agrc/wri-web/pull/13","diff_url":"https://github.com/agrc/wri-web/pull/13.diff","patch_url":"https://github.com/agrc/wri-web/pull/13.patch","issue_url":"https://api.github.com/repos/agrc/wri-web/issues/13","number":13,"state":"open","locked":false,"title":"Centroids","user":{"login":"steveoh","id":325813,"avatar_url":"https://avatars.githubusercontent.com/u/325813?v=3","gravatar_id":"","url":"https://api.github.com/users/steveoh","html_url":"https://github.com/steveoh","followers_url":"https://api.github.com/users/steveoh/followers","following_url":"https://api.github.com/users/steveoh/following{/other_user}","gists_url":"https://api.github.com/users/steveoh/gists{/gist_id}","starred_url":"https://api.github.com/users/steveoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveoh/subscriptions","organizations_url":"https://api.github.com/users/steveoh/orgs","repos_url":"https://api.github.com/users/steveoh/repos","events_url":"https://api.github.com/users/steveoh/events{/privacy}","received_events_url":"https://api.github.com/users/steveoh/received_events","type":"User","site_admin":false},"body":"> View all projects by project centroid by default. Show project features when prompted by user, or when user zooms in past a certain threshold. The zoom threshold is still TBD, I would just set what looks best in your opinion.\r\n\r\nonly need to show project features when prompted but I think this is a good start.","created_at":"2015-06-30T01:14:18Z","updated_at":"2015-06-30T15:39:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f0b736a457619393800da22f2c506d89a279653","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/agrc/wri-web/pulls/13/commits","review_comments_url":"https://api.github.com/repos/agrc/wri-web/pulls/13/comments","review_comment_url":"https://api.github.com/repos/agrc/wri-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/agrc/wri-web/issues/13/comments","statuses_url":"https://api.github.com/repos/agrc/wri-web/statuses/36f755d698e562ad4efbb3da40603112d4c25131","head":{"label":"agrc:centroids","ref":"centroids","sha":"36f755d698e562ad4efbb3da40603112d4c25131","user":{"login":"agrc","id":709415,"avatar_url":"https://avatars.githubusercontent.com/u/709415?v=3","gravatar_id":"","url":"https://api.github.com/users/agrc","html_url":"https://github.com/agrc","followers_url":"https://api.github.com/users/agrc/followers","following_url":"https://api.github.com/users/agrc/following{/other_user}","gists_url":"https://api.github.com/users/agrc/gists{/gist_id}","starred_url":"https://api.github.com/users/agrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrc/subscriptions","organizations_url":"https://api.github.com/users/agrc/orgs","repos_url":"https://api.github.com/users/agrc/repos","events_url":"https://api.github.com/users/agrc/events{/privacy}","received_events_url":"https://api.github.com/users/agrc/received_events","type":"Organization","site_admin":false},"repo":{"id":33880292,"name":"wri-web","full_name":"agrc/wri-web","owner":{"login":"agrc","id":709415,"avatar_url":"https://avatars.githubusercontent.com/u/709415?v=3","gravatar_id":"","url":"https://api.github.com/users/agrc","html_url":"https://github.com/agrc","followers_url":"https://api.github.com/users/agrc/followers","following_url":"https://api.github.com/users/agrc/following{/other_user}","gists_url":"https://api.github.com/users/agrc/gists{/gist_id}","starred_url":"https://api.github.com/users/agrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrc/subscriptions","organizations_url":"https://api.github.com/users/agrc/orgs","repos_url":"https://api.github.com/users/agrc/repos","events_url":"https://api.github.com/users/agrc/events{/privacy}","received_events_url":"https://api.github.com/users/agrc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/agrc/wri-web","description":"Mapping portion of the WRI web application.","fork":false,"url":"https://api.github.com/repos/agrc/wri-web","forks_url":"https://api.github.com/repos/agrc/wri-web/forks","keys_url":"https://api.github.com/repos/agrc/wri-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agrc/wri-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agrc/wri-web/teams","hooks_url":"https://api.github.com/repos/agrc/wri-web/hooks","issue_events_url":"https://api.github.com/repos/agrc/wri-web/issues/events{/number}","events_url":"https://api.github.com/repos/agrc/wri-web/events","assignees_url":"https://api.github.com/repos/agrc/wri-web/assignees{/user}","branches_url":"https://api.github.com/repos/agrc/wri-web/branches{/branch}","tags_url":"https://api.github.com/repos/agrc/wri-web/tags","blobs_url":"https://api.github.com/repos/agrc/wri-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agrc/wri-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agrc/wri-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/agrc/wri-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agrc/wri-web/statuses/{sha}","languages_url":"https://api.github.com/repos/agrc/wri-web/languages","stargazers_url":"https://api.github.com/repos/agrc/wri-web/stargazers","contributors_url":"https://api.github.com/repos/agrc/wri-web/contributors","subscribers_url":"https://api.github.com/repos/agrc/wri-web/subscribers","subscription_url":"https://api.github.com/repos/agrc/wri-web/subscription","commits_url":"https://api.github.com/repos/agrc/wri-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/agrc/wri-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/agrc/wri-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/agrc/wri-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/agrc/wri-web/contents/{+path}","compare_url":"https://api.github.com/repos/agrc/wri-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agrc/wri-web/merges","archive_url":"https://api.github.com/repos/agrc/wri-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agrc/wri-web/downloads","issues_url":"https://api.github.com/repos/agrc/wri-web/issues{/number}","pulls_url":"https://api.github.com/repos/agrc/wri-web/pulls{/number}","milestones_url":"https://api.github.com/repos/agrc/wri-web/milestones{/number}","notifications_url":"https://api.github.com/repos/agrc/wri-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agrc/wri-web/labels{/name}","releases_url":"https://api.github.com/repos/agrc/wri-web/releases{/id}","created_at":"2015-04-13T16:34:30Z","updated_at":"2015-06-29T19:23:07Z","pushed_at":"2015-06-30T01:14:18Z","git_url":"git://github.com/agrc/wri-web.git","ssh_url":"git@github.com:agrc/wri-web.git","clone_url":"https://github.com/agrc/wri-web.git","svn_url":"https://github.com/agrc/wri-web","homepage":null,"size":304,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"agrc:master","ref":"master","sha":"0baa45eebd0b663744ed1bfb6d30121ebee270fc","user":{"login":"agrc","id":709415,"avatar_url":"https://avatars.githubusercontent.com/u/709415?v=3","gravatar_id":"","url":"https://api.github.com/users/agrc","html_url":"https://github.com/agrc","followers_url":"https://api.github.com/users/agrc/followers","following_url":"https://api.github.com/users/agrc/following{/other_user}","gists_url":"https://api.github.com/users/agrc/gists{/gist_id}","starred_url":"https://api.github.com/users/agrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrc/subscriptions","organizations_url":"https://api.github.com/users/agrc/orgs","repos_url":"https://api.github.com/users/agrc/repos","events_url":"https://api.github.com/users/agrc/events{/privacy}","received_events_url":"https://api.github.com/users/agrc/received_events","type":"Organization","site_admin":false},"repo":{"id":33880292,"name":"wri-web","full_name":"agrc/wri-web","owner":{"login":"agrc","id":709415,"avatar_url":"https://avatars.githubusercontent.com/u/709415?v=3","gravatar_id":"","url":"https://api.github.com/users/agrc","html_url":"https://github.com/agrc","followers_url":"https://api.github.com/users/agrc/followers","following_url":"https://api.github.com/users/agrc/following{/other_user}","gists_url":"https://api.github.com/users/agrc/gists{/gist_id}","starred_url":"https://api.github.com/users/agrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrc/subscriptions","organizations_url":"https://api.github.com/users/agrc/orgs","repos_url":"https://api.github.com/users/agrc/repos","events_url":"https://api.github.com/users/agrc/events{/privacy}","received_events_url":"https://api.github.com/users/agrc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/agrc/wri-web","description":"Mapping portion of the WRI web application.","fork":false,"url":"https://api.github.com/repos/agrc/wri-web","forks_url":"https://api.github.com/repos/agrc/wri-web/forks","keys_url":"https://api.github.com/repos/agrc/wri-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agrc/wri-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agrc/wri-web/teams","hooks_url":"https://api.github.com/repos/agrc/wri-web/hooks","issue_events_url":"https://api.github.com/repos/agrc/wri-web/issues/events{/number}","events_url":"https://api.github.com/repos/agrc/wri-web/events","assignees_url":"https://api.github.com/repos/agrc/wri-web/assignees{/user}","branches_url":"https://api.github.com/repos/agrc/wri-web/branches{/branch}","tags_url":"https://api.github.com/repos/agrc/wri-web/tags","blobs_url":"https://api.github.com/repos/agrc/wri-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agrc/wri-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agrc/wri-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/agrc/wri-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agrc/wri-web/statuses/{sha}","languages_url":"https://api.github.com/repos/agrc/wri-web/languages","stargazers_url":"https://api.github.com/repos/agrc/wri-web/stargazers","contributors_url":"https://api.github.com/repos/agrc/wri-web/contributors","subscribers_url":"https://api.github.com/repos/agrc/wri-web/subscribers","subscription_url":"https://api.github.com/repos/agrc/wri-web/subscription","commits_url":"https://api.github.com/repos/agrc/wri-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/agrc/wri-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/agrc/wri-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/agrc/wri-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/agrc/wri-web/contents/{+path}","compare_url":"https://api.github.com/repos/agrc/wri-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agrc/wri-web/merges","archive_url":"https://api.github.com/repos/agrc/wri-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agrc/wri-web/downloads","issues_url":"https://api.github.com/repos/agrc/wri-web/issues{/number}","pulls_url":"https://api.github.com/repos/agrc/wri-web/pulls{/number}","milestones_url":"https://api.github.com/repos/agrc/wri-web/milestones{/number}","notifications_url":"https://api.github.com/repos/agrc/wri-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agrc/wri-web/labels{/name}","releases_url":"https://api.github.com/repos/agrc/wri-web/releases{/id}","created_at":"2015-04-13T16:34:30Z","updated_at":"2015-06-29T19:23:07Z","pushed_at":"2015-06-30T01:14:18Z","git_url":"git://github.com/agrc/wri-web.git","ssh_url":"git@github.com:agrc/wri-web.git","clone_url":"https://github.com/agrc/wri-web.git","svn_url":"https://github.com/agrc/wri-web","homepage":null,"size":304,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/agrc/wri-web/pulls/13"},"html":{"href":"https://github.com/agrc/wri-web/pull/13"},"issue":{"href":"https://api.github.com/repos/agrc/wri-web/issues/13"},"comments":{"href":"https://api.github.com/repos/agrc/wri-web/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/agrc/wri-web/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/agrc/wri-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/agrc/wri-web/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/agrc/wri-web/statuses/36f755d698e562ad4efbb3da40603112d4c25131"}}}}