# Geometry :

Subject: Re: [geometry] "covered_by" for polygons
From: Volker Schöch (vschoech_at_[hidden])
Date: 2012-02-16 04:45:15

Barend,

> > Any pros or cons for A.covered_by(B) := area(A-B)==0 vs. A.covered_by(B) := (A&B)==A ?
>
> The difference and intersection do have the same complexity and precision.

Thanks, that's what I expected.

> The equals-test will cost you more than the area-test.

That's a detail I wasn't aware of. I'll prefer the A-B implementation then. Given that A and B are multi-polygons, and based on your reply to my earlier post < http://lists.boost.org/geometry/2012/02/1818.php> I assume that I can simply check for empty() and skip the area test altogether. In other words: Is there a guarantee that if A is covered by B, (A-B) will be an empty container, rather than a container that contains one or more empty polygons?

> But area(A-B)==0 is not always a good test. Suppose A is empty. Than A-B = empty as well. But A is not covered by B

Sure. We will have to decide what we need in these corner cases and treat them explicitly if need be. What is your approach? Will an empty (multi-)polygon be a valid input to a (currently hypothetical) implementation of covered_by?

> > Do you think there are any optimization opportunities in a dedicated covered_by algorithm?
>
> The intersection or difference operations are not necessary. Getting intersection points and some additional logic should be enough.

Ok then, I'm looking forward to a dedicated implementation some day! :-)
Thanks again
Volker

```--
Volker Schöch | vschoech_at_[hidden]
Senior Software Engineer
think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany
http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091
Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl
```

Geometry list run by mateusz at loskot.net