hypercadaster-ES 1.4.0__tar.gz → 1.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hypercadaster_es-1.4.0/hypercadaster_es.egg-info → hypercadaster_es-1.4.2}/PKG-INFO +18 -5
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/README.md +2 -2
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/__init__.py +1 -1
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/_db.py +22 -3
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/building_inference.py +12 -7
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/energy.py +337 -62
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/mergers.py +5 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/utils.py +11 -11
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2/hypercadaster_es.egg-info}/PKG-INFO +18 -5
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_es.egg-info/requires.txt +1 -1
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/setup.py +2 -2
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/LICENSE +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/MANIFEST.in +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/_pretty.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/cached_files/ine_inspire_codes.xlsx +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/downloaders.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/energy_config.yaml +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/functions.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/interoperability.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/reporting.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/social.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/topology.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_ES/weather.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_es.egg-info/SOURCES.txt +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_es.egg-info/dependency_links.txt +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_es.egg-info/top_level.txt +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/setup.cfg +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_aggregation.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_agricultural_archetype.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_cartociudad_api.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_cat_address.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_cat_cache.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_cat_empty_schema.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_census_tract_aggregations.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_code_normalisation.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_codes.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_db_layer.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_dem_tiles.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_energy_config.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_energy_scenarios.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_floorplan_partition.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_geometry.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_import_surface.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_live_smoke.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_shadow_rules.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_social.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_theoretical_cat_spaces.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_topology.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_weather.py +0 -0
- {hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/tests/test_zero_floor_buildings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hypercadaster_es
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.2
|
|
4
4
|
Summary: Python library to obtain the Spanish cadaster data joined with external attributes.
|
|
5
5
|
Home-page: https://github.com/BeeGroup-cimne
|
|
6
6
|
Author: Jose Manuel Broto Vispe
|
|
@@ -80,13 +80,26 @@ Requires-Dist: regex<2027.0,>=2023.12
|
|
|
80
80
|
Requires-Dist: tqdm>=4.66
|
|
81
81
|
Requires-Dist: six>=1.16
|
|
82
82
|
Requires-Dist: PyYAML>=6.0
|
|
83
|
-
Requires-Dist: social_ES>=1.0.
|
|
83
|
+
Requires-Dist: social_ES>=1.0.4
|
|
84
84
|
Provides-Extra: dev
|
|
85
85
|
Requires-Dist: black>=24.0; extra == "dev"
|
|
86
86
|
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
87
87
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
88
88
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
89
89
|
Requires-Dist: pdoc>=14.0; extra == "dev"
|
|
90
|
+
Dynamic: author
|
|
91
|
+
Dynamic: author-email
|
|
92
|
+
Dynamic: classifier
|
|
93
|
+
Dynamic: description
|
|
94
|
+
Dynamic: description-content-type
|
|
95
|
+
Dynamic: home-page
|
|
96
|
+
Dynamic: keywords
|
|
97
|
+
Dynamic: license
|
|
98
|
+
Dynamic: license-file
|
|
99
|
+
Dynamic: provides-extra
|
|
100
|
+
Dynamic: requires-dist
|
|
101
|
+
Dynamic: requires-python
|
|
102
|
+
Dynamic: summary
|
|
90
103
|
|
|
91
104
|
# hypercadaster_ES
|
|
92
105
|
|
|
@@ -94,7 +107,7 @@ A comprehensive Python library for downloading, processing, and analyzing Spanis
|
|
|
94
107
|
|
|
95
108
|
[](https://python.org)
|
|
96
109
|
[](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
|
|
97
|
-
[](https://github.com/BeeGroup-cimne/hypercadaster_ES)
|
|
98
111
|
|
|
99
112
|
## 🎯 Overview
|
|
100
113
|
|
|
@@ -221,4 +234,4 @@ This project is licensed under the **EUPL v1.2**. See the [license](https://join
|
|
|
221
234
|
|
|
222
235
|
*hypercadaster_ES - Built with ❤️ for the Spanish urban analysis and building research community*
|
|
223
236
|
|
|
224
|
-
*Last updated: November 2026 | Version 1.4.
|
|
237
|
+
*Last updated: November 2026 | Version 1.4.2*
|
|
@@ -4,7 +4,7 @@ A comprehensive Python library for downloading, processing, and analyzing Spanis
|
|
|
4
4
|
|
|
5
5
|
[](https://python.org)
|
|
6
6
|
[](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
|
|
7
|
-
[](https://github.com/BeeGroup-cimne/hypercadaster_ES)
|
|
8
8
|
|
|
9
9
|
## 🎯 Overview
|
|
10
10
|
|
|
@@ -131,4 +131,4 @@ This project is licensed under the **EUPL v1.2**. See the [license](https://join
|
|
|
131
131
|
|
|
132
132
|
*hypercadaster_ES - Built with ❤️ for the Spanish urban analysis and building research community*
|
|
133
133
|
|
|
134
|
-
*Last updated: November 2026 | Version 1.4.
|
|
134
|
+
*Last updated: November 2026 | Version 1.4.2*
|
|
@@ -26,7 +26,7 @@ from ._db import ResultsHandle
|
|
|
26
26
|
from . import (mergers, utils, building_inference, downloaders, interoperability,
|
|
27
27
|
energy, weather, social, topology, reporting)
|
|
28
28
|
|
|
29
|
-
__version__ = "1.4.
|
|
29
|
+
__version__ = "1.4.2"
|
|
30
30
|
__author__ = "Jose Manuel Broto Vispe"
|
|
31
31
|
__email__ = "jmbrotovispe@gmail.com"
|
|
32
32
|
|
|
@@ -120,6 +120,11 @@ def fetch_first(con: duckdb.DuckDBPyConnection, sql: str,
|
|
|
120
120
|
return rows[0] if rows else None
|
|
121
121
|
|
|
122
122
|
|
|
123
|
+
def _is_null_type(type_name: str) -> bool:
|
|
124
|
+
"""True for DuckDB's untyped "NULL" column type (DESCRIBE shows it quoted)."""
|
|
125
|
+
return type_name.strip('"').upper() == "NULL"
|
|
126
|
+
|
|
127
|
+
|
|
123
128
|
def _table_exists(con: duckdb.DuckDBPyConnection, table: str) -> bool:
|
|
124
129
|
"""True when ``table`` exists in the connection's own ``main`` schema.
|
|
125
130
|
|
|
@@ -441,6 +446,12 @@ def _df_with_wkb(gdf: gpd.GeoDataFrame, geom_cols: Iterable[str]) -> pd.DataFram
|
|
|
441
446
|
for col in df.columns:
|
|
442
447
|
if col in geom_set or df[col].dtype != object:
|
|
443
448
|
continue
|
|
449
|
+
# A bool column with nulls (e.g. br__detached once the CAT undeveloped
|
|
450
|
+
# parcels are appended) turns object; keep it BOOLEAN, not a pickled
|
|
451
|
+
# BLOB, so it still matches a table created from an all-bool frame.
|
|
452
|
+
if pd.api.types.infer_dtype(df[col], skipna=True) == "boolean":
|
|
453
|
+
df[col] = df[col].astype("boolean")
|
|
454
|
+
continue
|
|
444
455
|
if _object_kind(df[col]) in ("null", "str", "bytes"):
|
|
445
456
|
continue
|
|
446
457
|
df[col] = [None if _is_null(v) else _to_pickle_bytes(v) for v in df[col]]
|
|
@@ -501,14 +512,22 @@ def write_gdf(con: duckdb.DuckDBPyConnection, table: str, gdf: gpd.GeoDataFrame,
|
|
|
501
512
|
con.register("_tmp_write_gdf", df)
|
|
502
513
|
|
|
503
514
|
def _reconcile_schema():
|
|
504
|
-
"""ADD COLUMN for every frame column the table doesn't have yet.
|
|
505
|
-
|
|
515
|
+
"""ADD COLUMN for every frame column the table doesn't have yet.
|
|
516
|
+
|
|
517
|
+
A column created from an all-None frame column gets DuckDB's "NULL"
|
|
518
|
+
type, which nothing can be cast into; once a frame carries a real type
|
|
519
|
+
for it, the table column is retyped to that type.
|
|
520
|
+
"""
|
|
521
|
+
existing = {r[0]: str(r[1])
|
|
522
|
+
for r in con.execute(f'DESCRIBE "{table}"').fetchall()}
|
|
506
523
|
tmp_types = {r[0]: str(r[1])
|
|
507
524
|
for r in con.execute('DESCRIBE _tmp_write_gdf').fetchall()}
|
|
508
525
|
for c in df.columns:
|
|
526
|
+
_ty = 'GEOMETRY' if c in geom_set else tmp_types.get(c, 'VARCHAR')
|
|
509
527
|
if c not in existing:
|
|
510
|
-
_ty = 'GEOMETRY' if c in geom_set else tmp_types.get(c, 'VARCHAR')
|
|
511
528
|
con.execute(f'ALTER TABLE "{table}" ADD COLUMN "{c}" {_ty}')
|
|
529
|
+
elif (_is_null_type(existing[c]) and not _is_null_type(_ty)):
|
|
530
|
+
con.execute(f'ALTER TABLE "{table}" ALTER COLUMN "{c}" TYPE {_ty}')
|
|
512
531
|
|
|
513
532
|
try:
|
|
514
533
|
select_sql = _geom_select_sql(df.columns, geom_cols)
|
|
@@ -3129,8 +3129,10 @@ def parse_horizontal_division_buildings_CAT_files(cadaster_code, CAT_files_dir):
|
|
|
3129
3129
|
return None
|
|
3130
3130
|
|
|
3131
3131
|
# Join the building space and building spaces detailed datasets. Order the items by floor.
|
|
3132
|
-
|
|
3133
|
-
|
|
3132
|
+
# parse_CAT_file stores blank fields as null; this function relies on blank
|
|
3133
|
+
# text fields being "" (filters, concat_str of references, floor sorting).
|
|
3134
|
+
building_spaces_detailed = combined_dfs[14].with_columns(pl.col(pl.Utf8).fill_null(""))
|
|
3135
|
+
building_spaces = combined_dfs[15].with_columns(pl.col(pl.Utf8).fill_null(""))
|
|
3134
3136
|
building_spaces = building_spaces.with_columns(
|
|
3135
3137
|
pl.concat_str(['building_reference', 'space1_reference'], separator=""
|
|
3136
3138
|
).alias("building_space_reference"),
|
|
@@ -3290,12 +3292,15 @@ def parse_horizontal_division_buildings_CAT_files(cadaster_code, CAT_files_dir):
|
|
|
3290
3292
|
)
|
|
3291
3293
|
|
|
3292
3294
|
# Calculate the complete address
|
|
3295
|
+
# Blank numbers ("" once nulls are filled, e.g. a space with no address)
|
|
3296
|
+
# are left empty like the all-zero ones. The cast runs on every row before
|
|
3297
|
+
# pl.when masks it, so "" is nulled first rather than cast.
|
|
3293
3298
|
building_spaces_detailed = building_spaces_detailed.with_columns(
|
|
3294
|
-
(pl.when(pl.col("street_number1")
|
|
3295
|
-
pl.col("street_number1").cast(pl.Int16))).alias("street_number1"),
|
|
3296
|
-
(pl.when(pl.col("street_number2")
|
|
3297
|
-
pl.col("street_number2").cast(pl.Int16))).alias("street_number2"),
|
|
3298
|
-
(pl.when(pl.col("km")
|
|
3299
|
+
(pl.when(pl.col("street_number1").is_in(["0000", ""])).then(pl.lit("")).otherwise(
|
|
3300
|
+
pl.col("street_number1").replace("", None).cast(pl.Int16))).alias("street_number1"),
|
|
3301
|
+
(pl.when(pl.col("street_number2").is_in(["0000", ""])).then(pl.lit("")).otherwise(
|
|
3302
|
+
pl.col("street_number2").replace("", None).cast(pl.Int16))).alias("street_number2"),
|
|
3303
|
+
(pl.when(pl.col("km").is_in(["00000", ""])).then(pl.lit("")).otherwise(pl.col("km").replace("", None).cast(pl.Int16))).alias("km")
|
|
3299
3304
|
)
|
|
3300
3305
|
# Human-readable street components for the postal address: expand the
|
|
3301
3306
|
# two-letter cadastral street-type acronym to its literal ("CR" ->
|
|
@@ -227,10 +227,28 @@ def _default_idd_path():
|
|
|
227
227
|
env = os.environ.get("HC_ENERGYPLUS_IDD")
|
|
228
228
|
if env and os.path.exists(env):
|
|
229
229
|
return env
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
# The IDD must come from the engine that will run the IDF: eppy derives the
|
|
231
|
+
# executable path from the IDF Version, so a bundled-9.2 IDD sends it to a
|
|
232
|
+
# non-existent EnergyPlus-9-2-0 install. Prefer the engine on PATH.
|
|
233
|
+
import shutil
|
|
234
|
+
exe = shutil.which("energyplus")
|
|
235
|
+
if exe:
|
|
236
|
+
idd = os.path.join(os.path.dirname(os.path.realpath(exe)), "Energy+.idd")
|
|
237
|
+
if os.path.exists(idd):
|
|
238
|
+
return idd
|
|
239
|
+
|
|
240
|
+
def _version_key(path):
|
|
241
|
+
nums = re.findall(r"\d+", os.path.basename(os.path.dirname(path)))
|
|
242
|
+
return tuple(int(n) for n in nums)
|
|
243
|
+
|
|
244
|
+
hits = []
|
|
245
|
+
for p in ("/Applications/EnergyPlus*/Energy+.idd", # macOS
|
|
246
|
+
"/usr/local/EnergyPlus*/Energy+.idd", # Linux
|
|
247
|
+
"/opt/EnergyPlus*/Energy+.idd",
|
|
248
|
+
"C:/EnergyPlusV*/Energy+.idd"): # Windows
|
|
249
|
+
hits.extend(glob.glob(p))
|
|
250
|
+
if hits:
|
|
251
|
+
return max(hits, key=_version_key)
|
|
234
252
|
import eppy
|
|
235
253
|
idds = glob.glob(os.path.join(os.path.dirname(eppy.__file__),
|
|
236
254
|
"resources", "iddfiles", "Energy+V9_2_0.idd"))
|
|
@@ -2905,6 +2923,9 @@ def build_energy_model(gdf, building_reference, wd=None, output_path=None,
|
|
|
2905
2923
|
residential_behavior=residential_behavior,
|
|
2906
2924
|
residential_period=residential_period,
|
|
2907
2925
|
behavior_seed=behavior_seed, wd=wd)
|
|
2926
|
+
# Start the RunPeriod on the weather year's real weekday (blank means
|
|
2927
|
+
# Sunday), so a plain idf.run() keeps weekend schedules on the weekend.
|
|
2928
|
+
_set_run_period(idf, None)
|
|
2908
2929
|
|
|
2909
2930
|
# Neighbour-shading filter + cap, BEFORE the model is written or returned, so
|
|
2910
2931
|
# the .idf on disk, the 3-D plot and the simulated context are the same panels.
|
|
@@ -5350,7 +5371,8 @@ _IDF_VIEW_COLORS = {
|
|
|
5350
5371
|
"Window": "cornflowerblue",
|
|
5351
5372
|
"Door: main": "saddlebrown",
|
|
5352
5373
|
"Door: parking": "sienna",
|
|
5353
|
-
"Shading":
|
|
5374
|
+
"Shading: building": "olivedrab",
|
|
5375
|
+
"Shading: neighbours": "darkolivegreen",
|
|
5354
5376
|
}
|
|
5355
5377
|
|
|
5356
5378
|
|
|
@@ -5361,8 +5383,12 @@ def _surface_category(s):
|
|
|
5361
5383
|
main/parking). Drives the per-category legend groups in ``plot_idf_geometry``
|
|
5362
5384
|
so every type and subtype can be toggled independently."""
|
|
5363
5385
|
st = getattr(s, "Surface_Type", None)
|
|
5364
|
-
if st is None:
|
|
5365
|
-
|
|
5386
|
+
if st is None: # Shading:*:Detailed has no type
|
|
5387
|
+
# Neighbour (context) panels vs the building's own reveals, balconies,
|
|
5388
|
+
# awnings and footprint remainders.
|
|
5389
|
+
name = str(getattr(s, "Name", ""))
|
|
5390
|
+
return ("Shading: neighbours" if name.startswith(_NEIGHBOUR_SHADE_PREFIX)
|
|
5391
|
+
else "Shading: building")
|
|
5366
5392
|
st = st.lower()
|
|
5367
5393
|
bc = (getattr(s, "Outside_Boundary_Condition", "") or "").lower()
|
|
5368
5394
|
if st == "wall":
|
|
@@ -5398,7 +5424,7 @@ def _idf_surfaces_by_category(idf, include_shading=True):
|
|
|
5398
5424
|
out = OrderedDict()
|
|
5399
5425
|
for s in vg._get_surfaces(idf):
|
|
5400
5426
|
cat = _surface_category(s)
|
|
5401
|
-
if cat
|
|
5427
|
+
if cat.startswith("Shading") and not include_shading:
|
|
5402
5428
|
continue
|
|
5403
5429
|
coords = vg.getcoords(s)
|
|
5404
5430
|
if coords and len(coords) >= 3:
|
|
@@ -5407,35 +5433,294 @@ def _idf_surfaces_by_category(idf, include_shading=True):
|
|
|
5407
5433
|
return out
|
|
5408
5434
|
|
|
5409
5435
|
|
|
5436
|
+
# Standalone three.js page for plot_idf_geometry. three.js is loaded from the
|
|
5437
|
+
# jsDelivr CDN (pinned), so viewing the page needs an internet connection.
|
|
5438
|
+
_THREEJS_VERSION = "0.160.0"
|
|
5439
|
+
_IDF_VIEW_HTML = """<!doctype html>
|
|
5440
|
+
<html lang="en">
|
|
5441
|
+
<head>
|
|
5442
|
+
<meta charset="utf-8">
|
|
5443
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5444
|
+
<title>__TITLE__</title>
|
|
5445
|
+
<style>
|
|
5446
|
+
html, body { margin: 0; height: 100%; overflow: hidden; background: #ffffff;
|
|
5447
|
+
font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: #222; }
|
|
5448
|
+
#view { position: absolute; inset: 0; }
|
|
5449
|
+
#panel { position: absolute; top: 10px; left: 10px; max-height: calc(100% - 20px); overflow: auto;
|
|
5450
|
+
background: rgba(255,255,255,0.92); border: 1px solid #ddd; border-radius: 6px;
|
|
5451
|
+
padding: 8px 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
|
|
5452
|
+
#panel h1 { font-size: 14px; margin: 0 0 6px; }
|
|
5453
|
+
#panel .hint { color: #777; font-size: 11px; margin-top: 6px; }
|
|
5454
|
+
.row { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; padding: 1px 0; }
|
|
5455
|
+
.sw { width: 14px; height: 14px; border: 1px solid rgba(0,0,0,0.35); border-radius: 2px; flex: none; }
|
|
5456
|
+
.row.off { opacity: 0.4; }
|
|
5457
|
+
#tip { position: absolute; pointer-events: none; display: none; background: rgba(30,30,30,0.85);
|
|
5458
|
+
color: #fff; padding: 3px 6px; border-radius: 3px; font-size: 12px; white-space: nowrap; }
|
|
5459
|
+
</style>
|
|
5460
|
+
</head>
|
|
5461
|
+
<body>
|
|
5462
|
+
<div id="view"></div>
|
|
5463
|
+
<div id="panel">
|
|
5464
|
+
<h1 id="ttl"></h1>
|
|
5465
|
+
<div id="legend"></div>
|
|
5466
|
+
<div class="hint">Drag: rotate · Right-drag: pan · Wheel: zoom<br>Click a category to toggle it<br>
|
|
5467
|
+
Grid cell: <span id="cell"></span> m</div>
|
|
5468
|
+
</div>
|
|
5469
|
+
<div id="tip"></div>
|
|
5470
|
+
<script type="application/json" id="hc-data">__DATA__</script>
|
|
5471
|
+
<script>
|
|
5472
|
+
// Surface load failures (no internet for the CDN, no WebGL) in the panel.
|
|
5473
|
+
function hcFail(msg) {
|
|
5474
|
+
const d = document.createElement("div");
|
|
5475
|
+
d.style.cssText = "color:#b00020;margin-top:6px;max-width:320px";
|
|
5476
|
+
d.textContent = "Viewer error: " + msg;
|
|
5477
|
+
document.getElementById("panel").appendChild(d);
|
|
5478
|
+
}
|
|
5479
|
+
window.addEventListener("error", (e) => hcFail(e.message || "could not load three.js (offline?)"), true);
|
|
5480
|
+
window.addEventListener("unhandledrejection", (e) => hcFail(String(e.reason)));
|
|
5481
|
+
</script>
|
|
5482
|
+
<script type="importmap">
|
|
5483
|
+
{"imports": {"three": "https://cdn.jsdelivr.net/npm/three@__V__/build/three.module.js",
|
|
5484
|
+
"three/addons/": "https://cdn.jsdelivr.net/npm/three@__V__/examples/jsm/"}}
|
|
5485
|
+
</script>
|
|
5486
|
+
<script type="module">
|
|
5487
|
+
import * as THREE from "three";
|
|
5488
|
+
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
5489
|
+
|
|
5490
|
+
const DATA = JSON.parse(document.getElementById("hc-data").textContent);
|
|
5491
|
+
const ttl = document.getElementById("ttl");
|
|
5492
|
+
if (DATA.title) ttl.textContent = DATA.title; else ttl.remove();
|
|
5493
|
+
|
|
5494
|
+
const view = document.getElementById("view");
|
|
5495
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true, preserveDrawingBuffer: true });
|
|
5496
|
+
renderer.setPixelRatio(window.devicePixelRatio);
|
|
5497
|
+
renderer.setSize(view.clientWidth, view.clientHeight);
|
|
5498
|
+
view.appendChild(renderer.domElement);
|
|
5499
|
+
|
|
5500
|
+
const scene = new THREE.Scene();
|
|
5501
|
+
scene.background = new THREE.Color(0xffffff);
|
|
5502
|
+
scene.add(new THREE.AmbientLight(0xffffff, 1.6));
|
|
5503
|
+
const sun = new THREE.DirectionalLight(0xffffff, 1.4);
|
|
5504
|
+
sun.position.set(1, -1.5, 2);
|
|
5505
|
+
scene.add(sun);
|
|
5506
|
+
|
|
5507
|
+
const box = new THREE.Box3(); // everything (sizes the grid)
|
|
5508
|
+
const focus = new THREE.Box3(); // the building itself (frames the camera)
|
|
5509
|
+
const meshes = [];
|
|
5510
|
+
const legend = document.getElementById("legend");
|
|
5511
|
+
|
|
5512
|
+
for (const cat of DATA.categories) {
|
|
5513
|
+
const group = new THREE.Group();
|
|
5514
|
+
// Filled faces: flat-shaded, double-sided, see-through like the plotly view.
|
|
5515
|
+
const g = new THREE.BufferGeometry();
|
|
5516
|
+
g.setAttribute("position", new THREE.Float32BufferAttribute(cat.positions, 3));
|
|
5517
|
+
g.setIndex(cat.indices);
|
|
5518
|
+
const flat = g.toNonIndexed();
|
|
5519
|
+
flat.computeVertexNormals();
|
|
5520
|
+
// Windows and doors lie in their wall's plane. Pulled towards the camera and
|
|
5521
|
+
// drawn FIRST with depth writes, so their own wall can't cover them, while
|
|
5522
|
+
// any roof or wall in front still blends over them and dims them.
|
|
5523
|
+
const inset = cat.name === "Window" || cat.name.startsWith("Door");
|
|
5524
|
+
const mat = new THREE.MeshLambertMaterial({
|
|
5525
|
+
color: new THREE.Color(cat.color), side: THREE.DoubleSide,
|
|
5526
|
+
transparent: cat.opacity < 1, opacity: cat.opacity, depthWrite: inset || cat.opacity >= 1,
|
|
5527
|
+
polygonOffset: true, polygonOffsetFactor: inset ? -2 : 1, polygonOffsetUnits: inset ? -4 : 1,
|
|
5528
|
+
});
|
|
5529
|
+
const mesh = new THREE.Mesh(flat, mat);
|
|
5530
|
+
// The roof is blended last, over everything it covers (walls, shading, the
|
|
5531
|
+
// windows and doors under it); the rest follows three.js' depth sorting.
|
|
5532
|
+
mesh.renderOrder = inset ? -1 : (cat.name === "Roof" ? 2 : 0);
|
|
5533
|
+
mesh.userData.name = cat.name;
|
|
5534
|
+
group.add(mesh);
|
|
5535
|
+
meshes.push(mesh);
|
|
5536
|
+
// Crisp polygon outlines.
|
|
5537
|
+
const eg = new THREE.BufferGeometry();
|
|
5538
|
+
eg.setAttribute("position", new THREE.Float32BufferAttribute(cat.edges, 3));
|
|
5539
|
+
group.add(new THREE.LineSegments(eg, new THREE.LineBasicMaterial({
|
|
5540
|
+
color: 0x282828, transparent: true, opacity: cat.edge_opacity })));
|
|
5541
|
+
scene.add(group);
|
|
5542
|
+
flat.computeBoundingBox();
|
|
5543
|
+
box.union(flat.boundingBox);
|
|
5544
|
+
if (!cat.context) focus.union(flat.boundingBox);
|
|
5545
|
+
|
|
5546
|
+
const row = document.createElement("div");
|
|
5547
|
+
row.className = "row";
|
|
5548
|
+
const sw = document.createElement("span");
|
|
5549
|
+
sw.className = "sw";
|
|
5550
|
+
sw.style.background = cat.color;
|
|
5551
|
+
const label = document.createElement("span");
|
|
5552
|
+
label.textContent = `${cat.name} (${cat.count})`;
|
|
5553
|
+
row.append(sw, label);
|
|
5554
|
+
row.addEventListener("click", () => {
|
|
5555
|
+
group.visible = !group.visible;
|
|
5556
|
+
row.classList.toggle("off", !group.visible);
|
|
5557
|
+
});
|
|
5558
|
+
legend.appendChild(row);
|
|
5559
|
+
}
|
|
5560
|
+
|
|
5561
|
+
// True 1:1:1 metre scale, z up. The camera frames the building; the ground
|
|
5562
|
+
// grid (at the model's lowest point) spans the neighbour shading too.
|
|
5563
|
+
if (focus.isEmpty()) focus.copy(box);
|
|
5564
|
+
const size = focus.getSize(new THREE.Vector3());
|
|
5565
|
+
const center = focus.getCenter(new THREE.Vector3());
|
|
5566
|
+
const span = Math.max(size.x, size.y, size.z, 1);
|
|
5567
|
+
const all = box.getSize(new THREE.Vector3());
|
|
5568
|
+
const allCenter = box.getCenter(new THREE.Vector3());
|
|
5569
|
+
const cell = Math.pow(10, Math.floor(Math.log10(Math.max(all.x, all.y, 1) / 2)));
|
|
5570
|
+
const cells = Math.ceil((Math.max(all.x, all.y) * 1.2) / cell / 2) * 2;
|
|
5571
|
+
const grid = new THREE.GridHelper(cells * cell, cells, 0xbbbbbb, 0xe3e3e3);
|
|
5572
|
+
grid.rotation.x = Math.PI / 2;
|
|
5573
|
+
grid.position.set(allCenter.x, allCenter.y, box.min.z);
|
|
5574
|
+
scene.add(grid);
|
|
5575
|
+
document.getElementById("cell").textContent = cell;
|
|
5576
|
+
|
|
5577
|
+
const camera = new THREE.PerspectiveCamera(40, view.clientWidth / view.clientHeight, span / 1000, Math.max(span, all.x, all.y) * 100);
|
|
5578
|
+
camera.up.set(0, 0, 1);
|
|
5579
|
+
const eye = new THREE.Vector3(1.5, -1.5, 1.0).normalize().multiplyScalar(span * 1.8);
|
|
5580
|
+
camera.position.copy(center).add(eye);
|
|
5581
|
+
const controls = new OrbitControls(camera, renderer.domElement);
|
|
5582
|
+
controls.target.copy(center);
|
|
5583
|
+
controls.enableDamping = true;
|
|
5584
|
+
controls.update();
|
|
5585
|
+
|
|
5586
|
+
// Hover: name of the surface category under the cursor.
|
|
5587
|
+
const tip = document.getElementById("tip");
|
|
5588
|
+
const ray = new THREE.Raycaster();
|
|
5589
|
+
const ndc = new THREE.Vector2();
|
|
5590
|
+
renderer.domElement.addEventListener("pointermove", (ev) => {
|
|
5591
|
+
const r = renderer.domElement.getBoundingClientRect();
|
|
5592
|
+
ndc.set(((ev.clientX - r.left) / r.width) * 2 - 1, -((ev.clientY - r.top) / r.height) * 2 + 1);
|
|
5593
|
+
ray.setFromCamera(ndc, camera);
|
|
5594
|
+
const hit = ray.intersectObjects(meshes.filter((m) => m.parent.visible), false)[0];
|
|
5595
|
+
if (hit) {
|
|
5596
|
+
tip.textContent = hit.object.userData.name;
|
|
5597
|
+
tip.style.left = `${ev.clientX + 12}px`;
|
|
5598
|
+
tip.style.top = `${ev.clientY + 12}px`;
|
|
5599
|
+
tip.style.display = "block";
|
|
5600
|
+
} else {
|
|
5601
|
+
tip.style.display = "none";
|
|
5602
|
+
}
|
|
5603
|
+
});
|
|
5604
|
+
renderer.domElement.addEventListener("pointerleave", () => { tip.style.display = "none"; });
|
|
5605
|
+
|
|
5606
|
+
window.addEventListener("resize", () => {
|
|
5607
|
+
camera.aspect = view.clientWidth / view.clientHeight;
|
|
5608
|
+
camera.updateProjectionMatrix();
|
|
5609
|
+
renderer.setSize(view.clientWidth, view.clientHeight);
|
|
5610
|
+
});
|
|
5611
|
+
renderer.setAnimationLoop(() => { controls.update(); renderer.render(scene, camera); });
|
|
5612
|
+
</script>
|
|
5613
|
+
</body>
|
|
5614
|
+
</html>
|
|
5615
|
+
"""
|
|
5616
|
+
|
|
5617
|
+
|
|
5618
|
+
def _open_html_in_browser(page, timeout=120):
|
|
5619
|
+
"""Open ``page`` in the web browser from a one-shot local HTTP server.
|
|
5620
|
+
|
|
5621
|
+
A ``file://`` URL is not enough: PyCharm's remote-dev ``BROWSER`` hook only
|
|
5622
|
+
forwards ``http(s)`` links to the client machine (as plotly's ``fig.show``
|
|
5623
|
+
does). The server answers the first request for the page, in a daemon
|
|
5624
|
+
thread, and gives up after ``timeout`` seconds."""
|
|
5625
|
+
import threading
|
|
5626
|
+
import time
|
|
5627
|
+
import webbrowser
|
|
5628
|
+
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
5629
|
+
|
|
5630
|
+
body = page.encode("utf-8")
|
|
5631
|
+
served = threading.Event()
|
|
5632
|
+
|
|
5633
|
+
class _Handler(BaseHTTPRequestHandler):
|
|
5634
|
+
def do_GET(self):
|
|
5635
|
+
if self.path.split("?")[0] != "/":
|
|
5636
|
+
self.send_response(404)
|
|
5637
|
+
self.end_headers()
|
|
5638
|
+
return
|
|
5639
|
+
self.send_response(200)
|
|
5640
|
+
self.send_header("Content-Type", "text/html; charset=utf-8")
|
|
5641
|
+
self.send_header("Content-Length", str(len(body)))
|
|
5642
|
+
self.end_headers()
|
|
5643
|
+
self.wfile.write(body)
|
|
5644
|
+
served.set()
|
|
5645
|
+
|
|
5646
|
+
def log_message(self, *args):
|
|
5647
|
+
pass
|
|
5648
|
+
|
|
5649
|
+
server = HTTPServer(("127.0.0.1", 0), _Handler)
|
|
5650
|
+
server.timeout = 1
|
|
5651
|
+
|
|
5652
|
+
def _serve():
|
|
5653
|
+
deadline = time.time() + timeout
|
|
5654
|
+
while not served.is_set() and time.time() < deadline:
|
|
5655
|
+
server.handle_request()
|
|
5656
|
+
server.server_close()
|
|
5657
|
+
|
|
5658
|
+
threading.Thread(target=_serve, daemon=True).start()
|
|
5659
|
+
webbrowser.open(f"http://127.0.0.1:{server.server_port}/")
|
|
5660
|
+
|
|
5661
|
+
|
|
5662
|
+
class IDFGeometryView:
|
|
5663
|
+
"""The three.js page returned by :func:`plot_idf_geometry`.
|
|
5664
|
+
|
|
5665
|
+
``html`` holds the standalone page and ``path`` the file it was saved to
|
|
5666
|
+
(or ``None``). ``show()`` opens it in the web browser; in Jupyter it renders
|
|
5667
|
+
inline. Its repr is one line, so the page isn't dumped into the console."""
|
|
5668
|
+
|
|
5669
|
+
def __init__(self, html, path=None):
|
|
5670
|
+
self.html = html
|
|
5671
|
+
self.path = path
|
|
5672
|
+
|
|
5673
|
+
def show(self):
|
|
5674
|
+
_open_html_in_browser(self.html)
|
|
5675
|
+
|
|
5676
|
+
def __repr__(self):
|
|
5677
|
+
where = f", saved to {self.path}" if self.path else ""
|
|
5678
|
+
return f"<IDFGeometryView: {len(self.html) // 1024} KB{where}>"
|
|
5679
|
+
|
|
5680
|
+
def _repr_html_(self):
|
|
5681
|
+
import html as _html
|
|
5682
|
+
return (f'<iframe srcdoc="{_html.escape(self.html, quote=True)}" '
|
|
5683
|
+
'style="width:100%;height:600px;border:0"></iframe>')
|
|
5684
|
+
|
|
5685
|
+
|
|
5410
5686
|
def plot_idf_geometry(idf, output_path=None, show=False, opacity=0.8,
|
|
5411
5687
|
include_shading=True, title=None, shading_opacity=0.2,
|
|
5412
5688
|
**_ignored):
|
|
5413
5689
|
"""Render the 3-D geometry of an EnergyPlus IDF — zone walls/roofs/floors,
|
|
5414
|
-
windows and neighbour shadings — as an INTERACTIVE
|
|
5415
|
-
|
|
5690
|
+
windows and neighbour shadings — as an INTERACTIVE three.js page (rotate /
|
|
5691
|
+
pan / zoom, toggle surface categories, hover for the category name).
|
|
5416
5692
|
|
|
5417
5693
|
Parameters
|
|
5418
5694
|
----------
|
|
5419
5695
|
idf : a ``geomeppy``/``eppy`` IDF object, or a path to an ``.idf`` file.
|
|
5420
|
-
output_path : optional path to save the
|
|
5696
|
+
output_path : optional path to save the viewer; written as a standalone
|
|
5421
5697
|
``.html`` (any other extension is coerced to ``.html``).
|
|
5422
|
-
show : if True and no ``output_path``, open the
|
|
5423
|
-
|
|
5698
|
+
show : if True and no ``output_path``, open the viewer in the default web
|
|
5699
|
+
browser (served from a one-shot local HTTP server).
|
|
5700
|
+
include_shading : draw the ``Shading:*:Detailed`` surfaces: the neighbour
|
|
5701
|
+
obstructions (``Shading: neighbours``) and the building's own reveals,
|
|
5702
|
+
balconies and awnings (``Shading: building``).
|
|
5424
5703
|
opacity : fill opacity of the building surfaces (default 0.8, so a surface
|
|
5425
5704
|
seen through one or more others reads as clearly blurred/dimmed).
|
|
5426
|
-
shading_opacity : fill opacity of the neighbour
|
|
5705
|
+
shading_opacity : fill opacity of the neighbour shading panels (default
|
|
5427
5706
|
0.2) — kept well below ``opacity`` so the context obstructions don't
|
|
5428
|
-
compete with the building itself.
|
|
5429
|
-
|
|
5707
|
+
compete with the building itself. The building's own shading uses
|
|
5708
|
+
``opacity``.
|
|
5709
|
+
title : page title.
|
|
5430
5710
|
|
|
5431
|
-
Returns the
|
|
5711
|
+
Returns an :class:`IDFGeometryView` (``.html`` is the page, ``.show()``
|
|
5712
|
+
opens it, and it renders inline in Jupyter).
|
|
5713
|
+
|
|
5714
|
+
The geometry is embedded in the page; three.js itself is loaded from the
|
|
5715
|
+
jsDelivr CDN, so opening the page needs an internet connection.
|
|
5432
5716
|
|
|
5433
5717
|
Party walls (``Wall: party``) and adiabatic partitions (``Wall: adiabatic``)
|
|
5434
5718
|
are separate legend groups/colours: both share the Adiabatic boundary
|
|
5435
5719
|
condition, but a party wall abuts the neighbour building (its outer face sees
|
|
5436
5720
|
outdoor air) whereas an adiabatic wall is a purely internal partition.
|
|
5437
5721
|
"""
|
|
5438
|
-
import
|
|
5722
|
+
import html as _html
|
|
5723
|
+
import json
|
|
5439
5724
|
|
|
5440
5725
|
if isinstance(idf, str):
|
|
5441
5726
|
IDF = _ensure_idd()
|
|
@@ -5446,53 +5731,41 @@ def plot_idf_geometry(idf, output_path=None, show=False, opacity=0.8,
|
|
|
5446
5731
|
# Stable fallback palette for categories not in _IDF_VIEW_COLORS.
|
|
5447
5732
|
_fallback = ["#8dd3c7", "#fb8072", "#80b1d3", "#fdb462", "#b3de69",
|
|
5448
5733
|
"#bc80bd", "#ffed6f", "#fccde5", "#d9d9d9"]
|
|
5449
|
-
|
|
5734
|
+
categories = []
|
|
5450
5735
|
for ci, (cat, polys) in enumerate(polys_by_cat.items()):
|
|
5451
5736
|
if not polys:
|
|
5452
5737
|
continue
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
xs, ys, zs, i, j, k = [], [], [], [], [], []
|
|
5456
|
-
ex, ey, ez = [], [], [] # edge polylines (None-separated)
|
|
5738
|
+
# One fan-triangulated mesh + one outline set per category.
|
|
5739
|
+
positions, indices, edges = [], [], []
|
|
5457
5740
|
for poly in polys:
|
|
5458
|
-
base = len(
|
|
5741
|
+
base = len(positions) // 3
|
|
5459
5742
|
for (x, y, z) in poly:
|
|
5460
|
-
|
|
5743
|
+
positions += [round(x, 3), round(y, 3), round(z, 3)]
|
|
5461
5744
|
for t in range(1, len(poly) - 1):
|
|
5462
|
-
|
|
5463
|
-
for
|
|
5464
|
-
|
|
5465
|
-
ex.append(None); ey.append(None); ez.append(None)
|
|
5745
|
+
indices += [base, base + t, base + t + 1]
|
|
5746
|
+
for a, b in zip(poly, poly[1:] + poly[:1]):
|
|
5747
|
+
edges += [round(v, 3) for v in (*a, *b)]
|
|
5466
5748
|
# Neighbour shading is context — render it much more transparent than the
|
|
5467
|
-
# building surfaces so it never competes with them.
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
color
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
xaxis=dict(title="x (m)"),
|
|
5488
|
-
yaxis=dict(title="y (m)"),
|
|
5489
|
-
zaxis=dict(title="Height (m)"),
|
|
5490
|
-
aspectmode="data",
|
|
5491
|
-
camera=dict(eye=dict(x=1.5, y=-1.5, z=1.0)),
|
|
5492
|
-
),
|
|
5493
|
-
legend=dict(title="Surface", x=0.01, y=0.99),
|
|
5494
|
-
margin=dict(l=0, r=0, b=40, t=40),
|
|
5495
|
-
)
|
|
5749
|
+
# building surfaces so it never competes with them. The building's own
|
|
5750
|
+
# shading (reveals, balconies, awnings) is drawn like the building.
|
|
5751
|
+
is_shading = cat == "Shading: neighbours"
|
|
5752
|
+
categories.append({
|
|
5753
|
+
"name": cat,
|
|
5754
|
+
"color": _IDF_VIEW_COLORS.get(cat, _fallback[ci % len(_fallback)]),
|
|
5755
|
+
"opacity": float(shading_opacity if is_shading else opacity),
|
|
5756
|
+
"edge_opacity": 0.25 if is_shading else 0.6,
|
|
5757
|
+
"context": is_shading,
|
|
5758
|
+
"count": len(polys),
|
|
5759
|
+
"positions": positions, "indices": indices, "edges": edges,
|
|
5760
|
+
})
|
|
5761
|
+
|
|
5762
|
+
# "</" is escaped so the JSON can't close its <script> block early.
|
|
5763
|
+
data = json.dumps({"title": title, "categories": categories},
|
|
5764
|
+
separators=(",", ":")).replace("</", "<\\/")
|
|
5765
|
+
page = (_IDF_VIEW_HTML
|
|
5766
|
+
.replace("__TITLE__", _html.escape(title or "IDF geometry"))
|
|
5767
|
+
.replace("__V__", _THREEJS_VERSION)
|
|
5768
|
+
.replace("__DATA__", data))
|
|
5496
5769
|
|
|
5497
5770
|
if output_path:
|
|
5498
5771
|
ext = output_path.rsplit(".", 1)[-1].lower() if "." in output_path else ""
|
|
@@ -5500,11 +5773,13 @@ def plot_idf_geometry(idf, output_path=None, show=False, opacity=0.8,
|
|
|
5500
5773
|
output_path = (output_path.rsplit(".", 1)[0] + ".html"
|
|
5501
5774
|
if "." in output_path else output_path + ".html")
|
|
5502
5775
|
os.makedirs(os.path.dirname(output_path) or ".", exist_ok=True)
|
|
5503
|
-
|
|
5776
|
+
with open(output_path, "w", encoding="utf-8") as fh:
|
|
5777
|
+
fh.write(page)
|
|
5504
5778
|
print(f"IDF geometry plot saved to {output_path}")
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5779
|
+
view = IDFGeometryView(page, output_path or None)
|
|
5780
|
+
if show and not output_path:
|
|
5781
|
+
view.show()
|
|
5782
|
+
return view
|
|
5508
5783
|
|
|
5509
5784
|
|
|
5510
5785
|
# =========================================================================== #
|
|
@@ -1552,10 +1552,15 @@ def join_cadaster_building(gdf, cadaster_dir, census_tracts_dir, DEM_raster_dir,
|
|
|
1552
1552
|
# like br__building_spaces_*); other GEOMETRY columns
|
|
1553
1553
|
# stay as raw WKB bytes so write_gdf downstream doesn't
|
|
1554
1554
|
# see unexpected geopandas 'geometry' dtype columns.
|
|
1555
|
+
# _br_merged is built by raw SQL, so _meta holds no CRS for it
|
|
1556
|
+
# and read_gdf would return crs=None; carry the source CRS over.
|
|
1555
1557
|
with utils.stage_timer("merge: read _br_merged into GeoDataFrame"):
|
|
1558
|
+
_src_crs = building_gdf_.crs
|
|
1556
1559
|
building_gdf_ = _db_mod.read_gdf(
|
|
1557
1560
|
central_con, "_br_merged", geom_col="building_geometry"
|
|
1558
1561
|
)
|
|
1562
|
+
if building_gdf_.crs is None and _src_crs is not None:
|
|
1563
|
+
building_gdf_ = building_gdf_.set_crs(_src_crs)
|
|
1559
1564
|
|
|
1560
1565
|
# Also keep br_results for building_part_gdf downstream
|
|
1561
1566
|
with utils.stage_timer("merge: br_results -> pandas (building_part_gdf)"):
|
|
@@ -3844,7 +3844,7 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3844
3844
|
break
|
|
3845
3845
|
|
|
3846
3846
|
if not per_space_cols:
|
|
3847
|
-
sys.stderr.write("[FLAT] No per-space columns found")
|
|
3847
|
+
sys.stderr.write("[FLAT] No per-space columns found\n")
|
|
3848
3848
|
return pd.DataFrame()
|
|
3849
3849
|
|
|
3850
3850
|
renamed_space_cols = {
|
|
@@ -3857,11 +3857,11 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3857
3857
|
if c not in per_space_cols
|
|
3858
3858
|
]
|
|
3859
3859
|
|
|
3860
|
-
sys.stderr.write(f"[FLAT] per-space columns: {len(per_space_cols)}")
|
|
3860
|
+
sys.stderr.write(f"[FLAT] per-space columns: {len(per_space_cols)}\n")
|
|
3861
3861
|
|
|
3862
|
-
sys.stderr.write(f"[FLAT] context columns: {len(context_cols)}")
|
|
3862
|
+
sys.stderr.write(f"[FLAT] context columns: {len(context_cols)}\n")
|
|
3863
3863
|
|
|
3864
|
-
sys.stderr.write("[FLAT] Counting building spaces
|
|
3864
|
+
sys.stderr.write("[FLAT] Counting building spaces...\n")
|
|
3865
3865
|
|
|
3866
3866
|
# Determine how many output rows we need.
|
|
3867
3867
|
total_records = 0
|
|
@@ -3870,7 +3870,7 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3870
3870
|
|
|
3871
3871
|
for start in range(0, n_buildings, chunk_size):
|
|
3872
3872
|
stop = min(start + chunk_size, n_buildings)
|
|
3873
|
-
sys.stderr.write(f"[FLAT] counting buildings {start:,} -> {stop:,}")
|
|
3873
|
+
sys.stderr.write(f"[FLAT] counting buildings {start:,} -> {stop:,}\n")
|
|
3874
3874
|
part = gdf.iloc[start:stop]
|
|
3875
3875
|
|
|
3876
3876
|
for _, row in part.iterrows():
|
|
@@ -3892,12 +3892,12 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3892
3892
|
|
|
3893
3893
|
gc.collect()
|
|
3894
3894
|
|
|
3895
|
-
sys.stderr.write(f"[FLAT] Total records: {total_records:,}")
|
|
3895
|
+
sys.stderr.write(f"[FLAT] Total records: {total_records:,}\n")
|
|
3896
3896
|
|
|
3897
3897
|
if total_records == 0:
|
|
3898
3898
|
return pd.DataFrame()
|
|
3899
3899
|
|
|
3900
|
-
sys.stderr.write("[FLAT] Allocating output columns
|
|
3900
|
+
sys.stderr.write("[FLAT] Allocating output columns...\n")
|
|
3901
3901
|
|
|
3902
3902
|
output = {}
|
|
3903
3903
|
|
|
@@ -3914,7 +3914,7 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3914
3914
|
for start in range(0, n_buildings, chunk_size):
|
|
3915
3915
|
stop = min(start + chunk_size, n_buildings)
|
|
3916
3916
|
|
|
3917
|
-
sys.stderr.write(f"
|
|
3917
|
+
sys.stderr.write(f"[FLAT] filling buildings {start:,} -> {stop:,}\n")
|
|
3918
3918
|
|
|
3919
3919
|
part = gdf.iloc[start:stop]
|
|
3920
3920
|
|
|
@@ -3959,14 +3959,14 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3959
3959
|
|
|
3960
3960
|
gc.collect()
|
|
3961
3961
|
|
|
3962
|
-
sys.stderr.write(f"[FLAT] filled {pos:,} / {total_records:,}")
|
|
3962
|
+
sys.stderr.write(f"[FLAT] filled {pos:,} / {total_records:,}\n")
|
|
3963
3963
|
|
|
3964
3964
|
if pos != total_records:
|
|
3965
3965
|
raise RuntimeError(
|
|
3966
3966
|
f"Expected {total_records:,} records but generated {pos:,}"
|
|
3967
3967
|
)
|
|
3968
3968
|
|
|
3969
|
-
sys.stderr.write("
|
|
3969
|
+
sys.stderr.write("[FLAT] Creating final DataFrame...\n")
|
|
3970
3970
|
|
|
3971
3971
|
result = pd.DataFrame(output)
|
|
3972
3972
|
|
|
@@ -3979,7 +3979,7 @@ def flat_gdf_to_building_spaces_resolution(gdf, building_reference_col="building
|
|
|
3979
3979
|
|
|
3980
3980
|
gc.collect()
|
|
3981
3981
|
|
|
3982
|
-
sys.stderr.write(f"[FLAT] Final DataFrame: {len(result):,} rows")
|
|
3982
|
+
sys.stderr.write(f"[FLAT] Final DataFrame: {len(result):,} rows\n")
|
|
3983
3983
|
|
|
3984
3984
|
return result
|
|
3985
3985
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hypercadaster_es
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.2
|
|
4
4
|
Summary: Python library to obtain the Spanish cadaster data joined with external attributes.
|
|
5
5
|
Home-page: https://github.com/BeeGroup-cimne
|
|
6
6
|
Author: Jose Manuel Broto Vispe
|
|
@@ -80,13 +80,26 @@ Requires-Dist: regex<2027.0,>=2023.12
|
|
|
80
80
|
Requires-Dist: tqdm>=4.66
|
|
81
81
|
Requires-Dist: six>=1.16
|
|
82
82
|
Requires-Dist: PyYAML>=6.0
|
|
83
|
-
Requires-Dist: social_ES>=1.0.
|
|
83
|
+
Requires-Dist: social_ES>=1.0.4
|
|
84
84
|
Provides-Extra: dev
|
|
85
85
|
Requires-Dist: black>=24.0; extra == "dev"
|
|
86
86
|
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
87
87
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
88
88
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
89
89
|
Requires-Dist: pdoc>=14.0; extra == "dev"
|
|
90
|
+
Dynamic: author
|
|
91
|
+
Dynamic: author-email
|
|
92
|
+
Dynamic: classifier
|
|
93
|
+
Dynamic: description
|
|
94
|
+
Dynamic: description-content-type
|
|
95
|
+
Dynamic: home-page
|
|
96
|
+
Dynamic: keywords
|
|
97
|
+
Dynamic: license
|
|
98
|
+
Dynamic: license-file
|
|
99
|
+
Dynamic: provides-extra
|
|
100
|
+
Dynamic: requires-dist
|
|
101
|
+
Dynamic: requires-python
|
|
102
|
+
Dynamic: summary
|
|
90
103
|
|
|
91
104
|
# hypercadaster_ES
|
|
92
105
|
|
|
@@ -94,7 +107,7 @@ A comprehensive Python library for downloading, processing, and analyzing Spanis
|
|
|
94
107
|
|
|
95
108
|
[](https://python.org)
|
|
96
109
|
[](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
|
|
97
|
-
[](https://github.com/BeeGroup-cimne/hypercadaster_ES)
|
|
98
111
|
|
|
99
112
|
## 🎯 Overview
|
|
100
113
|
|
|
@@ -221,4 +234,4 @@ This project is licensed under the **EUPL v1.2**. See the [license](https://join
|
|
|
221
234
|
|
|
222
235
|
*hypercadaster_ES - Built with ❤️ for the Spanish urban analysis and building research community*
|
|
223
236
|
|
|
224
|
-
*Last updated: November 2026 | Version 1.4.
|
|
237
|
+
*Last updated: November 2026 | Version 1.4.2*
|
|
@@ -3,7 +3,7 @@ from setuptools import find_packages, setup
|
|
|
3
3
|
|
|
4
4
|
HERE = pathlib.Path(__file__).parent
|
|
5
5
|
|
|
6
|
-
VERSION = "1.4.
|
|
6
|
+
VERSION = "1.4.2"
|
|
7
7
|
PACKAGE_NAME = "hypercadaster_es"
|
|
8
8
|
AUTHOR = "Jose Manuel Broto Vispe"
|
|
9
9
|
AUTHOR_EMAIL = "jmbrotovispe@gmail.com"
|
|
@@ -104,7 +104,7 @@ INSTALL_REQUIRES = [
|
|
|
104
104
|
# --- Socioeconomic INE datasets (EUPL-1.2) ---
|
|
105
105
|
# 1.0.3 emits the Essential-Characteristics variables already translated to
|
|
106
106
|
# English snake_case and adds the dwellings / empty-and-secondary censuses.
|
|
107
|
-
"social_ES>=1.0.
|
|
107
|
+
"social_ES>=1.0.4",
|
|
108
108
|
]
|
|
109
109
|
|
|
110
110
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hypercadaster_es-1.4.0 → hypercadaster_es-1.4.2}/hypercadaster_es.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|