PHP Classes

Improvements

Recommend this page to a friend!

      Shape File Reader  >  All threads  >  Improvements  >  (Un) Subscribe thread alerts  
Subject:Improvements
Summary:Error handling and new recordtype
Messages:2
Author:Nick Parker
Date:2009-10-15 11:04:48
Update:2009-10-15 11:06:43
 

  1. Improvements   Reply   Report abuse  
Picture of Nick Parker Nick Parker - 2009-10-15 11:04:48
When the class meets ShapeFile record types it doesn't know
it just gives back an empty array. Not very useful.
Here are some suggestions for modification:

Add error handling to the example:
46,53c46,48
< if ( $shp_data === false )
< echo '<p>' . $record->getError() . '</p>' ;
< else
< {
< //Dump the information
< var_dump($dbf_data);
< var_dump($shp_data);
< }
---
> //Dump the information
> var_dump($dbf_data);
> var_dump($shp_data);

The record type PolygonZ is exactly the same as Polygon exacept for Z information at the end. If you're not interested in that then the following mod allows you to read the PolygonZ records:
217,218c212
< 5 => "RecordPolygon",
< 15 => "RecordPolygon");
---
> 5 => "RecordPolygon");

The function getShpData doesn't return the error condition. This modification allows it to:
276c270
< return ( $this->setError( sprintf(INEXISTENT_FUNCTION, $
function_name) ) ) ;
---
> $this->setError( sprintf(INEXISTENT_FUNCTION, $function_
name) );

  2. Re: Improvements   Reply   Report abuse  
Picture of Nick Parker Nick Parker - 2009-10-15 11:06:43 - In reply to message 1 from Nick Parker
Sorry the diff was back-to-front in the suggested modifications.