haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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 GetTile (Number idx)
{
  #keys: '1[103544.0.740665520]'
  TextBody:
  [*
    // Administrator Mar-12-2012 (created)
    library := this.LibOSM_OSMGISLibrary();
    utils := library.LibOSM_Utils();
    mapserver := library.LibOSM_MapServer();
    
    arguments := library.Arguments();
    zoomlevelhandle := arguments.GetHandle( "zoomlevel" );
    tilehandle := arguments.GetHandle( "tile" );
    xhandle := arguments.GetHandle( "x" );
    yhandle := arguments.GetHandle( "y" );
    argumentsroot := arguments.Root();
    
    requestabletile := argumentsroot.Children( tilehandle ).Element( idx );
    utils.DebugDump( "gettiles_currentrequestabletile.txt", requestabletile );
    zoomlevel := argumentsroot.Child( zoomlevelhandle ).GetValueAsNumber();
    x := requestabletile.Child( xhandle ).GetValueAsNumber();
    y := requestabletile.Child( yhandle ).GetValueAsNumber();
    
    // Generate the URL
    url := mapserver.GenerateTileURL( zoomlevel, x, y );
    
    // Generate the HTTPInterface instance that will be used to send the request to the OpenStreetMap map server
    httpinterface := mapserver.CreateHTTPInterface();
    httpinterface.URL(url );
    onsuccesscallback := Reflection::FindMethodBySignature( typeof( LibOSM_MapServer ).Name(), "ProcessTileResponse", typeof( HTTPInterface ).Name() );
    assert( not isnull( onsuccesscallback ), "GetTilesCall.GetTile: failed to retrieve the method that will serve as the OnSuccess callback" );
    httpinterface.OnSuccessCallback( onsuccesscallback, mapserver );
    onfailurecallback := Reflection::FindMethodBySignature( typeof( LibOSM_MapServer ).Name(), "ProcessTileErrorResponse", typeof( HTTPInterface ).Name() );
    assert( not isnull( onfailurecallback ), "GetTilesCall.GetTile: failed to retrieve the method that will serve as the OnFailure callback" );
    httpinterface.OnFailureCallback( onfailurecallback, mapserver );
    
    // Send the request, asynchronously
    key := httpinterface.ASyncCall();
    library.LibOSM_OSMServerCall( relinsert, construct( LibOSM_OSMServerCall, ArgumentID := idx, SentRequestID := key ) );
  *]
}