question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New module proposal @turf/filter

See original GitHub issue

New module proposal @turf/filter

This module should return true/false if the Feature should be filtered based on the GeoJSON properties.

This type of behavior is already being used in @turf/clusters & @turf/dissolve, this module would replace the filter functionality within these two modules and act as a stand alone module with it’s own independent testing.

Could also call this module @turf/boolean-filter since the output will strictly be a boolean.

How to use module

const {point} = require('@turf/helpers')
const filter = require('@turf/filter')

const pt = point([10, 20], {foo: 'bar'})
filter(pt, {foo: 'bar'})
//=true
filter(pt, {hello: 'world'})
//=false

Source code

Tests

Ref: https://github.com/Turfjs/turf/pull/907#issuecomment-324851611

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewharveycommented, Apr 20, 2018

I’d rather not call this filter as I naturally would expect it to behave like Array.filter.

I came here to suggest we implement the equivalent of the JS filter function.

var onlyPoints = turf.filter(geojson, (feature) => {
    return turf.getType(feature) === 'Point';
})

along with map

var ids = turf.map(geojson, (feature, index) => {
    feature.id = index;
    return feature;
})

The advantage of doing this with turf rather than straight JS is the corner cases of where GeoJSON is just one feature rather than a feature collection is abstracted.

1reaction
rowanwinscommented, Aug 29, 2017

interesting idea @DenisCarriere , some of those more extended uses could certainly be nifty

Read more comments on GitHub >

github_iconTop Results From Across the Web

REQUEST FOR PROPOSAL 2010-04 Heating and Air ...
(8) 20x20x2, (4) 16x20x2, (4) 20x25x2 filters ... its proposal and submitting a new sealed proposal that complies with the.
Read more >
REQUEST FOR PROPOSALS - California Courts
Provide and deliver to Court replacement filters/medias. 3. Install Filters ... Latest date and time proposal may be submitted. February 24, 2014.
Read more >
Best Practices for Operation and Maintenance of Photovoltaic ...
An entire row of modules can fail if one module is lost, and they are held ... a timeframe when the grass-cutting is...
Read more >
PROPOSAL - NYSDOT
Proposal Description: Large Culvert Repairs/ Replacements on NY. Rtes. 98 & 353 in the Towns of Franklinville,. Great Valley & New Albion.
Read more >
Training Module Narrative Detai
EARN Maryland Summer 2020 Solicitation for Implementation Grant Proposals ... Create new worksheets for each Training Module.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found