From eef0e8e39807e686910339fcbb84244c17bccb9f Mon Sep 17 00:00:00 2001 From: David Huggins-Daines Date: Wed, 10 Jul 2024 09:24:06 -0400 Subject: [PATCH] fix: make zone lookup more reliable --- zonalda/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zonalda/__init__.py b/zonalda/__init__.py index ed4d2f9..78b5a2a 100644 --- a/zonalda/__init__.py +++ b/zonalda/__init__.py @@ -43,11 +43,15 @@ def __getitem__(self, name: str) -> tuple[ zone = zones.iloc[0] district, collecte = None, None districts = self.districts.loc[self.districts.contains(zone.geometry)] + if len(districts) == 0: + districts = self.districts.loc[self.districts.intersects(zone.geometry)] if len(districts) > 1: LOGGER.warning("Plusieurs districts trouvé pour %s: %s", name, districts) if len(districts): district = districts.iloc[0] collectes = self.collectes.loc[self.collectes.contains(zone.geometry)] + if len(collectes) == 0: + collectes = self.collectes.loc[self.collectes.intersects(zone.geometry)] if len(collectes) > 1: LOGGER.warning( "Plusieurs zones de collectes trouvé pour %s: %s", name, collectes