Se nenhuma função de callback for fornecida, a solicitação será feita de forma síncrona. Se um callback for fornecido, a solicitação será feita de forma assíncrona.
O modo assíncrono é preferível porque o síncrono interrompe todo o outro código (por exemplo, a interface do editor de código do EE) enquanto aguarda o servidor. Para fazer uma solicitação assíncrona, é melhor usar evaluate() em vez de getInfo().
Retorna o valor calculado deste objeto.
Uso | Retorna |
---|---|
String.getInfo(callback) | Objeto |
Argumento | Tipo | Detalhes |
---|---|---|
isso: computedobject | ComputedObject | A instância ComputedObject. |
callback | Função, opcional | Um callback opcional. Se não for fornecido, a chamada será feita de forma síncrona. |
Exemplos
Editor de código (JavaScript)
// After getInfo(), the instance is a local JavaScript string. // Regular JavaScript string manipulations are then available. // // Note: getInfo() fetches results from Earth Engine immediately, and may freeze // the browser or lead to poor performance. Use evaluate() to avoid this. print(ee.String('abc').getInfo().charAt(1)); // b print(ee.String('abc').getInfo()[2]); // c // Using + with ee.String has unexpected results print(ee.String('abc') + 'def'); // ee.String("abc")def // Fetch string using getInfo print(ee.String('abc').getInfo() + 'def'); // abcdef // Improved solution: cat is available on ee.String print(ee.String('abc').cat('def')); // abcdef
import ee import geemap.core as geemap
Colab (Python)
# After getInfo(), the instance is a local Python string. # Regular Python string manipulations are then available. # Note: getInfo() fetches results from Earth Engine synchronously; # later expressions will not be evaluated until it completes. print(ee.String('abc').getInfo()[-2]) # b print(ee.String('abc').getInfo()[2]) # c # Fetch string using getInfo print(ee.String('abc').getInfo() + 'def') # abcdef