hypercadaster-ES 1.4.3__tar.gz → 1.4.4__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.
Files changed (50) hide show
  1. {hypercadaster_es-1.4.3/hypercadaster_es.egg-info → hypercadaster_es-1.4.4}/PKG-INFO +3 -3
  2. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/README.md +2 -2
  3. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/__init__.py +1 -1
  4. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/energy.py +101 -8
  5. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/energy_config.yaml +6 -0
  6. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4/hypercadaster_es.egg-info}/PKG-INFO +3 -3
  7. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/setup.py +1 -1
  8. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_energy_scenarios.py +31 -0
  9. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/LICENSE +0 -0
  10. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/MANIFEST.in +0 -0
  11. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/_db.py +0 -0
  12. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/_pretty.py +0 -0
  13. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/building_inference.py +0 -0
  14. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/cached_files/ine_inspire_codes.xlsx +0 -0
  15. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/downloaders.py +0 -0
  16. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/functions.py +0 -0
  17. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/interoperability.py +0 -0
  18. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/mergers.py +0 -0
  19. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/reporting.py +0 -0
  20. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/social.py +0 -0
  21. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/topology.py +0 -0
  22. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/utils.py +0 -0
  23. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_ES/weather.py +0 -0
  24. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_es.egg-info/SOURCES.txt +0 -0
  25. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_es.egg-info/dependency_links.txt +0 -0
  26. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_es.egg-info/requires.txt +0 -0
  27. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/hypercadaster_es.egg-info/top_level.txt +0 -0
  28. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/setup.cfg +0 -0
  29. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_aggregation.py +0 -0
  30. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_agricultural_archetype.py +0 -0
  31. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_cartociudad_api.py +0 -0
  32. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_cat_address.py +0 -0
  33. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_cat_cache.py +0 -0
  34. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_cat_empty_schema.py +0 -0
  35. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_census_tract_aggregations.py +0 -0
  36. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_code_normalisation.py +0 -0
  37. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_codes.py +0 -0
  38. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_db_layer.py +0 -0
  39. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_dem_tiles.py +0 -0
  40. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_energy_config.py +0 -0
  41. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_floorplan_partition.py +0 -0
  42. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_geometry.py +0 -0
  43. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_import_surface.py +0 -0
  44. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_live_smoke.py +0 -0
  45. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_shadow_rules.py +0 -0
  46. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_social.py +0 -0
  47. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_theoretical_cat_spaces.py +0 -0
  48. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_topology.py +0 -0
  49. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_weather.py +0 -0
  50. {hypercadaster_es-1.4.3 → hypercadaster_es-1.4.4}/tests/test_zero_floor_buildings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypercadaster_es
3
- Version: 1.4.3
3
+ Version: 1.4.4
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
@@ -107,7 +107,7 @@ A comprehensive Python library for downloading, processing, and analyzing Spanis
107
107
 
108
108
  [![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://python.org)
109
109
  [![License](https://img.shields.io/badge/license-EUPL%20v1.2-blue.svg)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
110
- [![Version](https://img.shields.io/badge/version-1.4.3-green.svg)](https://github.com/BeeGroup-cimne/hypercadaster_ES)
110
+ [![Version](https://img.shields.io/badge/version-1.4.4-green.svg)](https://github.com/BeeGroup-cimne/hypercadaster_ES)
111
111
 
112
112
  ## 🎯 Overview
113
113
 
@@ -235,4 +235,4 @@ This project is licensed under the **EUPL v1.2**. See the [license](https://join
235
235
 
236
236
  *hypercadaster_ES - Built with ❤️ for the Spanish urban analysis and building research community*
237
237
 
238
- *Last updated: December 2026 | Version 1.4.3*
238
+ *Last updated: December 2026 | Version 1.4.4*
@@ -4,7 +4,7 @@ A comprehensive Python library for downloading, processing, and analyzing Spanis
4
4
 
5
5
  [![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://python.org)
6
6
  [![License](https://img.shields.io/badge/license-EUPL%20v1.2-blue.svg)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
7
- [![Version](https://img.shields.io/badge/version-1.4.3-green.svg)](https://github.com/BeeGroup-cimne/hypercadaster_ES)
7
+ [![Version](https://img.shields.io/badge/version-1.4.4-green.svg)](https://github.com/BeeGroup-cimne/hypercadaster_ES)
8
8
 
9
9
  ## 🎯 Overview
10
10
 
@@ -132,4 +132,4 @@ This project is licensed under the **EUPL v1.2**. See the [license](https://join
132
132
 
133
133
  *hypercadaster_ES - Built with ❤️ for the Spanish urban analysis and building research community*
134
134
 
135
- *Last updated: December 2026 | Version 1.4.3*
135
+ *Last updated: December 2026 | Version 1.4.4*
@@ -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.3"
29
+ __version__ = "1.4.4"
30
30
  __author__ = "Jose Manuel Broto Vispe"
31
31
  __email__ = "jmbrotovispe@gmail.com"
32
32
 
@@ -3483,12 +3483,95 @@ def _refine_exterior_bcs(idf, row, zone_meta, floor_height, ground_floor_height,
3483
3483
  return party_names, main_facade_names
3484
3484
 
3485
3485
 
3486
- def _add_shading(idf, shadows, ox, oy, floor_height, ground_floor_height, eps=0.05):
3486
+ def _merge_coplanar_panels(panels, angle_tol_deg=1.0, offset_tol=0.1, gap_tol=0.05):
3487
+ """Join vertical shading panels that lie in one plane into fewer, larger ones.
3488
+
3489
+ ``panels`` are ``(x0, y0, x1, y1, z0, z1, floor)``. Panels whose footprint
3490
+ segments are collinear within ``angle_tol_deg`` and ``offset_tol`` m share a
3491
+ plane. In each plane, the panels of a storey are joined along the line
3492
+ where they touch or overlap (gaps up to ``gap_tol`` m), then the joined
3493
+ strips that cover the same stretch on consecutive storeys are stacked into
3494
+ one panel. A neighbour's façade drawn as one panel per storey and per
3495
+ boundary segment thus becomes a single rectangle. Every result is a
3496
+ rectangle, so each panel stays convex. Returns panels in the same shape,
3497
+ with ``floor`` the lowest storey it spans; the points are projected onto
3498
+ the shared plane, which moves them by at most ``offset_tol``."""
3499
+ tol = math.radians(angle_tol_deg)
3500
+ planes = [] # [theta, d, ux, uy, nx, ny, [(s0, s1, z0, z1, floor)]]
3501
+ buckets = {} # round(theta / tol) -> plane indices
3502
+ for x0, y0, x1, y1, z0, z1, fl in panels:
3503
+ th = math.atan2(y1 - y0, x1 - x0) % math.pi
3504
+ key = int(round(th / tol))
3505
+ hit = None
3506
+ for k in (key - 1, key, key + 1, key - int(round(math.pi / tol)),
3507
+ key + int(round(math.pi / tol))):
3508
+ for i in buckets.get(k, ()):
3509
+ pth, pd, ux, uy, nx, ny, _ = planes[i]
3510
+ dth = abs(th - pth)
3511
+ if min(dth, math.pi - dth) > tol:
3512
+ continue
3513
+ if (abs(nx * x0 + ny * y0 - pd) <= offset_tol
3514
+ and abs(nx * x1 + ny * y1 - pd) <= offset_tol):
3515
+ hit = i
3516
+ break
3517
+ if hit is not None:
3518
+ break
3519
+ if hit is None:
3520
+ ux, uy = math.cos(th), math.sin(th)
3521
+ nx, ny = -uy, ux
3522
+ pd = nx * (x0 + x1) / 2 + ny * (y0 + y1) / 2
3523
+ planes.append([th, pd, ux, uy, nx, ny, []])
3524
+ hit = len(planes) - 1
3525
+ buckets.setdefault(key, []).append(hit)
3526
+ _, _, ux, uy, _, _, members = planes[hit]
3527
+ sa, sb = sorted((ux * x0 + uy * y0, ux * x1 + uy * y1))
3528
+ members.append((sa, sb, z0, z1, fl))
3529
+
3530
+ out = []
3531
+ for _, pd, ux, uy, nx, ny, members in planes:
3532
+ # 1) per storey band: union of the intervals along the line
3533
+ bands = {}
3534
+ for sa, sb, z0, z1, fl in members:
3535
+ bands.setdefault((round(z0, 6), round(z1, 6), fl), []).append((sa, sb))
3536
+ strips = []
3537
+ for (z0, z1, fl), ivs in bands.items():
3538
+ ivs.sort()
3539
+ ca, cb = ivs[0]
3540
+ for sa, sb in ivs[1:]:
3541
+ if sa <= cb + gap_tol:
3542
+ cb = max(cb, sb)
3543
+ else:
3544
+ strips.append([ca, cb, z0, z1, fl])
3545
+ ca, cb = sa, sb
3546
+ strips.append([ca, cb, z0, z1, fl])
3547
+ # 2) stack the same stretch on consecutive storeys
3548
+ strips.sort(key=lambda t: (t[2], t[0]))
3549
+ open_ = []
3550
+ for st in strips:
3551
+ for o in open_:
3552
+ if (abs(o[3] - st[2]) <= 1e-6 and abs(o[0] - st[0]) <= gap_tol
3553
+ and abs(o[1] - st[1]) <= gap_tol):
3554
+ o[3] = st[3]
3555
+ break
3556
+ else:
3557
+ open_.append(st)
3558
+ for sa, sb, z0, z1, fl in open_:
3559
+ out.append((sa * ux + pd * nx, sa * uy + pd * ny,
3560
+ sb * ux + pd * nx, sb * uy + pd * ny, z0, z1, fl))
3561
+ return out
3562
+
3563
+
3564
+ def _add_shading(idf, shadows, ox, oy, floor_height, ground_floor_height, eps=0.05,
3565
+ merge=None):
3487
3566
  """Add neighbour-obstruction shading surfaces from ``br__shadows`` — the
3488
3567
  SAME per-floor shadow boundary the 3-D plot draws. Each boundary segment
3489
3568
  (excluding the analysis buffer-circle, detected via the radial gap, exactly
3490
3569
  as the plot does) becomes a vertical ``Shading:Building:Detailed`` panel
3491
- spanning its floor, in the model's local origin (``ox, oy``)."""
3570
+ spanning its floor, in the model's local origin (``ox, oy``).
3571
+
3572
+ With ``merge`` (default ``shading.neighbours.merge_coplanar``) coplanar
3573
+ panels are joined first (``_merge_coplanar_panels``): fewer surfaces for
3574
+ EnergyPlus's shadow calculation, the same obstruction."""
3492
3575
  if not isinstance(shadows, dict) or not shadows:
3493
3576
  return 0
3494
3577
  radii = []
@@ -3512,7 +3595,7 @@ def _add_shading(idf, shadows, ox, oy, floor_height, ground_floor_height, eps=0.
3512
3595
  if best_at is not None and best_gap >= 3.0:
3513
3596
  cut = best_at + 1e-6
3514
3597
 
3515
- n = 0
3598
+ panels = []
3516
3599
  for floor, poly in sorted(shadows.items()):
3517
3600
  if poly is None or getattr(poly, "is_empty", True):
3518
3601
  continue
@@ -3533,11 +3616,21 @@ def _add_shading(idf, shadows, ox, oy, floor_height, ground_floor_height, eps=0.
3533
3616
  continue # buffer-circle artefact (not a real obstruction)
3534
3617
  if math.hypot(x1 - x0, y1 - y0) < eps:
3535
3618
  continue
3536
- o = idf.newidfobject("SHADING:BUILDING:DETAILED",
3537
- Name=f"Shade_F{fl}_{n}")
3538
- o.setcoords([(x0 - ox, y0 - oy, z0), (x1 - ox, y1 - oy, z0),
3539
- (x1 - ox, y1 - oy, z1), (x0 - ox, y0 - oy, z1)])
3540
- n += 1
3619
+ panels.append((x0 - ox, y0 - oy, x1 - ox, y1 - oy, z0, z1, fl))
3620
+ nb = globals().get("_SHADE_NEIGHBOURS", {}) or {}
3621
+ if merge is None:
3622
+ merge = bool(nb.get("merge_coplanar", True))
3623
+ if merge and panels:
3624
+ panels = _merge_coplanar_panels(
3625
+ panels,
3626
+ angle_tol_deg=float(nb.get("merge_angle_tol_deg", 1.0)),
3627
+ offset_tol=float(nb.get("merge_offset_tol", 0.1)))
3628
+ n = 0
3629
+ for x0, y0, x1, y1, z0, z1, fl in panels:
3630
+ o = idf.newidfobject("SHADING:BUILDING:DETAILED",
3631
+ Name=f"Shade_F{fl}_{n}")
3632
+ o.setcoords([(x0, y0, z0), (x1, y1, z0), (x1, y1, z1), (x0, y0, z1)])
3633
+ n += 1
3541
3634
  return n
3542
3635
 
3543
3636
 
@@ -77,6 +77,12 @@ shading:
77
77
  # hemisphere), or hidden behind a nearer panel
78
78
  max_panels: 200 # hard cap on what survives the filter (E+ runtime
79
79
  # grows with panel count); null or -1 = keep them all
80
+ merge_coplanar: true # join panels in one plane before the filter: a
81
+ # neighbour's façade becomes one rectangle instead of
82
+ # one panel per storey and per boundary segment
83
+ # (1706206CG0110F: 2510 -> 613 panels, same area)
84
+ merge_angle_tol_deg: 1.0 # segments within this angle ...
85
+ merge_offset_tol: 0.1 # ... and this distance (m) share a plane
80
86
  sun_exclude_halfwidth: 67.5 # upper bound (deg either side of due north) on the
81
87
  # sun-free sector; the site latitude narrows it to
82
88
  # the solstice-sunrise azimuth (57.9° at 41.6° N)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypercadaster_es
3
- Version: 1.4.3
3
+ Version: 1.4.4
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
@@ -107,7 +107,7 @@ A comprehensive Python library for downloading, processing, and analyzing Spanis
107
107
 
108
108
  [![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://python.org)
109
109
  [![License](https://img.shields.io/badge/license-EUPL%20v1.2-blue.svg)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
110
- [![Version](https://img.shields.io/badge/version-1.4.3-green.svg)](https://github.com/BeeGroup-cimne/hypercadaster_ES)
110
+ [![Version](https://img.shields.io/badge/version-1.4.4-green.svg)](https://github.com/BeeGroup-cimne/hypercadaster_ES)
111
111
 
112
112
  ## 🎯 Overview
113
113
 
@@ -235,4 +235,4 @@ This project is licensed under the **EUPL v1.2**. See the [license](https://join
235
235
 
236
236
  *hypercadaster_ES - Built with ❤️ for the Spanish urban analysis and building research community*
237
237
 
238
- *Last updated: December 2026 | Version 1.4.3*
238
+ *Last updated: December 2026 | Version 1.4.4*
@@ -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.3"
6
+ VERSION = "1.4.4"
7
7
  PACKAGE_NAME = "hypercadaster_es"
8
8
  AUTHOR = "Jose Manuel Broto Vispe"
9
9
  AUTHOR_EMAIL = "jmbrotovispe@gmail.com"
@@ -1537,6 +1537,37 @@ def test_neighbour_prefix_matches_the_generator():
1537
1537
  assert 'Name=f"Shade_F{fl}_{n}"' in src
1538
1538
 
1539
1539
 
1540
+ def test_coplanar_shading_panels_are_joined():
1541
+ gf, fh = 4.0, 3.0
1542
+ z = [energy._floor_z(f, gf, fh) for f in range(3)]
1543
+ panels = []
1544
+ for f, (z0, z1) in enumerate(z):
1545
+ # one neighbour façade along y = 20, cut into two touching segments on
1546
+ # every storey, the second nudged 2 cm off the line
1547
+ panels += [(0.0, 20.0, 6.0, 20.0, z0, z1, f),
1548
+ (6.0, 20.02, 10.0, 20.02, z0, z1, f)]
1549
+ # a perpendicular façade on floor 0 only, and a parallel one 5 m behind
1550
+ panels += [(10.0, 20.0, 10.0, 30.0, *z[0], 0),
1551
+ (0.0, 25.0, 10.0, 25.0, *z[1], 1)]
1552
+ out = energy._merge_coplanar_panels(panels)
1553
+ assert len(out) == 3
1554
+ front = [p for p in out if abs(p[1] - 20.0) < 0.1 and abs(p[3] - 20.0) < 0.1]
1555
+ assert len(front) == 1
1556
+ x0, _, x1, _, z0, z1, fl = front[0]
1557
+ assert sorted((x0, x1)) == pytest.approx([0.0, 10.0], abs=1e-6)
1558
+ assert (z0, z1, fl) == (pytest.approx(0.0), pytest.approx(z[2][1]), 0)
1559
+ area = lambda ps: sum(np.hypot(p[2] - p[0], p[3] - p[1]) * (p[5] - p[4]) for p in ps)
1560
+ assert area(out) == pytest.approx(area(panels), rel=1e-3)
1561
+
1562
+
1563
+ def test_staggered_storeys_are_not_stacked():
1564
+ # floor 1 covers only half of floor 0's stretch: two panels, not one tall one
1565
+ # that would shade where nothing stands
1566
+ out = energy._merge_coplanar_panels([(0, 0, 10, 0, 0.0, 4.0, 0),
1567
+ (0, 0, 5, 0, 4.0, 7.0, 1)])
1568
+ assert len(out) == 2
1569
+
1570
+
1540
1571
  # --------------------------------------------------------------------------- #
1541
1572
  # Wall winding: every wall must face OUT of its own room
1542
1573
  # --------------------------------------------------------------------------- #