feat: 补齐全量网格成果并改用竞对图层名
全量包与单市场包含同类完整数据且不含 online;AOI 由报表按最大接触面积自动匹配。Excel 占比写成文本百分号,竞对信号文件和图层改用正确用字。
This commit is contained in:
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
import json
|
||||
import sqlite3
|
||||
from datetime import datetime, timezone
|
||||
from time import sleep
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .gpkg import quote_identifier
|
||||
@@ -15,6 +16,18 @@ ACTIVE_THEMES = [theme for theme in THEMES if theme['key'] != 'mobile_wifi']
|
||||
# ACTIVE_THEMES = THEMES # 需要恢复移动 WIFI 专题时启用这一行,并停用上一行。
|
||||
|
||||
|
||||
def _vacuum(path):
|
||||
for attempt in range(10):
|
||||
try:
|
||||
with closing(sqlite3.connect(path)) as conn:
|
||||
conn.execute("VACUUM")
|
||||
return
|
||||
except PermissionError:
|
||||
if attempt == 9:
|
||||
raise
|
||||
sleep(0.3)
|
||||
|
||||
|
||||
def export_themes(source_path):
|
||||
results = []
|
||||
with closing(sqlite3.connect(source_path)) as source:
|
||||
@@ -40,7 +53,9 @@ def export_themes(source_path):
|
||||
(STYLES / (theme['key'] + '.qml')).read_text(encoding='utf-8'),
|
||||
'', 1, '', '', None, datetime.now(timezone.utc).isoformat()))
|
||||
target.execute("INSERT OR REPLACE INTO gpkg_contents(table_name,data_type,srs_id) VALUES ('layer_styles','attributes',0)")
|
||||
target.execute('VACUUM')
|
||||
# Windows 上不能在仍打开该文件的连接里 VACUUM,否则替换文件会报 WinError 32。
|
||||
_vacuum(output)
|
||||
with closing(sqlite3.connect(output)) as target:
|
||||
count = target.execute('SELECT count(*) FROM NRBuildingsData').fetchone()[0]
|
||||
results.append({'output': str(output), 'feature_count': count, 'name': theme['name']})
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user