in reply to Solved! (was: Re^10: Geo Package files)
in thread Geo Package files
Good to hear it works now. It would be useful to have a generalised WKB reader (and writer) on CPAN.
WRT the midpoints - the centroid will work as a start. However, if your mid-point must correspond with a street address on the road then it is not too hard to find the mid-point along a series of vertices.
One approach is to convert the array of vertices to cumulative distances and then use a binary search to find the distance that is half the maximum (which is the last cumulative distance array element). It won't make much difference with small numbers of geometries but if you have many geometries with many vertices then it adds up as the average case will be of the order of (n+log(n)) calculations compared with 1.5n for a two pass search that exits when the half way point is found. (For 100,000 vertices this is ~100,011 compared with 150,000). There are binary search implementations on CPAN that will avoid the problems of implementing your own, two I have used are in List::MoreUtils and List::BinarySearch.
Edit - updated the n+log(n) value to use the natural log, and a typo.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Solved! (was: Re^10: Geo Package files)
by Bod (Parson) on Mar 11, 2022 at 23:57 UTC | |
by swl (Parson) on Mar 12, 2022 at 02:08 UTC | |
WKB Reader (was: Re^2: Solved! (was: Re^10: Geo Package files))
by Bod (Parson) on Dec 23, 2023 at 22:19 UTC | |
by swl (Parson) on Dec 24, 2023 at 00:21 UTC |