Operation to check if two polygons overlap is inefficient
@adybbroe ci sta già lavorando.
Dal 20/7/2021.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Code Sample, a minimal, complete, and verifiable piece of code
I did a profiling of the below code. The input was a list of trollsched.satpass.Pass satellite passes with only two passes overlapping each other over the areas of interest.
The _bool_opermethod of SphPolygon class was called three times, each taking almost 5 seconds. In tot al the code ran for 19 seconds.
# Your code here
def derive_combined_coverage(passes, area_def):
"""From a sequence of satellite overpasses derived the total coverage of an area."""
npasses = len(passes)
if npasses == 0:
print("No passes in time window!")
return 0
area_boundary = AreaDefBoundary(area_def, frequency=100)
area_boundary = area_boundary.contour_poly
list_of_polygons = []
for mypass in passes:
list_of_polygons.append(mypass.boundary.contour_poly)
non_overlaps = GetNonOverlapUnions(list_of_polygons)
non_overlaps.merge()
polygons = non_overlaps.get_polygons()
pass_ids = non_overlaps.get_ids()
coverage = 0
for polygon in polygons:
isect = polygon.intersection(area_boundary)
if isect:
coverage = coverage + isect.area()
area_cov = coverage / area_boundary.area()
print("Area coverage = {0}".format(area_cov))
Problem description
In the newly merged PR #347 new functionality is added in order to for instance support the problem of deriving the total coverage of several (possibly overlapping) satellite overpasses over an area of interest. However, when checking if two polygons overlap in the function check_if_two_polygons_overlap a union is performed, and when performing this union operation with the _bool_oper method of the SphPolygon class a lot of (in this case) unnecessary calculations finding the new polygon is carried out. This takes time when we only need to know if the two polygons intersects.
In addition to solving this it would be beneficial to refactor the SphPolygon class a bit, so that the methods are smaller and do preferably only one thing.
Expected Output
Actual Result, Traceback if applicable
Versions of Python, package at hand and relevant dependencies
- Lingua principale
- Python
- Stelle
- 388
- Fork
- 103
- Merge medio
- 7g 4h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytroll/pyresample
-
Geometry `__eq__` and `__hash__` violate Python's hash/equality contractForse di nuovo libera @pnuu l’ha presa 48 giorni fa e non c’è nessuna pull request aperta. Apertabug Priority-Medium
pytroll/pyresample#745 · 1 commento · 3 assegnatari ·
-
Improve resampler x/y coordinate metadataForse di nuovo libera @djhoese l’ha presa 66 giorni fa e non c’è nessuna pull request aperta. Apertabug
pytroll/pyresample#739 · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
pytroll/pyresample#698 · 1 commento ·
-
`AreaDefinition.get_area_slices` doesn't work for cropped geostationary areas like SEVIRI RSSAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
pytroll/pyresample#694 · 5 commenti ·
-
gradient_search comb effectForse di nuovo libera @mraspaud l’ha presa 387 giorni fa e non c’è nessuna pull request aperta. Aperta
pytroll/pyresample#682 · 7 commenti · 1 assegnatario ·
Tutte le issue di pytroll/pyresample
Issue simili
-
Project submission:Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
slavakurilyak/awesome-ai-agents#845 ·
I maintainer di solito rispondono entro 1 giorno
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directoryForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadifficulty:2 enhancement good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
MakazhanAlpamys/Soup#2178 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-valuesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
scverse/rapids-singlecell#854 ·
I maintainer di solito rispondono entro 1 giorno
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGLForse già presa @ninglinLiu l’ha presa oggi. Apertaarea:frontend backend:slang bug direction:input
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 13 giorni