Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm doing a spatial query, but I always get an error:

"msPOSTGISLayerGetShape(): Query error. msPOSTGISLayerGetShape called on unopened layer (layerinfo = NULL)"

This is my code:

layerObj layerUtbs = Util.MSMap.getLayerByName("Utbs");
if (layerUtbs.queryByRect(Util.MSMap, rect) == (int)MS_RETURN_VALUE.MS_SUCCESS)
    resultCacheObj resultado = layerUtbs.getResults();

    if (resultado.numresults > 0)
        // here i got a error.
        layerUtbs.getFeature(resultado.getResult(0).shapeindex, resultado.getResult(0).tileindex);

Here's my map file configuration

        CONNECTIONTYPE postgis 
        NAME "Utbs" 
        CONNECTION "user=pmc dbname=SiteInovacao host=localhost password=123 port=5432"
        DATA "geom from (SELECT *, oid FROM pmc.utbs) as utbs using unique oid using srid=31983"



share|improve this question

1 Answer 1

up vote 1 down vote accepted

Its basically telling you whats wrong- you have not 'opened' the layer Try this:

if (resultado.numresults > 0)
                // Open layer

                // here i got a error (you shouldn't now);.
                layerUtbs.getFeature(resultado.getResult(0).shapeindex, resultado.getResult(0).tileindex);
share|improve this answer
This is exactly what i want!! Thank you very much!! – Michel Andrade Jul 6 '11 at 12:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.