Skip to content

Commit

Permalink
no lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wroge committed Nov 23, 2023
1 parent dbf7885 commit 61731d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
12 changes: 7 additions & 5 deletions epsg.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:gomnd,goerr113,forcetypeassert,gochecknoglobals,lll,funlen,gocognit,gocyclo,cyclop,ireturn,maintidx

Check failure on line 1 in epsg.go

View workflow job for this annotation

GitHub Actions / lint

: # github.com/wroge/wgs84/v2
package wgs84

import (
Expand Down Expand Up @@ -134,23 +135,24 @@ func EPSG(code int) CRS {
case 900913:
crs = EPSG(3857)
default:
if code > 3941 && code < 3951 {
switch {
case code > 3941 && code < 3951:
lat := float64(code - 3900)

crs = LambertConformalConic2SP(EPSG(4171), 3, lat, lat-0.75, lat+0.75, 1700000, 2200000+(lat-43)*1000000)
} else if code > 25827 && code < 25839 {
case code > 25827 && code < 25839:
zone := float64(code - 25800)

crs = TransverseMercator(EPSG(4258), zone*6-183, 0, 0.9996, 500000, 0)
} else if code > 31465 && code < 31470 {
case code > 31465 && code < 31470:
zone := float64(code - 31464)

crs = TransverseMercator(EPSG(4314), zone*3, 0, 1, zone*1000000+500000, 0)
} else if code > 32600 && code < 32661 {
case code > 32600 && code < 32661:
zone := float64(code - 32600)

crs = TransverseMercator(EPSG(4326), zone*6-183, 0, 0.9996, 500000, 0)
} else if code > 32700 && code < 32761 {
case code > 32700 && code < 32761:
zone := code - 32700

crs = TransverseMercator(EPSG(4326), float64(zone)*6-183, 0, 0.9996, 500000, 10000000)
Expand Down
42 changes: 23 additions & 19 deletions wgs84.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:varnamelen,nonamedreturns,ireturn,gomnd,exhaustivestruct,exhaustruct,cyclop,errname,lll,funlen
package wgs84

import (
Expand All @@ -17,8 +18,10 @@ type CRS interface {
}

func Transform(from, to CRS) Func {
var toBase []Func
var fromBase []Func
var (
toBase []Func
fromBase []Func
)

for {
if from == nil {
Expand Down Expand Up @@ -109,11 +112,11 @@ func (errorCRS) Spheroid() Spheroid {
return Spheroid{}
}

func (errorCRS) ToBase(x0, y0, z0 float64) (float64, float64, float64) {
func (errorCRS) ToBase(_, _, _ float64) (float64, float64, float64) {
return math.NaN(), math.NaN(), math.NaN()
}

func (errorCRS) FromBase(x0, y0, z0 float64) (float64, float64, float64) {
func (errorCRS) FromBase(_, _, _ float64) (float64, float64, float64) {
return math.NaN(), math.NaN(), math.NaN()
}

Expand Down Expand Up @@ -191,7 +194,6 @@ func Geographic(geocentric CRS, spheroid Spheroid) CRS {
}

return geographic{

b: geocentric,
s: spheroid,
}
Expand Down Expand Up @@ -220,7 +222,6 @@ func (b geographic) FromBase(x, y, z float64) (lon, lat, h float64) {

func Helmert(tx, ty, tz, rx, ry, rz, ds float64) CRS {
return helmert{

tx: tx,
ty: ty,
tz: tz,
Expand Down Expand Up @@ -264,10 +265,8 @@ func calcHelmert(x, y, z, tx, ty, tz, rx, ry, rz, ds float64) (x0, y0, z0 float6
return
}

var (
//go:embed ntv2
res embed.FS
)
//go:embed ntv2
var res embed.FS

func loadNTv2(name string, spheroid Spheroid, base CRS) CRS {
file, err := res.Open("ntv2/" + name)
Expand Down Expand Up @@ -338,11 +337,13 @@ func NTv2(reader io.Reader, spheroid Spheroid, base CRS) CRS {

func toFloat32(b []byte) float32 {
i := binary.LittleEndian.Uint32(b)

return math.Float32frombits(i)
}

func toFloat(b []byte) float64 {
i := binary.LittleEndian.Uint64(b)

return math.Float64frombits(i)
}

Expand All @@ -356,13 +357,13 @@ type ntv2 struct {
numOrec int32
numSrec int32
numFile int32
gsCount int32
sLat float64
nLat float64
eLong float64
wLong float64
latInc float64
longInc float64
gsCount int32
values [][4]float32
}

Expand Down Expand Up @@ -417,28 +418,31 @@ func (n ntv2) Shift(lon, lat float64) (float64, float64) {
sw = se
nw = ne
}

if row >= ppc-1 {
ne = se
nw = sw
}

if col <= 0 {
se = sw
ne = nw
}

if row <= 0 {
se = ne
sw = nw
}

se_index := min(max(int(se), 0), len(n.values)-1)
sw_index := min(max(int(sw), 0), len(n.values)-1)
ne_index := min(max(int(ne), 0), len(n.values)-1)
nw_index := min(max(int(nw), 0), len(n.values)-1)
seIndex := min(max(int(se), 0), len(n.values)-1)

Check failure on line 437 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: min

Check failure on line 437 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: max
swIndex := min(max(int(sw), 0), len(n.values)-1)

Check failure on line 438 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: min

Check failure on line 438 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: max
neIndex := min(max(int(ne), 0), len(n.values)-1)

Check failure on line 439 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: min

Check failure on line 439 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: max
nwIndex := min(max(int(nw), 0), len(n.values)-1)

Check failure on line 440 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: min

Check failure on line 440 in wgs84.go

View workflow job for this annotation

GitHub Actions / lint

undefined: max

sse := n.values[se_index]
ssw := n.values[sw_index]
sne := n.values[ne_index]
snw := n.values[nw_index]
sse := n.values[seIndex]
ssw := n.values[swIndex]
sne := n.values[neIndex]
snw := n.values[nwIndex]

dx := fcol - col
dy := frow - row
Expand Down

0 comments on commit 61731d2

Please sign in to comment.