コード例 #1
0
ファイル: views.full.py プロジェクト: GeoDaSandbox/DynTM
 def ts(self):
     """ Search for the TileSetName in the Request and try and load it from Memcache or DataStore, return True or False """
     if self._ts:
         return self._ts
     if self.tsid:
         tsid = self.tsid
     else:
         tileSetName = self.request.REQUEST.get('ts')
         if tileSetName:
             self.tsid = tsid = 'ts:'+tileSetName
         else:
             return False
     ts = memcache.get(tsid)
     if ts is not None:
         self._ts = ts
     else:
         ts = TileSet.get_by_key_name(tsid)
         #if ts is not None and not memcache.add(tsid, ts):
         #    logging.error("Memcache set failed [ %s ]"%tsid)
         self._ts = ts
     #logging.info(self._ts)
     if ts is not None:
         return self._ts
     else:
         return False
コード例 #2
0
ファイル: views.full.py プロジェクト: GeoDaSandbox/DynTM
 def cs(self):
     """ Search for the Color Scheme Name in the Request and try and load it from Memcache or DataStore, return True or False """
     if self._cs:
         return self._cs
     colorSchemeName = self.request.REQUEST.get('cs','DEFAULT')
     self.csid = csid = "cs:"+colorSchemeName
     cs = memcache.get(csid)
     if cs is not None:
         self._cs = cs
     else:
         if csid:
             cs = ColorScheme.get_by_key_name(csid)
             if cs:
                 #logging.info('found colorScheme(%s)'%csid)
                 #CHECK URL FOR BANGGROUND OPTIONS...
                 background = self.request.REQUEST.get('transparentBackground')
                 if background == 'OFF':
                     cs.alphas = ''
                 self._cs = cs
         if self.cl:
             if cs and cs.n==self.cl.n:
                 pass
             else:
                 N = min(self.cl.n-2,MAX_N)
                 if csid[:9] == 'cs:random':
                     rid = 'ts:%s&cl:%s&cs:%s'%(self.request.REQUEST.get('ts'),self.request.REQUEST.get('cl'),self.request.REQUEST.get('cs'))
                     cs = memcache.get(rid)
                     if not cs:
                         cs = colors.random(N,borders=(60,60,60))
                         memcache.add(rid, cs)
                     self._cs = cs
                     return cs
                 else:
                     if self.cl.n == 3:
                         cs = colors.ColorScheme([(0,0,1),(0,0,0)]+[(255,90,0)]*N)
                     else:
                         cs = colors.fade(self.cl.n-2)
         self._cs = cs
     if cs is not None:
         return cs
     else:
         return False
コード例 #3
0
ファイル: views.full.py プロジェクト: GeoDaSandbox/DynTM
 def get_tile(self,z,x,y):
     tid = "t:%s:%d+%d+%d"%(self.ts.name,z,x,y)
     tile = memcache.get(tid)
     if tile is not None:
         self._tile = tile
         return True
     tile = Tile.get_by_key_name(tid)
     if tile:
         #if tile.typ == 'B':
         #    tile.delete()
         #    return False
         #if not memcache.add(tid, tile):
         #    logging.error("Memcache set failed [ %s ]"%tid)
         self._tile = tile
         return True
     return False
コード例 #4
0
ファイル: views.full.py プロジェクト: GeoDaSandbox/DynTM
 def cl(self):
     """ Search for the Classification Name in the Request and try and load it from Memcache or DataStore, return True or False """
     if self._cl:
         return self._cl
     classificationName = self.request.REQUEST.get('cl','DEFAULT')
     if classificationName == 'random':
         self.clid = clid = "cl:random"
     elif classificationName.isdigit():
         self.clid = clid = "cl:__digit:"+self.ts.name+":"+classificationName
     elif self.ts:
         self.clid = clid = "cl:"+self.ts.name+":"+classificationName
     else:
         return False
     cl = memcache.get(clid)
     if cl is not None:
         self._cl = cl
     else:
         cl = None
         if self.ts:
             N = self.ts.idlen
             if clid == 'cl:random':
                 cl = classification.random(N,min(N,MAX_n))
             elif clid.startswith('cl:__digit:'):
                 cl = classification.random(N,min(int(classificationName)+2,MAX_n))
             elif clid.startswith('cl:key_'):
                 C = Classification.get(classificationName[4:])
                 if C:
                     cl = classification.Classification(C.a)
             elif clid:
                 C = Classification.get_by_key_name(clid)
                 if C:
                     cl = classification.Classification(C.a)
             #if cl and clid != 'cl:random':
                 #if not memcache.add(clid, cl, 60):
                 #    logging.error("Memcache set failed [ %s ]"%clid)
             if not cl:
                 cl = classification.random(N,3)
         self._cl = cl
     if cl is not None:
         return cl
     else:
         return False