Coverage for pychlv / chlvTuples.py: 97%

88 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-07-17 14:31 -0400

1 

2# -*- coding: utf-8 -*- 

3 

4u'''Classes L{ChLV9Tuple}, L{ChLVEN2Tuple}, L{ChLVYX2Tuple} and L{ChLVyx2Tuple}. 

5''' 

6 

7from pychlv.__pygeodesy import (_X_, _Y_, _all_OTHER, _NamedTuple) 

8from pygeodesy import (Local9Tuple, Meter, 

9 Property_RO, property_RO, property_ROver) 

10__all__ = () 

11__version__ = '26.07.16' 

12 

13 

14class _chlvs(object): # module 

15 '''(INTERNAL) Get classes L{ChLV}, L{ChLVe}, L{ChLVe} and C{ChLVr} 

16 and static methods C{false2} and C{unfalse2}, I{once lazily}. 

17 ''' 

18 @property_ROver 

19 def ChLV(self): 

20 from pychlv.chlvs import ChLV 

21 return ChLV 

22 

23 @property_ROver 

24 def ChLVa(self): 

25 from pychlv.chlvs import ChLVa 

26 return ChLVa 

27 

28 @property_ROver 

29 def ChLVe(self): 

30 from pychlv.chlvs import ChLVe 

31 return ChLVe 

32 

33 @property_ROver 

34 def ChLVr(self): 

35 from pychlv.chlvs import ChLVr 

36 return ChLVr 

37 

38_chlvs = _chlvs() # PYCHOK singleton 

39 

40 

41class ChLV9Tuple(Local9Tuple): 

42 '''9-Tuple C{(Y, X, h_, lat, lon, height, ltp, ecef, M)} with I{B{unfalsed} Swiss (Y, 

43 X, h_)} coordinates and height, all in C{meter}, C{ltp} either a L{ChLV}, L{ChLVa} 

44 or L{ChLVe} instance and C{ecef} (U{EcefKarney<https://MrJean1.GitHub.io/PyGeodesy/ 

45 docs/pygeodesy.ecef-module.html>} I{at Bern, Ch}), otherwise like U{Local9Tuple 

46 <https://MrJean1.GitHub.io/PyGeodesy/docs/pygeodesy.ltpTuples.Local9Tuple-class.html>}. 

47 ''' 

48 _Names_ = (_Y_, _X_, 'h_') + Local9Tuple._Names_[3:] 

49 

50 @Property_RO 

51 def E_LV95(self): 

52 '''Get the B{falsed} I{Swiss E_LV95} easting (C{meter}). 

53 ''' 

54 return self.EN2_LV95.E_LV95 

55 

56 @Property_RO 

57 def EN2_LV95(self): 

58 '''Get the I{falsed Swiss (E_LV95, N_LV95)} easting and northing (L{ChLVEN2Tuple}). 

59 ''' 

60 return ChLVEN2Tuple(*_chlvs.ChLV.false2(*self.YX, LV95=True), name=self.name) 

61 

62 @Property_RO 

63 def h_LV03(self): 

64 '''Get the I{Swiss h_} height (C{meter}). 

65 ''' 

66 return self.h_ 

67 

68 @Property_RO 

69 def h_LV95(self): 

70 '''Get the I{Swiss h_} height (C{meter}). 

71 ''' 

72 return self.h_ 

73 

74 @property_RO 

75 def isChLV(self): 

76 '''Is this a L{ChLV}-generated L{ChLV9Tuple}? 

77 ''' 

78 return type(self.ltp) is _chlvs.ChLV 

79 

80 @property_RO 

81 def isChLVa(self): 

82 '''Is this a L{ChLVa}-generated L{ChLV9Tuple}? 

83 ''' 

84 return type(self.ltp) is _chlvs.ChLVa 

85 

86 @property_RO 

87 def isChLVe(self): 

88 '''Is this a L{ChLVe}-generated L{ChLV9Tuple}? 

89 ''' 

90 return type(self.ltp) is _chlvs.ChLVe 

91 

92 @property_RO 

93 def isChLVr(self): 

94 '''Is this a L{ChLVr}-generated L{ChLV9Tuple}? 

95 ''' 

96 return type(self.ltp) is _chlvs.ChLVr 

97 

98 @Property_RO 

99 def N_LV95(self): 

100 '''Get the B{falsed} I{Swiss N_LV95} northing (C{meter}). 

101 ''' 

102 return self.EN2_LV95.N_LV95 

103 

104 @Property_RO 

105 def x(self): 

106 '''Get the I{local x, Swiss Y} northing (C{meter}). 

107 ''' 

108 return self.Y 

109 

110 @Property_RO 

111 def x_LV03(self): 

112 '''Get the B{falsed} I{Swiss x_LV03} northing (C{meter}). 

113 ''' 

114 return self.yx2_LV03.x_LV03 

115 

116 @Property_RO 

117 def y(self): 

118 '''Get the I{local y, Swiss X} easting (C{meter}). 

119 ''' 

120 return self.X 

121 

122 @Property_RO 

123 def y_LV03(self): 

124 '''Get the B{falsed} I{Swisss y_LV03} easting (C{meter}). 

125 ''' 

126 return self.yx2_LV03.y_LV03 

127 

128 @Property_RO 

129 def YX(self): 

130 '''Get the B{unfalsed} easting and northing (L{ChLVYX2Tuple}). 

131 ''' 

132 return ChLVYX2Tuple(self.Y, self.X, name=self.name) 

133 

134 @Property_RO 

135 def yx2_LV03(self): 

136 '''Get the B{falsed} I{Swiss (y_LV03, x_LV03)} easting and northing (L{ChLVyx2Tuple}). 

137 ''' 

138 return ChLVyx2Tuple(*_chlvs.ChLV.false2(*self.YX, LV95=False), name=self.name) 

139 

140 @Property_RO 

141 def z(self): 

142 '''Get the I{local z, Swiss h_} height (C{meter}). 

143 ''' 

144 return self.h_ 

145 

146 

147class ChLVYX2Tuple(_NamedTuple): 

148 '''2-Tuple C{(Y, X)} with B{unfalsed} I{Swiss LV95} easting and northing 

149 in C{meter}. 

150 ''' 

151 _Names_ = (_Y_, _X_) 

152 _Units_ = ( Meter, Meter) 

153 

154 def false2(self, LV95=True): 

155 '''Return the falsed C{Swiss LV95} or C{LV03} version of the projection. 

156 

157 @see: Function L{ChLV.false2} for more information. 

158 ''' 

159 return _chlvs.ChLV.false2(*self, LV95=LV95, name=self.name) 

160 

161 

162class ChLVEN2Tuple(_NamedTuple): 

163 '''2-Tuple C{(E_LV95, N_LV95)} with B{falsed} I{Swiss LV95} easting and 

164 northing in C{meter (2_600_000, 1_200_000)} and origin at C{Bern, Ch}. 

165 ''' 

166 _Names_ = ('E_LV95', 'N_LV95') 

167 _Units_ = ChLVYX2Tuple._Units_ 

168 

169 def unfalse2(self): 

170 '''Return this projection as an B{unfalsed} L{ChLVYX2Tuple}. 

171 

172 @see: Method L{ChLV.unfalse2} for more information. 

173 ''' 

174 return _chlvs.ChLV.unfalse2(*self, LV95=True, name=self.name) 

175 

176 

177class ChLVyx2Tuple(_NamedTuple): 

178 '''2-Tuple C{(y_LV03, x_LV03)} with B{falsed} I{Swiss LV03} easting and 

179 northing in C{meter (600_000, 200_000)} and origin at C{Bern, Ch}. 

180 ''' 

181 _Names_ = ('y_LV03', 'x_LV03') 

182 _Units_ = ChLVYX2Tuple._Units_ 

183 

184 def unfalse2(self): 

185 '''Return this projection as an B{unfalsed} L{ChLVYX2Tuple}. 

186 

187 @see: Method L{ChLV.unfalse2} for more information. 

188 ''' 

189 return _chlvs.ChLV.unfalse2(*self, LV95=False, name=self.name) 

190 

191 

192__all__ += _all_OTHER(ChLV9Tuple, ChLVEN2Tuple, ChLVYX2Tuple, ChLVyx2Tuple) 

193 

194# **) MIT License 

195# 

196# Copyright (C) 2016-2026 -- mrJean1 at Gmail -- All Rights Reserved. 

197# 

198# Permission is hereby granted, free of charge, to any person obtaining a 

199# copy of this software and associated documentation files (the "Software"), 

200# to deal in the Software without restriction, including without limitation 

201# the rights to use, copy, modify, merge, publish, distribute, sublicense, 

202# and/or sell copies of the Software, and to permit persons to whom the 

203# Software is furnished to do so, subject to the following conditions: 

204# 

205# The above copyright notice and this permission notice shall be included 

206# in all copies or substantial portions of the Software. 

207# 

208# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

209# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

210# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 

211# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 

212# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

213# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 

214# OTHER DEALINGS IN THE SOFTWARE.