Exemplo n.º 1
0
  private void assertCandidate(Tuple<MatcherCandidate, Double> candidate, Point sample) {
    Polyline polyline = map.get(candidate.one().point().edge().id()).geometry();
    double f = spatial.intercept(polyline, sample);
    Point i = spatial.interpolate(polyline, f);
    double l = spatial.distance(i, sample);
    double sig2 = Math.pow(5d, 2);
    double sqrt_2pi_sig2 = Math.sqrt(2d * Math.PI * sig2);
    double p = 1 / sqrt_2pi_sig2 * Math.exp((-1) * l / (2 * sig2));

    assertEquals(f, candidate.one().point().fraction(), 10E-6);
    assertEquals(p, candidate.two(), 10E-6);
  }
Exemplo n.º 2
0
  @SuppressWarnings("unused")
  private Set<Long> refset(Point sample, double radius) {
    Set<Long> refset = new HashSet<Long>();
    Iterator<Road> roads = map.edges();
    while (roads.hasNext()) {
      Road road = roads.next();
      double f = spatial.intercept(road.geometry(), sample);
      Point i = spatial.interpolate(road.geometry(), f);
      double l = spatial.distance(i, sample);

      if (l <= radius) {
        refset.add(road.id());
      }
    }
    return refset;
  }