JSPM

geobound-object

0.1.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 3
    • Score
      100M100P100Q5682F
    • License MIT

    convert different type of arrays to a unified bound object with getter methods

    Package Exports

    • geobound-object

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (geobound-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    geobound-object

    This package provides a constructor to create bound objects, specific for geographic usage. The style is similar to Leaflet's LatLngBound object, with much less functionality (and with arrays instead of LatLng elements returned). It can be used if you need to define unique bounds with variable input. This package is used as output format of osmtile2bound and as input format for bound2osmtile.

    Installation

    Use standard npm installation

    npm install --save geobound-object

    Usage

    This package provides a constructor only. This constructor has to be called with the new statement. If invalid properties are passed, the constructor throws an error.

    Input parameter

    There are many different types of allowed inputs

    Edge - Array

    // [north, east, south, west]
    new Bound([48.1354432, 11.6037082, 48.123412, 11.621389]);
    
    // output: Bound object

    Bound - Array

    // [[north east], [south west]]
    new Bound([[48.1354432, 11.6037082], [48.123412, 11.621389]]);
    
    // output: Bound object

    Bound - LatLng Array

    // [LatLng, LatLng]
    new Bound([L.latLng([48.1354432, 11.6037082]), L.latLng([48.123412, 11.621389])]);
    
    // output: Bound object

    LatLngBound or Identity

    new Bound(new Bound([48.1354432, 11.6037082, 48.123412, 11.621389]));
    
    // output: Bound object

    Bound Object

    The returned bound object has several getter methods.

    • getNorth() - Number, north point
    • getEast() - Number, east point
    • getSouth() - Number, south point
    • getWest() - Number, west point
    • getSouthWest - [Number, Number], [south, west]
    • getNorthWest - [Number, Number], [north, west]
    • getNorthEast - [Number, Number], [north, east]
    • getSouthEast - [Number, Number], [south, east]
    • getCenter - [Number, Number], [lat, lng] of center of the bounds

    Contribute

    Feel free to add issues or pull requests. I'm glad for every kind of feedback!