0

All,

I am writing an app that produces 64800 polygons and I want each of them to have a unique time stamp. The problem is that my script runs in about 3 seconds which means that there are exactly 3 unique dates spread across all 64k polygons. I've tried going back in time using timedelta() which does actually go back in time from utcnow() but the problem is that it still iterates for 3 seconds with the 3 unique date stamps. I have been working on variations of this...

def time():
    now = datetime.datetime.utcnow()
    start_day = datetime.timedelta(days=-2000)
    timer = now + start_day

Can anyone lend a hand to get me to the 64800 unique time stamps?

Thanks, Adam

aeupinhere
  • 2,883
  • 6
  • 31
  • 39
  • You could try to generate a pseudo timestamp. With python you cant have a better resolution than 1s on some systems. Try multiplicating your timestamp by a million or 100 thousand and then increment it. You will not get an accurate timestamp, but an chronologic set of timestamps. – Lynch Jul 04 '11 at 23:57

1 Answers1

1

You could add a polygon counter to the generated timestamp to differentiate each polygon from the previous one. As a matter of fact, if you do not need accurate wall-clock timestamps - and your messing with the timestamps with timedelta() indicates that you do not - you could even use an abritrary counter as your clock, as long as it's atomically increased.

If you do need accurate timestamps, you could try for sub-second resolution, as mentioned here. Keep in mind, however, that many systems will only provide timestamps in increments of several milli-seconds, which is still plenty of time for more than one polygon to be created, so you will still have to use an additional counter or something similar to create unique timestamps.

We might be able to help you more if you mentioned what these timestamps will be used for...

Community
  • 1
  • 1
thkala
  • 84,049
  • 23
  • 157
  • 201
  • Well...I am trying to animate the kml which means that each of these polygons must have a unique timestamp like this 2006-01-12T00:58:29Z. You're right in that the date can be totally fake which makes this a lot easier. – aeupinhere Jul 05 '11 at 00:17