[Mapserver-users] Query by point shape and tile indexes are -1
Will Richardson
willrichardson at teq-services.com
Tue Mar 9 10:45:18 PST 2004
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() );
}
More information about the MapServer-users
mailing list