Skip to content

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

@babldev babldev force-pushed the remove-array-merge branch from ae5be7a to 3d16d79 Compare April 20, 2016 02:01
@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.

3 participants