[Mapserver-users] queryByShape explanation please
Gijs Epping
gijs at gijs.com
Fri Mar 19 08:49:12 PST 2004
Hello,
I have some problems with the polygon shape query on a multiple point
shape file, Could some body explane it to me how i can get the data from
the points that lay in the polygon zone. The areacode layer is just some
point data. At the moment it gives this error:
Warning: [MapServer Error]: msQueryByShape(): No matching record(s)
found.
But in the zone are I think 100 point present.
This is the code that generates the polygon circle thanks to the some
Mapserver users.
Thanks in advance.
G
********************* CODE ***********************
function createPoint( $x1, $y2, $programId, $radius, $name, $color,
&$oShp)
{
GLOBAL $map;
$shpFname = "/var/www/html/atmsv03/$name";
$shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POLYGON);
$dbfFile = dbase_create( $shpFname.".dbf", array(array("ID", "N", 5,
0)));
// Create shape
$oShp = ms_newShapeObj(MS_SHAPE_POLYGON);
$oLine = ms_newLineObj();
$pointObj = ms_newPointObj();
for ($i = 0; $i <= 360; $i = $i + 10)
{
$x = $x1 + (cos($i * (22 / 7) / 180) * $radius);
$y = $y2 - (sin($i * (22 / 7) / 180) * $radius);
$pointObj->setXY($x, $y);
$oLine->add($pointObj);
}
$oShp->add($oLine);
$shpFile->addShape($oShp);
// Write attribute record
dbase_add_record($dbfFile, array($programId));
$shpFile->free();
dbase_close($dbfFile);
$layer = ms_newlayerObj($map);
$layer->set("name", "dangerZone");
$layer->set("type", MS_LAYER_POLYGON);
$layer->set("status", MS_ON);
$layer->set("data", $name);
$layer->set("transparency", 30);
$class = ms_newClassObj($layer);
$style = ms_newStyleObj($class);
$arr=explode(",", $color);
$style->color->setRGB($arr[0],$arr[1],$arr[2]);
}// end function
if ($postcode)
{
createPoint($punt[0], $punt[1], 1, 1000, 'name', '0,0,0', $oShp);
}
$lay = $map->getLayerByName("areacode");
$lay->queryByShape($oShp);
More information about the MapServer-users
mailing list