當前位置: 首頁>>代碼示例>>Python>>正文


Python FileManager.write_geojson方法代碼示例

本文整理匯總了Python中FileManager.FileManager.write_geojson方法的典型用法代碼示例。如果您正苦於以下問題:Python FileManager.write_geojson方法的具體用法?Python FileManager.write_geojson怎麽用?Python FileManager.write_geojson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FileManager.FileManager的用法示例。


在下文中一共展示了FileManager.write_geojson方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import write_geojson [as 別名]
def main():
	try:
		logger.warning("Capting Archdaily...")
		
		now = datetime.now().strftime('%y-%m-%d')
		loaded_json = ArchdailyCaptor().get_data()
		
		logger.info("Building the GeoJSON...")
		loaded_geojson = ArchdailyGeojsonBuilder().build_geojson(loaded_json)
		
		logger.info("Writing GeoJSON...")
		file_manager = FileManager()
		try:
			file_manager.write_geojson(loaded_geojson, source, None, now)
			file_manager.write_js_geojson(loaded_geojson, source, None, now)
		except IOError:
			raise InitError("The folder %s is missing"% file_manager.get_folder_path(source))
		
		logger.warning("New GeoJSON written for Archdaily: %d locations"% len(loaded_json))
		return 0
	
	except InitError as e:
		logger.critical("%s: %s"% (type(e).__name__, e))
		return 1
	except requests.exceptions.RequestException as e:
		logger.critical(e, exc_info=True)
		return 2
	except Exception as e:
		logger.critical(e, exc_info=True)
		return 3
開發者ID:ComplexCity,項目名稱:capture,代碼行數:32,代碼來源:ArchdailyCapture.py

示例2: build

# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import write_geojson [as 別名]
	def build(self):
		fileManager = FileManager()
		
		cities = [dir for dir in os.listdir(self.source) if os.path.isdir(os.path.join(self.source, dir))]
		for city in cities:
			city_path = os.path.join(self.source, city)
			self.logger.info("%s ..."% city)
			files = [os.path.splitext(os.path.normcase(file))[0] for file in os.listdir(city_path) if os.path.splitext(file)[1] == '.json']
			for file in files:
				json_file = os.path.join(city_path, "%s.json"% file)
				geojson_file = os.path.join(city_path, "%s.geojson"% file)
				js_geojson_file = os.path.join(city_path, "%s.js"% file)
				self.logger.info("%s.json"% file)
				if not os.path.isfile(geojson_file) or not os.path.isfile(js_geojson_file):
					f = open(json_file, 'r')
					loaded_json = json.load(f)
					f.close()
					
					loaded_geojson = self.builder.build_geojson(loaded_json)

					fileManager.write_geojson(loaded_geojson, self.source, city, file)
					self.logger.info(" => %s.geojson"% file)
					
					fileManager.write_js_geojson(loaded_geojson, self.source, city, file)
					self.logger.info(" => %s.js"% file)
開發者ID:ComplexCity,項目名稱:capture,代碼行數:27,代碼來源:GeojsonBuilding.py


注:本文中的FileManager.FileManager.write_geojson方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。