Add polygon in shapefile
"LAGACHE Alexandre - VNF/Dir. Infrastructure-Environnement/Div. Géo Carto"
Alexandre.Lagache at VNF.FR
Thu Feb 9 06:36:04 PST 2006
Hello All,
I'd like to dynamically add polygons to a shapefile (php mapscript 4.80b).
Here is what I do :
$zone_shp = ms_newShapefileObj("zone_shp", MS_SHP_POLYGON);
$shape = ms_newShapeObj(MS_SHAPE_POLYGON);
$ecluse_sel_a = ms_newPointObj();
$ecluse_sel_a-> setxy($mix,$miy);
$ecluse_sel_b = ms_newPointObj();
$ecluse_sel_b-> setxy($mix,$may);
$ecluse_sel_c = ms_newPointObj();
$ecluse_sel_c-> setxy($max,$may);
$ecluse_sel_d = ms_newPointObj();
$ecluse_sel_d-> setxy($max,$miy);
$line_a = ms_newLineObj();
$line_a->add($ecluse_sel_a);
$line_a->add($ecluse_sel_b);
$line_b = ms_newLineObj();
$line_b->add($ecluse_sel_b);
$line_b->add($ecluse_sel_c);
$line_c = ms_newLineObj();
$line_c->add($ecluse_sel_c);
$line_c->add($ecluse_sel_d);
$line_d = ms_newLineObj();
$line_d->add($ecluse_sel_d);
$line_d->add($ecluse_sel_a);
$shape->add($line_a);
$shape->add($line_b);
$shape->add($line_c);
$shape->add($line_d);
$zone_shp->addShape($shape);
$shape->free();
$zone_shp->free();
It seems to work fine but when I look at the layer, objects are multiline
instead of polygons...
Any idea ??? What am I doing wrong ?
Thanks !
Alexandre LAGACHE
More information about the MapServer-users
mailing list