Creation of shapefiles (PHP)

Matt Brown mbrown at AL1CALL.COM
Fri Jan 21 06:49:49 PST 2005


Jorge,

I don't know if this is the problem, but you might try building one line,
instead of four, and make sure that the beginning and ending points are the
same.  then add the line object to the shape object

Matt

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
Behalf Of Jorge Gaspar Sanz Salinas
Sent: Friday, January 21, 2005 8:24 AM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] Creation of shapefiles (PHP)


Hello,

With PHP/MapScript, I'm trying to create a simple shapefile with one
rectagle dinamically from some points. The shapefile is been created but
it seems not in the correct way. This I say, when I make a dynamic layer
with it, seems like a polyline because MapServer doesn't fill it.

In ArcMap the polygon has no area and can't draw it properly (without
color) as MapServer.

I work with Mapserver44, WindowsXP (PRO SP2) and PHP4.3.8

MapServer version 4.4.0-beta2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF SUPPORTS=PROJ SUPPORTS=FREETYPE
SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER INPUT=POSTGIS INPUT=OGR
INPUT=GDAL INPUT=SHAPEFILE

PHP 4.3.8 (cgi-fcgi) (built: Jul 13 2004 17:36:43)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


The code to generate the shapefile is (four lines are created few lines
before):
//**************************************************
//Add four lines to the ShpObj
$shpObj = ms_newShapeObj(MS_SHAPE_POLYGON);
$shpObj->add($linW);
$shpObj->add($linS);
$shpObj->add($linE);
$shpObj->add($linN);

//Generate a unique filename
$szFileRect = $mapa->web->imagepath . uniqid("");

//Define a shapefile object
$shpRect = ms_newShapefileObj($szFileRect, MS_SHP_POLYGON);

//Create a new DBF attached with one attribute
$hDbf = dbase_create($szFileRect.".dbf",array(array("NAME", "C", 50, 0)));
if (!$hDbf)
   return;

//Add the shpobj to the shapefile
$shpRect->addShape($shpObj);

//Add the attribute
$atts[0] = "Experimento";
dbase_add_record($hDbf, $atts);

//Close the objects
$shpObj->free();
dbase_close($hDbf);
$shpRect->free
//**************************************************


Thanks,
--
Jorge Gaspar Sanz Salinas
Departamento de Ingeniería Cartográfica, Geodesia y Fotogrametría
Universidad Politécnica de Valencia



More information about the MapServer-users mailing list