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)
SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia",'line' AS "type" FROM planet_osm_line WHERE (tags ? 'wikipedia') AND ((amenity = 'place_of_worship') OR (building = 'church') OR (building = 'cathedral') OR (building = 'chapel')) UNION SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia", 'polygon' AS "type" FROM planet_osm_polygon WHERE (tags ? 'wikipedia') AND ((amenity = 'place_of_worship') OR (building = 'church') OR (building = 'cathedral') OR (building = 'chapel')) UNION SELECT osm_id, name, tags -> 'wikipedia' AS "wikipedia", 'roads' AS "type" FROM planet_osm_roads WHERE (tags ? 'wikipedia') AND ((amenity = 'place_of_worship') OR (building = 'church') OR (building = 'cathedral') OR (building = 'chapel')) """ res = geodb.query(query) geodb.close() HEADER = ['pagename', 'osm_id', 'osm_type', 'osm_lon', 'osm_lat', 'wiki_lon', 'wiki_lat', 'distance', 'intersects' ] NOWIKI_HEADER = ['pagename', 'osm_id',