{"action":"created","comment":{"url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/comments/63697188","id":63697188,"diff_hunk":"@@ -0,0 +1,213 @@\n+# -*- coding: UTF-8 -*-\n+\"\"\"\n+FileName: transform.py\n+=============================================================================\n+Converts EPSG:4326 (WGS84) latitude and longitude to Easting/Northing \n+coordinates in EPSG:2056\n+\n+This was done regarding the rigorous approach described in this paper:\n+http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.63873.DownloadFile.tmp/swissprojectionfr.pdf\n+(last accessed 2016/05/18)\n+=============================================================================\n+\n+Created: [2016/05/18]\n+Author: Michael Kalbermatten\n+\"\"\"\n+\n+import math\n+import logging\n+\n+\n+def mn95wgs84(easting, northing):\n+\n+    FORMAT = \"%(levelname)s: %(message)s\"    \n+    logging.basicConfig(level=logging.INFO, format=FORMAT)\n+    \n+    # Step 3.3\n+    # Constants:\n+    r = 6378815.90365\n+    b0 = math.radians(46.0 + 54.0/60.0 + 27.83324844/3600.0)\n+    alpha = 1.00072913843038   \n+    lon0 = 7.0 + 26.0/60.0 + 22.5/3600.0\n+    lon0 = math.radians(lon0)\n+    k = 0.0030667323772751\n+    e2 =0.006674372230614\n+    e = math.sqrt(e2)\n+    \n+    y = easting - 2600000.0\n+    x = northing - 1200000.0\n+\n+    l_ = y / r\n+    b_ = 2 * (math.atan(math.exp(x/r)) - math.pi/4)\n+    \n+    b = math.asin(math.cos(b0)*math.sin(b_) + math.sin(b0)*math.cos(b_)*math.cos(l_))\n+    l = math.atan(math.sin(l_)/(math.cos(b0)*math.cos(l_) - math.sin(b0)*math.tan(b_)))\n+    \n+    lambda_ = lon0 + l/alpha\n+    \n+    phi = b\n+    s0 = (math.log(math.tan(math.pi/4 + b /2)) -k ) / alpha\n+\n+    count = 0\n+    delta = 10000\n+    while delta != 0.0:\n+        \n+        s1 = e * math.log(math.tan(math.pi/4 + math.asin(e*math.sin(phi))/2))\n+        s = s0 + s1\n+        phi_new = 2*math.atan(math.exp(s)) - math.pi/2\n+        delta = phi - phi_new\n+        #~ print delta\n+        phi = phi_new\n+        #~ print 'The count is:', count\n+        count += count\n+        if count > 1000:\n+            logging.info('Solution did not converge')\n+            sys.exit(1)\n+            break\n+\n+    # Step 2.1\n+    a = 6377397.155\n+    rn = a / math.sqrt(1 - e2*math.sin(phi)*math.sin(phi))\n+    h = 0.0\n+    X = (rn + h) * math.cos(phi) * math.cos(lambda_)\n+    Y = (rn + h) * math.cos(phi) * math.sin(lambda_)\n+    Z = (rn * (1 - e2) + h) * math.sin(phi)\n+\n+    # Step 1.4\n+    x_chtrs95 = X + 674.374\n+    y_chtrs95 = Y + 15.056\n+    z_chtrs95 = Z + 405.346\n+\n+    #Step 2.2   \n+    lambda_ = math.atan(y_chtrs95/x_chtrs95)\n+    \n+    # Constant (GRS 80 ellipsoid)\n+    a = 6378137.000\n+    e2 = 0.006694380023011\n+    \n+    phi = math.atan(z_chtrs95 / math.sqrt(x_chtrs95*x_chtrs95+y_chtrs95*y_chtrs95))\n+\n+    count = 0\n+    delta = 10000\n+    while delta != 0.0:\n+        \n+        x2_y2 = math.sqrt(x_chtrs95*x_chtrs95 + y_chtrs95*y_chtrs95)\n+        \n+        rn = a / math.sqrt(1 - e2*math.sin(phi)*math.sin(phi))\n+\n+        h = (x2_y2 / math.cos(phi)) - rn\n+        \n+        numerator = z_chtrs95 / x2_y2\n+    \n+        denominator = (1-((rn*e2)/(rn+h)))\n+        ","path":"projections/transform.py","position":103,"original_position":103,"commit_id":"f0742560e32f76347eeecba87a905998eb4aaecc","original_commit_id":"f0742560e32f76347eeecba87a905998eb4aaecc","user":{"login":"monodo","id":3356536,"avatar_url":"https://avatars.githubusercontent.com/u/3356536?v=3","gravatar_id":"","url":"https://api.github.com/users/monodo","html_url":"https://github.com/monodo","followers_url":"https://api.github.com/users/monodo/followers","following_url":"https://api.github.com/users/monodo/following{/other_user}","gists_url":"https://api.github.com/users/monodo/gists{/gist_id}","starred_url":"https://api.github.com/users/monodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monodo/subscriptions","organizations_url":"https://api.github.com/users/monodo/orgs","repos_url":"https://api.github.com/users/monodo/repos","events_url":"https://api.github.com/users/monodo/events{/privacy}","received_events_url":"https://api.github.com/users/monodo/received_events","type":"User","site_admin":false},"body":"empty line","created_at":"2016-05-18T12:59:22Z","updated_at":"2016-05-18T12:59:22Z","html_url":"https://github.com/sitn/sitn_python_lib/pull/2#discussion_r63697188","pull_request_url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/comments/63697188"},"html":{"href":"https://github.com/sitn/sitn_python_lib/pull/2#discussion_r63697188"},"pull_request":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2","id":70519795,"html_url":"https://github.com/sitn/sitn_python_lib/pull/2","diff_url":"https://github.com/sitn/sitn_python_lib/pull/2.diff","patch_url":"https://github.com/sitn/sitn_python_lib/pull/2.patch","issue_url":"https://api.github.com/repos/sitn/sitn_python_lib/issues/2","number":2,"state":"open","locked":false,"title":"Add script for projection conversion","user":{"login":"kalbermattenm","id":1681332,"avatar_url":"https://avatars.githubusercontent.com/u/1681332?v=3","gravatar_id":"","url":"https://api.github.com/users/kalbermattenm","html_url":"https://github.com/kalbermattenm","followers_url":"https://api.github.com/users/kalbermattenm/followers","following_url":"https://api.github.com/users/kalbermattenm/following{/other_user}","gists_url":"https://api.github.com/users/kalbermattenm/gists{/gist_id}","starred_url":"https://api.github.com/users/kalbermattenm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalbermattenm/subscriptions","organizations_url":"https://api.github.com/users/kalbermattenm/orgs","repos_url":"https://api.github.com/users/kalbermattenm/repos","events_url":"https://api.github.com/users/kalbermattenm/events{/privacy}","received_events_url":"https://api.github.com/users/kalbermattenm/received_events","type":"User","site_admin":false},"body":"This PR defines two functions to convert WGS84 into 1903+ and vice versa...\r\n\r\n@monodo, could you have look at this PR ?","created_at":"2016-05-18T12:36:59Z","updated_at":"2016-05-18T12:59:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"deeb37f57cd0394b67bfb8978bab30bef84560f8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2/commits","review_comments_url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2/comments","review_comment_url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sitn/sitn_python_lib/issues/2/comments","statuses_url":"https://api.github.com/repos/sitn/sitn_python_lib/statuses/f0742560e32f76347eeecba87a905998eb4aaecc","head":{"label":"kalbermattenm:proj","ref":"proj","sha":"f0742560e32f76347eeecba87a905998eb4aaecc","user":{"login":"kalbermattenm","id":1681332,"avatar_url":"https://avatars.githubusercontent.com/u/1681332?v=3","gravatar_id":"","url":"https://api.github.com/users/kalbermattenm","html_url":"https://github.com/kalbermattenm","followers_url":"https://api.github.com/users/kalbermattenm/followers","following_url":"https://api.github.com/users/kalbermattenm/following{/other_user}","gists_url":"https://api.github.com/users/kalbermattenm/gists{/gist_id}","starred_url":"https://api.github.com/users/kalbermattenm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalbermattenm/subscriptions","organizations_url":"https://api.github.com/users/kalbermattenm/orgs","repos_url":"https://api.github.com/users/kalbermattenm/repos","events_url":"https://api.github.com/users/kalbermattenm/events{/privacy}","received_events_url":"https://api.github.com/users/kalbermattenm/received_events","type":"User","site_admin":false},"repo":{"id":36643020,"name":"sitn_python_lib","full_name":"kalbermattenm/sitn_python_lib","owner":{"login":"kalbermattenm","id":1681332,"avatar_url":"https://avatars.githubusercontent.com/u/1681332?v=3","gravatar_id":"","url":"https://api.github.com/users/kalbermattenm","html_url":"https://github.com/kalbermattenm","followers_url":"https://api.github.com/users/kalbermattenm/followers","following_url":"https://api.github.com/users/kalbermattenm/following{/other_user}","gists_url":"https://api.github.com/users/kalbermattenm/gists{/gist_id}","starred_url":"https://api.github.com/users/kalbermattenm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalbermattenm/subscriptions","organizations_url":"https://api.github.com/users/kalbermattenm/orgs","repos_url":"https://api.github.com/users/kalbermattenm/repos","events_url":"https://api.github.com/users/kalbermattenm/events{/privacy}","received_events_url":"https://api.github.com/users/kalbermattenm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kalbermattenm/sitn_python_lib","description":"Repository containing various python libs","fork":true,"url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib","forks_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/forks","keys_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/teams","hooks_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/hooks","issue_events_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/issues/events{/number}","events_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/events","assignees_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/assignees{/user}","branches_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/branches{/branch}","tags_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/tags","blobs_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/git/refs{/sha}","trees_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/statuses/{sha}","languages_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/languages","stargazers_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/stargazers","contributors_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/contributors","subscribers_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/subscribers","subscription_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/subscription","commits_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/commits{/sha}","git_commits_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/git/commits{/sha}","comments_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/comments{/number}","issue_comment_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/issues/comments{/number}","contents_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/contents/{+path}","compare_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/merges","archive_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/downloads","issues_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/issues{/number}","pulls_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/pulls{/number}","milestones_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/milestones{/number}","notifications_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/labels{/name}","releases_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/releases{/id}","deployments_url":"https://api.github.com/repos/kalbermattenm/sitn_python_lib/deployments","created_at":"2015-06-01T06:49:55Z","updated_at":"2015-06-01T06:49:56Z","pushed_at":"2016-05-18T12:35:46Z","git_url":"git://github.com/kalbermattenm/sitn_python_lib.git","ssh_url":"git@github.com:kalbermattenm/sitn_python_lib.git","clone_url":"https://github.com/kalbermattenm/sitn_python_lib.git","svn_url":"https://github.com/kalbermattenm/sitn_python_lib","homepage":null,"size":15,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sitn:master","ref":"master","sha":"16cfc02b8211bb1559ed643c64cec8dabd5d9cea","user":{"login":"sitn","id":4532493,"avatar_url":"https://avatars.githubusercontent.com/u/4532493?v=3","gravatar_id":"","url":"https://api.github.com/users/sitn","html_url":"https://github.com/sitn","followers_url":"https://api.github.com/users/sitn/followers","following_url":"https://api.github.com/users/sitn/following{/other_user}","gists_url":"https://api.github.com/users/sitn/gists{/gist_id}","starred_url":"https://api.github.com/users/sitn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sitn/subscriptions","organizations_url":"https://api.github.com/users/sitn/orgs","repos_url":"https://api.github.com/users/sitn/repos","events_url":"https://api.github.com/users/sitn/events{/privacy}","received_events_url":"https://api.github.com/users/sitn/received_events","type":"Organization","site_admin":false},"repo":{"id":36603356,"name":"sitn_python_lib","full_name":"sitn/sitn_python_lib","owner":{"login":"sitn","id":4532493,"avatar_url":"https://avatars.githubusercontent.com/u/4532493?v=3","gravatar_id":"","url":"https://api.github.com/users/sitn","html_url":"https://github.com/sitn","followers_url":"https://api.github.com/users/sitn/followers","following_url":"https://api.github.com/users/sitn/following{/other_user}","gists_url":"https://api.github.com/users/sitn/gists{/gist_id}","starred_url":"https://api.github.com/users/sitn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sitn/subscriptions","organizations_url":"https://api.github.com/users/sitn/orgs","repos_url":"https://api.github.com/users/sitn/repos","events_url":"https://api.github.com/users/sitn/events{/privacy}","received_events_url":"https://api.github.com/users/sitn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sitn/sitn_python_lib","description":"Repository containing various python libs","fork":false,"url":"https://api.github.com/repos/sitn/sitn_python_lib","forks_url":"https://api.github.com/repos/sitn/sitn_python_lib/forks","keys_url":"https://api.github.com/repos/sitn/sitn_python_lib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sitn/sitn_python_lib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sitn/sitn_python_lib/teams","hooks_url":"https://api.github.com/repos/sitn/sitn_python_lib/hooks","issue_events_url":"https://api.github.com/repos/sitn/sitn_python_lib/issues/events{/number}","events_url":"https://api.github.com/repos/sitn/sitn_python_lib/events","assignees_url":"https://api.github.com/repos/sitn/sitn_python_lib/assignees{/user}","branches_url":"https://api.github.com/repos/sitn/sitn_python_lib/branches{/branch}","tags_url":"https://api.github.com/repos/sitn/sitn_python_lib/tags","blobs_url":"https://api.github.com/repos/sitn/sitn_python_lib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sitn/sitn_python_lib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sitn/sitn_python_lib/git/refs{/sha}","trees_url":"https://api.github.com/repos/sitn/sitn_python_lib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sitn/sitn_python_lib/statuses/{sha}","languages_url":"https://api.github.com/repos/sitn/sitn_python_lib/languages","stargazers_url":"https://api.github.com/repos/sitn/sitn_python_lib/stargazers","contributors_url":"https://api.github.com/repos/sitn/sitn_python_lib/contributors","subscribers_url":"https://api.github.com/repos/sitn/sitn_python_lib/subscribers","subscription_url":"https://api.github.com/repos/sitn/sitn_python_lib/subscription","commits_url":"https://api.github.com/repos/sitn/sitn_python_lib/commits{/sha}","git_commits_url":"https://api.github.com/repos/sitn/sitn_python_lib/git/commits{/sha}","comments_url":"https://api.github.com/repos/sitn/sitn_python_lib/comments{/number}","issue_comment_url":"https://api.github.com/repos/sitn/sitn_python_lib/issues/comments{/number}","contents_url":"https://api.github.com/repos/sitn/sitn_python_lib/contents/{+path}","compare_url":"https://api.github.com/repos/sitn/sitn_python_lib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sitn/sitn_python_lib/merges","archive_url":"https://api.github.com/repos/sitn/sitn_python_lib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sitn/sitn_python_lib/downloads","issues_url":"https://api.github.com/repos/sitn/sitn_python_lib/issues{/number}","pulls_url":"https://api.github.com/repos/sitn/sitn_python_lib/pulls{/number}","milestones_url":"https://api.github.com/repos/sitn/sitn_python_lib/milestones{/number}","notifications_url":"https://api.github.com/repos/sitn/sitn_python_lib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sitn/sitn_python_lib/labels{/name}","releases_url":"https://api.github.com/repos/sitn/sitn_python_lib/releases{/id}","deployments_url":"https://api.github.com/repos/sitn/sitn_python_lib/deployments","created_at":"2015-05-31T13:06:07Z","updated_at":"2016-04-22T06:35:24Z","pushed_at":"2016-05-18T12:36:59Z","git_url":"git://github.com/sitn/sitn_python_lib.git","ssh_url":"git@github.com:sitn/sitn_python_lib.git","clone_url":"https://github.com/sitn/sitn_python_lib.git","svn_url":"https://github.com/sitn/sitn_python_lib","homepage":null,"size":13,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2"},"html":{"href":"https://github.com/sitn/sitn_python_lib/pull/2"},"issue":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/issues/2"},"comments":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/sitn/sitn_python_lib/statuses/f0742560e32f76347eeecba87a905998eb4aaecc"}}}}