diff --git a/admin/shapefile.php b/admin/shapefile.php index c8b2977..d0f897c 100644 --- a/admin/shapefile.php +++ b/admin/shapefile.php @@ -10,7 +10,6 @@ // Query -require_once("../config.db.php"); require_once ("../config.php"); @@ -22,13 +21,14 @@ $coords_array = array (); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $coords_array[]=$row; } +//DEBUG echo "
"; print_r($coords_array); echo "
"; // If no results are found, echo a message and stop //if ($coords_array == false) { echo "No results"; exit; } -unlink ("shape/ideenmelder.shp"); -unlink ("shape/ideenmelder.dbf"); -unlink ("shape/ideenmelder.shx"); +if (file_exists("shape/ideenmelder.shp")) {unlink ("shape/ideenmelder.shp");} +if (file_exists("shape/ideenmelder.dbf")) {unlink ("shape/ideenmelder.dbf");} +if (file_exists("shape/ideenmelder.shx")) {unlink ("shape/ideenmelder.shx");} //unlink ("shape/ideenmelder.dbt"); require_once('../vendor/Shapefile/ShapefileAutoloader.php'); @@ -43,10 +43,9 @@ use Shapefile\Geometry\Point; try { // Open Shapefile $Shapefile = new ShapefileWriter('shape/ideenmelder.shp'); - // Set shape type + $Shapefile->setShapeType(Shapefile::SHAPE_TYPE_POINT); - // Create field structure $Shapefile->addNumericField('ID', 10); $Shapefile->addCharField('DESC'); @@ -55,7 +54,7 @@ try { $Shapefile->addCharField('DEFECT',60); foreach ($coords_array as $coords) { - //echo "Coords ".$coords['id'].":";print_r($coords);echo "
"; + //DEBUG echo "Coords ".$coords['id'].":";print_r($coords);echo "
"; // Create a Point Geometry $lat=$coords['lat']; $lon=$coords['lng'];