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.

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/38421/1291464/WME%20Utils%20-%20NavigationPoint.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            WME Utils - NavigationPoint
// @namespace       WazeDev
// @version         2023.12.05.01
// @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 = structuredClone(point);
            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 structuredClone(this._point);
        }

        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();
        }
    }