Project

mq_reader

0.0
No commit activity in last 3 years
No release in over 3 years
This is a wrapper for mapquest's geocoding api.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

= 0.13.1
 Project Readme

MQReader

MQReader helps you make calls to the mapquest open geocoding api.

It's meant to be simple and easy to use.

Contents

  • Overview
  • Installation
  • Usage
  • Contributing
## Overview

Using MQReader, you can:

Easily Geocode addresses using the MapQuest open geocoding api. It's meant to be as simple as possible. For those cases when you just want to geocode an address.

## Installation

Add 'mq_reader' to your Gemfile, then 'bundle'

gem 'mq_reader'
## Usage

You first need to configure your MapQuest api key. You can get one at their website. Once you have it, you can configure it wherever you want like this:

MQReader.configure do |config|
  config.api_key = YOUR_API_KEY
end

Now it's ready to be used!

Just do:

geocode = MQReader.geocode_address("2710 Avenida 8 de Octubre, Montevideo, Uruguay")

And you'll have a MQGeocode object from which you can get every detail of the geocode.

geocode.street
  #=> "Avenida 8 de Octubre 2710"
geocode.lat
  #=> -34.889265
geocode.lng
  #=> -56.15989

MQReader generates accesor methods for everything that comes with the response. You can check the MapQuest api to see what other values come with the response. Lets say you want the value of geocodeQualityCode. You just do:

geocode.geocode_quality_code
  #=> "P1XXX"

...and when in the future the response geocoded address comes with a aNewThingResponded attribute. The accesor will already be generated. You can do:

geocode.a_new_thing_responded
  #=> value of aNewThingResponded attribute in the response.

You can also add more params to the geocode request with an options hash:

geocode = MQReader.geocode_address("2710 Avenida 8 de Octubre, Montevideo, Uruguay", {max_results: 2})

Params can be written in ruby sintax(snake case).

## Contributing

Feel free to contribute or make suggestions!