[Script] WME Closest Segment

Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

Moderators: Unholy, bextein, Glodenox, JustinS83

Forum rules
Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

DO NOT START a new thread unless it is about a new idea. Keep discussion of existing tools within the main thread for that tool.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

Re: [Script] WME Closest Segment

Postby JustinS83 » Tue Sep 27, 2016 4:31 pm

Numerous changes to WME since the production push yesterday/today broke this script. I have reached out to the author but he hasn't been in the forum since July, so outlined below are the changes that I made to fix the script.

To get it to work in the beta editor change
Code: Select all
// @include         https://editor-beta.waze.com/*


to
Code: Select all
// @include         https://beta.waze.com/*


To fix the script since WME update yesterday:

Change all instances of:
Code: Select all
 W.geometryEditing.editors.venue


to
Code: Select all
W.geometryEditing.activeEditor



Change the removeDragCallbacks function to this (starts at roughly line 112 and goes to 123):
Code: Select all
function removeDragCallbacks() {
        if(!W.geometryEditing.activeEditor == null){
            W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
                W.geometryEditing.activeEditor.dragVertex.apply(W.geometryEditing.activeEditor.venue, [e, t]);
            };
            if (null !== typeof navPoint) {
                try {
                    navPoint.events.unregister('drag', W.geometryEditing.activeEditor.venue, findNearestSegment);
                } catch (err) { }
            }
        }
      clearLayerFeatures();
   }


Some things need changed & moved around in the checkSelection function, so I will just paste the changes here. Copy and paste over the entire function (starts around line 194 and ends at roughly 238)
Code: Select all
   function checkSelection() {
      'use strict';
      log('Selection change called.', 2);


      if (!checkConditions()) {
         removeDragCallbacks();
      } else {
         if (W.selectionManager.hasSelectedItems()) {
            selectedItem = W.selectionManager.selectedItems[0];
            if ('venue' !== selectedItem.model.type) {
               log('Selection is not a place.', 2);
               removeDragCallbacks();
               clearLayerFeatures();
            } else {
                   
                    navPoint = W.geometryEditing.activeEditor.navigationPoint;
               getSegmentsInExtent();
               if (selectedItem.model.isPoint()) {
                  log('Selection is point venue.', 2);
                  W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
                     W.geometryEditing.activeEditor.venue.dragVertex.apply(W.geometryEditing.activeEditor.venue, [e, t]);
                     findNearestSegment();
                  };
                  findNearestSegment();
               } else {
                  log('Selection is area venue.', 2);
                  if (null !== typeof navPoint) {
                     navPoint.events.register('drag', W.geometryEditing.activeEditor.venue, findNearestSegment);
                     if (inMapExtent(navPoint.lonlat.toPoint())) {
                        findNearestSegment();
                     } else {
                        log('navPoint not on screen.', 2);
                        W.map.events.register('moveend', window, handleNavPointOffScreen);
                     }
                  }
               }
            }
         } else {
            log('No item selected.', 2);
            removeDragCallbacks();
            clearLayerFeatures();
         }
      }
   }
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Tue Sep 27, 2016 8:03 pm

A few more changes. Moving a point Place wasn't registering to be saved.

Comment out line 214 (place "//" in front of it as seen below):
Code: Select all
W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
                     //W.geometryEditing.activeEditor.venue.dragVertex.apply(W.geometryEditing.activeEditor, [e, t]);
                     findNearestSegment();
      };

as it does not seem to be needed anymore & dragVertex no longer exists (that I can find).


Since the license seems to allow redistributing with minor changes to the code to fix the issue, here is a link to easily copy & paste the script in its entirety, with my changes to get it working since the latest WME release.

http://pastebin.com/9vyEb5SF
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Wed Sep 28, 2016 3:45 pm

russblau wrote:Even after making these changes (thanks, Justin), this script is still giving me fits today. If I try to move a geometry node on a street, or a junction node, the change does not appear on the screen (the node appears to float away from the street segment), and cannot be saved. Turning off Closest Segment eliminates the issue.


I just loaded a new tab with the script enabled with these changes and am not seeing any of the mentioned issues. Did you make the changes or copy from the pastebin link at the end of the 2nd post? I would suggest copying from pastebin since that was copied from my locally modified copy of the script after getting it working.

If you are still experiencing issues, open your console (F12 in Chrome then go to the Console tab) and take a screenshot of any errors and send them to me and I can take a look.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Thu Sep 29, 2016 3:07 pm

onryou wrote:Hi,

I meet a problem with another script and I'm not the only one.

When Closest segment is activated we can't use speedhelper and when I select a segment and I click on "Select entire road", it does'nt work.

I desactive your script and I work again.

Thanks for your reply
onryou


Onryou,

Try the fix from this post.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Thu Sep 29, 2016 7:40 pm

taco909 wrote:For those applying fixes, please remember that once the code is modified, Greasemonkey will no longer automatically update when (or if) the original author publishes an update.


I can't say for Greasemonkey, but Tampermonkey will still update it after making code changes as long as you don't change the @namespace line.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Wed Nov 09, 2016 12:55 pm

Looks like the beta changed that removed "require" was pushed. Most scripts are going to be down.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Fri Nov 11, 2016 9:21 pm

I updated the pastebin code to remove the @require statement for wLib since it isn't used at all in the script and what is causing the script to be non-functional since the WME update.

Pastebin link: http://pastebin.com/9vyEb5SF
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Thu Jan 12, 2017 7:26 pm

Update released - version 1.0.2.3

Bug fix: when changing from a point to an area you couldn't adjust the area geometry until you saved and then re-selected the place.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Thu Jan 12, 2017 9:50 pm

jwe252 wrote:Cannot delete a place with this script enabled since the update.


Sorry about that!

Updated released - version 1.0.2.4
Bug fix - could not delete Places after the previous update.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

Re: [Script] WME Closest Segment

Postby JustinS83 » Mon Jan 30, 2017 6:43 pm

G_W1Z wrote:
JustinS83 wrote:
jwe252 wrote:Cannot delete a place with this script enabled since the update.


Sorry about that!

Updated released - version 1.0.2.4
Bug fix - could not delete Places after the previous update.


Thanks for releasing these updates! I can save with the new release but it isn't showing the line from the PP to the nearest road.


I haven't had any issue with the line not showing. Please check your console for errors.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1344
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2384 times

PreviousNext

Return to Addons, Extensions, and Scripts

Who is online

Users browsing this forum: No registered users