Git Product home page Git Product logo

reverse-geoplanet's Introduction

reverse-geoplanet

reverse-geoplanet is a simple web application to reverse geocode a latitude and longitude using the Flickr reverse geocoder. Results include both the primary Where On Earth (WOE) ID for the lat,lon and a truncated hierarchy of parent WOE IDs. Results are cached in both a MySQL instance local to the application as well as Memcache, if it is installed.

reverse-geoplanet was originally developed for the building=yes project.

You will need a valid Flickr API key in order to use reverse-geoplanet.

Installing reverse-geoplanet

Please consult the INSTALL.md document.

How to

http://example.com/reverse-geoplanet/www/?lat=37.765219&lon=-122.419787

http://example.com/reverse-geoplanet/www/?ll=37.765219,-122.419787

{
	"latitude":"37.765",
	"longitude":"-122.420",
	"geohash":"9q8yy6bm",
	"woeid":"23512048",
	"locality":"2487956",
	"region":"2347563",
	"country":"23424977",
	"created":"1327172399",
	"name":"Mission Dolores, San Francisco, CA, US, United States",
	"placetype":"22",
	"stat":"ok"
}

Do you see the part where the name attribute contains the country name twice? The part where it says "Mission Dolores, San Francisco, CA, US, United States"? That's actually I bug that I am responsible for from back, so many moons ago, when I still worked at Flickr. I'm sorry. It hurts every time I see it...

By default reverse-geoplanet outputs JSON and is expected to be run more as a service for other robots rather than a website for humans. You can force results to be returned as HTML by specifying the inline=1 argument. For example:

http://example.com/reverse-geoplanet/www/?lat=37.765219&lon=-122.419787&inline=1

PHP

You can also call the reverse geocoder directly from a Flamework project like this:

include("include/init.php");
loadlib("reverse_geoplanet");

$lat = 40.721294;
$lon = -73.983994;
$remote = 'http://reverse.example.com/';

dumper(reverse_geoplanet($lat, $lon));
dumper(reverse_geoplanet($lat, $lon, $remote));

The third argument is optional and tells the code to call another remote instance of reverse-geoplanet for results.

If you want to bolt the functionality in to another Flamework project itself you'll need to copy the following files:

(I should probably just write a shell script to automate this...)

Python

There is a client-side Python library included that will call your instance of reverse-geoplanet and also cache the results locally using an in-memory SQLite database. In case you want to do reverse geocoding from your laptop or something. Like this:

$> cd python/reverse_geoplanet

$> python __init__.py 'example.com/reverse-geoplanet/www'

{
	u'stat': u'ok',
	u'name': u'Ygnacio Valley, Concord, CA, US, United States',
	u'locality': u'2384020',
	u'woeid': u'55858555',
	u'region': u'2347563',
	u'created': u'1327172577',
	u'longitude': u'-122.022',
	u'placetype': u'22',
	u'geohash': u'9q9pxrf7',
	u'country': u'23424977',
	u'latitude': u'37.924'
}

Flamework

reverse-geoplanet is built on top of Flamework which means if you're poking around the code you may be wondering what all that other stuff is for. At the moment: Nothing and it's all disabled. In the future, who knows?

See also

reverse-geoplanet's People

Contributors

nvkelso avatar thisisaaronland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nvkelso

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.