Category

Knihovna, která umožňuje autorům skriptů generovat výstupy z GeoGetu řazené a seskupované dle přidělených klíčů - kategorií. Ve výchozím nastavení jsou data exportována v pořadí tak, jak jsou zobrazena v načteném seznamu. Pomocí této knihovny lze každé keši v seznamu přidělit klíč a zařadit ji do fronty ke zpracování. Následně je pak fronta seřazena podle kategorií (abecedně) a zpracovávána v daném pořadí.

Autor

  • HaLuMa - kód
  • medwyn_cz - testování, drobné úpravy, ukázkové exportní makro

Automatická instalace

Nainstalovat do GeoGetu
Instalaci doplňku spustíte kliknutím na tlačítko vlevo. Následně budete v prostředí GeoGetu provedeni instalačním procesem. Pro zajištění této funkce je třeba mít na počítači již nainstalovaný a spuštěný program GeoGet .
Kliknuli jste na tlačítko a nic se nestalo? Máte opravdu spuštěný GeoGet ? Je to potřeba! Mění se Vám při přejetí přes tlačítko kurzor na ručičku? Instalační tlačítko využívá JavaScript a Flash. Váš webový prohlížeč tedy pravděpodobně nesplňuje potřebné předpoklady. Nevadí, instalaci doplňku můžete jednoduše vyvolat i prostým zkopírováním (označit text → klik pravým tlačítkem → kopírovat) následujícího odkazu do schránky: http://geoget.ararat.cz/doku.php/user:skript:category?download

Popis

Dostupné funkce

  • Seřazeny tak, jak budou pravděpodobně při používání volány
procedure CatInit;
  • Initializes the library
procedure CatSetCallback(callback : TCatCallback);
  • Set the callback procedure. This procedure is called back during the execution of CatSort procedure.
  • The parameter supplied must be a link to a procedure signed:
    procedure(const geo: tgeo; const wpt: TWpt; category: string)
procedure CatBeginUpdate;
  • Starts new transaction
procedure CatAddGC(GC: TGeo; category: string);
  • Adds geocache to category database
procedure CatAddWpt(Wpt: TWpt; category: string);
  • Adds additional waypoint to category database
procedure CatSort;
  • Sorts the database and for each point calls the Cat_Callback method.
procedure CatCategories(const value: TStrings);
  • Returns categories in category database.
function CatSize: Integer;
  • Returns total size of category database - total count of points
function CatCategorySize(category : string) : Integer;
  • Returns count of points in given category
procedure CatEndUpdate;
  • Commits the transaction
procedure CatFinish;
  • Frees up the category database.

Ukázkové exportní makro

Zde je plný opis zdrojového kódu makra, které používá tuto knihovnu ke generování HTML výstupu seřazeného dle kategorie keší. Výstup je jinak shodný s makrem html.gge.pas.

html-sorted.gge.pas
{$include category.lib.pas} //Include the library
 
var exportData : String; //this field holds the exported data
var exportCounter : Integer; //this field holds the current number of already exported points
var lastCategory : String; //this field holds the name of the last exported category
 
{This function returns the extension of the exported file}
function ExportExtension: string;
begin
  result := 'HTML';
end;
 
{This function returns the description of this export format}
function ExportDescription: string;
begin
  result := 'HTML list - sorted by category';
end;
 
{This function returns the data about one point, which should be written to the body of the export file}
function ExportPoint: string;
begin
    //Only divide points in to categories, do not generate any output yet!
 
	  CatAddGC(GC,GC.CacheType); //Register the processed point to the category library. Use the cachetype as the category
 
    Result := ''; //We are using category library as a workaround. No data must be exported to the file at this stage.
end;
 
{This function generates the HTML output based on the given TGeo}
function GenerateOutputGeo(geo :TGeo): string;
var
  n: integer;
  wcnt: integer;
begin
  wcnt := 0;
  for n := 0 to geo.Waypoints.Count - 1 do
    if geo.Waypoints[n].IsListed then
      inc(wcnt);
  Result := '  <tr>' + CRLF;
  Result := Result + '  <td rowspan='+inttostr(2 * wcnt + 2) +' valign="top"><b>' + geo.ID + '</b></td>' + CRLF;
  Result := Result + '  <td>' + geo.IDtag + '</td>' + CRLF;
  Result := Result + '  <td><b>' + '<A href="' + geo.URL + '">' + geo.Name + '</a></b></td>' + CRLF;
  Result := Result + '  <td><font face="arial, helvetica">' + ansitoutf(geo.GetCoord) + '</font></td>' + CRLF;
  Result := Result + '  </tr>' + CRLF;
  Result := Result + '  <tr>' + CRLF;
  Result := Result + '  <td colspan=3><font size=-1><i>Hint: ' + geo.hint + '</i></font></td>' + CRLF;
  Result := Result + '  </tr>' + CRLF;
  for n := 0 to geo.Waypoints.Count - 1 do
    if geo.Waypoints[n].IsListed then
    begin
      Result := Result + '  <tr>' + CRLF;
      Result := Result + '  <td>' + geo.Waypoints[n].TypeID + ' ' + geo.Waypoints[n].prefixid+ '</td>' + CRLF;
      Result := Result + '  <td><b>' + geo.Waypoints[n].Name + '</b></td>' + CRLF;
      Result := Result + '  <td><font face="arial, helvetica">' + ansitoutf(geo.Waypoints[n].GetCoord) + '</font></td>' + CRLF;
      Result := Result + '  </tr>' + CRLF;
      Result := Result + '  <tr>' + CRLF;
      Result := Result + '  <td colspan=3><font size=-1><i>' + geo.Waypoints[n].Description + '</i></font></td>' + CRLF;
      Result := Result + '  </tr>' + CRLF;
    end;  
end;
 
{This function will be called by the category library and will take care of the export itself}
procedure ExportCallback(const geo: tgeo; const wpt: TWpt; category: string);
begin
    if geo <> nil then
      begin
        exportCounter := exportCounter + 1; //Increment the counter
 
        //handle busy dialog 
        if lastCategory <> category then
        begin
           lastCategory := category;
           GeoBusyKind('Generating HTML output - (' + category + ', ' + IntToStr(CatCategorySize(category))+ ' points)');
        end;
        GeoBusyProgress(exportCounter,CatSize);
 
        //Handle the point export   
        exportData := exportData + GenerateOutputGeo(geo);
      end
    else if wpt <> nil 
      then ShowMessage('Error occured. No waypoints should be added to category library in this demo export!') //Handle the waypoint export
    else ShowMessage('Error occured. Invalid parameters supplied!'); 
end;
 
procedure ExportInit;
begin
  CatInit; //Initialize the category library
  CatSetCallback(@ExportCallback); //Set the callback procedure. This procedure will be called by the category library during the sort process
  CatBeginUpdate; //Start transaction on category library
 
  exportData := ''; //Make sure that the result variable is empty at the beginning
  exportCounter := 0; //Set the number of already exported points to 0
end;
 
{This function returns the data which should be written to the beginning of the exported file}
function ExportHeader: string;
begin
  ExportInit(); //Initialize the export
 
  Result := '<html>' + CRLF;
  Result := Result + '<head>' + CRLF;
  Result := Result + '<title>GeoGet cache list</title>' + CRLF;
  Result := Result + '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' + CRLF;
  Result := Result + '</head>' + CRLF;
  Result := Result + '<body>' + CRLF;
  Result := Result + '<table width="100%" border=0 column=4>' + CRLF;
end;
 
{This function returns the data which should be written to the end of the exported file}
function ExportFooter: string;
begin
  CatEndUpdate; //Close transaction on category library
  CatSort; //Call the main function of the library. This call will ensure that exportData variable will be full of sorted output
  CatFinish; //Free the memory used by the category library
 
  Result := exportData; //Write the exported data to the file
  Result := Result + '</table>' + CRLF + '</body>' + CRLF; //close the file
end;
 
{This function is called after the output is written to the file}
function ExportAfter(value: string): string;
begin
  Result := '';
  RunShell(value); //Open the result file in the browser
end; 

Seznam skriptů, které používají tuto knihovnu

PageDateDescriptionTags
Be-on-road 2012/04/17 12:01 Plugin pro export keší do navigace Be On Road. Autor * mikrom, <mikrom@mikrom.cz> * LudekV - ikony keší à la a:drake Pokud se Vám doplněk líbí, můžete př… , , , , , , , , ,
POI Garmin 2011/12/22 10:57 Skript, který exportuje z Geogetu GPX soubory vhodné pro použití s POI Loaderem. Pomocí POI Loaderu je možné nahrát soubory do navigace jako Vlastní body zájmu … , , , , , , , , , , , , , , ,
POIeTrex 2011/12/22 10:57 Export Geocache do GPS Garmin řady eTrex. Generuje sadu GPX souborů pro program PoiLoader, včetně optimalizovaných ikonek. Autor * HaLuMa * medwyn_cz, med… , , , , , , , , , , , ,
TomTom 2012/05/04 18:07 Export keší do navigací TomTom. Autor mikrom, <mikrom@mikrom.cz> Pokud se Vám doplněk líbí, můžete přispět na jeho vývoj! Pokud se nekamarádíte s PayPalem ja… , , , , , , , , ,

Pokud jste narazili na skript, který knihovnu používá, ale není zde uveden, kontaktujte, prosím, autory.

Stažení

:!: Stáhnout aktuální verzi: category-0.1.3.gip

Seznam dostupných verzí

FilenameLast modified
category-0.1.3.gip (1.89 KiB, 4328 downloads)2011/01/04 20:23
category-0.1.2.gip (1.66 KiB, 106 downloads)2010/11/03 20:58
category-0.1.1.gip (1.64 KiB, 24 downloads)2010/11/03 17:56

Seznam změn

0.1.3 (2011/01/04)

  • Added option to use the library both as a unit and as an includable sorce

:!: Zobrazit změny ve starších verzích

Skrýt změny ve starších verzích

Skrýt změny ve starších verzích

0.1.2 (2010/11/03)

  • Added option to set callback procedure via function

0.1.1 (2010/11/03)

  • Changed from unit to includable source
user/skript/category.txt · Last modified: 2011/12/22 11:27 by gord
CC Attribution-Noncommercial 3.0 Unported
www.chimeric.de Driven by DokuWiki Recent changes RSS feed