/*
   * getting all the parking slots
   */
  public String checkBlockMidPoint(Double lat, Double lon) {

    String finalDestination = "";
    DistanceMap distanceMap = new Weight().pointWeight(lat, lon, ParkingExtractPoints.midPoint);
    if (distanceMap.getDist() < ConstData.INTERSECTION_THRESHOLD) {
      finalDestination =
          distanceMap.getPoint().getLatitude() + "," + distanceMap.getPoint().getLongitude();
    }
    return finalDestination;
  }
  /*
   * getting all the intersection co-ordinates on the path
   */
  public String checkIntersection(HttpServletRequest request) {

    String interSection = "";

    String intersectionPoints = request.getParameter("getPoints");
    String splitString[] = intersectionPoints.split(",");

    Double intersectionLat = Double.parseDouble(splitString[0].replace("(", "").trim());
    Double intersectionLong = Double.parseDouble(splitString[1].replace(")", "").trim());

    DistanceMap distanceMap =
        new Weight().pointWeight(intersectionLat, intersectionLong, ExtractPoints.point);

    if (distanceMap.getDist() < ConstData.INTERSECTION_THRESHOLD) {
      interSection =
          distanceMap.getPoint().getLatitude() + "," + distanceMap.getPoint().getLongitude();
    }
    return interSection;
  }
Esempio n. 3
0
  public DistanceMap pointWeight(Double latitude, Double longitude, ArrayList<Coordinates> point) {
    DistanceMap d1;
    Double dist;
    ArrayList<DistanceMap> distPoint = new ArrayList<DistanceMap>();
    DistanceMap coodinate = new DistanceMap();

    for (Coordinates i : point) {
      d1 = new DistanceMap();
      dist =
          ConstData.INTERSECTION_DISTANCE_MULTIPLIER
              * Math.sqrt(
                  ((i.getLongitude() - longitude) * (i.getLongitude() - longitude))
                      + ((i.getLatitude() - latitude) * (i.getLatitude() - latitude)));
      // d1.point.latitude = i.latitude;
      d1.getPoint().setLatitude(i.getLatitude());
      d1.getPoint().setLongitude(i.getLongitude());

      d1.setDist(dist);

      distPoint.add(d1);
      // System.out.println(d1.getPoint().getLatitude()+" , "+d1.getPoint().getLongitude()+" ,
      // "+d1.getDist());

    }

    dist = distPoint.get(0).getDist();

    coodinate.setDist(distPoint.get(0).getDist());
    coodinate.getPoint().setLatitude(distPoint.get(0).getPoint().getLatitude());
    coodinate.getPoint().setLongitude(distPoint.get(0).getPoint().getLongitude());
    for (DistanceMap i : distPoint) {

      if (dist > i.getDist()) {
        dist = i.getDist();
        coodinate.getPoint().setLatitude(i.getPoint().getLatitude());
        coodinate.getPoint().setLongitude(i.getPoint().getLongitude());
        coodinate.setDist(i.getDist());
      }
    }

    return coodinate;
  }