Example #1
0
func BenchmarkFromLatLonF(b *testing.B) {
	defer func() {
		if r := recover(); r != nil {
			b.Fatal("benchmark fatal BenchmarkFromLatLonF")
		}
	}()
	lat := 64.83778
	lon := -147.71639
	for i := 0; i < b.N; i++ {
		UTM.FromLatLonF(lat, lon)
	}
}
Example #2
0
func TestFromLatLonBadInputF(t *testing.T) {

	suppressPanic := func(i int) {
		defer func() {
			recover()
		}()
		UTM.FromLatLonF(badInputLatLon[i].Latitude, badInputLatLon[i].Longitude)
		t.Errorf("Expected panic. badInputLatLon TestFromLatLonBadInput case %d", i)
	}
	for i := range badInputLatLon {
		suppressPanic(i)
	}

	defer func() {
		if r := recover(); r != nil {
			s := r.(string)
			t.Errorf("not cover latitude %s", s)
		}
	}()
	longitude := 0.
	latitude := 0.
	for i := -8000.0; i < 8401.0; i++ {
		latitude = i / 100
		UTM.FromLatLonF(latitude, longitude)
	}
	defer func() {
		if r := recover(); r != nil {
			s := r.(string)
			t.Errorf("not cover longitude %s", s)
		}
	}()
	latitude = 0.
	for i := -18000.0; i < 18001.0; i++ {
		longitude = i / 100
		UTM.FromLatLonF(latitude, longitude)
	}
}
Example #3
0
func TestFromLatLonF(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			t.Fatalf(r.(string))
		}
	}()

	for i, data := range knownValues {
		e, n := UTM.FromLatLonF(data.LatLon.Latitude, data.LatLon.Longitude)
		if round(data.UTM.Easting) != round(e) {
			t.Errorf("Easting FromLatLon case %d", i)
		}
		if round(data.UTM.Northing) != round(n) {
			t.Errorf("Northing FromLatLon case %d", i)
		}
	}
}
Example #4
0
func TestFromLatLonAndF(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			s := r.(string)
			t.Errorf("not cover longitude %s", s)
		}
	}()
	for i, data := range knownValues {
		result, err := data.LatLon.FromLatLon()
		if err != nil {
			t.Fatal(err.Error())
		}
		e, n := UTM.FromLatLonF(data.LatLon.Latitude, data.LatLon.Longitude)
		if round(e) != round(result.Easting) {
			t.Errorf("Easting FromLatLon case %d", i)
		}
		if round(n) != round(result.Northing) {
			t.Errorf("Northing FromLatLon case %d", i)
		}
	}
}