Ejemplo n.º 1
0
  /**
   * look through the list of coordinate, and see if any are contained within the currently visible
   * area
   */
  private boolean isVisible(
      final LatLonPoint tl, final LatLonPoint br, final CoordFloatString coords) {
    boolean res = false;
    final MWC.GenericData.WorldLocation _tl =
        new MWC.GenericData.WorldLocation(tl.getLatitude(), tl.getLongitude(), 0);
    final MWC.GenericData.WorldLocation _br =
        new MWC.GenericData.WorldLocation(br.getLatitude(), br.getLongitude(), 0);
    final MWC.GenericData.WorldArea area = new MWC.GenericData.WorldArea(_tl, _br);
    area.normalise();

    for (int i = 0; i < coords.maxIndex(); i++) {
      final float x = coords.getXasFloat(i);
      final float y = coords.getYasFloat(i);

      _workingLocation.setLat(y);
      _workingLocation.setLong(x);

      if (area.contains(_workingLocation)) {
        res = true;
        continue;
      }
    }

    return res;
  }
Ejemplo n.º 2
0
  private boolean overlaps(
      final LatLonPoint tl, final LatLonPoint br, final CoordFloatString coords) {
    boolean res = false;
    float maxLat = 0, minLat = 0, maxLong = 0, minLong = 0;
    boolean first = true;

    // create our area of interest
    _workingArea.getTopLeft().setLat(tl.getLatitude());
    _workingArea.getTopLeft().setLong(tl.getLongitude());
    _workingArea.getBottomRight().setLat(br.getLatitude());
    _workingArea.getBottomRight().setLong(br.getLongitude());

    // build up the area of the coords
    final int len = Math.abs(coords.maxIndex());

    for (int i = 0; i < len; i++) {
      // retrieve the x and y values
      final float x = coords.getXasFloat(i);
      final float y = coords.getYasFloat(i);

      // initialise our values if this is the first pass
      if (first) {
        first = false;
        maxLat = minLat = y;
        maxLong = minLong = x;
      } else {
        // else update our extreme values
        minLat = Math.min(minLat, y);
        maxLat = Math.max(maxLat, y);

        minLong = Math.min(minLong, x);
        maxLong = Math.max(maxLong, x);
      }
    }

    // put our limits into the area of this line
    _otherWorkingArea.getTopLeft().setLat(maxLat);
    _otherWorkingArea.getTopLeft().setLong(minLong);
    _otherWorkingArea.getBottomRight().setLat(minLat);
    _otherWorkingArea.getBottomRight().setLong(maxLong);

    // so, we've now got our two areas, see if they overlap
    res = _workingArea.overlaps(_otherWorkingArea);

    // well done!
    return res;
  }