osmlinter
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

OSM Linter

Build Status npm version MIT licensed ES5

Standard - JavaScript Style Guide

Advanced OSM linter for node and browsers

Install

npm

$ yarn osmlinter

web

<script type='module'>
import { getAngle } from "https://unpkg.com/osmlinter?module"
console.log(getAngle([5, 5], [5, 6], [3, 4]))
</script> 

API

closestEndNodes

Closest End Nodes, this validator detects if a line has ending nodes closer to other lines.

End Nodes touching lines are ignored.

JSOM Linter (Way end node near other highway)

Parameters

  • lines (FeatureCollection | Feature<(LineString | MultiLineString)>) GeoJSON (Multi)LineString(s)
  • options Object? Optional parameters
    • options.maxDistance number Maximum distance a node is allowed from lines (optional, default 7.5)
    • options.units number Measured distance units (kilometers, meters, miles) (optional, default "meters")

Examples

const lines = turf.featureCollection([
  turf.lineString([[5.00001, 6.00001], [2, 2], [0, 1]]),
  turf.lineString([[5, 5], [5, 6], [3, 4]])
])
const endNodes = osmlinter.closestEndNodes(lines)
//=endNodes

Returns FeatureCollection<Point> End nodes near other lines

index

Finds the angle between 3 points.

Parameters

Examples

osmlinter.getAngle([5, 5], [5, 6], [3, 4])
//=45

Returns number angle

index

Detects if line is closed

Parameters

  • geojson Feature<(LineString | MultiLineString | Polygon | MultiPolygon)> LineString(s) or Polygons(s)
  • options Object Optional parameters (optional, default {})

Examples

const line1 = turf.lineString([[5, 5], [5, 6], [3, 4], [5, 5]])
const line2 = turf.lineString([[5, 5], [5, 6], [3, 4], [3, 3]])
 
osmlinter.isLineClosed(line1)
//=true
osmlinter.isLineClosed(line2)
//=false

Returns boolean true/false if line is closed

impossibleAngle

Impossible Angle, this validator detects lines with less likely turning angles.

Parameters

  • lines (FeatureCollection | Feature<(LineString | MultiLineString)>) GeoJSON (Multi)LineString(s)
  • options Object? Optional parameters
    • options.minAngle number Minimum Angle in degrees (optional, default 10)
    • options.maxAngle number Maximum Angle in degrees (optional, default Infinity)

Examples

const line = {
  type: 'LineString',
  coordinates: [[5, 5], [5, 6], [3, 4]]
}
osmlinter.impossibleAngle(line)

Returns boolean true/false

isBuilding

Detects if geometry is highly likely to be a building

Parameters

  • geojson Feature<(LineString | MultiLineString | Polygon | MultiPolygon)> LineString(s) or Polygons(s)
  • options Object Optional parameters (optional, default {})
    • options.minArea number Minimum area in square meters (optional, default 0)
    • options.maxArea number Maximum area in square meters (optional, default 40000)

Examples

const line = turf.lineString([[5, 5], [5, 6], [3, 4], [4, 4] [5, 5]])
 
osmlinter.isBuilding(line)
//=true/false

Returns boolean true/false

isRiverbank

Detects if geometry is highly likely to be a riverbank

Parameters

  • geojson Feature<(LineString | MultiLineString | Polygon | MultiPolygon)> LineString(s) or Polygons(s)
  • options Object Optional parameters (optional, default {})
    • options.minArea number Minimum area in square meters (optional, default 40000)
    • options.maxArea number Maximum area in square meters (optional, default Infinity)

Examples

const line = turf.lineString([[5, 5], [5, 6], [3, 4]])
 
osmlinter.isRiverbank(line)
//=true/false

Returns boolean true/false

totalNodes

Count the amount of Nodes in a GeoJSON Geometry

Parameters

  • geojson GeoJSON GeoJSON

Examples

const line = turf.lineString([[10, 5], [-10, 0]])
 
osmlinter.totalNodes(line) // => 2

Returns number Total number of nodes in GeoJSON

Readme

Keywords

none

Package Sidebar

Install

npm i osmlinter

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • deniscarriere