diff --git a/backend/apis/GoogleSolarApi.py b/backend/apis/GoogleSolarApi.py index c5167e32..1354bbff 100644 --- a/backend/apis/GoogleSolarApi.py +++ b/backend/apis/GoogleSolarApi.py @@ -154,7 +154,9 @@ class GoogleSolarApi: # Automatically exclude north-facing segments self.exclude_north_facing_segments() # If a property is semi-detached, it's possible for us to include segments from an attached unit - if property_instance.data["built-form"] == "Semi-Detached": + if (property_instance.data["built-form"] == "Semi-Detached") and ( + property_instance.data["extension-count"] == 0 + ): self.exclude_likely_duplicate_surfaces() self.roof_area = self.insights_data["solarPotential"]["wholeRoofStats"]['areaMeters2'] @@ -506,6 +508,7 @@ class GoogleSolarApi: property_center = self.insights_data["center"] deduped_segments = [] + dropped_segments = [] for segment in self.roof_segments: if not deduped_segments: deduped_segments.append(segment) @@ -529,12 +532,16 @@ class GoogleSolarApi: if current_dist < similar_dist: deduped_segments.remove(similar_segment) deduped_segments.append(segment) + dropped_segments.append(similar_segment) + else: + dropped_segments.append(segment) # If we have a semi-detached property that has duplicated segments, we should expect to half the number of # segments if len(deduped_segments) < len(self.roof_segments): if len(deduped_segments) != len(self.roof_segments) / 2: - raise ValueError("We don't have half the number of segments that we started with") + # We don't perform any dropping in this case + return # Because the segments are duplicated, but the sizes aren't necessarily split perfectly in half, what # we need to do is perform the solar analysis and then half the results. We set an indicator which diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index a108176b..7e14b61f 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -440,7 +440,10 @@ async def trigger_plan(body: PlanTriggerRequest): logger.info("Performing solar analysis") # TODO: Tidy this up # TODO: If a property is semi-detached, we might get roof surfaces for the main building + the neighbour - # + # TODO: If we can't get high image quality, should we use the solar API? Maybe just for semi-detached units with + # extensions, since it doesn't seem to do a great job + # TODO: For simple properties, we should do a comparison/check between the solar API's roof area and the + # basic estimate of roof area building_ids = [ { "building_id": p.building_id,