1

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"
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 6, 2011 at 2:40

1 Answer 1

2

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);
 }
 }
answered Jul 6, 2011 at 7:42
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.