Page 1 of 12

[Script] WME Closest Segment

PostPosted: Sat Mar 21, 2015 4:49 am
by SAR85
——— ——— ——— ——— ——— ——— ——— ——— ———
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

Re: [Script] WME Closest Segment

PostPosted: Sat Mar 21, 2015 5:01 am
by SAR85
Point example:
point.PNG
(231.47 KiB) Downloaded 5565 times


Area example:
area3.PNG
(153.49 KiB) Downloaded 5532 times

Re: [Script] WME Closest Segment

PostPosted: Sun Mar 22, 2015 12:40 pm
by Olestas
Very good. Thanks.

Re: [Script] WME Closest Segment

PostPosted: Sun Mar 22, 2015 4:35 pm
by davielde
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());

Re: [Script] WME Closest Segment

PostPosted: Sun Mar 22, 2015 5:28 pm
by SAR85
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!

Update

PostPosted: Mon Mar 23, 2015 5:53 am
by SAR85
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.

Re: [Script] WME Closest Segment

PostPosted: Mon Mar 23, 2015 9:23 pm
by davielde
Suggestion retracted! ;)

Re: [Script] WME Closest Segment

PostPosted: Thu Mar 26, 2015 7:09 am
by Olestas
Sometimes it draws string not to nearest segment, but somewhere off screen.. It can only be changed buy moving places target pin.

Re: [Script] WME Closest Segment

PostPosted: Thu Mar 26, 2015 2:36 pm
by SAR85
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?

Re: [Script] WME Closest Segment

PostPosted: Thu Mar 26, 2015 3:46 pm
by Olestas
Don't know.. I have seen it 3-4 times, but cannot repeat it on purpose.