Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve getPoints() + explode() performance for large geometries #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

babldev
Copy link

@babldev babldev commented Apr 20, 2016

Issue
For geometries with 10k+ points, it can take 10+ seconds on a modern machine to call getPoints() or pointInPolygon().

Root Cause
The points array was built using array_merge(), which gets more complex (n^2) as the array gets larger.

Fix
Use simple array appending instead of array_merge()

Before:

$ time ../vendor/bin/phpunit tests/largeInputTest.php 
real    0m13.354s
user    0m13.318s
sys 0m0.030s

After:

$ time ../vendor/bin/phpunit tests/largeInputTest.php 
real    0m0.194s
user    0m0.172s
sys 0m0.016s

@BathoryPeter
Copy link

Nice improvements, but I also fixed it in pull requests #103 and #125.

@babldev
Copy link
Author

babldev commented Apr 20, 2016

@BathoryPeter Thanks for the info. #103 is closed and #125 looks like a pretty large change.

Perhaps this a smaller one that can be added sooner.

gholol added a commit to gholol/geoPHP-1 that referenced this pull request May 17, 2016
itamair added a commit to itamair/geoPHP that referenced this pull request Feb 4, 2023
@itamair
Copy link

itamair commented Feb 4, 2023

This repo looks kind of abandoned/un-mantanied.

FYI, this has been embedded/fixed into this fork repo:
https://github.com/itamair/geoPHP
throughout this commit: itamair@c1a7af6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants