Question

I'm wanting to use the Mapquest geocoding API. Opening this URL in a browser returns XML containing results:

http://open.mapquestapi.com/nominatim/v1/search?format=xml&q=Wangaratta

<searchresults timestamp="Mon, 07 Apr 14 07:30:18 +0000" attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright" querystring="Wangaratta" polygon="false" exclude_place_ids="6310497,2436827371,2461158662,51900617,41796980,50259050,2461159039,41201823,2466076780" more_url="http://open.mapquestapi.com/nominatim/v1/search?format=xml&exclude_place_ids=6310497,2436827371,2461158662,51900617,41796980,50259050,2461159039,41201823,2466076780&accept-language=en-AU,en;q=0.8,en-US;q=0.6,fr;q=0.4&q=Wangaratta">
<place place_id="6310497" osm_type="node" osm_id="662026831" place_rank="18" boundingbox="-36.3962509,-36.3162509,146.2830914,146.3630914" lat="-36.3562509" lon="146.3230914" display_name="Wangaratta, Victoria" class="place" type="town" importance="0.48506868719577" icon="http://open.mapquestapi.com/nominatim/v1/images/mapicons/poi_place_town.p.20.png"/>
<place place_id="2436827371" osm_type="relation" osm_id="2562060" place_rank="20" boundingbox="-36.40642,-36.3243,146.25683,146.37104" lat="-36.36536" lon="146.311987722222" display_name="Wangaratta, Victoria, Australia" class="boundary" type="administrative" importance="0.35" icon="http://open.mapquestapi.com/nominatim/v1/images/mapicons/poi_boundary_administrative.p.20.png"/>
<place place_id="2461158662" osm_type="way" osm_id="220567499" place_rank="26" boundingbox="-36.3508096,-36.3504818,146.310831,146.3127119" lat="-36.3508096" lon="146.3127119" display_name="Rowan Street, Wangaratta, Victoria, 3677" class="highway" type="tertiary" importance="0.2"/>
<place place_id="51900617" osm_type="way" osm_id="52507281" place_rank="26" boundingbox="-36.3570551,-36.3551449,146.3200286,146.3228768" lat="-36.3558843" lon="146.3217743" display_name="Ovens Street, Wangaratta, Victoria, 3676, Australia" class="highway" type="tertiary" importance="0.2"/>
<place place_id="2466076780" osm_type="way" osm_id="225372336" place_rank="30" boundingbox="-36.3553793,-36.3549558,146.3167037,146.3171676" lat="-36.35516755" lon="146.316935620069" display_name="Wangaratta, Norton Street, Wangaratta, Victoria, 3677" class="railway" type="station" importance="0.101" icon="http://open.mapquestapi.com/nominatim/v1/images/mapicons/transport_train_station2.p.20.png"/>
</searchresults>

But trying it on the command line returns nothing useful:

$ curl http://open.mapquestapi.com/nominatim/v1/search?format=xml&q=Wangaratta
[1] 15525
$ <?xml version="1.0" encoding="UTF-8" ?>
<searchresults timestamp='Mon, 07 Apr 14 07:33:04 +0000' attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright' querystring='' polygon='false' more_url='http://open.mapquestapi.com/nominatim/v1/search?format=xml&amp;exclude_place_ids=&amp;q='>
</searchresults>

What's the difference?

Was it helpful?

Solution

It's so obvious now. The & in the URL is interpreted by Bash, so the URL needs to be wrapped in quotes.

$ curl 'http://open.mapquestapi.com/nominatim/v1/search?format=xml&q=Wangaratta'
<?xml version="1.0" encoding="UTF-8" ?>
<searchresults timestamp='Mon, 07 Apr 14 07:33:52 +0000' attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright' querystring='Wangaratta' polygon='false' exclude_place_ids='6310497,2436827371,2461158662,51900617,41796980,50259050,2461159039,41201823,2466076780' more_url='http://open.mapquestapi.com/nominatim/v1/search?format=xml&amp;exclude_place_ids=6310497,2436827371,2461158662,51900617,41796980,50259050,2461159039,41201823,2466076780&amp;q=Wangaratta'>
<place place_id='6310497' osm_type='node' osm_id='662026831' place_rank='18' boundingbox="-36.3962509,-36.3162509,146.2830914,146.3630914" lat='-36.3562509' lon='146.3230914' display_name='Wangaratta, Victoria' class='place' type='town' importance='0.48506868719577' icon='http://open.mapquestapi.com/nominatim/v1/images/mapicons/poi_place_town.p.20.png'/><place place_id='2436827371' osm_type='relation' osm_id='2562060' place_rank='20' boundingbox="-36.40642,-36.3243,146.25683,146.37104" lat='-36.36536' lon='146.311987722222' display_name='Wangaratta, Victoria, Australia' class='boundary' type='administrative' importance='0.35' icon='http://open.mapquestapi.com/nominatim/v1/images/mapicons/poi_boundary_administrative.p.20.png'/><place place_id='2461158662' osm_type='way' osm_id='220567499' place_rank='26' boundingbox="-36.3508096,-36.3504818,146.310831,146.3127119" lat='-36.3508096' lon='146.3127119' display_name='Rowan Street, Wangaratta, Victoria, 3677' class='highway' type='tertiary' importance='0.2'/><place place_id='51900617' osm_type='way' osm_id='52507281' place_rank='26' boundingbox="-36.3570551,-36.3551449,146.3200286,146.3228768" lat='-36.3558843' lon='146.3217743' display_name='Ovens Street, Wangaratta, Victoria, 3676, Australia' class='highway' type='tertiary' importance='0.2'/><place place_id='2466076780' osm_type='way' osm_id='225372336' place_rank='30' boundingbox="-36.3553793,-36.3549558,146.3167037,146.3171676" lat='-36.35516755' lon='146.316935620069' display_name='Wangaratta, Norton Street, Wangaratta, Victoria, 3677' class='railway' type='station' importance='0.101' icon='http://open.mapquestapi.com/nominatim/v1/images/mapicons/transport_train_station2.p.20.png'/></searchresults>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top