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

Eric Bridger eric at gomoos.org
Tue Mar 9 15:21:18 EST 2004


queryByPoint() returns 0 on success and 1 on failure. I know that's not
much help, but explains the -1 shapeindex, etc.

Do you have a TEMPLATE defined in your towermark layer? Even if it is
never used it must be there to make the layer queryable.

The other issue is that since you are creating the shape on the fly
there really is no shape index associated with it unless you set it
explicitly.

BTW, addFeature() can be used exactly this way to make the point
queryable even when there is no shape file associated with it, but what
will be returned in this case is the index property of the shape. I'm
not familiar with the java mapscript syntax, but in perl I always do
something like:

$shape->{index} = $i;

It is $i which will be returned in the query cache as the shape index.

HTH

Eric


On Tue, 2004-03-09 at 14:26, Will Richardson wrote:
> 
> 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
> > 
> > 
> 
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the mapserver-users mailing list