ol/source/Vector#getFeaturesAtCoordinate and implementations of ol/geom/Geometry#containsXY

33 views
Skip to first unread message

Tim K

unread,
Oct 25, 2018, 5:33:09 PM10/25/18
to OpenLayers Dev
I apologize for first posting this as an issue on github as upon further reading it seems that is not the desired approach - close https://github.com/openlayers/openlayers/issues/8863 if my question belongs here first


While trying to use ol/source/Vector#getFeaturesAtCoordinate to retrieve an array of coincident point features at a given coordinate I found that the lack of an override implementation of ol/geom/Geometry#containsXY always results in an empty array even when using the exact coordinate of a given feature's point geometry. What is the reasoning behind not implementing containsXY for PointMultiPointLineString and MultiLineString geometries?

I can achieve my goals by providing my own override as follows, but I am wondering why such implementations are excluded, and if I should be taking a different approach to getting my desired result:

import Point from 'ol/geom/Point'

Point.prototype.containsXY = function(x, y) {
  const coord = this.getCoordinates()
  return coord[0] === x && coord[1] === y
}


If these implementations are worth doing I will create specific issues for each and am willing to take a run at coding them up and making the pull requests.


Reply all
Reply to author
Forward
0 new messages