package autonavi

/*
var (
	autonaviAPI *API
	sugarLogger *zap.SugaredLogger
)

func init() {
	logger, _ := zap.NewDevelopment()
	sugarLogger = logger.Sugar()
	baseapi.Init(sugarLogger)

	autonaviAPI = New("49ae7e4552909cf33faba70443ad775b")
	autonaviAPI.SetCookieWithStr(`cna=dyUYGJ5k1VICAbffYm17n9kQ; UM_distinctid=176036a06055e-0ee495abe2301e-5c173a1b-15f900-176036a060673; isg=BOrqQBinfq1rFcyHs0cHGEFiO1CMW261b382TXSjAz3bp4phXO9bxTLWM9O7V-ZN; l=eBLn3bArQD-PVZ6OBO5ZPurza77tgIRb4sPzaNbMiInca6GF9FPIpNCI6EvkWdtjgtC33etzuK-oqdLHR3xJ2xDDB5XXG7RE3xvO.; tfstk=cgmVBA_rmnK25ur6JoZNGm2q2UqAZinnX3yUoV3YnkeyezzcifCTEIYxUAPpqrf..`)
}

func TestCoordinateConvert(t *testing.T) {
	gpsLng := 116.481499
	gpsLat := 39.990475
	desiredLng := 116.487585177952
	desiredLat := 39.991754014757
	lng, lat, err := autonaviAPI.CoordinateConvert(gpsLng, gpsLat, CoordSysGPS)
	if err != nil {
		t.Fatalf("TestCoordinateConvert failed with error:%v", err)
	} else {
		if lng != desiredLng || lat != desiredLat {
			t.Fatal("CoordinateConvert result is wrong")
		}
	}
}

func TestGetCoordinateDistrictCode(t *testing.T) {
	dongguanLng := 113.703870
	dongguanLat := 22.833210
	districtCode := autonaviAPI.GetCoordinateDistrictCode(dongguanLng, dongguanLat)
	if districtCode != 9441900 {
		t.Fatalf("TestGetCoordinateCodes failed")
	} else {
		t.Log(districtCode)
	}

	cdgxWuhouLng := 104.052971
	cdgxWuhouLat := 30.576076
	districtCode = autonaviAPI.GetCoordinateDistrictCode(cdgxWuhouLng, cdgxWuhouLat)
	if districtCode != 510107 {
		t.Fatalf("TestGetCoordinateCodes failed")
	} else {
		t.Log(districtCode)
	}

	districtCode = autonaviAPI.GetCoordinateDistrictCode(0, 0)
	if districtCode != 0 {
		t.Fatalf("TestGetCoordinateCodes failed")
	} else {
		t.Log(districtCode)
	}
}

func TestGetCoordinateTownInfo(t *testing.T) {
	dongguanLng := 120.74567
	dongguanLat := 31.69742
	townName, townCode := autonaviAPI.GetCoordinateTownInfo(dongguanLng, dongguanLat)
	if townName != "周市镇" || townCode != "320583102000" {
		t.Fatalf("townName:%s, townCode:%s", townName, townCode)
	}
}

func TestGetDistricts(t *testing.T) {
	districtList, err := autonaviAPI.GetDistricts(4, "成都")
	if err != nil {
		t.Fatal(err)
	}
	if len(districtList) == 0 {
		t.Fatal("should have ditrict")
	}
	t.Log(utils.Format4Output(districtList, false))
}

func TestGetCoordinateFromAddress(t *testing.T) {
	lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("重庆市渝北区龙山大道111号“龙湖紫都城”", "重庆市")
	t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
}

func TestWalkingDistance(t *testing.T) {
	distance := autonaviAPI.WalkingDistance(104.057289, 30.694798, 104.066289, 30.695598)
	t.Logf("distance:%f", distance)
}

func TestGeoCodeRegeo(t *testing.T) {
	lng := 104.052756
	lat := 30.685203
	result, err := autonaviAPI.GeoCodeRegeo([]*Coordinate{
		&Coordinate{
			Lng: lng,
			Lat: lat,
		},
		&Coordinate{
			Lng: lng,
			Lat: lat,
		},
	}, 0, false, nil, 0, 0)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestBatchWalkingDistance(t *testing.T) {
	result, err := autonaviAPI.BatchWalkingDistance(104.052756, 30.685203, []*Coordinate{
		&Coordinate{
			Lng: 104.052756,
			Lat: 30.687203,
		},
		&Coordinate{
			Lng: 104.032756,
			Lat: 30.685203,
		},
		&Coordinate{
			Lng: 104.032756,
			Lat: 30.685203,
		},
		&Coordinate{
			Lng: 104.032756,
			Lat: 30.685203,
		},
		&Coordinate{
			Lng: 104.032756,
			Lat: 30.685203,
		},
		&Coordinate{
			Lng: 104.032756,
			Lat: 30.685203,
		},
		&Coordinate{
			Lng: 104.032756,
			Lat: 30.685203,
		},
	})
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestAA(t *testing.T) {
	result, err := autonaviAPI.GetCoordinateAreaInfo(118.932092, 32.112661)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}
*/
