Permalink
Browse files

changing the name to geo i didnt realize theres a geonode already on npm

  • Loading branch information...
U-HBO\foliveir U-HBO\foliveir
U-HBO\foliveir authored and U-HBO\foliveir committed Mar 9, 2011
1 parent 5979320 commit 7ec406ef000baaebdc9dc55e1aee64e391cadd52
Showing with 12 additions and 116 deletions.
  1. +4 −4 README.md
  2. +5 −5 examples/geocode_lookup.js
  3. +0 −104 lib/geonode.js
  4. +3 −3 package.json
View
@@ -1,15 +1,15 @@
-# GeoNode for Node.js
+# Geo for Node.js
by Felipe Oliveira (http://twitter.com/_felipera)
-GeoNode is a basic, but simple, geocode library for Node.js using Google's Geocode API (V3) - Geo Spatial capability hopefully is coming out soon.
+Geo is a very basic, but simple, geocode library for Node.js using Google's Geocode API (V3) - Geo Spatial features are coming out soon.
## Usage
- var geonode = require('../lib/geonode');
+ var geo = require('../lib/geo');
var address = '885 6th Ave #15D New York, NY 10001';
var sensor = false;
- geonode.geocoder(geonode.google, address, sensor, function(formattedAddress, latitude, longitude) {
+ geo.geocoder(geo.google, address, sensor, function(formattedAddress, latitude, longitude) {
console.log("Formatted Address: " + formattedAddress);
console.log("Latitude: " + latitude);
console.log("Longitude: " + longitude);
View
@@ -1,18 +1,18 @@
// *********************************************
// *********************************************
-// GeoNode by Felipe Oliveira
+// Geo by Felipe Oliveira
// March 2011
-// http://geeks.aretotally.in/projects/geonode
+// http://geeks.aretotally.in/projects/geo
// http://twitter.com/_felipera
// *********************************************
// *********************************************
-var geonode = require('../lib/geonode');
+var geo = require('../lib/geo');
// Good Address
var address = '885 6th Ave #15D New York, NY 10001';
var sensor = false;
-geonode.geocoder(geonode.google, address, sensor, function(formattedAddress, latitude, longitude) {
+geo.geocoder(geo.google, address, sensor, function(formattedAddress, latitude, longitude) {
console.log("Formatted Address: " + formattedAddress);
console.log("Latitude: " + latitude);
console.log("Longitude: " + longitude);
@@ -21,7 +21,7 @@ geonode.geocoder(geonode.google, address, sensor, function(formattedAddress, lat
// Bad Address
var address = '1111 Foobar Ave #15D New York, NY 9999';
var sensor = false;
-geonode.geocoder(geonode.google, address, sensor, function(formattedAddress, latitude, longitude) {
+geo.geocoder(geo.google, address, sensor, function(formattedAddress, latitude, longitude) {
console.log("Formatted Address: " + formattedAddress);
console.log("Latitude: " + latitude);
console.log("Longitude: " + longitude);
View
@@ -1,104 +0,0 @@
-// *********************************************
-// *********************************************
-// GeoNode by Felipe Oliveira
-// March 2011
-// http://geeks.aretotally.in/projects/geonode
-// http://twitter.com/_felipera
-// *********************************************
-// *********************************************
-
-// Version
-this.version = [0, 0, 2];
-
-// Import HTTP to Request Geocode
-var http = require('http');
-
-// Google Geocode Provider
-function GoogleGeocoder() {};
-
-// Google Geocode Provider - Request
-GoogleGeocoder.prototype.request = function(location, sensor) {
- return {
- host: 'maps.googleapis.com',
- port: 80,
- path: '/maps/api/geocode/json?address=' + escape(location) + '&sensor=' + sensor,
- method: 'GET'
- };
-};
-
-// Google Geocode Provider - Response
-GoogleGeocoder.prototype.responseHandler = function(response, callback) {
- json = JSON.parse(response);
- if ( json.results == null || json.results[0] == null ) {
- callback(null, null, null);
- } else {
- callback( json.results[0].formatted_address, json.results[0].geometry.location.lat, json.results[0].geometry.location.lng);
- }
-};
-
-
-// Main GeoNode Class
-function GeoNode() {
-
- // Read more about it: http://ejohn.org/blog/adv-javascript-and-processingjs/
- if (! (this instanceof arguments.callee)) {
- return new arguments.callee(arguments);
- }
-
- // Init Class
- var self = this;
- self.init();
-
-};
-
-// Constructor
-GeoNode.prototype.init = function() {
-
- var self = this;
- self.google = new GoogleGeocoder();
-
-};
-
-// Get Geocode
-GeoNode.prototype.geocoder = function(geocoder, location, sensor, callback) {
- // Check Input
- if ( geocoder == null ) {
- throw new Error("Invalid Geocoder");
- }
- if ( location == null ) {
- throw new Error("Invalid Location");
- }
- if ( sensor == null ) {
- sensor = false;
- }
- if ( callback == null ) {
- throw new Error("Invalid Callback");
- }
-
- // Get HTTP Request Options
- var options = geocoder.request(location, sensor);
-
- // Make Request
- connection = http.createClient(options.port, options.host);
- var request = connection.request("GET", options.path);
-
- // Handle Response
- request.addListener("response", function (response) {
- var responseBody = "";
- response.addListener("data", function(chunk) {
- responseBody += chunk;
- });
- response.addListener("end", function() {
- geocoder.responseHandler(responseBody, callback);
- });
- });
-
- // End Request - Listener will take care of Response
- request.end();
-
-};
-
-// Export Main Class
-module.exports = new GeoNode();
-
-
View
@@ -1,14 +1,14 @@
{
- "name" : "geonode",
- "description" : "GeoNode is a basic, but simple, geocode library for Node.js - Geo Spatial capability hopefully is coming out soon",
+ "name" : "geo",
+ "description" : "Geo is a very basic, but simple, geocode library for Node.js - Geo Spatial features are coming out soon",
"url" : "http://geeks.aretotally.in/projects/geonode",
"keywords" : [],
"author" : "Felipe Oliveira <felipera@gmail.com>",
"contributors" : [],
"licenses" : ["MIT"],
"dependencies" : [],
"lib" : "lib",
- "main" : "./lib/geonode",
+ "main" : "./lib/geo",
"version" : "0.0.2",
"directories" : { "test": "./test" },
"engines" : { "node": ">= 0.3.0" }

0 comments on commit 7ec406e

Please sign in to comment.