Announcing the Stupid Simple Geocoder

Over at Moore Spatial I just announced the initial release of the Stupid Simple Geocoder.

Download it over at GitHub!

It’s written PHP and uses the Geonames geocoding service. It tries to cache geocode results in an SQLite database.

It’s stupidly simple, with a single optional parameter in the constructor and a single public method.

The parameter is an optional path to specify a location for an SQLite database.

The method is called “geocode” and takes an array of place names. It returns an array of GeoJSON Features which you can create FeatureClasses with, or use however you want.

It’s a piece of larger project I’m working on, but seemed semi-useful on its own.

Here’s an example of using it to create a feature class out of several places names in an array:

<?php
$places = Array(
  'Ironwood, MI, USA',
  'Sacramento, MG, Brazil',
  'Provo',
  'Lostlandneverfoundcity'
);

require_once('ssgeocoder.php');
$ssgeocoder = new ssgeocoder();
$features = $ssgeocoder->geocode($places);
$geojson = Array(
    'type' => 'FeatureCollection',
    'features' => $features
);

print json_encode($geojson);

Not too bad, right? You’ll see this used again in a couple of other projects I’m working on.

This entry was posted in Computers, GitHub, Programming and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *