public static double distanceBetween(GeoPoint geoPoint1, GeoPoint geoPoint2) { return distanceBetween( geoPoint1.getLatitude(), geoPoint1.getLongitude(), geoPoint2.getLatitude(), geoPoint2.getLongitude()); }
@Override public String toString() { return "GeoCircle[" + getLatitude() + ", " + getLongitude() + ", " + getRadius() + "]"; } }
@Override public boolean onTap(GeoPoint p,MapView mapView){ Log.d("TOUCHED_PLACE", "Latitutde:"+p.getLatitudeE6()/1E6 + " Longitude:"+p.getLongitude()/1E6); }
@Override public boolean within(GeoShape geoShape) { if (geoShape instanceof GeoPoint) { GeoPoint pt = (GeoPoint) geoShape; return GeoPoint.distanceBetween(getLatitude(), getLongitude(), pt.getLatitude(), pt.getLongitude()) <= getRadius(); } throw new SecureGraphException("Not implemented for argument type " + geoShape.getClass().getName()); }
@Override public String toString() { return "(" + getLatitude() + ", " + getLongitude() + ")"; }
@Override public int compareTo(GeoPoint other) { int i; if ((i = compare(getLatitude(), other.getLatitude())) != 0) { return i; } if ((i = compare(getLongitude(), other.getLongitude())) != 0) { return i; } if (getAltitude() != null && other.getAltitude() != null) { return compare(getAltitude(), other.getAltitude()); } if (getAltitude() != null) { return 1; } if (other.getAltitude() != null) { return -1; } return 0; }
@Override public GeoRect getGeoCell() { org.elasticsearch.common.geo.GeoPoint northWest = new org.elasticsearch.common.geo.GeoPoint(); org.elasticsearch.common.geo.GeoPoint southEast = new org.elasticsearch.common.geo.GeoPoint(); GeohashUtils.decodeCell(getKey(), northWest, southEast); return new GeoRect(new GeoPoint(northWest.getLat(), northWest.getLon()), new GeoPoint(southEast.getLat(), southEast.getLon())); } };
Projection pj = mapView.getProjection(); Point pix = pj.toPixels(p); pix.y -= 10; //10 pixels up GeoPoint p2 = pj.fromPixels(pix2.x, pix2.y); double offset = p2.getLatitude() - p.getLatitude();
private String valueToString(Object val) { if (val instanceof GeoPoint) { val = ((GeoPoint) val).getDescription(); } else if (val instanceof StreamingPropertyValue) { val = ((StreamingPropertyValue) val).readToString(); } return ((String) val).toLowerCase(); }
@Override public String toString() { return "[" + getNorthWest() + "," + getSouthEast() + "]"; } }
public static double distanceBetween(double latitude1, double longitude1, double latitude2, double longitude2) { double dLat = toRadians(latitude2 - latitude1); double dLon = toRadians(longitude2 - longitude1); latitude1 = toRadians(latitude1); latitude2 = toRadians(latitude2); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return EARTH_RADIUS * c; }
@Override public boolean within(GeoShape geoShape) { if (geoShape instanceof GeoPoint) { GeoPoint pt = (GeoPoint) geoShape; return GeoPoint.distanceBetween(getLatitude(), getLongitude(), pt.getLatitude(), pt.getLongitude()) <= getRadius(); } throw new SecureGraphException("Not implemented for argument type " + geoShape.getClass().getName()); }
@Override public String toString() { return "(" + getLatitude() + ", " + getLongitude() + ")"; }
@Override public int compareTo(GeoPoint other) { int i; if ((i = compare(getLatitude(), other.getLatitude())) != 0) { return i; } if ((i = compare(getLongitude(), other.getLongitude())) != 0) { return i; } if (getAltitude() != null && other.getAltitude() != null) { return compare(getAltitude(), other.getAltitude()); } if (getAltitude() != null) { return 1; } if (other.getAltitude() != null) { return -1; } return 0; }
public static double distanceBetween(GeoPoint geoPoint1, GeoPoint geoPoint2) { return distanceBetween( geoPoint1.getLatitude(), geoPoint1.getLongitude(), geoPoint2.getLatitude(), geoPoint2.getLongitude()); }
@Override public String toString() { return "GeoCircle[" + getLatitude() + ", " + getLongitude() + ", " + getRadius() + "]"; } }
@Override public GeoRect getGeoCell() { org.elasticsearch.common.geo.GeoPoint northWest = new org.elasticsearch.common.geo.GeoPoint(); org.elasticsearch.common.geo.GeoPoint southEast = new org.elasticsearch.common.geo.GeoPoint(); GeohashUtils.decodeCell(getKey(), northWest, southEast); return new GeoRect(new GeoPoint(northWest.getLat(), northWest.getLon()), new GeoPoint(southEast.getLat(), southEast.getLon())); } };
@Override public String toString() { return "[" + getNorthWest() + "," + getSouthEast() + "]"; } }
public static double distanceBetween(double latitude1, double longitude1, double latitude2, double longitude2) { double dLat = toRadians(latitude2 - latitude1); double dLon = toRadians(longitude2 - longitude1); latitude1 = toRadians(latitude1); latitude2 = toRadians(latitude2); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return EARTH_RADIUS * c; }
GetNService gn = new GetNService(); NGeoPoint nearest = gn.getN(lat, lon); GeoPoint city = nearest.getPoint(); double lat = city.getLatitude(); double lon = city.getLongitude();