2

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

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

...

Thanks!

1

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

if (resultado.numresults > 0)
            {
                // Open layer
                layerUtbs.open();

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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