This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Get Address from Coordinates

Tags: None
(comma "," separated)
malint
Registered Member
Posts
6
Karma
0

Get Address from Coordinates

Tue Aug 16, 2016 10:15 am
Hi,

I wonder if it is possible to get the address of a coordinate as a struct. Currently I am using the ReverseGeocodingRunnerManager which returns the address as a String. My problem is that I like to save the street number, city, country and more as separate variables.
I get this output after I tested five different coordinates in searchReverseGeoCoding(coordinates, 0.0, Marble::GeoDataCoordinates::Degree ) function

" 13.21288°E, 55.71320°N" is "Ole Römers väg, Ideon Pålsjö, Norr, Lund, Lund Municipality, Skåne, Götaland, 22370, Sweden"
" 13.34883°E, 55.71735°N" is "29a, Allégatan, Södra Sandby, Lund Municipality, Skåne, Götaland, 24731, Sweden"
" 12.15152°E, 55.65119°N" is "9, Holbækmotorvejen, Trekroner, Roskilde Municipality, Region Zealand, Denmark"
" 12.13853°E, 55.82131°N" is "Hagerupvej, Ølstykke, Egedal Municipality, Capital Region of Denmark, 3650, Denmark"
" 12.61169°E, 56.03595°N" is "30B, Sudergade, Elsinore, Helsingør Municipality, Capital Region of Denmark, 3000, Denmark"

My problem is that there seems to be no way to know where in the string the city is located. For example in the first row the city is located as the fourth to the left. On the second row as the third to the left. And the same problem if I try counting from the right.

Does anyone know if there is way to get the city, street number and country as a struct?

Thanks!
User avatar
Earthwings
KDE Developer
Posts
172
Karma
1
OS

Re: Get Address from Coordinates

Sun Sep 04, 2016 5:27 pm
It's saved as KML extended data in the placemark. You can retrieve it using the extendedData() method, it's basically a key/value map of strings. The serialized version of such a placemark looks like this:

Code: Select all
            <Placemark>
                <address>118, Rüppurrer Straße, Südstadt, Karlsruhe, Regierungsbezirk Karlsruhe, Baden-Württemberg, 76137, Deutschland</address>
                <Point>
                    <coordinates>8.4072981342,48.9959213634</coordinates>
                </Point>
                <ExtendedData xmlns:mx="http://marble.kde.org">
                    <mx:OsmPlacemarkData id="0">
                        <mx:tag k="addr:suburb" v="Südstadt"/>
                        <mx:tag k="addr:state" v="Baden-Württemberg"/>
                        <mx:tag k="addr:country" v="de"/>
                        <mx:tag k="addr:postcode" v="76137"/>
                        <mx:tag k="addr:city" v="Karlsruhe"/>
                        <mx:tag k="addr:housenumber" v="118"/>
                        <mx:tag k="addr:street" v="Rüppurrer Straße"/>
                        <mx:tag k="addr:district" v="Regierungsbezirk Karlsruhe"/>
                    </mx:OsmPlacemarkData>
                </ExtendedData>
            </Placemark>


Update: Just realized there were some changes to that recently. The output for older Marble versions might look slightly different, but it has very similar data.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell