GeoGet

Complete geocaching solutions

User Tools

Site Tools


user:skript:category

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
user:skript:category [2010/11/03 19:19] medwyn_czuser:skript:category [2021/05/02 19:02] (current) – [Stažení] mikrom
Line 1: Line 1:
 ====== Category ====== ====== Category ======
-FIXME /* Stručný popis funkce skriptu. Prvních cca 140 znaků popisu se zobrazuje automaticky generovaných seznamech stránekTento text by měl uživateli objasnit, k čemu je skript vhodný*/+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 pořadí tak, jak jsou zobrazena v načteném seznamuPomocí 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 ===== ===== Autor =====
-  * **[[http://www.geocaching.com/profile/?u=HaLuMa|HaLuMa]]** - kód +  * **[[http://www.geocaching.com/profile/?u=HaLuMa|geby]]** - kód 
-  * **[[http://www.geocaching.com/profile/?u=medwyn_cz|medwyn_cz]]** - testování, drobné úpravy+  * **[[http://www.geocaching.com/profile/?u=medwyn_cz|medwyn_cz]]** - testování, drobné úpravy, ukázkové exportní makro
  
 ===== Automatická instalace ===== ===== Automatická instalace =====
Line 16: Line 17:
  
 ==== Dostupné funkce ==== ==== Dostupné funkce ====
 +  * Seřazeny tak, jak budou pravděpodobně při používání volány
 +
 +<code delphi>procedure CatInit;</code>
 +  * Initializes the library
 +  
 +<code delphi>procedure CatSetCallback(callback : TCatCallback);</code>
 +  * 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: <code delphi>procedure(const geo: tgeo; const wpt: TWpt; category: string)</code> 
 +
 <code delphi>procedure CatBeginUpdate;</code> <code delphi>procedure CatBeginUpdate;</code>
   * Starts new transaction   * Starts new transaction
- 
-<code delphi>procedure CatEndUpdate;</code> 
-  * Commits the transaction 
  
 <code delphi>procedure CatAddGC(GC: TGeo; category: string);</code> <code delphi>procedure CatAddGC(GC: TGeo; category: string);</code>
Line 40: Line 47:
   * Returns count of points in given category   * Returns count of points in given category
  
-<code delphi>procedure catFinish;</code>+<code delphi>procedure CatEndUpdate;</code> 
 +  * Commits the transaction  
 + 
 +<code delphi>procedure CatFinish;</code>
   * Frees up the category database.    * Frees up the category database. 
  
-/* ==== Ukázka ==== +==== Ukázkové exportní makro ==== 
-Pokud je to možné vhodnéměl by popis obsahovat snímky obrazovek jak vypadají ovládací dialogy skriptujak vypadají výstupy exportu a podobně*/+ 
 +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**. 
 + 
 +<code delphi 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 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="arialhelvetica">' + 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="arialhelvetica">' + 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;  
 +</code>
  
 /* ===== Instalace ===== /* ===== Instalace =====
Line 54: Line 193:
 /* ===== Poznámky, známé problémy ===== /* ===== Poznámky, známé problémy =====
 Případné poznámky ke skriptu - např. další plán vývoje, známé chyby apod. */ Případné poznámky ke skriptu - např. další plán vývoje, známé chyby apod. */
 +
 +===== Seznam skriptů, které používají tuto knihovnu =====
 +{{topic>uses_category}}
 +
 +Pokud jste narazili na skript, který knihovnu používá, ale není zde uveden, kontaktujte, prosím, autory.
  
 ===== Stažení ===== ===== Stažení =====
-<box round 95% #DEE7EC+<WRAP round download
-:!: Stáhnout aktuální verzi: ~~DOWNLOAD category-*.gip highest~~ +Stáhnout aktuální verzi: ~~DOWNLOAD category-*.gip highest~~ 
-</box>+</WRAP>
  
 ==== Seznam dostupných verzí ==== ==== Seznam dostupných verzí ====
Line 64: Line 208:
  
 ===== Seznam změn ===== ===== Seznam změn =====
-=== 0.1.(2010/11/03) === +=== 0.1.(2011/01/04) === 
-   Changed from unit to includable source           +   Added option to use the library both as a unit and as an includable sorce 
 +   
 <hidden onHidden=":!: **Zobrazit změny ve starších verzích**" onVisible="Skrýt změny ve starších verzích"> <hidden onHidden=":!: **Zobrazit změny ve starších verzích**" onVisible="Skrýt změny ve starších verzích">
-=== 0.1 (2010/11/03) === +=== 0.1.2 (2010/11/03) === 
-   Úvodní verze +   Added option to set callback procedure via function   
 + 
 +=== 0.1.1 (2010/11/03) === 
 +   * Changed from unit to includable source  
 </hidden> </hidden>
  
-{{tag>skript lib}}+{{tag>author_geby author_medwyn skript lib}}
  
user/skript/category.1288808369.txt.gz · Last modified: 2010/11/03 00:00 (external edit)