Opened 20 years ago

Closed 20 years ago

#898 closed defect (wontfix)

check for layer queryability inside query functions

Reported by: sgillies@… Owned by: sgillies@…
Priority: high Milestone:
Component: MapScript-SWIG Version: 4.3
Severity: normal Keywords:
Cc:

Description

New users often get tripped up by the way that mapserver uses layer.template
to control the queryability of a layer.

When a user calls queryByPoint() for example, they expect to get results, and
we could save new users a lot of trouble by setting the template value for
them inside the function if NULL, and then setting it back to NULL.

The queryByPoint method, for example, would become:

    int queryByPoint(mapObj *map, pointObj *point, int mode, double buffer) 
    {
        int retval;
        if (self->template == NULL) {
            // make queryable
            self->template = strdup("query");
            retval = msQueryByPoint(map, self->index, mode, *point, buffer);
            free(self->template);
            self->template = NULL;
        }
        else if (strlen(self->template) < 1) {  // string like ""
            free(self->template);
            self->template = strdup("query");
            retval = msQueryByPoint(map, self->index, mode, *point, buffer);
            free(self->template);
            self->template = strdup("");
        }
        else {
            retval = msQueryByPoint(map, self->index, mode, *point, buffer);
        }
        return retval;            
    }

maybe some macros would be helpful to do this for all the query methods.

Change History (2)

comment:1 by dmorissette, 20 years ago

Cc: warmerdam@… steve.lime@… added
(Adding Frank and Steve to the CC... I think we really need a bug email alias
that includes all developers.)

I'm not sure doing this automatically is a good idea. Normally, you set a
template only in the layers that have meanningful data to query, so a layer
without a template is a legitimate case that needs to be respected by the
application code.

Perhaps what we need is a layer.isQueryable() function that application code can
call before calling queryByPoint(), and if the layer is not queryable then
present an error to the user saying "this layer is not queryable", or just don't
offer this layer as queryable in the user interface.

comment:2 by sgillies@…, 20 years ago

Resolution: wontfix
Status: newclosed
OK, nevermind.

Note: See TracTickets for help on using tickets.