Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More
( 7 months ago )

PHP MapScript - Query GDB Geodatabase?

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Deepak Parmar

User

( 7 months ago )

 

For anyone new to Mapscript or in a similar situation, I ended up having too much with extent and bounds and just needed to simplify to match my buildings.map file and this code gets it done in a map file with no TEMPLATE:

$map = new mapObj($map_path."buildings.map");
$layer = $map->getLayer(0);
$status = $layer->open();
while ($shape = $layer->nextShape()) {
    echo $shape->index ."=>";
    echo 'Type='.$shape->type.'<br>';
    print_r($shape->values);
}
$layer->close();

usr_profile.png
Karlie Kloss

User

( 7 months ago )

 

I'm trying to use/learn some PHP MapScript on a GDB file and cannot get anything from it.

The PHP below works great if I use countries.sqllite (via countries.map) file I have and shows me an array of countries both in a for and while loop.

However, when I switch and point to a buildings.gdb file (via buildings.map) I get an error of "msQueryByRect(): No matching record(s) found." for the first for loop and blank or no data for the while loop.

Both .map files just point to the one layer and show fine as WMS in OpenLayers and in QGIS.

I've been searching through PHP MapScript API stuff all afternoon (starting with https://mapserver.org/mapscript/php/phpmapscript.html) and found nothing to help me, and am asking if there is anything I missed or any special considerations I need to use MapScript a GDB file.

$map_path = "/ms4w/maps/";
$map = ms_newMapObj($map_path."buildings.map");
$map = ms_newMapObj($map_path."countries.map");
print_r($map);

$layers = $map->getAllLayerNames();           print_r($layers);
$myLayerName = $layers[0];                    echo '|'.$myLayerName.'|<br>';


$l = $map->getLayerByName($myLayerName);      print_r($map->extent);
$l->queryByRect($map->extent);
for ($i=0; $i<$l->getNumResults();$i++){
    $s = $l->getShape($l->getResult($i));
    echo $i.'=';                              print_r($s->values);
}

$layer = $map->getLayer(0);                 print_r($layer);
$status = $layer->open();                   print_r($status.'<br>');
$extent = $map->extent;                     print_r($extent);
$status = $layer->whichShapes($extent);     print_r('<hr>'.$status.'<hr>');
while ($shape = $layer->nextShape()) {
    echo $shape->index ."=>";               print_r($shape->values);
}
$layer->close();

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif