[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 james890526 » Tue Jul 19, 2016 6:46 am

Any plans to update the link for WME beta? While changes can be done individually, I figure it's better for the script author to update the script too?
Best regards,
Zhong Zhen (james890526)

[ img ][ img ][ img ][ img ]

Waze Malaysia [ img ] [ img ]
james890526
Waze Local Champs
Waze Local Champs
 
Posts: 226
Joined: Sun Jun 22, 2014 7:00 pm
Has thanked: 51 times
Been thanked: 36 times

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();
         }
      }
   }
Script Writing Community Coordinator
[ img ][ img ][ img ][ img ][ img ]
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1321
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 336 times
Been thanked: 2341 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
Script Writing Community Coordinator
[ img ][ img ][ img ][ img ][ img ]
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1321
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 336 times
Been thanked: 2341 times

Re: [Script] WME Closest Segment

Postby roarlions1 » Wed Sep 28, 2016 1:53 pm

Thanks Justin, this is a massive help!!!
roarlions1
Map Raider
Map Raider
 
Posts: 96
Joined: Sun Mar 01, 2015 9:05 pm
Location: Philadelphia, PA area
Has thanked: 27 times
Been thanked: 18 times

Re: [Script] WME Closest Segment

Postby paulkok_my » Wed Sep 28, 2016 3:26 pm

JustinS83 wrote: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
Thanks for taking the time to solve it. :D
[ img ][ img ][ img ]
Coordinator & Country Manager: Malaysia & Brunei
Send me a Telegram!
Join our FB group: Peninsular Malaysia, WazeBORNEO
paulkok_my
Waze Global Champs
Waze Global Champs
 
Posts: 1434
Joined: Thu Jul 19, 2012 4:34 am
Location: Selangor, Malaysia
Has thanked: 516 times
Been thanked: 379 times

Re: [Script] WME Closest Segment

Postby russblau » Wed Sep 28, 2016 3:36 pm

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.
[ img ] [ img ] [ img ] [ img ]
MAR MSM; State Manager: District of Columbia
AM Sussex County, DE/Westchester/Putnam/Rockland Counties, NY
russblau
State Manager
State Manager
 
Posts: 1467
Joined: Fri Oct 19, 2012 11:36 pm
Has thanked: 288 times
Been thanked: 634 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.
Script Writing Community Coordinator
[ img ][ img ][ img ][ img ][ img ]
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1321
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 336 times
Been thanked: 2341 times

Re: [Script] WME Closest Segment

Postby russblau » Wed Sep 28, 2016 4:21 pm

Yep, that did the trick! Thanks.
[ img ] [ img ] [ img ] [ img ]
MAR MSM; State Manager: District of Columbia
AM Sussex County, DE/Westchester/Putnam/Rockland Counties, NY
russblau
State Manager
State Manager
 
Posts: 1467
Joined: Fri Oct 19, 2012 11:36 pm
Has thanked: 288 times
Been thanked: 634 times

Re: [Script] WME Closest Segment

Postby onryou » Thu Sep 29, 2016 3:05 pm

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
State Manager Yonne (89) & Côte d'Or (21)
Area Manager 東京,日本
Twitter Yonne & Côte d'Or@Waze8921
onryou
State Manager
State Manager
 
Posts: 771
Joined: Wed Dec 29, 2010 2:31 pm
Location: Sens
Has thanked: 21 times
Been thanked: 29 times

Re: [Script] WME Closest Segment

Postby onryou » Thu Sep 29, 2016 3:06 pm

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
State Manager Yonne (89) & Côte d'Or (21)
Area Manager 東京,日本
Twitter Yonne & Côte d'Or@Waze8921
onryou
State Manager
State Manager
 
Posts: 771
Joined: Wed Dec 29, 2010 2:31 pm
Location: Sens
Has thanked: 21 times
Been thanked: 29 times

PreviousNext

Return to Addons, Extensions, and Scripts

Who is online

Users browsing this forum: No registered users