geoPHP icon indicating copy to clipboard operation
geoPHP copied to clipboard

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

Open babldev opened this issue 9 years ago • 3 comments

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 avatar Apr 20 '16 01:04 babldev

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

BathoryPeter avatar Apr 20 '16 08:04 BathoryPeter

@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.

babldev avatar Apr 20 '16 17:04 babldev

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: https://github.com/itamair/geoPHP/commit/c1a7af62e126f680f4c5ef898602e435826292f3

itamair avatar Feb 04 '23 23:02 itamair