Package org.apache.lucene.spatial.geometry

Examples of org.apache.lucene.spatial.geometry.LatLng


    writer.close();
  }


  public void testDistances() throws IOException, InvalidGeoException {
    LatLng p1 = new FloatLatLng( 7.06, 171.2 );
    LatLng p2 = new FloatLatLng( 21.6032207, -158.0 );
    double miles = p1.arcDistance( p2, DistanceUnits.MILES );
    System.out.println("testDistances");
    System.out.println("miles:" + miles);
    assertEquals(2288.82495932794, miles);
    LatLng p3 = new FloatLatLng( 41.6032207, -73.087749);
    LatLng p4 = new FloatLatLng( 55.0, 4.0 );
    miles = p3.arcDistance( p4, DistanceUnits.MILES );
    System.out.println("miles:" + miles);
    assertEquals(3474.331719997617, miles);
  }
View Full Code Here


 
    if (miles < MILES_FLOOR) {
      miles = MILES_FLOOR;
    }
    LLRect box1 = LLRect.createBox( new FloatLatLng( latitude, longitude ), miles, miles );
    LatLng ll = box1.getLowerLeft();
    LatLng ur = box1.getUpperRight();

    double latY = ur.getLat();
    double latX = ll.getLat();
    double longY = ur.getLng();
    double longX = ll.getLng();
    double longX2 = 0.0;

    if (ur.getLng() < 0.0 && ll.getLng() > 0.0) {
  longX2 = ll.getLng();
   longX = -180.0
    }
    if (ur.getLng() > 0.0 && ll.getLng() < 0.0) {
  longX2 = ll.getLng();
   longX = 0.0
    }
   
    //System.err.println("getBoxShape:"+latY+"," + longY);
View Full Code Here

    writer.close();
  }


  public void testDistances() throws IOException, InvalidGeoException {
    LatLng p1 = new FloatLatLng( 7.06, 171.2 );
    LatLng p2 = new FloatLatLng( 21.6032207, -158.0 );
    double miles = p1.arcDistance( p2, DistanceUnits.MILES );
    if (VERBOSE) {
      System.out.println("testDistances");
      System.out.println("miles:" + miles);
    }
    assertEquals(2288.82495932794, miles);
    LatLng p3 = new FloatLatLng( 41.6032207, -73.087749);
    LatLng p4 = new FloatLatLng( 55.0, 4.0 );
    miles = p3.arcDistance( p4, DistanceUnits.MILES );
    if (VERBOSE) System.out.println("miles:" + miles);
    assertEquals(3474.331719997617, miles);
  }
View Full Code Here

  }
 
  public double getLLMDistance (double x1, double y1, double x2, double y2) { 

    LatLng p1 = new FloatLatLng( x1, y1 );
    LatLng p2 = new FloatLatLng( x2, y2 );
    return p1.arcDistance( p2, DistanceUnits.MILES );
  }
View Full Code Here

   
    double lngDelta=(widthMi/2)/miplngdeg;
    double latDelta=(heightMi/2)/miplatdeg;
   
    // TODO: Prob only works in northern hemisphere?
    LatLng ll=new FloatLatLng(center.getLat()-latDelta, center.getLng()-lngDelta);
    LatLng ur=new FloatLatLng(center.getLat()+latDelta, center.getLng()+lngDelta);
   
    return new LLRect(ll, ur);
  }
View Full Code Here

    writer.close();
  }


  public void testDistances() throws IOException, InvalidGeoException {
    LatLng p1 = new FloatLatLng( 7.06, 171.2 );
    LatLng p2 = new FloatLatLng( 21.6032207, -158.0 );
    double miles = p1.arcDistance( p2, DistanceUnits.MILES );
    System.out.println("testDistances");
    System.out.println("miles:" + miles);
    assertEquals(2288.82495932794, miles);
    LatLng p3 = new FloatLatLng( 41.6032207, -73.087749);
    LatLng p4 = new FloatLatLng( 55.0, 4.0 );
    miles = p3.arcDistance( p4, DistanceUnits.MILES );
    System.out.println("miles:" + miles);
    assertEquals(3474.331719997617, miles);
  }
View Full Code Here

 
    if (miles < MILES_FLOOR) {
      miles = MILES_FLOOR;
    }
    LLRect box1 = LLRect.createBox( new FloatLatLng( latitude, longitude ), miles, miles );
    LatLng ll = box1.getLowerLeft();
    LatLng ur = box1.getUpperRight();

    double latY = ur.getLat();
    double latX = ll.getLat();
    double longY = ur.getLng();
    double longX = ll.getLng();
    double longX2 = 0.0;
  //These two if checks setup us up to deal with issues around the prime meridian and the 180th meridian
  //In these two cases, we need to get tiles (tiers) from the lower left up to the meridian and then
  //from the meridan to the upper right
  //Are we crossing the 180 deg. longitude, if so, we need to do some special things
    if (ur.getLng() < 0.0 && ll.getLng() > 0.0) {
  longX2 = ll.getLng();
   longX = -180.0
    }
  //are we crossing the prime meridian (0 degrees)?  If so, we need to account for it and boxes on both sides
    if (ur.getLng() > 0.0 && ll.getLng() < 0.0) {
  longX2 = ll.getLng();
   longX = 0.0
    }
   
    //System.err.println("getBoxShape:"+latY+"," + longY);
View Full Code Here

   * @param widthMi
   * @param heightMi
   */
  public static LLRect createBox(LatLng center, double widthMi, double heightMi) {
    double d = widthMi;
    LatLng ur = boxCorners(center, d, 45.0); // assume right angles
    LatLng ll = boxCorners(center, d, 225.0);

    //System.err.println("boxCorners: ur " + ur.getLat() + ',' + ur.getLng());
    //System.err.println("boxCorners: cnt " + center.getLat() + ',' + center.getLng());
    //System.err.println("boxCorners: ll " + ll.getLat() + ',' + ll.getLng());
    return new LLRect(ll, ur);
View Full Code Here

    lat2 = (lat2*180)/Math.PI;
    lon2 = (lon2*180)/Math.PI;

    // normalize long first
    LatLng ll = normLng(lat2,lon2);

    // normalize lat - could flip poles
    ll = normLat(ll.getLat(),ll.getLng());

    return ll;
}
View Full Code Here

                lng = lng+180;
        } else {
                lng=lng-180;
        }
    }
    LatLng ll=new FloatLatLng(lat, lng);
    return ll;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.spatial.geometry.LatLng

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.