
Geo::Cloudmade - An extended interface to Cloudmade's Geo API

Cloudmade is a provider of FREE map of the world (L<http://cloudmade.com>). This module implements an OO wrapper around Cloudmade's Geo API. For now the following features were implemented: - geocoding and geosearching - routing - obtaining tiles Some of functionality providede by Cloudmade is not implemented yet in this module. If you have any questions or/and suggestions please contact me.

use Geo::Cloudmade;
#use api key for access to service
my $geo = Geo::Cloudmade->new('BC9A493B41014CAABB98F0471D759707');
#find coordinates of geo object
my @arr = $geo->find("Potsdamer Platz,Berlin,Germany", {results=>5, skip=>0});
print $geo->error(), "\n" unless @arr;
print "Number of results: ", scalar (@arr), "\n";
foreach (@arr) {
print $_->name,":\n", $_->centroid->lat, "/", $_->centroid->long, "\n"
}
# finding closest poi
# for list all available objects please look at http://developers.cloudmade.com/projects/show/geocoding-http-api
@arr = $geo->find_closest('library', [59.12, 81.1], {return_geometry=>'True'});
print "No closest variants\n" unless @arr;
#calculate route
my $route = $geo->get_route([47.25976, 9.58423], [47.66117, 9.99882], { type=>'car', method=>'shortest' } );
print "Distance: ", $route->total_distance, "\n";
print "Start: ", $route->start, "\n";
print "End: ", $route->end, "\n";
print "Route segments:\n";
print join (',', @$_), "\n" foreach (@{$route->segments});
#get tile
my $tile = $geo->get_tile([47.26117, 9.59882], {zoom=>10, tile_size=>256});
open (my $fh, '>', 'test.png') or die "Cannot open file $!\n";
binmode $fh;
print $fh $tile;

Usage : my $geo = Geo::Cloudmade->new('your-ip-key');
Function : Constructs and returns a new Geo::Cloudmade object
Returns : a Geo::Cloudmade object
API-KEY : api key provided by Cloudmade. For request api key please visit L<http://developers.cloudmade.com/projects>

Usage : my @arr = $geo->find("Potsdamer Platz,Berlin,Germany", {results=>5, skip=>0});
Function: Returns geo objects (bound box and\or location) by query or nothing
Returns : Array of Geo::Cloudmade::Result objects or one Geo::Cloudmade::Results if scalar value was expected
QUERY : Query in format POI, House Number, Street, City, County like "Potsdamer Platz, Berlin, Germany".
Also near is supported in queries, e.g. "hotel near Potsdamer Platz, Berlin, Germany"
PARAMS : Hash for control ouptut. Valid elements are bbox, results, skip, bbox_only, return_geometry, return_location
For more info about parameters please look at L<http://developers.cloudmade.com/wiki/geocoding-http-api/Documentation>
Usage: @arr = $geo->find_closest('library', [59.12, 81.1], {return_geometry=>'True'});
Function: Find closest (only one or zero!) object.
Returns array of Geo::Cloudmade::Result objects like find method, but size of array can be only 1 or zero.
OBJECT - point of interest, list of supported objects located at L<http://developers.cloudmade.com/projects/show/geocoding-http-api>
POINT - reference of array of [$lattitude, $longtitude]
PARAMS - optional parameters like return_geometry and return_location
Usage: my $route = $geo->get_route([47.25976, 9.58423], [47.66117, 9.99882],
{ type=>'car', method=>'shortest' } );
Function: Calculates route from START to END and returns Geo::Cloudmade::Route object
Returns raw png data of specified map point
CENTER array reference to latitude and longtitude
PARAMS optional parameters. Allowed parameters are zoom, stile, size
For more info please look at official documentation from Cloudmade

Official documentation about services from Cloudmade http://developers.cloudmade.com/projects You can find more specific info about: - geocoding and geosearching in L<http://developers.cloudmade.com/projects/show/geocoding-http-api> - routing in L<http://developers.cloudmade.com/projects/show/routing-http-api> - obtaining tiles in L<http://developers.cloudmade.com/projects/tiles/documents>

Dmytro Gorbunov, <dmitro.gorbunov@gmail.com>

Copyright (C) 2009 by Dmytro Gorbunov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.