Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New module @turf/line-overlap #640

Merged
merged 4 commits into from
Apr 7, 2017
Merged

New module @turf/line-overlap #640

merged 4 commits into from
Apr 7, 2017

Conversation

DenisCarriere
Copy link
Member

@DenisCarriere DenisCarriere commented Apr 2, 2017

New Module! @turf/line-overlap 🎉

Takes any LineString or Polygon and returns the overlapping lines between both features.

JSDocs

/**
 * Takes any LineString or Polygon and returns the overlapping lines between both features.
 *
 * @name lineOverlap
 * @param {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} line1 any LineString or Polygon
 * @param {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} line2 any LineString or Polygon
 * @returns {FeatureCollection<LineString>} lines(s) that are overlapping between both features

JS Example

var line1 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [[115, -35], [125, -30], [135, -30], [145, -35]
    ]
  }
}
var line2 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [[115, -25], [125, -30], [135, -30], [145, -25]
    ]
  }
}
var overlapping = turf.lineOverlap(line1, line2);
//= overlapping

Dependencies

"dependencies": {
  "@turf/helpers": "^4.0.1",
  "@turf/invariant": "^4.0.1",
  "@turf/line-segment": "^4.0.1",
  "@turf/meta": "^4.0.1",
  "deep-equal": "^1.0.1",
  "geojson-rbush": "^1.0.1"
}

Benchmark Results

polygons x 3,567 ops/sec ±1.61% (85 runs sampled)
simple1 x 9,013 ops/sec ±1.15% (86 runs sampled)
simple2 x 10,278 ops/sec ±1.52% (86 runs sampled)
simple3 x 13,124 ops/sec ±1.37% (85 runs sampled)

Test Examples

Blue Lines: Input features
Red Lines: Lines that are shared between features

image

image

CC: #638 @Turfjs/ownership

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Have read How To Contribute.
  • Run npm test at the sub modules where changes have occurred.
  • Run npm run lint to ensure code style at the turf module level.

@DenisCarriere
Copy link
Member Author

Primarily trying to find a solution to replicate JOSM warning "Overlapping (high)ways".

http://wiki.openstreetmap.org/wiki/JOSM/Validator

Checks for two (high)ways that share the same nodes
Remove the double (high)way

Come to think about the name, might change it to @turf/line-overlap.

@DenisCarriere DenisCarriere changed the title Implement line-share module Implement line-overlap module Apr 6, 2017
@DenisCarriere DenisCarriere changed the title Implement line-overlap module New module @turf/line-overlap Apr 6, 2017
@DenisCarriere DenisCarriere merged commit b301bf3 into master Apr 7, 2017
@DenisCarriere DenisCarriere deleted the line-share branch April 7, 2017 12:39
@DenisCarriere DenisCarriere added this to the 4.1.0 milestone Apr 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant