oracle spatial queries
Francesco Sozzi
fsozzi at INTERCAD.CH
Wed Jan 19 03:31:28 PST 2005
Hi,
I send you a couple of parts of my code that works fine with Oracle 9 (I
uses for Polygons, Lines and Points).
This uses QueryByRect, but with some simple changes you can also uses with
QueryByPoint.
Hope this helps.
Regards
Francesco
////////////////////////////////////////////////////////////////////////
...
////////////////////////////////////////////////////////////////////////
//set current extent (got in map coordinates)
$extentMapCoordStr = explode(" ",$hiddenMapCurrentExtent);
$gMap->setextent($extentMapCoordStr[0],
$extentMapCoordStr[1],
$extentMapCoordStr[2],
$extentMapCoordStr[3]);
//get box drawned extent (in screen coordinates)
$rectDrawnedScreenCoord = explode(" ",$hiddenMapImageBox);
$minXObj=hlpPixelToGeo($gMap,$rectDrawnedScreenCoord[0],$rectDrawnedScreenCo
ord[1]);
$maxXObj=hlpPixelToGeo($gMap,$rectDrawnedScreenCoord[2],$rectDrawnedScreenCo
ord[3]);
$rectDrawnedMapCoord = ms_newrectObj();
$rectDrawnedMapCoord->setextent($minXObj->x,
$minXObj->y,
$maxXObj->x,
$maxXObj->y);
//get layer
$isLayerFound=FALSE;
for($idxLayer=0;$idxLayer<$gMap->numlayers;$idxLayer++)
{
$layer=$gMap->getLayer($idxLayer);
if($layer->name!=$hiddenCurLayer) continue;
$isLayerFound=TRUE;
break;
}
if(!$isLayerFound) break;
//set query
$qresult = @$layer->queryByRect($rectDrawnedMapCoord);
////////////////////////////////////////////////////////////////////////
...
////////////////////////////////////////////////////////////////////////
function hlpPixelToGeo($map,$x,$y) {
$minx = $map->extent->minx;
$miny = $map->extent->miny;
$maxx = $map->extent->maxx;
$maxy = $map->extent->maxy;
$dx = $maxx - $minx;
$dy = $maxy - $miny;
$width = $map->width;
$height = $map->height;
$dxpp = (double)$dx/$width;
$dypp = (double)$dy/$height;
$geox = $minx + $dxpp*$x;
$geoy = $maxy - $dypp*$y;
$pointObj = ms_newPointObj();
$pointObj->setXY($geox,$geoy);
return $pointObj;
}
----- Original Message -----
From: "Solomon Maina Thuo" <solo6259 at YAHOO.COM>
To: <MAPSERVER-USERS at LISTS.UMN.EDU>
Sent: Wednesday, January 19, 2005 11:08 AM
Subject: [UMN_MAPSERVER-USERS] oracle spatial queries
> hi guys. i got problems performing querybypoint. i am connecting to
> oraclespatial 9.0 rv 2 running on a linux box. i am using mapserver 4.2
and
> so have i have been able to solve most problems relating to connecting to
> the database and displaying layers. i am using the native connection
> method. the problem is that i don't know how to query the databse about
> specific points. just don't know how. please help
>
>
More information about the MapServer-users
mailing list