[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.

[Script] WME Closest Segment

Postby SAR85 » Sat Mar 21, 2015 4:49 am

——— ——— ——— ——— ——— ——— ——— ——— ———
MOD NOTE – MOD NOTE – MOD NOTE

Note 2. JustinS83 added the functionality of this script to WME Place Interface Enhancements. He will no longer work on the fork he created in note 1.

Note 1. Due to the original script author's absence, please get the forked version of the script from this here link.

THANK YOU!
edited by sketch – 2 Mar 2017
edited by carloslaso – 13 Jul 2017
——— ——— ——— ——— ——— ——— ——— ——— ———


Description:
WME Closest Segment helps you determine the closest segment to the navigation stop point of a place. A line is drawn from a selected place (for point places) or its navigation point (for area places) to the nearest segment.

Current version: 1.00

Installation:
Use Greasemonkey (Firefox) or Tampermonkey (Chrome) and get the script here.

To use:
The line to the closest segment will appear on the map when a place is selected/moved. To disable the line, disable the "Closest Segment" layer in the layer selector or press Ctrl+Shift+C.

For best results, make sure you can see the segments on all sides of the navigation stop point on the map. If the navigation stop point is at the edge of the map, the line will be drawn to the closest segment in the visible map area but the actual closest segment could be outside of the visible map area.

Please report bugs, feature requests, or other issues. Known issues and development goals can be seen here.

Change log:
  • v1.00
    • Ignores pedestrian boardwalk, stairways, runways, and railroads when finding the closest segment.
  • v0.93
    • Bug fix: line no longer drawn outside of map area
    • Bug fix: editing house numbers now works correctly with this script enabled
  • v0.92
    • Quick fix for last version which broke the script in Firefox
    • Improved finding nearest segment
  • v0.91:
    • Changed the line and point styles
    • Added ctrl-shift-c as keyboard shortcut
  • v0.9: Performance improvements
  • v0.8: First release
Last edited by SAR85 on Sun Jul 19, 2015 12:03 am, edited 5 times in total.
SAR85
Area Manager
Area Manager
 
Posts: 123
Joined: Thu Jan 30, 2014 6:01 am
Location: California, USA
Has thanked: 43 times
Been thanked: 144 times

Re: [Script] WME Closest Segment

Postby SAR85 » Sat Mar 21, 2015 5:01 am

Point example:
point.PNG
(231.47 KiB) Downloaded 5566 times


Area example:
area3.PNG
(153.49 KiB) Downloaded 5532 times
Last edited by SAR85 on Fri Mar 27, 2015 4:13 am, edited 3 times in total.
SAR85
Area Manager
Area Manager
 
Posts: 123
Joined: Thu Jan 30, 2014 6:01 am
Location: California, USA
Has thanked: 43 times
Been thanked: 144 times

Re: [Script] WME Closest Segment

Postby Olestas » Sun Mar 22, 2015 12:40 pm

Very good. Thanks.
[ img ][ img ][ img ][ img ]

GC: Latvia
Coordinator: Latvia
Country manager (Full coverage): Latvia/Lithuania/Belarus/Russia/Ukraine
Olestas
Coordinators
Coordinators
 
Posts: 6337
Joined: Wed Mar 09, 2011 7:08 pm
Location: Latvia
Has thanked: 3473 times
Been thanked: 2356 times

Re: [Script] WME Closest Segment

Postby davielde » Sun Mar 22, 2015 4:35 pm

Nice work!

Aesthetically, I really like the stroke color matching WME, at least for point Places. I'm kind of up in the air about it though when looking at an area Place. It may be better to differentiate more between your closest segment line and area outline--if not by color then perhaps by stroke width?

[ img ]

Second thing is something that I would recommend after having coded the Measurement Tool for Toolbox. I noticed that you are using distanceTo between two points. In most cases, it probably would not make a difference, especially with smaller distances. With the spherical mercator map projection, however, it would be more appropriate to get the geodesic length, which is available if you first create a linestring between the two points. Here's some sample code from Toolbox:
Code: Select all
var line = new OpenLayers.Geometry.LineString([array containing your two OL.Geometry.Point(s)]);
var measureDistance = line.getGeodesicLength(Waze.map.getProjectionObject());
[ img ]
CM: USA
SM: Michigan, Vermont
AM: Ann Arbor, MI & Thunder Bay, ON
WME Michigan
davielde
 
Posts: 1219
Joined: Tue Sep 17, 2013 2:01 pm
Location: Michigan, USA
Has thanked: 461 times
Been thanked: 759 times

Re: [Script] WME Closest Segment

Postby SAR85 » Sun Mar 22, 2015 5:28 pm

Davielde,

Thanks for the suggestions. I will experiment with the line properties for area places. Alternatively, if there was enough interest from script users, some of the line color, width, or style properties could be made to be customized by the user.

You also made a really good point about geodesic length. I will have to incorporate that for sure!
SAR85
Area Manager
Area Manager
 
Posts: 123
Joined: Thu Jan 30, 2014 6:01 am
Location: California, USA
Has thanked: 43 times
Been thanked: 144 times

Update

Postby SAR85 » Mon Mar 23, 2015 5:53 am

Version 0.9 has some big performance improvements to reduce CPU usage and is now live on GreasyFork.

As far as geosdesic length versus linear distance, this is what I've found. The Waze map uses a spherical projection (EPSG:900913), which means that the geodesic distance, while different than the linear distance, is different by the same factor no matter which direction the line travels or where on the globe the points are. Using the map's projection, the geodesic distance of a line appears to be consistently about 80% of the linear distance. Because WME Closest Segment is concerned with relative distances, and the projection affects all the distances by the same factor, the absolute differences between the projected and linear distances do not matter.

If the absolute distance is important, such as when measuring distances to make sure a segment is greater than 15m to allow U-turns, then the geodesic length should be used.

As a point of interest, with a projection based on an ellipsoid rather than a sphere the difference between the projected and linear distances would vary depending on the location of the line (i.e. the ratio would not always be 80%). In this case, it would be important to get the projected distance, even if comparing relative distances.
SAR85
Area Manager
Area Manager
 
Posts: 123
Joined: Thu Jan 30, 2014 6:01 am
Location: California, USA
Has thanked: 43 times
Been thanked: 144 times

Re: [Script] WME Closest Segment

Postby davielde » Mon Mar 23, 2015 9:23 pm

Suggestion retracted! ;)
[ img ]
CM: USA
SM: Michigan, Vermont
AM: Ann Arbor, MI & Thunder Bay, ON
WME Michigan
davielde
 
Posts: 1219
Joined: Tue Sep 17, 2013 2:01 pm
Location: Michigan, USA
Has thanked: 461 times
Been thanked: 759 times

Re: [Script] WME Closest Segment

Postby Olestas » Thu Mar 26, 2015 7:09 am

Sometimes it draws string not to nearest segment, but somewhere off screen.. It can only be changed buy moving places target pin.
[ img ][ img ][ img ][ img ]

GC: Latvia
Coordinator: Latvia
Country manager (Full coverage): Latvia/Lithuania/Belarus/Russia/Ukraine
Olestas
Coordinators
Coordinators
 
Posts: 6337
Joined: Wed Mar 09, 2011 7:08 pm
Location: Latvia
Has thanked: 3473 times
Been thanked: 2356 times

Re: [Script] WME Closest Segment

Postby SAR85 » Thu Mar 26, 2015 2:36 pm

Olestas wrote:Sometimes it draws string not to nearest segment, but somewhere off screen.. It can only be changed buy moving places target pin.

I haven't seen that happen before. Any idea of when this happens? For example, is it right after you finish moving the map?
SAR85
Area Manager
Area Manager
 
Posts: 123
Joined: Thu Jan 30, 2014 6:01 am
Location: California, USA
Has thanked: 43 times
Been thanked: 144 times

Re: [Script] WME Closest Segment

Postby Olestas » Thu Mar 26, 2015 3:46 pm

Don't know.. I have seen it 3-4 times, but cannot repeat it on purpose.
[ img ][ img ][ img ][ img ]

GC: Latvia
Coordinator: Latvia
Country manager (Full coverage): Latvia/Lithuania/Belarus/Russia/Ukraine
Olestas
Coordinators
Coordinators
 
Posts: 6337
Joined: Wed Mar 09, 2011 7:08 pm
Location: Latvia
Has thanked: 3473 times
Been thanked: 2356 times

Next

Return to Addons, Extensions, and Scripts

Who is online

Users browsing this forum: BenEnmen