MCPcopy Index your code
hub / github.com/schachmat/wego / Distance

Method Distance

iface/iface.go:144–165  ·  view source on GitHub ↗
(distM float32)

Source from the content-addressed store, hash-verified

142}
143
144func (u UnitSystem) Distance(distM float32) (res float32, unit string) {
145 if u == UnitsMetric || u == UnitsSi || u == UnitsMetricMs {
146 if distM < 1 {
147 return distM * 1000, "mm"
148 } else if distM < 1000 {
149 return distM, "m"
150 } else {
151 return distM / 1000, "km"
152 }
153 } else if u == UnitsImperial {
154 res, unit = distM/0.0254, "in"
155 if res < 3*12 { // 1yd = 3ft, 1ft = 12in
156 return
157 } else if res < 8*10*22*36 { //1mi = 8fur, 1fur = 10ch, 1ch = 22yd
158 return res / 36, "yd"
159 } else {
160 return res / 8 / 10 / 22 / 36, "mi"
161 }
162 }
163 log.Fatalln("Unknown unit system:", u)
164 return
165}
166
167type Backend interface {
168 Setup()

Callers 4

formatVisibilityMethod · 0.80
formatRainMethod · 0.80
formatVisibilityMethod · 0.80
formatRainMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected