예제 #1
0
 def __init__(self, options):
     self.name = options['name']
     self.hidden = True
     self.stopped = True
     if 'type' in options:
         self.type = options['type']
     else:
         self.type = 'character'
     self.setted_lon = options['lon']
     self.setted_lat = options['lat']
     self.curr_lon = self.setted_lon
     self.curr_lat = self.setted_lat
     self.head_lon = self.setted_lon
     self.head_lat = self.setted_lat
     self.heading_change = 0
     self.speed = [0, 0]
     self.db_object = CartoDb_object(cartoPy)
예제 #2
0
 def __init__(self, options):
   self.name = options['name']
   self.hidden = True
   self.stopped = True
   if 'type' in options:
     self.type = options['type']
   else:
     self.type = 'character'
   self.setted_lon = options['lon']
   self.setted_lat = options['lat']
   self.curr_lon = self.setted_lon
   self.curr_lat = self.setted_lat
   self.head_lon = self.setted_lon
   self.head_lat = self.setted_lat
   self.heading_change = 0
   self.speed = [0, 0]
   self.db_object = CartoDb_object(cartoPy)
예제 #3
0
class Character:
  import_version = 21
  def __init__(self, options):
    self.name = options['name']
    self.hidden = True
    self.stopped = True
    if 'type' in options:
      self.type = options['type']
    else:
      self.type = 'character'
    self.setted_lon = options['lon']
    self.setted_lat = options['lat']
    self.curr_lon = self.setted_lon
    self.curr_lat = self.setted_lat
    self.head_lon = self.setted_lon
    self.head_lat = self.setted_lat
    self.heading_change = 0
    self.speed = [0, 0]
    self.db_object = CartoDb_object(cartoPy)
  def change_heading(self, options):
    if 'hidden' in options:
      self.heading_change = options['round']
      if options['hidden'] == True:
        self.hidden = True
      else:
        self.hidden = False

    if not 'stopped' in options:
      self.hidden = False
      self.stopped = False
      self.heading_change = options['round']
      self.head_lon = options['coordinates']['lon']
      self.head_lat = options['coordinates']['lat']
    else:
      self.heading_change = options['round']
      self.stopped = True
  def step(self, current_round):
    if not self.stopped and not self.hidden:
      speed_x = (self.head_lon - self.curr_lon) / (self.heading_change - current_round)
      speed_y = (self.head_lat - self.curr_lat) / (self.heading_change - current_round)
      self.speed = [speed_x, speed_y]
      self.curr_lat = self.curr_lat + speed_y
      self.curr_lon = self.curr_lon + speed_x
  def get_pos(self):
    return [self.curr_lon, self.curr_lat]
  def save(self, round):
    if not self.hidden:
      self.db_object.set('character',self.name)
      self.db_object.set('type',self.type)
      self.db_object.set('the_geom', '{"type":"Point", "coordinates": ['+str(self.curr_lon)+','+str(self.curr_lat)+']}');
      self.db_object.set('round',round)
      self.db_object.set('import_version', self.import_version)
      # self.db_object.set('date', str_date)
      self.db_object.save()
      return True
예제 #4
0
class Character:
    import_version = 21

    def __init__(self, options):
        self.name = options['name']
        self.hidden = True
        self.stopped = True
        if 'type' in options:
            self.type = options['type']
        else:
            self.type = 'character'
        self.setted_lon = options['lon']
        self.setted_lat = options['lat']
        self.curr_lon = self.setted_lon
        self.curr_lat = self.setted_lat
        self.head_lon = self.setted_lon
        self.head_lat = self.setted_lat
        self.heading_change = 0
        self.speed = [0, 0]
        self.db_object = CartoDb_object(cartoPy)

    def change_heading(self, options):
        if 'hidden' in options:
            self.heading_change = options['round']
            if options['hidden'] == True:
                self.hidden = True
            else:
                self.hidden = False

        if not 'stopped' in options:
            self.hidden = False
            self.stopped = False
            self.heading_change = options['round']
            self.head_lon = options['coordinates']['lon']
            self.head_lat = options['coordinates']['lat']
        else:
            self.heading_change = options['round']
            self.stopped = True

    def step(self, current_round):
        if not self.stopped and not self.hidden:
            speed_x = (self.head_lon - self.curr_lon) / (self.heading_change -
                                                         current_round)
            speed_y = (self.head_lat - self.curr_lat) / (self.heading_change -
                                                         current_round)
            self.speed = [speed_x, speed_y]
            self.curr_lat = self.curr_lat + speed_y
            self.curr_lon = self.curr_lon + speed_x

    def get_pos(self):
        return [self.curr_lon, self.curr_lat]

    def save(self, round):
        if not self.hidden:
            self.db_object.set('character', self.name)
            self.db_object.set('type', self.type)
            self.db_object.set(
                'the_geom', '{"type":"Point", "coordinates": [' +
                str(self.curr_lon) + ',' + str(self.curr_lat) + ']}')
            self.db_object.set('round', round)
            self.db_object.set('import_version', self.import_version)
            # self.db_object.set('date', str_date)
            self.db_object.save()
            return True