Getting MAX FEATURES to work for postgis Layers

Newland Agbenowosi newland at VT.EDU
Sat Sep 4 14:48:03 EDT 2004


Dear all,
I noticed that the layer MAX FEATURES option in the mapfile does not work
for postgis layers.  I managed to fix this by editing the mappostgis.c file
as shown below.  My question is: am I doing this the right way or am missing
something?

Thanks.

        //start transaction required by cursor

    result = PQexec(layerinfo->conn, "BEGIN");
    if (!(result) || PQresultStatus(result) != PGRES_COMMAND_OK)
    {
              msSetError(MS_QUERYERR, "Error executing POSTGIS  BEGIN
statement.",
                 "msPOSTGISLayerWhichShapes()");

                PQclear(result);
                layerinfo->query_result = NULL;
                return(MS_FAILURE);             // totally screwed
    }


    PQclear(result);
        //set enable_seqscan=off not required (already done)
//--BEGINNING OF MY FIX
        if (layer->maxfeatures>0)
                        sprintf(query_string_0_6,"%s limit %li",
query_string_0_6,layer->maxfeatures);
//--END OF MY FIX
        if (layer->debug)
                msDebug("query_string_0_6:%s\n",query_string_0_6);
    result = PQexec(layerinfo->conn, query_string_0_6 );

    if ( (result!=NULL) && (PQresultStatus(result) == PGRES_COMMAND_OK) )
    {
                //PQclear(result);
                *sql_results = result;
                strcpy(query_string, query_string_0_6 );
                return (MS_SUCCESS);
    }



More information about the mapserver-users mailing list