Open a shapefile and read its shapes' attributes

Jedi Knight friendvn2000 at YAHOO.COM
Wed Jul 11 23:11:22 EDT 2007


Hi all,
I want to open a line shapefile (routes.shp) and read attribute (RouteName)
from it.
My codes here:
<?php 
		$Path = '\ms4w\apps\map\routes.shp'; // must use full path [:(]
		$LineFile = ms_newShapefileObj($Path,-1); // open for read-only
		$numshapes = $LineFile->numshapes;				
		if($numshapes > 0)
		{		
			for($i = 0; $i < $numshapes; $i++)
			{
				$Line = $LineFile->getShape($i);				
				$RouteName  = $Line->values["RouteName"];
				printf($RouteName ); // it show nothing
				$Line->free();
			}	
		}		
		$LineFile->free();
?>

But it doesn't works!
Can someone explain to me. Thanks!



More information about the mapserver-users mailing list