This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
land_survey_field_codes_available_code.py
133 lines (124 loc) · 5.34 KB
/
land_survey_field_codes_available_code.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- coding: utf-8 -*-
"""
/***************************************************************************
A QGIS plugin
This plugin allows you to easily import data from a land survey (GPS or total station) to draw automatically in a database using a codification (aka Field Codes).
-------------------
begin : 2018-04-05
git sha : $Format:%H$
copyright : (C) 2018 by Loïc Bartoletti (Oslandia)
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from qgis.core import QgsMapLayerProxyModel
from PyQt5.QtCore import QSettings
AVAILABLE_CODE = [
{"name": "Circle from 2 points",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 2,
"nbparams": 0,
"available": True,
"code": "Circle2Points"},
{"name": "Circle from 3 points",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 3,
"nbparams": 0,
"available": True,
"code": "Circle3Points"},
{"name": "Circle from center and radius",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 1,
"nbparams": 1,
"available": True,
"code": "CircleCenterRadius"},
{"name": "Circle from center and diameter",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 1,
"nbparams": 1,
"available": True,
"code": "CircleCenterDiameter"},
{"name": "Square from 2 points",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 2,
"nbparams": 0,
"available": True,
"code": "Square2Points"},
{"name": "Square from 2 diagonal points",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 2,
"nbparams": 0,
"available": True,
"code": "Square2Diagonal"},
{"name": "Rectangle from 2 points and height",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 2,
"nbparams": 1,
"available": True,
"code": "Rectangle2PointsHeight"},
{"name": "Rectangle from 3 points (3rd point = distance)",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 3,
"nbparams": 0,
"available": True,
"code": "Rectangle3PointsDistance"},
{"name": "Rectangle from 3 points (3rd point = projected orthogonal)",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer |
QgsMapLayerProxyModel.PointLayer,
"nbpoints": 3,
"nbparams": 0,
"available": True,
"code": "Rectangle3PointsProjected"},
{"name": "Line",
"filter": QgsMapLayerProxyModel.PolygonLayer |
QgsMapLayerProxyModel.LineLayer,
"nbpoints": -1,
"nbparams": 0,
"available": True,
"code": "Line"},
{"name": "Point",
"filter": QgsMapLayerProxyModel.PointLayer,
"nbpoints": 1,
"nbparams": 0,
"available": True,
"code": "Point"}]
TRANSLATION = {
"en" : ["Circle from 2 points","Circle from 3 points", "Circle from center and radius", "Circle from center and diameter", "Square from 2 points", "Square from 2 diagonal points","Rectangle from 2 points and height", "Rectangle from 3 points (3rd point = distance)", "Rectangle from 3 points (3rd point = projected orthogonal)", "Line","Point"],
"fr" : ["Cercle par 2 points", "Cercle par 3 points", "Cercle par le centre et le rayon", "Cercle par le centre et le diamètre", "Carré par 2 points", "Carré par 2 points en diagonale", "Rectangle par 2 points et une hauteur", "Rectangle par 3 points (3ème point = distance)", "Rectangle par 3 points (3ème point = projetée orthogonale)", "Ligne", "Point"]
}
def translatedName(name):
locale = QSettings().value('locale/userLocale')[0:2]
if locale not in TRANSLATION.keys():
locale = "en"
idx = TRANSLATION['en'].index(name)
return TRANSLATION[locale][idx]
def translatedNameFromGeometryType(geometryType):
for code in AVAILABLE_CODE:
if code['code'] == geometryType:
return translatedName(code['name'])
print("Hmmm... geometryType not found")
return geometryType