Skip to content
roberto404 edited this page Oct 23, 2017 · 1 revision

Table of Contents

geometry

src/geometry.js:6-6

deg2rad

src/geometry/deg2rad.js:14-14

Convert degree to radian

Parameters

  • deg int degree

Examples

deg2rad(180);
// => Math.PI

Returns int radian

Meta

  • since: 1.0.0

getDistanceFromLatLonInKm

src/geometry/getDistanceFromLatLonInKm.js:31-43

Calculate distance two geographic coordinates Decimal (World Geodetic System WGS84)

Parameters

  • lat1 int From GPS latitude
  • lon1 int From GPS longitude
  • lat2 int To GPS latitude
  • lon2 int To GPS longitude

Examples

getDistanceFromLatLonInKm(47.4925, 19.0513, 40.71448, -74.00598);
// => 7008
// Budapest - New York distance

Returns int distance in km

distance

src/geometry/distance.js:15-18

Calculate distance two coordinate points

Parameters

Examples

distance({ x: 1, y: 1 }, { x: 2, y: 2 });
// => 1.4142135623730951

Returns int

Meta

  • since: 1.2.0

pointInRect

src/geometry/pointInRect.js:20-22

Check a point is inside of a rectangle

Parameters

  • a [object] observed point
  • b [object] rectangle top left corner
  • c [object] rectangle bottom right corner

Examples

pointInRect(
{ x: 1, y: 1 },
{ x: 1, y: 2 },
{ x: 1, y: 4 },
)
// => false

Returns bool

Meta

  • since: 1.2.0

twoLineIntersection

src/geometry/twoLineIntersection.js:24-53

Intersection of two lines

Parameters

  • a1
  • a2
  • b1
  • b2

Examples

twoLineIntersection(
{ x: 5, y: 10 },
{ x: 5, y: 1 },
{ x: 1, y: 5 },
{ x: 10, y: 5 },
)
// => { x: 5, y: 5 }

Returns object Intersection point coorinate

Meta

  • since: 1.2.0

math

src/math.js:6-6

clamp

src/math/clamp.js:17-23

Clamping is the process of limiting a position to an area. Interval two value (min -> {x} <- max)

Parameters

  • value int inspected value
  • min int value must be minimum
  • max int value can not be more than the maximum

Examples

clamp(10, 15, 20);
// => 15

Returns int value among min and max

Meta

  • since: 1.0.0

models

src/models.js:6-6

Data

src/models/data.js:58-564

Helper to Data grid Object transforms: paginate, sort, filters

Parameters

  • data
  • settings (optional, default {})

Examples

// data
[
  { id: 1, name: 'Megan J. Cushman', gender: 1, visits: '2017-07-23' },
  { id: 2, name: 'Taylor R. Fallin', gender: 2, visits: '2017-07-22' },
  { id: 3, name: 'Jose C. Rosado', gender: 1, visits: '2017-07-20' },
  { id: 4, name: 'Sammy C. Brandt', gender: 1, visits: '2017-07-10' },
];

// settings

{
  paginate:
  {
    limit: 2,
  },
  order:
  {
    column: 'name',
    direction: 'desc',
  },
  filters:
  [
    {
      id: 'search',
      handler: (record, value) =>
        record.name
          .toString()
          .toLowerCase()
          .indexOf(value.toString().toLowerCase()) >= 0,
      arguments: [],
      status: false,
    },
  ],
};

Meta

  • since: 1.0.0

data

src/models/data.js:106-109

Raw data.

results

src/models/data.js:121-124

Handled data results.

order

src/models/data.js:141-144

Current order settings

Examples

const data = new Data(json);

data.order = {column: 'name', direction: 'asc'};
// => data.results

filters

src/models/data.js:202-205

Filter Collections

Examples

const data = new Data(json);

data.filters = [
{
   id: 'foo',
   handler: (record, foo, bar) => record.foo == foo,
   arguments: ['foo', 'bar'],
   status: true,
}];

// => data.results

paginate

src/models/data.js:265-268

Current order settings

Examples

const data = new Data(json);

data.paginate = {
   page: 3,
   limit: 1
};

// => data.paginate.results

handle

src/models/data.js:485-497

Data handling process -> this.results

  • apply filters
  • sort results

Returns void

getDataByIndex

src/models/data.js:505-513

Return data element by index

Parameters

  • index int

Returns object

getResultByIndex

src/models/data.js:521-529

Return results element by index

Parameters

  • index int

Returns object

getResultsGroupBy

src/models/data.js:549-563

It returns grouped results

Parameters

  • field string grouping result by this object key
  • labelIteratee function group field value format method. Default return original value (optional, default (records,field))
  • valueIteratee function group field items method. Default is count group elements (optional, default (records,field))

Examples

Grouping by date, where the value sum every record person property [{date: '2016-02-03', person: '3'}...]

// return {'2016-02-03': 22, '2016-02-04': 25 }
groupByResults('date', (value, key) => (_.sum(_.map(value, i => parseInt(i.person)))))

Returns object {'group1': ineratee return, 'group2': valueIteratee return}