def findAoiIntersection(i, kml, tmpPoints, allObjects, theFpl, lookAt, tmpBegin) : # Find intrsection with AOI deparatureTime = theFpl.deparatureTime estimatedTime = theFpl.estimatedTime arrivalTime = deparatureTime + estimatedTime line1 = { 'lat1' : tmpPoints[0]['latitude'], 'long1' : tmpPoints[0]['longitude'], 'lat2' : tmpPoints[1]['latitude'], 'long2' : tmpPoints[1]['longitude'], } aoi = allObjects['aoi']['aoi'] aoiPoints = aoi['VCC1_AOI'].points for j in xrange(len(aoiPoints)-1) : line2 = { 'lat1' : aoiPoints[j].coordinate['latitude'], 'long1' : aoiPoints[j].coordinate['longitude'], 'lat2' : aoiPoints[j+1].coordinate['latitude'], 'long2' : aoiPoints[j+1].coordinate['longitude'], } intersection = usualFonction.findIntersection(line1, line2) if intersection: distance = Convertion.distanceBetwennTwoPoint( intersection['latitude'], intersection['longitude'], tmpPoints[0]['latitude'], tmpPoints[0]['longitude'], theFpl.points[i]['altitude'] ) pToPTime = theFpl.points[i+1]['estimatedPointTime'] pToPDistance = theFpl.points[i+1]['lastPointDistance'] iTime = pToPTime *int(distance * 1000000000 / pToPDistance) iTime =iTime / 1000000000 intersectionTime = tmpBegin + iTime begin = deparatureTime.strftime("%Y-%m-%dT%H:%MZ") end = arrivalTime.strftime("%Y-%m-%dT%H:%MZ") position = lookAt.copy() position['longitude'] = intersection['longitude'] position['latitude'] = intersection['latitude'] description ='' style = 'redCircle' visibility = 1 ptName = ( str(intersectionTime.strftime("%H:%M - ")) + str(theFpl.name)) kml.addPlacemark( ptName, description , position, visibility, style, begin, end ) return kml
def setDistance (self) : """ Add distance in milles """ # initiate the first point self.points[0]['totalDistance'] = 0 self.points[0]['lastPointDistance'] = 0 for i in xrange(1,len(self.points)): point = self.points[i] lastPoint = self.points[i-1] ltd = lastPoint['totalDistance'] distance = Convertion.distanceBetwennTwoPoint( point['coordinate']['latitude'], point['coordinate']['longitude'], lastPoint['coordinate']['latitude'], lastPoint['coordinate']['longitude'], lastPoint['altitude'] ) lpd = distance td = ltd + lpd point['totalDistance'] = td point['lastPointDistance'] = lpd