From 84250d1250f4958e4cce45b4dacfdf67bacd3994 Mon Sep 17 00:00:00 2001 From: id101010 Date: Mon, 10 Oct 2016 16:00:21 +0200 Subject: [PATCH] Updated swisstopo link in the description. --- pyWGS84toLV03.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) mode change 100755 => 100644 pyWGS84toLV03.py diff --git a/pyWGS84toLV03.py b/pyWGS84toLV03.py old mode 100755 new mode 100644 index c3d3792..1d36f52 --- a/pyWGS84toLV03.py +++ b/pyWGS84toLV03.py @@ -1,13 +1,37 @@ #!/usr/bin/python2 #-*- coding: utf-8 -*- -# -# WGS84 <-> LV03 converter based on the scripts at -# http://www.swisstopo.admin.ch written for python2.7 -# + +# The MIT License (MIT) +# +# Copyright (c) 2014 Federal Office of Topography swisstopo, Wabern, CH and Aaron Schmocker +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +# WGS84 <-> LV03 converter based on the scripts of swisstopo written for python2.7 # Aaron Schmocker [aaron@duckpond.ch] -# # vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +# Source: http://www.mont-terri.ch/internet/swisstopo/en/home/products/software/products/skripts.html (see PDFs under "Documentation") +# Updated 10.10.2016 +# Please validate your results with NAVREF on-line service: http://www.swisstopo.admin.ch/internet/swisstopo/en/home/apps/calc/navref.html (difference ~ 1-2m) + import math class GPSConverter(object): @@ -56,7 +80,7 @@ class GPSConverter(object): minute = int(math.floor((dec - degree) * 60)) second = (((dec - degree) * 60) - minute) * 60 return degree + (float(minute) / 100) + (second / 10000) - + # Convert sexagesimal angle (dd.mmss,ss) to seconds def SexAngleToSeconds(self, dms): degree = 0 @@ -105,7 +129,7 @@ class GPSConverter(object): + (119.79 * pow(lat_aux, 3)) return x - # Convert WGS lat/long (° dec) to CH y + # Convert WGS lat/long (° dec) to CH y def WGStoCHy(self, lat, lng): lat = self.DecToSexAngle(lat) lng = self.DecToSexAngle(lng)