[Mapserver-users] Query by point shape and tile indexes are -1

Will Richardson willrichardson at teq-services.com
Tue Mar 9 14:26:25 EST 2004


sorry, the problem is that shapeindex is -1 and tileindex is -1 so getShape 
returns a null object as it can't find any shape. I am using mapscript for 
mapserver 3.6.3 as this is the only version i have found that i can get java 
mapscript to work.

my understanding is that the shape and tile index would be set in the layer 
after i add a feature but then when i query the layer i do find 1 
resultCacheMemberObj but the values in there are -1. How do i fix this?

in the java mapscript version i have, the code you have below is wrapped so 
that the java method i call (getShape) does return a shapeObj.

thanks

Quoting Sean Gillies <sgillies at frii.com>:

> On Mar 9, 2004, at 11:45 AM, Will Richardson wrote:
> 
> > Hello,
> >
> > I am trying to do a query after i add a feature to a layer and the 
> > shape and
> > tile indexes are -1 so i can't get the shape that was queried. Below 
> > is my
> > code in java, if you have any suggestions, please let me know.
> >
> > thanks
> >
> >             layerObj layer = map.getLayerByName( "towermark" );
> >             layer.setStatus( MapScript.MS_ON );
> >
> >             pointObj myHouse = new pointObj();
> >             myHouse.setX( -104.06478597176886 );
> >             myHouse.setY( 38.46972580576644 );
> >
> >             lineObj line = new lineObj();
> >             line.add( myHouse );
> >             shapeObj shape = new shapeObj( MapScript.MS_SHAPE_POINT );
> >             shape.add( line );
> >             layer.addFeature( shape );
> >
> >             imageObj image = map.draw();
> >
> >             pointObj queryPoint = new pointObj();
> >             queryPoint.setX( -104.06478597176886 );
> >             queryPoint.setY( 38.46972580576644 );
> >             int result = layer.queryByPoint( map, queryPoint,
> > MapScript.MS_SINGLE, 10 );
> >
> >             System.out.println( "result of query: " + result );
> >             System.out.println( "MS_SUCCESS: " + MapScript.MS_SUCCESS 
> > );
> >             System.out.println( "MS_FAILURE: " + MapScript.MS_FAILURE 
> > );
> >
> >             resultCacheObj cache = layer.getResultcache();
> >             //prints 1
> >             System.out.println( "number of results: " + 
> > cache.getNumresults
> > () );
> >
> >             resultCacheMemberObj resultObj = layer.getResult( 0 );
> >             System.out.println( "shape index: " + 
> > resultObj.getShapeindex() );
> >             System.out.println( "tile index: " + 
> > resultObj.getTileindex() );
> >             System.out.println( "Class index: " + 
> > resultObj.getClassindex() );
> >
> >             shape = layer.getShape( resultObj.getTileindex(),
> > resultObj.getShapeindex() );
> >             if ( shape != null )
> >             {
> >                 System.out.println( "shape.getNumvalues(): " +
> > shape.getNumvalues() );
> >             }
> > ______
> 
> 
> Will,
> 
> I think you forgot to ask your question ... you want to know why
> getShape doesn't work as expected?
> 
> You don't say so, but I am assuming you are using a Java mapscript from
> Mapserver 3.x?  True?  Well, one problem is that getShape doesn't
> return a shapeObj.  Your code will have to be something like this:
> 
> shapeObj shape = shapeObj(layer.type);
> layer.getShape(shape, resultObj.getTileindex(), 
> resultObj.getShapeindex());
> 
> Hope this helps,
> Sean
> 
> --
> Sean Gillies
> sgillies at frii dot com
> http://users.frii.com/sgillies
> 
> 






More information about the mapserver-users mailing list