Exemplo n.º 1
0
  void queryIndex(Graph g, LocationIndex idx, double lat, double lon, double expectedDist) {
    QueryResult res = idx.findClosest(lat, lon, EdgeFilter.ALL_EDGES);
    if (!res.isValid()) {
      errors.add("node not found for " + lat + "," + lon);
      return;
    }

    GHPoint found = res.getSnappedPoint();
    double dist = distCalc.calcDist(lat, lon, found.lat, found.lon);
    if (Math.abs(dist - expectedDist) > .1) {
      errors.add(
          "queried lat,lon="
              + (float) lat
              + ","
              + (float) lon
              + " (found: "
              + (float) found.lat
              + ","
              + (float) found.lon
              + ")"
              + "\n   expected distance:"
              + expectedDist
              + ", but was:"
              + dist);
    }
  }
  boolean setupCalculations() {

    Vector calc;

    DistanceCalc distanceCalc = new DistanceCalc();
    calc = calculations[CALC_DISTANCE] = new Vector();
    for (int i = 0; i < bondCount; i++) {
      MinBond bond = bonds[i];
      double bondOrder = bond.atomIndexes[2];
      if (bond.isAromatic) bondOrder = 1.5;
      if (bond.isAmide) bondOrder = 1.41;
      distanceCalc.setData(calc, bond.atomIndexes[0], bond.atomIndexes[1], bondOrder);
    }

    calc = calculations[CALC_ANGLE] = new Vector();
    AngleCalc angleCalc = new AngleCalc();
    for (int i = angles.length; --i >= 0; ) angleCalc.setData(calc, i);

    calc = calculations[CALC_TORSION] = new Vector();
    TorsionCalc torsionCalc = new TorsionCalc();
    for (int i = torsions.length; --i >= 0; ) torsionCalc.setData(calc, i);

    calc = calculations[CALC_OOP] = new Vector();
    // set up the special atom arrays
    OOPCalc oopCalc = new OOPCalc();
    int elemNo;
    for (int i = 0; i < atomCount; i++) {
      MinAtom a = atoms[i];
      if (a.nBonds == 3 && isInvertible(elemNo = a.atom.getElementNumber()))
        oopCalc.setData(calc, i, elemNo);
    }

    pairSearch(calculations[CALC_VDW] = new Vector(), new VDWCalc());

    return true;
  }
  double compute(int iType, Object[] dataIn) {

    switch (iType) {
      case CALC_DISTANCE:
        return bondCalc.compute(dataIn);
      case CALC_ANGLE:
        return angleCalc.compute(dataIn);
      case CALC_TORSION:
        return torsionCalc.compute(dataIn);
      case CALC_OOP:
        return oopCalc.compute(dataIn);
      case CALC_VDW:
        return vdwCalc.compute(dataIn);
      case CALC_ES:
        return esCalc.compute(dataIn);
    }
    return 0.0;
  }
Exemplo n.º 4
0
  public double calcDistance(DistanceCalc calc) {
    double prevLat = Double.NaN;
    double prevLon = Double.NaN;
    double prevEle = Double.NaN;
    double dist = 0;
    for (int i = 0; i < size; i++) {
      if (i > 0) {
        if (is3D)
          dist +=
              distCalc3D.calcDist(
                  prevLat, prevLon, prevEle, latitudes[i], longitudes[i], elevations[i]);
        else dist += calc.calcDist(prevLat, prevLon, latitudes[i], longitudes[i]);
      }

      prevLat = latitudes[i];
      prevLon = longitudes[i];
      if (is3D) prevEle = elevations[i];
    }
    return dist;
  }