tvaLib
Public Member Functions | Public Attributes | List of all members
lib.scene.Site Class Reference

Declare site descriptor object. More...

Inheritance diagram for lib.scene.Site:

Public Member Functions

def __init__ (self, site, config, kwargs)
 
def new (self, sIdx, camTypeIdx, session, sqlFields={})
 
def write (self, site)
 
def getBaseDirectory (self)
 
def getFullSatFilename (self)
 
def getCombinedMasks (self)
 
def getADT (self, hourly_expansion_factors, kwargs)
 
def getAADT (self, hourly_expansion_factors, doweek_expansion_factors, monthly_expansion_factors, kwargs)
 
def exportToCode (self, moduleName='tvaMetaData', justifyCol1=35, justifyCol2=10, recursive=True)
 

Public Attributes

 config
 
 idx
 
 name
 
 description
 
 xcoordinate
 
 ycoordinate
 
 satres
 
 satFilename
 
 alignments
 Create and link abstract objects from data. More...
 
 crossStreet1
 Update standardised meta data if it exists. More...
 
 crossStreet2
 
 municipality
 

Detailed Description

Declare site descriptor object.

Definition at line 113 of file scene.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.scene.Site.__init__ (   self,
  site,
  config,
  kwargs 
)

Definition at line 114 of file scene.py.

114  def __init__(self, site, config, **kwargs):
115  tvaLib.Constructors.SuperList.__init__(self)
116  self.config = config
117  self.idx = site.idx
118  self.name = site.name
119  self.description = site.description
120  self.xcoordinate = site.xcoordinate
121  self.ycoordinate = site.xcoordinate
122  self.satres = site.satres
123  self.satFilename = site.satFilename
124 
125  self.alignments = Alignments(site.alignments, sidewalks=site.sidewalks, bikepaths=site.bikepaths, corridorMinProximity=config.corridorMinProximity, corridorMinContinuousDistance=config.corridorMinContDistance, connectorSearchDistance=config.connectorSearchDistance, intersectionDistanceFactor=config.intersectionDistanceFactor)
126  #site.camera_views = sorted(site.camera_views, key=lambda mbr: operator.attrgetter('name')(mbr).lower())
127  for scene in site.camera_views: self.data.append(Scene(scene, self.config))
128 
129 
130  self.crossStreet1 = None
131  self.crossStreet2 = None
132  self.municipality = None
133  if(self.config.meta_db and os.path.exists(os.path.join(self.config.dir, self.config.meta_db))):
134  with open(os.path.join(self.config.dir, self.config.meta_db), 'rb') as f:
135  reader = csv.reader(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
136  labels = reader.next()
137  description_column = labels.index('description')
138  for row in reader:
139  if(row[description_column] == self.description):
140  try:
141  self.crossStreet1 = unicode(row[labels.index('street1')], 'utf8')
142  self.crossStreet2 = unicode(row[labels.index('street2')], 'utf8')
143  self.municipality = unicode(row[labels.index('municipality')], 'utf8')
144  except Exception:
145  self.crossStreet1 = unicode(row[labels.index('street1')], 'latin-1')
146  self.crossStreet2 = unicode(row[labels.index('street2')], 'latin-1')
147  self.municipality = unicode(row[labels.index('municipality')], 'latin-1')
148  return
149 

Member Function Documentation

◆ exportToCode()

def lib.scene.Site.exportToCode (   self,
  moduleName = 'tvaMetaData',
  justifyCol1 = 35,
  justifyCol2 = 10,
  recursive = True 
)

Definition at line 200 of file scene.py.

200  def exportToCode(self, moduleName='tvaMetaData', justifyCol1=35, justifyCol2=10, recursive=True):
201  print("sites.append("+moduleName+".Site("+("'"+self.name+"',").ljust(justifyCol1)+(" '"+self.description+"',").ljust(justifyCol2)+" satres="+str(self.satres)+", satFilename='"+self.satFilename+"', alignments='"+self.alignments.write()+"'))")
202  if(recursive):
203  for camera in self: camera.exportToCode(moduleName, recursive=recursive)
204 

◆ getAADT()

def lib.scene.Site.getAADT (   self,
  hourly_expansion_factors,
  doweek_expansion_factors,
  monthly_expansion_factors,
  kwargs 
)
Compute, update, and return Average Annual Daily Traffic at this 
    site. See Scene.getADT() for more information

Definition at line 192 of file scene.py.

192  def getAADT(self, hourly_expansion_factors, doweek_expansion_factors, monthly_expansion_factors, **kwargs):
193  ''' Compute, update, and return Average Annual Daily Traffic at this
194  site. See Scene.getADT() for more information
195  '''
196  AADTs = filter(None, [scene.getAADT(hourly_expansion_factors, doweek_expansion_factors, monthly_expansion_factors, **kwargs) for scene in self.data])
197  if(AADTs == []): return None
198  else: return float(sum(AADTs))/float(len(AADTs))
199 

◆ getADT()

def lib.scene.Site.getADT (   self,
  hourly_expansion_factors,
  kwargs 
)
Compute, update, and return Average Daily Traffic at this site. See
    Scene.getADT() for more information.

Definition at line 184 of file scene.py.

184  def getADT(self, hourly_expansion_factors, **kwargs):
185  ''' Compute, update, and return Average Daily Traffic at this site. See
186  Scene.getADT() for more information.
187  '''
188  ADTs = filter(None, [scene.getADT(hourly_expansion_factors, **kwargs) for scene in self.data])
189  if(ADTs == []): return None
190  else: return float(sum(ADTs))/float(len(ADTs))
191 

◆ getBaseDirectory()

def lib.scene.Site.getBaseDirectory (   self)

Definition at line 175 of file scene.py.

175  def getBaseDirectory(self): return os.path.join(self.config.dir, self.name)

◆ getCombinedMasks()

def lib.scene.Site.getCombinedMasks (   self)

Definition at line 178 of file scene.py.

178  def getCombinedMasks(self):
179  masks = tvaLib.Constructors.SuperList()
180  for camera in self:
181  masks + camera.mask
182  return masks
183 

◆ getFullSatFilename()

def lib.scene.Site.getFullSatFilename (   self)

Definition at line 176 of file scene.py.

176  def getFullSatFilename(self): return os.path.join(self.config.dir, self.name, self.satFilename)
177 

◆ new()

def lib.scene.Site.new (   self,
  sIdx,
  camTypeIdx,
  session,
  sqlFields = {} 
)

Definition at line 150 of file scene.py.

150  def new(self, sIdx, camTypeIdx, session, sqlFields={}):
151  sites = session.query(tvaMetaData.Site).all()
152  camType = session.query(tvaMetaData.CamType).all()
153  data = tvaMetaData.CameraView([x for x in sites if x.idx==sIdx][0], [x for x in camType if x.idx==camTypeIdx][0], **sqlFields)
154  session.add_all([data])
155  session.commit()
156  self.data.append(Scene(data, self.config))
157  return True
158 

◆ write()

def lib.scene.Site.write (   self,
  site 
)

Definition at line 159 of file scene.py.

159  def write(self, site):
160  site.idx = self.idx
161  site.name = self.name
162  site.description = self.description
163  site.xcoordinate = self.xcoordinate
164  site.ycoordinate = self.xcoordinate
165  site.satres = self.satres
166  site.satFilename = self.satFilename
167 
168  site.alignments = self.alignments.write()
169  site.sidewalks = self.alignments.sidewalks.write()
170  site.bikepaths = self.alignments.bikepaths.write()
171  for sceneIx in range(len(site.camera_views)):
172  site.camera_views[sceneIx] = self.data[sceneIx].write(site.camera_views[sceneIx])
173  return site
174 

Member Data Documentation

◆ alignments

lib.scene.Site.alignments

Create and link abstract objects from data.

Definition at line 125 of file scene.py.

◆ config

lib.scene.Site.config

Definition at line 116 of file scene.py.

◆ crossStreet1

lib.scene.Site.crossStreet1

Update standardised meta data if it exists.

Definition at line 130 of file scene.py.

◆ crossStreet2

lib.scene.Site.crossStreet2

Definition at line 131 of file scene.py.

◆ description

lib.scene.Site.description

Definition at line 119 of file scene.py.

◆ idx

lib.scene.Site.idx

Definition at line 117 of file scene.py.

◆ municipality

lib.scene.Site.municipality

Definition at line 132 of file scene.py.

◆ name

lib.scene.Site.name

Definition at line 118 of file scene.py.

◆ satFilename

lib.scene.Site.satFilename

Definition at line 123 of file scene.py.

◆ satres

lib.scene.Site.satres

Definition at line 122 of file scene.py.

◆ xcoordinate

lib.scene.Site.xcoordinate

Definition at line 120 of file scene.py.

◆ ycoordinate

lib.scene.Site.ycoordinate

Definition at line 121 of file scene.py.


The documentation for this class was generated from the following file: