[Shapelib] Delete or hide Shape from Shapefile

Jelmer Baas Baas at speerit.nl
Tue May 12 07:49:52 PDT 2009


> > Hello,
> > 
> > I'm looking for a way to remove or hide a shape in a shape file. I'm
> > using MapServer to draw it, so it needs to be supported by 
> MapServer,
> > too. 
> > 
> > The PDF found on the shapelib page shows there's a shapetype 0 (Null
> > Shape), can't that somehow be used? Otherwise overwrite the style to
> > have a width of 0, something like that? I find it hard to 
> believe that
> > ESRI apps rewrite the entire file when a single object is 
> deleted... 
> > 
> The normal approach to this is to call DBFMarkRecordDeleted() 
> which flips
> the bit in the DBF file marking a record as deleted.  
> However, I see no
> evidence that the MapServer native shapefile code checks the deleted
> marker so this isn't likely to help you with MapServer.
> 
> I think replacing the shape with a SHPT_NULL shape is the next best
> alternative.

Frank,

Thank you for your quick reply. I tried setting the shpType to
NullShape, but this somehow doesn't seem to affect MapServer... I
verified the results and my modified shapefile is indeed different than
the original, and after re-loading the shpType is still 0. Setting the
vertices coordinates to zero *DID* have a result. 

Seems like the only way to somehow mark an item for deletion is to move
it to 0,0 and every now and then build a new shapefile with these shapes
excluded. 

If you have any other ideas, please let me know.

I'm happy at least the shapelib works in read/write mode. Thanks for all
your hard work.

-- 
Jelmer




More information about the Shapelib mailing list