[maplab-users] Can't activate Query Templates

Lorenzo Vaccari lorenzo.vaccari at provincia.tn.it
Wed May 19 09:43:31 EDT 2004


I didn't use templates but I used the following solution:

1) I added some metadata to map file for example:
    METADATA
      "DESCRIPTION"    "Small park"
      "RESULT_ALIAS" "Code Name Altitude Type Area"
      "RESULT_FIELDS" "Bio_cd Bio_na Bio_qt Bio_tp Bio_sup"
    END

2) I added the following routine to query.phtml file:

/************************************************************************/
/*                     function GMapDumpQueryResults()                  */
/*                                                                      */
/*      Produce a table with query results.                             */
/************************************************************************/
function GMapDumpQueryResults($gpoMap )
{
    $numResultsTotal = 0;
    for($iLayer=0; $iLayer < $gpoMap->numlayers; $iLayer++)
    {
        $oLayer = $gpoMap->GetLayer($iLayer);
        $numResults = $oLayer->getNumResults();
        if ($numResults == 0)
            continue;  // No results in this layer
        // Open layer's table... take the list of fields to display from 
        // the "HEADERRESULT_FIELDS" metadata in the layer object.
       // open the layer to make the shape properties available
 if ( strpos( strtoupper( ms_GetVersion() ), "VERSION 3.6") > 0 )
      $oLayer->open( $gpoMap->shapepath );
 else 
      $oLayer->open();
        $selFields = explode(" ", $oLayer->getMetaData("RESULT_FIELDS"));
        $selNameFields = explode(" ", $oLayer->getMetaData("RESULT_ALIAS"));
        printf("<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH=100%%>\n");
        printf("<TR>\n");
        printf("<TD COLSPAN=%d BGCOLOR=#C1D8E3>", sizeof($selFields));
        printf("<CENTER> %s </CENTER>", $oLayer->getMetaData("DESCRIPTION"));
        printf("</TR>\n");   
        //
        // Table header: attribute names...
        //
        printf("<TR>\n"); 
        for ($iField=0; $iField < sizeof($selFields); $iField++)
        {
            printf("<TD BGCOLOR=#E2EFF5>");
            printf("%s",$selNameFields[$iField]);
            printf("</TD>");
        }
        printf("</TR>\n"); 
        // One row in table for each selected record
        //
        for ($iRes=0; $iRes < $numResults; $iRes++)
        {
            $oRes = $oLayer->getResult($iRes);
            $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);
            printf("<TR>\n"); 
            printf("<!-- bounds(%f, %f)-(%f, %f)-->\n", 
                   $oShape->bounds->minx, $oShape->bounds->miny,
                   $oShape->bounds->maxx, $oShape->bounds->maxy);
     
            for($iField=0; $iField < sizeof($selFields); $iField++)
            {
                printf("<TD BGCOLOR=#FFFFFF>");
                printf("%s", $oShape->values[strtoupper($selFields[$iField])]);
                printf("</TD>");
            }
            printf("</TR>\n"); 
            $oShape->free();
            $numResultsTotal++;
        }
        $oLayer->close();
        printf("</TABLE>\n");
    }
    if ($numResultsTotal == 0)
        echo "Nothing found at query location.";
}

3) I modified the query.phtml file to call the routine:
...
    // format the query results
    //$szResults = formatQueryResults( $oResultSet, $aszLayers,$aszTemplate);
    $szResults =GMapDumpQueryResults ( $oMap);
...

4) I hope I don't forget nothing...

--------------------------------------------------------------------
Lorenzino Vaccari
Provincia Autonoma di Trento
Servizio Urbanistica e Tutela del Paesaggio
Sistema Informativo Territoriale
Italy
--------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/maplab-users/attachments/20040519/45e13a64/attachment-0001.htm


More information about the Maplab-users mailing list