Closed (fixed)
Project:
Openlayers
Version:
6.x-2.x-dev
Component:
OpenLayers CCK
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2010 at 16:18 UTC
Updated:
24 Aug 2010 at 16:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tmcw commentedIndeed, currently none of the what's-allowed things about the cck module are working. This is mostly because I don't want the OpenLayers module to do any real parsing of WKT. We need to recreate these things on the Javascript end if they're deemed necessary. The CCK editor could also be built out (currently you can't undo or select/delete a feature).
What do you mean by replace the features?
Comment #2
zzolo commentedI agree, theres no reason to do any heavy lifting, but I think we should respect the idea of limiting the number of features allowed per field, just like any other CCK field. Also, deleting is very important.
Well, the 1.x version limits the number of features depending on the field setting, and if you reach the max, it simply replaces the last feature with the new one you add. It's hard to say what is the best usability case for this, but I rather think the replacement method is nice.
Comment #3
tmcw commentedI think that there are practical reasons to limit the number of features one is able to input, but if we are to do it right, then the field should actually be multiple fields for each feature, or something of that sort - 'proper' multiple entities. 'Faking it' by counting occurrences of text in a text field isn't a good idea.
I don't really follow the second part - what is deleting in this context and why is it important?
Comment #4
zzolo commentedI tried a lot of different ways of doing it in CCK. The way we have done it in 1.x, I think stores the values properly, but I don't know for sure. But it definitely feels hackish, so any improvement is appreciated.
Deleting is being able to remove a feature from the map (field).
Comment #5
tmcw commentedSo, I think that the best option here is to prevent users from adding more than n features if the field is limited to that number, and then they either need to undo and redraw a feature (should we have an undo button) or use the draw feature control (which will be in the editing toolbar) to delete other features to fill space.
This will likely need some kind of notification in the UI, like a message under the map. This shouldn't be invisible. I think that this method is more predictable and possibly less destructive than simply removing the previous additions when you add something over the limit.
Comment #6
zzolo commentedThis sounds good.
If an Undo function is easy to implement I would support it, but if not, I don't think its all that worth it. One can easily hit cancel to not save the changes.
An obvious message is needed. It might be best to put an overlay on the map so that users see it more easily. It could show up when a feature is selected.
Comment #7
vlad.k commented"Well, the 1.x version limits the number of features depending on the field setting, and if you reach the max, it simply replaces the last feature with the new one you add. It's hard to say what is the best usability case for this, but I rather think the replacement method is nice."
This is definitely the best solution if the maximum number of features is one. The aproach described in #5 should only be taken into consideration if the maximum number of features is more then one.
Comment #8
zzolo commentedI have created a basic (not working) patch. It sets everything up to limit features by creating a new paramter to the draw feature behavior. It also translates CCK's multiple to the limit as well.
I am not sure the best way to manage the limit. I would assume in the update function there should be a check and a removal if we are over.
Comment #9
tmcw commentedGood to see progress here. I've noticed that we have kind of different commenting styles, which is fine, but please keep the comment
transform() modifies geometryin the final patch - it's rather important, since transform is somewhat unexpected in that behavior and it goes a long way toward explaining why that code exists. Saying that it's reprojecting features is also kind of wrong, since it's reprojecting a copy of the features which are never used on the map. I'm more into comments that explain the why than the what of code - like specifying unusual turns in code like transform.Comment #10
Anonymous (not verified) commentedWhat is the current status of this patch? It does not appear to be complete, is there any way to currently restrict the number of points (features) users can add? If not how do users delete points? How do users move points?
Use case:
User takes photograph.
User uploads photo to node.
User selects point on map where photograph taken, but gets it wrong on first click.
User wants to move point, so clicks again.... oops... now user has two points.
User tries to manually edit WKT, map doesn't respond.
User cancels node creation and has to start again... ?
What options does the user have when not getting it right first time? Is there a way to edit features that I'm missing?
Thanks!
Comment #11
ddorian commentedany progression at this
Comment #12
Sanjo commented+1
Comment #13
tmcw commentedOkay, this is, after all, fairly simple to patch. Here's a patch that rewrites a bunch of the code in drawfeatures, eliminating a bunch of variables and making it a bit more robust. It also removes the function that was put into the window. object by that behavior, and enforces the feature limit.
Please test, thanks.
Comment #14
tmcw commentedFurther reviewed, committed: http://drupal.org/cvs?commit=404072
Comment #15
strk commentedfunction openlayers_behavior_drawfeatures_update(features) {
WktWriter = new OpenLayers.Format.WKT();
if (this.feature_limit < features.object.features.length) {
features.feature.layer.removeFeatures(features.object.features.shift());
}
The code above fails to respect 'unlimited', which I belive would be encoded as this.feature_limit being 0.
Haven't tried, but had problems having unlimited features.
Also, when updating an existing system where many features are added bug having
a limit of 1 each click only drops a single old feature, not all except the new one.
Comment #16
tmcw commentedIndeed - try this patch that fixes both of those things.
Comment #17
strk commentedOk for the first issue (respecting unlimited) as for the second, there seems to be a bigger problem:
features.feature.layer is null
I'll inspect and provide a fix myself
Comment #18
strk commentedOk, the thing is that the same 'update' function is invoked on both 'featureadded' and 'featureremoved', with the latter being triggered by the former on removeFeature. The call on 'featureremoved' seems to lack the 'layer' attribute for some reason (a bug in OL?).
Anyway the double invocation doesn't seem to be nice to have. And in any case we only want to perform
the removal on 'featureadded'. Committed:
http://drupal.org/cvs?commit=404270
Comment #19
strk commentedtmwc: what's the point of performing these check on each iteration?
features.type == 'featureadded' && this.feature_limit
They only need to be performed once, which my patch did...
I'm referring to
http://drupalcode.org/viewvc/drupal/contributions/modules/openlayers/inc...
Comment #20
tmcw commentedDidn't seem to make sense as a performance optimization, given that the loop runs, in most cases, once per call. The only case in which it actually iterates is when somebody has created a lot of points and now wants them deleted, and even in that case, it only iterates through the points once. So, yeah, the performance hit - which is likely microscopic, given that there's no scoping problem and it's just testing equality - doesn't seem worth the extra control statement.
Comment #21
tmcw commentedOkay? Remarking as fixed..