Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The problem occurs when saving a node leaving the WTK field empty: openlayers_behavior_drawfeatures_update()
populates the WTK field with an empty geometry: GEOMETRYCOLLECTION()
.
When the same node is edited the empty geometry retrieved from the WTK field causes:
TypeError: features[i] is undefined { message="features[i] is undefined", more...}
in openlayers_behavior_drawfeatures.js and it also prevents the "Draw Feature" behavior to show up correctly on the WTK map. A patch is attached.
Comment | File | Size | Author |
---|---|---|---|
#5 | 920418_accept_geometrycollection.patch | 2.59 KB | tmcw |
openlayers-empty-geometry.patch | 926 bytes | ademarco | |
Comments
Comment #1
ademarco CreditAttribution: ademarco commentedChoosing a better title. :)
Comment #2
tmcw CreditAttribution: tmcw commentedWould a fix on the other side of this problem: making sure that drawfeatures can handle an empty features array - a
GEOMETRYCOLLECTION()
value - work as well for your use case? The code written in drawfeatures, and indeed, in the module needs to be robust to handle every valid/reasonable WKT input, I'd think.Comment #3
ademarco CreditAttribution: ademarco commentedYes, it would work anyway and, indeed, the module must be able to handle any kind of valid WKT value. Which kind of solution you'd suggest?
Comment #4
tmcw CreditAttribution: tmcw commentedHere's a patch that makes sure that the module will readily accept
GEOMETRYCOLLECTION()
, by checking against the [undefined] array that it generates. This works for the types of input I can think of: single elements, blank, geometrycollection(elements) and geometrycollection().Comment #5
tmcw CreditAttribution: tmcw commentedWhoops, here's the patch.
Comment #6
ademarco CreditAttribution: ademarco commentedThe patch works great for me. Thanks!
Comment #7
tmcw CreditAttribution: tmcw commentedGreat: committed: http://drupal.org/cvs?commit=428396
Comment #9
Francewhoa@Maintainers: Could you release a new version 6.x-2.0-alpha11? This patch missed the latest stable release by a few days.