lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Quintiq file version 2.0
#parent: #root
Method DoGeocode
{
  #keys: '1[105690.0.466136613]'
  Description:
  [*
    Entry point/method for a OSM Geocode operation call.
    Construct the geocode request and prepare the http interface, the callbacks and make an asynchronous call
  *]
  TextBody:
  [*
    // boon kiat Nov-1-2013 (created)
    utils := this.LibOSM_Utils();
    arguments := this.Arguments();
    argumentsroot := arguments.Root();
    utils.DebugDump( "geocode_args.txt", argumentsroot );
    
    geocodingserver := this.LibOSM_GeocodingServer( relnew );
    
    // Generate the actual request
    ticks := OS::PrecisionCounter();
    url := geocodingserver.GenerateGeocodeURL();
    utils.DebugEndTrace( "GeocodingServer.GenerateGeocodeURL", ticks );
    
    ticks := OS::PrecisionCounter();
    
    // Generate the HTTPInterface instance that will be used to send the request to the OpenStreetMap Nominatim server
    httpinterface := geocodingserver.CreateHTTPInterface();
    httpinterface.URL( url );
    onsuccesscallback := Reflection::FindMethodBySignature( typeof( LibOSM_GeocodingServer ).Name(), "ProcessGeocodeResponse", typeof( HTTPInterface ).Name() );
    assert( not isnull( onsuccesscallback ), "OSMGISLibrary.DoGeocode: failed to retrieve the method that will serve as the OnSuccess callback" );
    httpinterface.OnSuccessCallback( onsuccesscallback, geocodingserver );
    onfailurecallback := Reflection::FindMethodBySignature( typeof( LibOSM_Utils ).Name(), "HandleError", typeof( HTTPInterface ).Name() );
    assert( not isnull( onfailurecallback ), "OSMGISLibrary.DoGeocode: failed to retrieve the method that will serve as the OnFailure callback" );
    httpinterface.OnFailureCallback( onfailurecallback, utils );
    
    // Send the request, asynchronously
    httpinterface.ASyncCall();
    
    utils.DebugEndTrace( "The HTTP call to GeocodingServer", ticks );
  *]
}