-
Notifications
You must be signed in to change notification settings - Fork 0
/
bd2gps.py
63 lines (50 loc) · 1.62 KB
/
bd2gps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
import sys
try:
from PyQt5.QtWidgets import (QDialog, QApplication)
from ui_main5 import Ui_Dialog
from PyQt5.QtGui import QIcon
def unicode(s):
return s
except ImportError:
from PyQt4.QtGui import (QDialog, QApplication)
from ui_main4 import Ui_Dialog
from convertor import (
bd09togcj02,
gcj02towgs84,
wgs84togcj02,
gcj02tobd09)
import resources_rc
def bd09towgs84(lng, lat):
lng, lat = bd09togcj02(lng, lat)
return gcj02towgs84(lng, lat)
def wgs84tobd09(lng, lat):
lng, lat = wgs84togcj02(lng, lat)
return gcj02tobd09(lng, lat)
class MainDlg(QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(MainDlg, self).__init__(parent)
self.setupUi(self)
self.setWindowIcon(QIcon(':/app.ico'))
def start_convert(self):
self.textEditDst.clear()
src = unicode(self.textEditSrc.toPlainText())
lines = src.splitlines()
for line in lines:
try:
line = line.strip()
lng, lat = line.split(",")
lng, lat = float(lng.strip()), float(lat.strip())
if self.bd2Gps.checkState():
lng, lat = bd09towgs84(lng, lat)
else:
lng, lat = wgs84tobd09(lng, lat)
self.textEditDst.insertPlainText("%f,%f\n" % (lng, lat))
except:
self.textEditDst.insertPlainText("%s\n" % line)
# QtWidgets.qApp.processEvents()
if __name__ == '__main__':
app = QApplication([])
dialog = MainDlg()
dialog.show()
sys.exit(app.exec_())