Code Monkey home page Code Monkey logo

check-coord's Introduction

check-coord ๐ŸŒ

Easy to use, coordinate format checking tool.

๐Ÿ“ฅ Install

๐ŸŽฎ Usage

๐Ÿ“ Examples

๐Ÿ“ Return

Install

npm install check-coord

Usage

  1. Import the module: const checkCoord = require('check-coord');

  2. Call the function: checkCoord(inpCoord), where inpCoord is the string to be checked.

  3. Return value: The function will return an object with the following properties:

    • isTrue: Boolean value indicating whether the input string matches the pattern of latitude and longitude coordinates.
    • type: Type of the coordinate(s), which can be 'spot', 'line', or 'region'.
    • spots: Array of coordinate objects; only exists when type is 'spot' or 'line'. regionSpot: Number of points in the polygonal region; only exists when type is 'region'.
    • message: Error message; only exists when isTrue is false.

Examples

import checkCoord from "check-coord";

// Coordinate point
checkCoord("116.3978146455078,39.9076393154042");

// Coordinate line
checkCoord("116.3978146455078,39.9076393154042; 116.39652718518064,39.93344333054544");

// Coordinate region
checkCoord("116.3978146455078,39.9076393154042; 116.39652718518064,39.93344333054544; 116.41712655041502,39.93370658670286");

Return

// Coordinate point
{
    isTrue: true,   // The coordinate are correct.
    type: 'spot',   // The coordinate type is 'point'.
    // Coordinate array.
    spots: [
        {
            lng: '116.3978146455078',   // longitude
            lat: '39.9076393154042'     // latitude
        }
    ]
}

// Coordinate line
{
    isTrue: true,
    type: 'line',
    spots: [
        { 
            lng: '116.3978146455078', 
            lat: '39.9076393154042' 
        },
        { 
            lng: '116.39652718518064', 
            lat: '39.93344333054544' 
        }
    ]
}

// Coordinate region
{
    isTrue: true,
    type: 'region',
    spots: [
        { 
            lng: '116.3978146455078', 
            lat: '39.9076393154042' 
        },
        { 
            lng: '116.39652718518064', 
            lat: '39.93344333054544' 
        },
        { 
            lng: '116.41712655041502', 
            lat: '39.93370658670286' 
        }
    ],
    regionSpot: 3   // Number of area points.
}

check-coord's People

Contributors

mk965 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.