我需要验证行人是否使用GPS'读数和findNearestIntersectionOSM
调用以获取最近的交叉点。
对于来自geoname
的每个响应,我检查两个点之间的距离是否小于某个阈值并且还使用sin
函数,我检查交叉点之间的角度(GeoPoint.BearingTo
并且行人的当前位置翻转其标志
Sin(previous location reading) * Sin(Current location read) < 0
不幸的是,这是不够的,我有时会收到误报等等。
是否有更好的方法,或者我缺少的任何东西?
为了说清楚,我不打算深入Image Processing
字段,只是使用OSM
部分功能(如果可能)
private void OnClosestIntersectionPoint(GeoPoint gPtIntersection) {
int iDistance = mGeoLastKnownPosition.distanceTo(gPtIntersection);
double dbCurrentBearing = mGeoLastKnownPosition.bearingTo(gPtIntersection);
if(mDbLastKnownBearing == null) {
mDbLastKnownBearing = new Double(dbCurrentBearing);
return;
}
boolean bFlippedSignByCrossing = Math.sin(mDbLastKnownBearing) * Math.sin(dbCurrentBearing) < 0;
mDbLastKnownBearing = dbCurrentBearing; // update bearing regardless to what's going to happen
if(bFlippedSignByCrossing && iDistance <= 10 && !HasntMarkIntersectionAsCrossed(gPtIntersection))
MarkAsIntersectionCrossed(mGeoLastKnownIntersection);
}