NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi

I'm consuming the web service of nominatim to reverse geocoding in my .NET Application but the xml I get in my String variable is not the same as I see in the browser and accents the spoils me and makes me strange characters when using coordinates in asia

Any idea???

Thanks

asked 19 Mar '14, 15:02

kintela's gravatar image

kintela
11112
accept rate: 0%

edited 19 Mar '14, 16:07

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866

Could you give some examples (of the code that fails, the data that you're expecting, and the data that you get back)?

(19 Mar '14, 15:11) SomeoneElse ♦

Of course. For example this request http://nominatim.openstreetmap.org/reverse?format=xml&lat=50,9683209807591&lon=2,57099452814137&zoom=18&addressdetails=1

The result: D 70, farm, Bettencourt-Rivière, Amiens, Somme, Picardía, Francia metropolitana, 80890, Francia

But in my C# code

public string Inversa(double latitud, double longitud) { WebClient webClient = new WebClient();

        try
        {

            string cadena = "http://nominatim.openstreetmap.org/reverse?format=xml&lat=" + Convert.ToString(latitud) + "&lon=" + Convert.ToString(longitud) + "&zoom=18&addressdetails=1";

            string result = webClient.DownloadString(cadena);

            return result;
        }
        catch (Exception e)
        {
            throw e;
        }
    }

I get: D 70, farm, Bettencourt-Rivière, Amiens, Somme, Picardie, France métropolitaine, 80890, France

Thanks

(19 Mar '14, 15:17) kintela

Nominatim always returns its results in UTF-8 encoding. It looks like you are trying to interpret the result using some windows encoding. According to this stackoverflow question you need to set webClient.Encoding = System.Text.Encoding.UTF8 to enforce the correct encoding.

permanent link

answered 19 Mar '14, 15:40

lonvia's gravatar image

lonvia
6.2k25789
accept rate: 40%

Hi.

This must be done before using the web client.DownloadString

webClient.Encoding = Encoding.UTF8;

Thanks

(19 Mar '14, 15:58) kintela

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×689
×8

question asked: 19 Mar '14, 15:02

question was seen: 6,325 times

last updated: 19 Mar '14, 16:07

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum