1.0.2 • Published 8 years ago

geo-identify-position-format v1.0.2

Weekly downloads
120
License
Unlicense
Repository
github
Last release
8 years ago

geo-identify-position-format

Identifies a few common geometry position formats.

Install

npm install geo-identify-position-format

Use

var geoid = require('geo-identify-position-format');

geoid.identify(positions)

returns one of:

  • geoid.FLAT_ARRAY
  • geoid.ARRAY_OF_ARRAYS
  • geoid.TYPED_ARRAY
  • geoid.ARRAY_OF_TYPED_ARRAYS
  • geoid.NDARRAY

when positions has one of the following formats:

  • Flat arrays [1,2,3,4,5,6]
  • Array of arrays [[1,2,3], [4,5,6]]
  • Array of TypedArrays [new Float32Array([1,2,3]), new Float32Array([4,5,6])]
  • TypedArray new Float32Array([1,2,3,4,5,6])
  • ndarray ndarray(new Float32Array([1,2,3,4,5,6]))

If positions does not have one of the previously listed formats, geoid.identify will throw an error.

Credits

Extracted from @hughsk's gl-geometry.