turf-nearest

WebJar for turf-nearest

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

turf-nearest
Last Version

Last Version

3.0.12
Release Date

Release Date

Type

Type

jar
Description

Description

turf-nearest
WebJar for turf-nearest
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/turf-junkyard/turf-nearest

Download turf-nearest

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/turf-nearest/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>turf-nearest</artifactId>
    <version>3.0.12</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/turf-nearest/
implementation 'org.webjars.npm:turf-nearest:3.0.12'
// https://jarcasting.com/artifacts/org.webjars.npm/turf-nearest/
implementation ("org.webjars.npm:turf-nearest:3.0.12")
'org.webjars.npm:turf-nearest:jar:3.0.12'
<dependency org="org.webjars.npm" name="turf-nearest" rev="3.0.12">
  <artifact name="turf-nearest" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='turf-nearest', version='3.0.12')
)
libraryDependencies += "org.webjars.npm" % "turf-nearest" % "3.0.12"
[org.webjars.npm/turf-nearest "3.0.12"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : turf-distance jar [3.0.12,4)

Project Modules

There are no modules declared in this project.

turf-nearest

build status

turf nearest module

turf.nearest(point, against)

Takes a reference Point|point and a set of points and returns the point from the set closest to the reference.

Parameters

parameter type description
point Feature.<Point> the reference point
against FeatureCollection.<Point> input point set

Example

var point = {
  "type": "Feature",
  "properties": {
    "marker-color": "#0f0"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [28.965797, 41.010086]
  }
};
var against = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [28.973865, 41.011122]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [28.948459, 41.024204]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [28.938674, 41.013324]
      }
    }
  ]
};

var nearest = turf.nearest(point, against);
nearest.properties['marker-color'] = '#f00';

var resultFeatures = against.features.concat(point);
var result = {
  "type": "FeatureCollection",
  "features": resultFeatures
};

//=result

Returns Feature.<Point>, the closest point in the set to the reference point

Installation

Requires nodejs.

$ npm install turf-nearest

Tests

$ npm test
org.webjars.npm

deprecated turf modules: do not use or reference, for redirects only

turf is now a monorepo: all turf modules are in Turfjs/turf

Versions

Version
3.0.12