The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Flickr::Geo::ModestMaps - tools for working with geotagged Flickr photos and Modest Maps

SYNOPSIS

 my %opts = ();
 getopts('c:s:', \%opts);

 #
 # Defaults
 #

 my $cfg = Config::Simple->new($opts{'c'});

 #
 # Atkinson dithering is hawt but takes a really long
 # time...
 #

 $cfg->param("modestmaps.filter", "atkinson");
 $cfg->param("modestmaps.timeout", (45 * 60));

 #
 # Let's say all but one of your photos are in the center of
 # Paris and the last one is at the airport. If you try to render
 # a 'poster style' (that is all the tiles for the bounding box
 # containing those points at street level) map you will make 
 # your computer cry...
 #

 $cfg->param("pinwin.skip_photos", [506934069]);

 #
 # I CAN HAS MAPZ?
 #

 my $fl = Net::Flickr::Geo::ModestMaps->new($cfg);
 $fl->log()->add(Log::Dispatch::Screen->new('name' => 'scr', min_level => 'info'));

 my $map_data = $fl->mk_poster_map_for_photoset($opts{'s'});

 #
 # returns stuff like :
 #
 # {
 #  'url' => 'http://127.0.0.1:9999/?provider=YAHOO_AERIAL&marker=yadda yadda yadda',
 #  'image-height' => '8528',
 #  'marker-484080715' => '5076,5606,4919,5072,500,375',
 #  'marker-506435771' => '5256,4768,5099,542,500,375',
 #  'path' => '/tmp/dkl0o7uxjY.jpg',
 #  'image-width' => '6656',
 # }
 #

 my $results = $fl->upload_poster_map($map_data->{'path'});

 #
 # returns stuff like :
 #
 # [
 #   ['/tmp/GGsf4552h.jpg', '99999992'],
 #   ['/tmp/kosfGgsfdh.jpg', '99999254'],
 #   ['/tmp/h354jF590.jpg', '999984643'],
 #   [ and so on... ] 
 # ];
 #

DESCRIPTION

Tools for working with geotagged Flickr photos and the Modest Maps ws-pinwin HTTP service.

OPTIONS

Options are passed to Net::Flickr::Backup using a Config::Simple object or a valid Config::Simple config file. Options are grouped by "block".

flickr

  • api_key

    String. required

    A valid Flickr API key.

  • api_secret

    String. required

    A valid Flickr Auth API secret key.

  • auth_token

    String. required

    A valid Flickr Auth API token.

    The api_handler defines which XML/XPath handler to use to process API responses.

    • LibXML

      Use XML::LibXML.

    • XPath

      Use XML::XPath.

pinwin

  • map_height

    The height of the background map on which the pinwin/thumbnail will be placed.

    Default is 1024.

  • map_width

    The width of the background map on which the pinwin/thumbnail will be placed.

    Default is 1024.

  • upload

    Boolean.

    Automatically upload newly create map images to Flickr. Photos will be tagged with the following machine tags :

    • flickr:photo=photo_id

      Where photo_id is the photo that has been added to the map image.

    • flickr:map=pinwin

    Default is false.

  • upload_public

    Boolean.

    Mark pinwin uploads to Flickr as viewable by anyone.

    Default is false.

  • upload_friend

    Boolean.

    Mark pinwin uploads to Flickr as viewable only by friends.

    Default is false.

  • upload_family

    Boolean.

    Mark pinwin uploads to Flickr as viewable only by family.

    Default is false.

  • photo_size

    String.

    The string label for the photo size to display, as defined by the flickr.photos.getSizes API method :

     http://www.flickr.com/services/api/flickr.photos.getSizes.html

    Default is Medium

  • zoom

    Int.

    By default, the object will try to map the (Flickr) accuracy to the corresponding zoom level of the Modest Maps provider you have chosen. If this option is defined then it will be used as the zoom level regardless of what Flickr says.

  • crop_width

    Int.

    Used by the crop_poster_map (and by extension upload_poster_map) object methods to define the width of each slice taken from a poster map.

    Default is 1771

  • crop_height

    Int.

    Used by the crop_poster_map (and by extension upload_poster_map) object methods to define the height of each slice taken from a poster map.

    Default is 1239

  • skip_photos

    Int (or array refernce of ints)

    Used by photoset related object methods, a list of photos to exclude from the list returned by the Flickr API.

modestmaps

  • server

    The URL to a server running the ws-pinwin.py HTTP interface to the ModestMaps tile-creation service.

    This requires Modest Maps 1.0 release or higher.

  • provider

    A map provider and tile format for generating map images.

    As of this writing, current providers are :

    • MICROSOFT_ROAD

    • MICROSOFT_AERIAL

    • MICROSOFT_HYBRID

    • GOOGLE_ROAD

    • GOOGLE_AERIAL

    • GOOGLE_HYBRID

    • YAHOO_ROAD

    • YAHOO_AERIAL

    • YAHOO_HYBRID

  • method

    Used only when creating poster maps, the method parameter defines how the underlying map is generated. Valid options are :

    • extent

      Render map tiles at a suitable zoom level in order to fit the bounding box (for all the images in a photoset) in an image with specific dimensions (pinwin.map_height and pinwin.map_width).

    • bbox

      Render all the map tiles necessary to display the bounding box (for all the images in a photoset) at a specific zoom level.

    Default is bbox.

  • bleed

    If true then extra white space will be added the underlying image in order to fit any markers that may extend beyond the original dimensions of the map.

    Boolean.

    Default is true.

  • adjust

    Used only when creating poster maps, the adjust parameter tells the modest maps server to extend bbox passed by n kilometers. This is mostly for esthetics so that there is a little extra map love near pinwin located at the borders of a map.

    Boolean.

    Default is .25

  • filter

    Tell the Modest Maps server to filter the rendered map image before applying an markers. Valid options are :

    • atkinson

      Apply the Atkinson dithering filter to the map image.

      This is brutally slow. Especially for poster maps. That's life.

  • timeout

    Int.

    The number of seconds the object's HTTP handler will wait when requesting data from the Modest Maps server.

    Default is 300 seconds.

PACKAGE METHODS

__PACKAGE__->new($cfg)

Returns a Net::Flickr::Geo object.

OBJECT METHODS

$obj->mk_pinwin_map_for_photo($photo_id)

Fetch a map using the Modest Maps ws-pinwin API for a geotagged Flickr photo and place a "pinwin" style thumbnail of the photo over the map's marker.

Returns an array of arrays (kind of pointless really, but at least consistent).

The first element of the (second-level) array will be the path to the newly created map image. If uploads are enabled the newly created Flickr photo ID will be passed as the second element.

$obj->mk_pinwin_maps_for_photoset($photoset_id)

For each geotagged photo in a set, fetch a map using the Modest Maps ws-pinwin API for a geotagged Flickr photo and place a "pinwin" style thumbnail of the photo over the map's marker.

If uploads are enabled then each map for a given photo will be added such that it appears before the photo it references.

Returns an array of arrays.

The first element of each (second-level) array reference will be the path to the newly created map image. If uploads are enabled the newly created Flickr photo ID will be passed as the second element.

$obj->mk_poster_map_for_photoset($set_id)

For each geotagged photo in a set, plot the latitude and longitude and create a bounding box for the collection. Then fetch a map for that box using the Modest Maps ws-pinwin API for a geotagged Flickr photo and place a "pinwin" style thumbnail for each photo in the set.

Automatic uploads are not available for this method since the resultant images will almost always be too big.

Returns a hash reference containing the URL that was used to request the map image, the path to the data that was sent back as well as all of the Modest Maps specific headers sent back.

$obj->upload_poster_map($poster_map)

Take a file created by the mk_poster_map_for_photoset and chop it up in "postcard-sized" pieces and upload each to Flickr.

Returns an array of arrays.

The first element of the (second-level) array will be the path to the newly created map image. If uploads are enabled the newly created Flickr photo ID will be passed as the second element.

$obj->crop_poster_map($poster_map)

Take a file created by the mk_poster_map_for_photoset and chop it up in "postcard-sized" pieces.

The height and width of each piece are defined by the pinwin.crop_width and pinwin.crop_height config options.

Any image whose cropping creates a file smaller than either dimension will be padded with extra (white) space.

Returns a list of files.

VERSION

0.5

DATE

$Date: 2008/02/24 18:05:18 $

AUTHOR

Aaron Straup Cope <ascope@cpan.org>

EXAMPLES

http://flickr.com/photos/straup/tags/modestmaps/

REQUIREMENTS

Modest Maps 1.0 or higher.

http://modestmaps.mapstraction.com/

NOTES

All uploads to Flickr are marked with a content-type of "other".

SEE ALSO

Net::Flickr::Geo

http://modestmaps.com/

http://mike.teczno.com/notes/oakland-crime-maps/IX.html

BUGS

Sure, why not.

Please report all bugs via http://rt.cpan.org

LICENSE

Copyright (c) 2007-2008 Aaron Straup Cope. All Rights Reserved.

This is free software. You may redistribute it and/or modify it under the same terms as Perl itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 127:

'=item' outside of any '=over'

Around line 227:

You forgot a '=back' before '=head2'