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

Using a basic reverse geocode request like:

http://nominatim.openstreetmap.org/reverse.php?format=xml&lat=-22.77175&lon=-50.211006

how do i extract the osm_type from the result using PHP?

asked 12 Nov '13, 21:39

tonygil's gravatar image

tonygil
1223
accept rate: 0%


using php

$feedUrl = 'http://nominatim.openstreetmap.org/reverse.php?format=xml&lat=-22.77175&lon=-50.211006';
$rawFeed = file_get_contents($feedUrl);
$xml = new SimpleXmlElement($rawFeed);

foreach($xml->result as $result){
        $roadType = $result['osm_type'];
        $osmId = $result['osm_id'];

        echo "Type: $roadType Id: $osmId<br>";
}
permanent link

answered 12 Nov '13, 21:53

tonygil's gravatar image

tonygil
1223
accept rate: 0%

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:

×710
×689
×34
×2

question asked: 12 Nov '13, 21:39

question was seen: 8,799 times

last updated: 12 Nov '13, 21:53

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