MapServer / MapServer-import

3 stars 2 forks source link

check for layer queryability inside query functions #898

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: sgillies@frii.com Date: 2004/09/25 - 18:57

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.
tbonfort commented 12 years ago

Author: dmorissette Date: 2004/09/26 - 14:38

(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.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/09/28 - 15:40

OK, nevermind.