Reverse geocoding using Nominatim (2)

Hi again

In ordrer to use reverse geocoding I developed this function (coming this forum ;) ) :+1:

FUNCTION TfPrincipal.GetReverseGeocoding(
    CONST Coord: TTMSFNCMapsCoordinateRec;
    Langue: Byte;
    VAR Succes: Boolean;
    VAR Messages: STRING)
   : TTMSFNCGeocodingItem;
VAR
    req: TTMSFNCGeocodingRequest;
    Resultat: TTMSFNCCloudBaseRequestResult;
    Alocale: STRING;
    chaine : String;

BEGIN
    TRY
        Messages := '';
        CASE Langue OF
            1:
                   Alocale := 'fr-FR';
            2:
                   Alocale := 'gb-GB';
            ELSE
                   Alocale := '';
        END; // Fin de CASE
        FNCGeocoding.Request.Clear;
        FNCGeocoding.Request.ClearHeaders;
        FNCGeocoding.Request.Name := 'GET REVERSEGEOCODING';
        FNCGeocoding.Request.Method := FNCGeocoding.GeocodingInstance.GetRequestMethod;
        FNCGeocoding.Request.Host := FNCGeocoding.GeocodingInstance.GetReverseHost;
        FNCGeocoding.Request.Path := FNCGeocoding.GeocodingInstance.GetReversePath(Coord);
        FNCGeocoding.Request.Query := FNCGeocoding.GeocodingInstance.GetQuery(
            Coord,
            Alocale);
        FNCGeocoding.Request.PostData := FNCGeocoding.GeocodingInstance.GetPostData;
        Resultat := FNCGeocoding.ExecuteRequest(
            NIL, // DoRequestAddress,
            NIL,
            False);

        Messages := Resultat.ResultString;
        IF Resultat.Success THEN
        BEGIN
            req := FNCGeocoding.GeocodingRequests.Add;
            req.Items.Count;
            FNCGeocoding.GeocodingInstance.Parse(
                req,
                Resultat.ResultString);
            IF (req <> NIL) AND (req.Items.Count > 0) THEN
            BEGIN
                Succes := True;
                Result := req.Items[0];
            END
            ELSE
            BEGIN
                Succes := False;
                Result := NIL;
            END;
        END
        ELSE
        BEGIN
            // Cause de l'echec xxxx a faire
            Result := NIL;
            Succes := False;
            Messages := Resultat.ResultString;
        END;
    EXCEPT
        ON E: System.SysUtils.Exception DO
        BEGIN
            Succes := False;
            Messages := Resultat.ResultString;
        END;
    END; // Fin de EXCEPT
END;

This function send back a TTMSFNCGeocodingItem variable called Geo.
If I send this coordinate ; lat = 39.2715478, Long = -0.3187623

I received back this Geo.Adresse :

'La Socarrada, Sueca, la Ribera Baixa, València / Valencia, Comunitat Valenciana, 46420, España'

It is correct. However information available in some other variables are missing :
Geo.Country = 'España' :+1:
Geo.CountryCode = 'es' :+1:
Geo.Province = 'Comunitat Valenciana' :+1:
Geo.Region = 'la Ribera Baixa'
Geo.RegionCode = ''
Geo.City = '' :-1: should be 'Sueca'
Geo.Street = '' :-1: should be 'La Socarrada'

below, the detail coming from Nominatim :
La Socarrada
Sueca
la Ribera Baixa
Valence
Communauté Valencienne
46420
Espagne
<country_code>es</country_code>

https://nominatim.openstreetmap.org/ui/details.html?osmtype=N&osmid=1243403972&class=place

According I know from the spanish administrative level 'region' is not always an administrative level; it could be a 'cultural' level (comarques) ...

I know it is VERY complicate to distach these informations. Moreover, it is dependent from the service used .... In fact is is a nightmare :(

With Here, the other service I used,
we obtain :
Geo.Address = 'Sueca, Comunidad Valenciana, España'
Geo.Country = 'España'
Geo.CountryCode = 'esp'
Geo.Province = 'Valencia'
Geo.Region = 'Comunidad Valenciana'
Geo.RegionCode = ''
Geo.City = 'Sueca'
Geo.Street = ''

Thus, in order to get more opportunity to chose what we need (the user), is it possible to add more division than these 5 (country, province, region, city, street) even if some services provide less division ? for instance State, county, ...

Good luck

Hi Olivier,

Thank you for notifying.
Nominatim provides different levels of detail depending on the location. The address details have now been improved and the update will be available with the next release of TMS FNC Maps.

Thanks a lot
and good luck ;)