GeoDB::Search.3pm

Langue: en

Autres versions - même langue

Version: 2009-11-10 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

GeoDB::Search - module structure for searching a GeoDB database

SYNOPSIS

This module is merely a parent class for real search modules.

DESCRIPTION

BEGIN HELP

The searching features within geoqo let you search for waypoints in various ways. See the documentation for the sub-modules for futher details.

The list of search modules distributed with GeoQO are:

   Cache
   Waymark
   Geodining
   Wigle
   Waypoint
   Ident
   Log
   Attribute
   Attr
   Rating
   Tag
   Set
   File
   Track
   File
   Returnhome
   Gps
   Any
 
 

To see help on any of the above SUBTOPICs, run:

   > geoqo -d help:topic=search/SUBTOPIC
 
 

END HELP

When the GeoDB->search() function (geoqo -s STRING from the command shell) is called it will parse strings passed to it into modules. These modules are automatically loaded from the perl path and GeoDB::Search parent hierarchy. Thus, a search string of ``NAME:param1=foo,param2=bar'' will cause GeodB to autoload GeoDB::Search::Name (note the uppercase on only the first letter here!). Then the search function on that loaded module will be called with two arguments: a pointer to itself and the search string to parse (``param1=foo,param2=bar'' in the above example). The search function should then return a portion of a sql where clause that will be inserted into a greater statement. It should also return an array reference to the arguments to fill that clause.

As an example, if param1=foo,param2=bar was passed as the $list (second) argument then the search function might:

   return ("something = ? && somethingelse = ?", ['foo', 'bar'])
 
 

The new function is typically inherited and doesn't need to be created.

To write a real search module use the following template replacing NAME by your search name:

   package GeoDB::Search::NAME;
 
   use strict;
   require GeoDB::Search;
   our $VERSION = "1.11";
   our @ISA = qw(GeoDB::Search);
 
   sub search {
       my ($self, $list) = @_,;
       my $clause, @args;
 
       GEODEBUG(3, "searching using NAME: $list\n");
 
       # parse and deal with $list and then return a sql where clause string
 
       return ($clause, \@args);
   }
 
   1;
 
 

EXAMPLES

Look at the GeoDB::Search::Cache module for an example.