WME Utils - NavigationPoint

NavigationPoint class necessary for creating an entryExitPoint in code. Instantiate the class and pass the OL.Geometry.Point in the constructor then add the NavigationPoint object to the entryExitPoints array.

当前为 2018-02-13 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/38421/251065/WME%20Utils%20-%20NavigationPoint.js

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            WME Utils - NavigationPoint
// @namespace       WazeDev
// @version         2018.02.13.001
// @description     NavigationPoint class necessary for creating an entryExitPoint in code.  Instantiate the class and pass the OL.Geometry.Point in the constructor then add the NavigationPoint object to the entryExitPoints array.
// @author          JustinS83
// @license         GNU GPLv3
// ==/UserScript==

class NavigationPoint
    {
        constructor(point){
            this._point = point.clone();
            this._entry = true;
            this._exit = true;
            this._isPrimary = true;
            this._name = "";
        }

        with(){
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
            if(e.point == null)
                e.point = this.toJSON().point;
            return new this.constructor((this.toJSON().point, e.point));
        }

        getPoint(){
            return this._point.clone();
        }

        getEntry(){
            return this._entry;
        }

        getExit(){
            return this._exit;
        }

        getName(){
            return this._name;
        }

        isPrimary(){
            return this._isPrimary;
        }

        toJSON(){
            return  {
                point: this._point,
                entry: this._entry,
                exit: this._exit,
                primary: this._isPrimary,
                name: this._name
            };
        }

        clone(){
            return this.with();
        }
    }