[Mapserver-users] Dynamic Layer problems
Fernando S.
simon at inf.univali.br
Fri Jul 16 10:44:47 PDT 2004
Hi list,
I'm using PHP/MapScript to add features in one layer. And after I
try to query this layer using the function "queryByPoint". So, when I
execute the function "getResult(0)", this function return "shapeindex"
equal -1. I don't want return data information from function "values",
I only want return shapeindex.
When I execute the function "getNumResults()", the mapserver return
value 1, so how return the shapeindex for dynamic layer?
I'm using this php/mapscript code:
...
function transform_pixel_to_world( &$point, $map ){
$x0 = $map->extent->minx;
$y0 = $map->extent->miny;
$deltaX = $map->extent->maxx - $map->extent->minx;
$deltaY = $map->extent->maxy - $map->extent->miny;
$x = $point->x/$map->width*$deltaX + $x0;
$y = ($map->height - $point->y)/$map->height*$deltaY + $y0;
$point->setXY( $x, $y );
}
...
$glogger = $map->getLayerByName( "Glogger" );
foreach( $locations as $location ) {
$shp = ms_newShapeObj( MS_SHAPE_POINT );
$geom = ms_newLineObj();
$geom->addXY( $location["Long"], $location["Lat"] );
$shp->add( $geom );
$glogger->addFeature( $shp );
}
...
$click = ms_newPointObj();
$click->setXY( $_GET["map_x"], $_GET["map_y"] );
if ($action=="query") {
$mapext_lst = explode( " ", $_GET["mapext"] );
$map->extent->setextent( $mapext_lst[0], $mapext_lst[1],
$mapext_lst[2], $mapext_lst[3] );
transform_pixel_to_world( $click, $map );
$glogger = $map->getLayerByName( "Glogger" );
$glogger->queryByPoint( $click, MS_SINGLE, 0 );
$total_results = $glogger->getNumResults(); //Return 1
$sindex = $glogger->getResult(0); //Return shapeindex equal -1 }
......
This is the mapfile code:
...
LAYER
NAME "Glogger"
STATUS ON
TYPE POINT
FEATURE
END
CLASS
NAME "Places"
SYMBOL "Circle"
SIZE 8
COLOR 0 255 0
OUTLINECOLOR 0 0 0
END
TOLERANCE 5
TOLERANCEUNITS pixels
TEMPLATE "anything.html"
END
...
Thank's.
==========================================================================
Fernando Simon - simon at inf.univali.br
DataBase Manager, Mapserver, OracleSpatial and MapOracleSpatial Developer
G10 - Laboratório de Computação Aplicada
http://g10.cttmar.univali.br
==========================================================================
More information about the MapServer-users
mailing list