Doesnt parse from string - otherwise it works

This commit is contained in:
Miek Gieben 2012-04-30 23:59:15 +02:00
parent 2ea2204a8b
commit d30dcf93e0
3 changed files with 8 additions and 13 deletions

View File

@ -255,6 +255,8 @@ func TestParseLOC(t *testing.T) {
lt := map[string]string{
"SW1A2AA.find.me.uk. LOC 51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m":
"SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m",
// "SW1A2AA.find.me.uk. LOC 51 0 0.0 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m":
// "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 0 0.0 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m",
}
for i, o := range lt {
rr, e := NewRR(i)

View File

@ -595,7 +595,7 @@ func (rr *RR_LOC) String() string {
lat = lat % (1000 * 60 * 60)
m := lat / (1000 * 60)
lat = lat % (1000 * 60)
s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float64(lat) / 1000), north)
s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float32(lat) / 1000), north)
// Longitude
lon := rr.Longitude
east := "E"
@ -609,14 +609,14 @@ func (rr *RR_LOC) String() string {
lon = lon % (1000 * 60 * 60)
m = lon / (1000 * 60)
lon = lon % (1000 * 60)
s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float64(lon) / 1000), east)
s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float32(lon) / 1000), east)
s1 := rr.Altitude / 100.00
s1 -= 100000
if rr.Altitude%100 == 0 {
s += fmt.Sprintf("%.2fm ", float64(s1))
s += fmt.Sprintf("%.2fm ", float32(s1))
} else {
s += fmt.Sprintf("%.0fm ", float64(s1))
s += fmt.Sprintf("%.0fm ", float32(s1))
}
s += cmToString((rr.Size&0xf0)>>4, rr.Size&0x0f) + "m "
s += cmToString((rr.HorizPre&0xf0)>>4, rr.HorizPre&0x0f) + "m "

View File

@ -422,6 +422,7 @@ func setTALINK(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setLOC(h RR_Header, c chan lex, f string) (RR, *ParseError) {
// Defaults TODO(mg)
rr := new(RR_LOC)
rr.Hdr = h
ok := false
@ -430,7 +431,7 @@ func setLOC(h RR_Header, c chan lex, f string) (RR, *ParseError) {
if i, e := strconv.Atoi(l.token); e != nil {
return nil, &ParseError{f, "bad LOC Latitude", l}
} else {
rr.Latitude = uint32(1000.0 * i) // +0.0005 in ldns?
rr.Latitude = 1000 * uint32(i)
}
<-c // _BLANK
// Either number, 'N' or 'S'
@ -444,11 +445,7 @@ func setLOC(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr.Latitude += 1000 * 60 * uint32(i)
}
<-c // _BLANK
// Either number, 'N' or 'S'
l = <-c
if rr.Latitude, ok = locCheckNorth(l.token, rr.Latitude); ok {
goto East
}
if i, e := strconv.ParseFloat(l.token, 32); e != nil {
return nil, &ParseError{f, "bad LOC Latitude seconds", l}
} else {
@ -484,11 +481,7 @@ East:
rr.Longitude += 1000 * 60 * uint32(i)
}
<-c // _BLANK
// Either number, 'E' or 'W'
l = <-c
if rr.Longitude, ok = locCheckEast(l.token, rr.Longitude); ok {
goto Altitude
}
if i, e := strconv.ParseFloat(l.token, 32); e != nil {
return nil, &ParseError{f, "bad LOC Longitude seconds", l}
} else {