예제 #1
0
 def _from_db(self):
    
    if not self.coords:
       geodb = PostgreSQLConnector(WOC['GEODB'])
       geodb.connect()
       query = """SELECT 
                     centr_x AS x,
                     centr_y AS y  
                  FROM planet_osm_{type}
                  WHERE osm_id = {osm_id}
             """.format(type=self.item.osm_type,
                        osm_id=self.item.osm_id)
       logger.debug(query)
       res = geodb.query(query)
       logger.debug(res)
       geodb.close()
       
       if not (res is None) and len(res) != 0:
          lat=res[0][1]
          lon=res[0][0]
          self.coords = (lat,lon)
예제 #2
0
   else: 
      lvl = logging.INFO
   formatter = logging.Formatter(LOGFORMAT_STDOUT[lvl])
   console.setFormatter(formatter)
   console.setLevel(lvl)
else:
   h = NullHandler()
   console.setLevel(logging.WARNING)
   rootlogger.addHandler(h)

logger.info("BASE_DIR: %s" %BASE_DIR)
logger.info("CURR_DIR: %s" %CURR_DIR)
# ***** *****

# ***** OSM2Wiki *****
geodb = PostgreSQLConnector(WOC['GEODB'])

osmres = list()
try:
   osm_input = open('osm_query.txt','r')
   osmlist = osm_input.readlines()
   osmlist = [tuple(line.strip().split(',')) for line in osmlist] 
except:
   osm_input = None

if not osm_input:
   geodb.connect()
   query="""SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia", 'point' AS "type"
               FROM planet_osm_point 
               WHERE (tags ? 'wikipedia')  AND ((amenity = 'place_of_worship') OR (building = 'church')
               OR (building = 'cathedral') OR (building = 'chapel'))