[OpenLayers-Dev] [OpenLayers-Trac] [OpenLayers] #1324: OpenLayers.Feature.Vector.clone() must clone the fid property.

Roald de Wit rdewit at users.sourceforge.net
Mon Feb 11 17:54:28 EST 2008


Hi,

On Mon, 2008-02-11 at 09:17 -0500, Christopher Schmidt wrote:
> On Thu, Feb 07, 2008 at 03:18:55PM -0000, OpenLayers wrote:
> > #1324: OpenLayers.Feature.Vector.clone() must clone the fid property.
> 
> Anyone have thoughts on this? I'm not sure if we should be cloning this,
> since it feels to me like a clone is a different object, and fids should
> be unique...

If the requirement is that an object must always have a unique fid, then
not cloning the fid is also insufficient.

You'd have to create a new unique fid. The simplest way would be copying
the original fid and adding a random number, like: 

newObject.fid = oldObject.fid + "_" + Math.round(Math.random() * 1000));

(OK, it's not guaranteed it is unique)

If somebody for some reason wants to keep the old fid, he./she can
simply copy the old fid to the new object after cloning.

2 my cents.

Roald

-- 
Roald de Wit
Software Engineer
roald.dewit at lisasoft.com

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/




More information about the Dev mailing list