Definition at line 4 of file GeoCalc.java.
Static Public Member Functions | |
| static double | distance (Point p, Line l) |
| static double | distance (Point a, Point b) |
| static double | geoDistanceKm (Point a, Point b) |
| static double | geoDistanceM (Point a, Point b) |
| static double | getLatOffset (double lon, double lat, int meters) |
| static double | getLonOffset (double lon, double lat, int meters) |
Static Public Attributes | |
| static final int | EARTH_RADIUS_KM = 6371 |
| static double | KM_PER_LAT = 111.12 |
| static final double | LATITUDE_PER_KM = 1.0/111.12 |
| static double de::psi::telco::sumoplayer::util::GeoCalc::distance | ( | Point | p, | |
| Line | l | |||
| ) | [inline, static] |
This function returns the minimum distance from Poit p to Line l. It uses SUNs implementation which uses a scalarproduct projection length to determin the minimal distance.
| p | ||
| l |
Definition at line 30 of file GeoCalc.java.
References de::psi::telco::sumoplayer::util::Line::getA(), de::psi::telco::sumoplayer::util::Line::getB(), de::psi::telco::sumoplayer::util::Point::getX(), and de::psi::telco::sumoplayer::util::Point::getY().
00030 { 00031 double x1 = l.getA().getX(); 00032 double x2 = l.getB().getX(); 00033 double y1 = l.getA().getY(); 00034 double y2 = l.getB().getY(); 00035 double px = p.getX(); 00036 double py = p.getX(); 00037 00038 // Adjust vectors relative to x1,y1 00039 // x2,y2 becomes relative vector from x1,y1 to end of segment 00040 x2 -= x1; 00041 y2 -= y1; 00042 // px,py becomes relative vector from x1,y1 to test point 00043 px -= x1; 00044 py -= y1; 00045 double dotprod = px * x2 + py * y2; 00046 // dotprod is the length of the px,py vector 00047 // projected on the x1,y1=>x2,y2 vector times the 00048 // length of the x1,y1=>x2,y2 vector 00049 double projlenSq = dotprod * dotprod / (x2 * x2 + y2 * y2); 00050 // Distance to line is now the length of the relative point 00051 // vector minus the length of its projection onto the line 00052 double lenSq = px * px + py * py - projlenSq; 00053 if (lenSq < 0) { 00054 lenSq = 0; 00055 } 00056 return Math.sqrt(lenSq); 00057 }
| static double de::psi::telco::sumoplayer::util::GeoCalc::distance | ( | Point | a, | |
| Point | b | |||
| ) | [inline, static] |
Definition at line 10 of file GeoCalc.java.
References de::psi::telco::sumoplayer::util::Point::getX(), and de::psi::telco::sumoplayer::util::Point::getY().
00010 { 00011 return Math.sqrt( Math.pow(Math.abs(a.getX()-b.getX()),2) + Math.pow(Math.abs(a.getY()-b.getY()),2) ); 00012 }
| static double de::psi::telco::sumoplayer::util::GeoCalc::geoDistanceKm | ( | Point | a, | |
| Point | b | |||
| ) | [inline, static] |
Definition at line 13 of file GeoCalc.java.
References EARTH_RADIUS_KM, de::psi::telco::sumoplayer::util::Point::getX(), and de::psi::telco::sumoplayer::util::Point::getY().
Referenced by geoDistanceM().
00013 { 00014 return Math.acos(Math.sin(Math.toRadians(a.getY()))*Math.sin(Math.toRadians(b.getY())) + 00015 Math.cos(Math.toRadians(a.getY()))*Math.cos(Math.toRadians(b.getY())) * 00016 Math.cos(Math.toRadians(b.getX())-Math.toRadians(a.getX()))) * (double)EARTH_RADIUS_KM; 00017 }
| static double de::psi::telco::sumoplayer::util::GeoCalc::geoDistanceM | ( | Point | a, | |
| Point | b | |||
| ) | [inline, static] |
Definition at line 18 of file GeoCalc.java.
References geoDistanceKm().
00018 { 00019 return (geoDistanceKm(a, b)*1000); 00020 }
| static double de::psi::telco::sumoplayer::util::GeoCalc::getLatOffset | ( | double | lon, | |
| double | lat, | |||
| int | meters | |||
| ) | [inline, static] |
Definition at line 65 of file GeoCalc.java.
References KM_PER_LAT.
00065 { 00066 return (1.0/(KM_PER_LAT*1000))*meters; 00067 }
| static double de::psi::telco::sumoplayer::util::GeoCalc::getLonOffset | ( | double | lon, | |
| double | lat, | |||
| int | meters | |||
| ) | [inline, static] |
Definition at line 59 of file GeoCalc.java.
References KM_PER_LAT.
00059 { 00060 double latDelta = (1.0/(KM_PER_LAT*1000))*meters; 00061 double lonFact = Math.cos(Math.toRadians(lat)); 00062 return latDelta*lonFact; 00063 }
final int de::psi::telco::sumoplayer::util::GeoCalc::EARTH_RADIUS_KM = 6371 [static] |
double de::psi::telco::sumoplayer::util::GeoCalc::KM_PER_LAT = 111.12 [static] |
final double de::psi::telco::sumoplayer::util::GeoCalc::LATITUDE_PER_KM = 1.0/111.12 [static] |
Definition at line 7 of file GeoCalc.java.
1.5.6