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
44
45
46
47
48
Quintiq file version 2.0
#parent: #root
Method GenerateGeocodeURL () as String
{
  #keys: '1[105690.0.468906519]'
  Description: 'Generates the Geocoding request to send to Nominatim/MapQuest by constructing the request URL and modifying the appropriate fields'
  TextBody:
  [*
    // Administrator Sep-13-2011 (created)
    library := this.LibOSM_OSMGISLibrary();
    //utils := library.LibOSM_Utils();
    arguments := library.Arguments();
    countryhandle := arguments.GetHandle( "country" );
    statehandle := arguments.GetHandle( "state" );
    cityhandle := arguments.GetHandle( "city" );
    streethandle := arguments.GetHandle( "street" );
    housenumberhandle := arguments.GetHandle( "housenumber" );
    postcodehandle := arguments.GetHandle( "postcode" );
    argumentsroot := arguments.Root();
    
    street     := argumentsroot.Child( housenumberhandle ).ValueToString() +
                  " " + argumentsroot.Child( streethandle ).ValueToString();
    city       := argumentsroot.Child( cityhandle ).ValueToString();
    state      := argumentsroot.Child( statehandle ).ValueToString();
    postalcode := argumentsroot.Child( postcodehandle ).ValueToString();
    country    := argumentsroot.Child( countryhandle ).ValueToString();
    
    urlsuffix := '';
    
    if( this.Endpoint() = 'OSM-NOMINATIM' )
    {
      //TODO - To use structured URL or use one-line query URL?
      urlsuffix := LibOSM_GeocodingServer::GenerateGeocodeURL_Nominatim( street, city, state, postalcode, country );
    }
    else
    {
      urlsuffix := LibOSM_GeocodingServer::GenerateGeocodeURL_MapQuest( street, city, state, postalcode, country );
    }
    //Encodes any characters that are reserved characters in URL
    urlsuffix := StringUtil::EncodeURL( urlsuffix );
    
    url := urlsuffix;
    
    debuginfo( "GeocodingServer.GenerateGeocodeURL:", url );
    
    return url;
  *]
}