示例#1
0
 def distance(self, x, y):
     if self.geodesic:        
         start = ((self.x, 0, 0), (self.y, 0, 0))
         end = ((x, 0, 0), (y, 0, 0))
     
         return points2distance(start, end)
     else:
         return math.sqrt(math.pow(x - self.x,2) + math.pow(y - self.y, 2))
示例#2
0
def getDistance(geoPointJsonFrom, geoPointJsonTo):
    """TO BE FIXED : Gets distance between 2 raw Json GeoPoints

        Args:
            pointFrom : raw Json GeoPoint
            pointTo : raw Json GeoPoint

        Returns:
            Float
    """
    if (geoPointJsonFrom['Status']["code"] == 200
        and geoPointJsonTo['Status']["code"] == 200):
        return haversine.points2distance(
                            (
                             (geoPointJsonFrom['Placemark'][0]['Point']['coordinates'][1],0,0),
                             (geoPointJsonFrom['Placemark'][0]['Point']['coordinates'][0],0,0)
                            ),
                            (
                             (geoPointJsonTo['Placemark'][0]['Point']['coordinates'][1],0,0),
                             (geoPointJsonTo['Placemark'][0]['Point']['coordinates'][0],0,0)
                            )
                        )
    else:
        return -1
示例#3
0
try:

    #create LED
    led = LED(LEDPIN)

    #loop forever
    while True:
        
        plane_in_range = False

        #loop through the aircraft and see if one is in range
        for aircraft in myflights.aircraft:
            if aircraft.validposition == 1:
                startpos = ((args.lat, 0, 0), (args.lon, 0, 0))
                endpos = ((aircraft.lat, 0, 0), (aircraft.lon, 0, 0))
                distance = points2distance(startpos, endpos)
                #debug
                #print(distance)
                if distance <= args.range:
                    plane_in_range = True

        #turn the led on / off
        if plane_in_range:
            led.on()
            #print("on")
        else:
            led.off()
            #print("off")
            
        sleep(1)
示例#4
0
def distance(x1, y1, x2, y2):
    start = ((x1, 0, 0), (y1, 0, 0))
    end = ((x2, 0, 0), (y2, 0, 0))
    return points2distance(start, end)
示例#5
0
def distance(x1, y1, x2, y2):
    start = ((x1, 0, 0), (y1, 0, 0))
    end = ((x2, 0, 0), (y2, 0, 0))  
    return points2distance(start, end)
def distance(point1, point2):
    start = ((point1[0], 0, 0), (point1[1], 0, 0))
    end = ((point2[0], 0, 0), (point2[1], 0, 0))
    return haversine.points2distance(start, end)
示例#7
0
try:

    #create LED
    led = LED(LEDPIN)

    #loop forever
    while True:

        plane_in_range = False

        #loop through the aircraft and see if one is in range
        for aircraft in myflights.aircraft:
            if aircraft.validposition == 1:
                startpos = ((args.lat, 0, 0), (args.lon, 0, 0))
                endpos = ((aircraft.lat, 0, 0), (aircraft.lon, 0, 0))
                distance = points2distance(startpos, endpos)
                #debug
                #print(distance)
                if distance <= args.range:
                    plane_in_range = True

        #turn the led on / off
        if plane_in_range:
            led.on()
            #print("on")
        else:
            led.off()
            #print("off")

        sleep(1)