Example #1
0
 public bool isPointWithin(GeoPoint point)
 {
     double A = Math.Pow(point.Latitude - Center.Latitude, 2) / Math.Pow(witdh / 2, 2);
     double B = Math.Pow(point.Longitude - Center.Longitude, 2) / Math.Pow(height / 2, 2);
     if (A+B <= 1)
     {
         return true;
     }
     return false;
 }
Example #2
0
        public Ellipse(GeoPoint pt1, GeoPoint pt2)
        {
            double lat1 = pt1.Latitude;
            double lon1 = pt1.Longitude;
            double lat2 = pt2.Latitude;
            double lon2 = pt2.Longitude;

            GeoPoint elipseMiddle = GeoMath.getMiddlePoint(lat1, lon1, lat2, lon2);
            double distance = GeoMath.distanceLatLong(lat1, lon1, lat2, lon2);
            Center = elipseMiddle;
            witdh = distance;
            height = distance / 2;
        }
Example #3
0
        public static List<Ride> ClassificaCaronasComRota(List<Ride> Lista, GeoPoint usrOrg, GeoPoint usrDes)
        {
            Ellipse eVrd = new Ellipse(usrOrg, usrDes);
            Ellipse eAmr = new Ellipse();
            eAmr.witdh = eVrd.witdh * 1.3;
            eAmr.height = eVrd.height * 1.3;
            eAmr.Center = eVrd.Center;

            foreach (var r in Lista)
            {
                GeoPoint gOrg = new GeoPoint(r.LatOrigem, r.LonOrigem);
                if (eVrd.isPointWithin(gOrg))
                {
                    r.classOrg = ClassifiCarona.VERDE;
                }
                else if (eAmr.isPointWithin(gOrg))
                {
                    r.classOrg = ClassifiCarona.AMARELO;
                }
                else
                {
                    r.classOrg = ClassifiCarona.VERMELHO;
                }
                r.distanciaOrg = (decimal)GeoMath.distanceKM(usrOrg, gOrg);

                GeoPoint gDes = new GeoPoint(r.LatDestino, r.LonDestino);
                if (eVrd.isPointWithin(gDes))
                {
                    r.classDes = ClassifiCarona.VERDE;
                }
                else if (eAmr.isPointWithin(gDes))
                {
                    r.classDes = ClassifiCarona.AMARELO;
                }
                else
                {
                    r.classDes = ClassifiCarona.VERMELHO;
                }
                r.distanciaDes = (decimal)GeoMath.distanceKM(usrDes, gDes);
            }
            return Lista;
        }
Example #4
0
        public static List<Ride> ClassificaCaronasSemRota(List<Ride> Lista, GeoPoint usrOrg)
        {
            foreach (var r in Lista)
            {
                GeoPoint gOrg = new GeoPoint(r.LatOrigem, r.LonOrigem);
                r.distanciaOrg = (decimal)GeoMath.distanceKM(usrOrg, gOrg);

                r.classOrg = ClassifiCarona.NONE;
                r.classDes = ClassifiCarona.NONE;
            }
            return Lista;
        }
Example #5
0
 public static double distanceKM(GeoPoint g1, GeoPoint g2)
 {
     return distanceKM(g1.Latitude, g1.Longitude, g2.Latitude, g2.Longitude);
 }
Example #6
0
 public static GeoPoint getMiddlePoint(double lat1, double lon1, double lat2, double lon2)
 {
     GeoPoint gp = new GeoPoint();
     gp.Latitude = (lat1 + lat2) / 2;
     gp.Longitude = (lon1 + lon2) / 2;
     return gp;
 }