Пример #1
0
def find_drone_path(origin, destiny, path_name, incidence, is_returning=False):
    geo_point_origin = (origin.latitude, origin.longitude)
    geo_point_destiny = (destiny.latitude, destiny.longitude)
    file_path = path_name + "in" + str(incidence.id) + "drone.kml"
    dist = geopy.distance.distance(geo_point_origin, geo_point_destiny) \
        .kilometers
    bearing = \
        calculate_initial_compass_bearing(geo_point_origin, geo_point_destiny)
    take_off_steps = 8
    altitude = origin.altitude
    Kml(name="incidence" + str(incidence.id) + ".kml",
        url=path_name + "incidence" + str(incidence.id) + ".kml",
        visibility=True).save()
    create_emergency_marker(
        incidence, path_name + "incidence" + str(incidence.id) + ".kml")
    placemark_kml(incidence.drone,
                  (geo_point_origin[0], geo_point_origin[1], altitude),
                  file_path)
    take_off_steps -= 1
    altitude += 25
    sync_kml_galaxy()
    create_drone_manage_route(path_name, incidence.id)
    steps = 20
    lat = geo_point_origin[0]
    lon = geo_point_origin[1]

    for i in range(take_off_steps):
        placemark_kml(incidence.drone,
                      (geo_point_origin[0], geo_point_origin[1], altitude),
                      file_path)
        altitude += 25
        time.sleep(2)

    for i in range(steps):
        destination = VincentyDistance(kilometers=dist / steps) \
            .destination(geopy.Point(lat, lon), bearing)
        lat, lon = destination.latitude, destination.longitude
        placemark_kml(incidence.drone, (lat, lon, altitude), file_path)
        time.sleep(2)

    for i in range(8):
        placemark_kml(incidence.drone, (lat, lon, altitude), file_path)
        altitude -= 25
        time.sleep(2)

    time.sleep(5)
    os.remove(path_name + "incidence" + str(incidence.id) + ".kml")
    Kml.objects.filter(name="incidence" + str(incidence.id) + ".kml"). \
        delete()
    Kml(name="finishedincidence" + str(incidence.id) + ".kml",
        url=path_name + "finishedincidence" + str(incidence.id) +
        ".kml").save()
    create_emergency_marker(
        incidence,
        path_name + "finishedincidence" + str(incidence.id) + ".kml", True)
    sync_kml_galaxy()
    time.sleep(10)
    delete_incidence(incidence, path_name)
    time.sleep(30)
    delete_finished_incidence_marker(incidence, path_name)
Пример #2
0
 def create_logo(self, path, app_ip):
     self.stdout.write("Creating Logo Kml...")
     name = "faed_logo"
     faed_logo_kml(path + name,
                   "http://" + app_ip + "/static/img/static_icon.png", 1, 1,
                   0.2, 0.15)
     Kml(name=name + ".kml", url=path + name + ".kml", visibility=0).save()
     faed_logo_kml(path + "logos",
                   "http://" + app_ip + "/static/img/logos.png", 0, 0, 0.2,
                   0.3)
     Kml(name="logos.kml", url=path + "logos.kml", visibility=0).save()
Пример #3
0
 def create_droppoints(self, path):
     self.stdout.write("Creating Droppoints Kml...")
     dp = []
     for item in DropPoint.objects.all():
         name = "droppoint_" + str(item.id) + ".kml"
         create_droppoint_marker(item, path + name)
         dp.append(name)
     name_general = "general_dp.kml"
     create_general(path + name_general, dp)
     Kml(name=name_general, url=path + name_general).save()
Пример #4
0
def create_drone_manage_route(path_name, id_incidence):
    ip_server = get_server_ip()
    url_file = "http://" + str(ip_server)[0:(len(ip_server) - 1)] + \
               ":8000/static/kml/" + "in" + str(id_incidence) + \
               "drone.kml" + "\n"
    manage_kml(path_name + "manage" + str(id_incidence), url_file, 0.5)
    Kml(name="manage" + str(id_incidence) + ".kml",
        url="static/kml/manage" + str(id_incidence) + ".kml").save()
    sync_kml_galaxy()
    time.sleep(2)