Skip to content

Conversation

@rtrvrtg
Copy link

@rtrvrtg rtrvrtg commented Sep 2, 2016

I'm currently working with geoPHP within Drupal to generate polygons for geographical regions, but for some reason some of the arrays that are coming into WKB.class.php are associative, with their index starting from 1. In these cases, when $components[] = new Point($line_coords[$i],$line_coords[$i+1]); is called, an exception is thrown because $line_coords has no key $i + 1.

I intend to investigate why this function is getting malformed keys, and try and correct it, but decided to put together some sort of interim remedy in case anyone else had the same problem. This PR normalises the input array so that it's no longer associative, ensuring that the keys start from 0 and are properly consecutive. It also ensures that any malformed points are dropped. (Is your policy to drop malformed points, or to try and display them by any means necessary?)

Am also wondering if maybe we could use array_chunk to chunk the array into 2-tuples, and then clean up any malformed ones at the end. Actually, I've gone ahead and done that. Requires PHP 5.3+, but the functionality in question is much more apparent now.

@BathoryPeter
Copy link

geoPHP' current WKB implementation is buggy and fails for many input. I have a (huge) pull request #125 that hopefully fix them. Can you please try it?

OGC specification doesn't mention malformed geometries, simply considers all features is valid geometry. (http://www.opengeospatial.org/standards/sfa)

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.

2 participants