Beispiel #1
0
def write(
    output,
    geometri,
    geometrifil,
    buffer,
    fra,
    til,
    fixpunkter,
    fixpunkterfil,
    parameterfil,
):
    """Create a gama input file"""
    writer = GamaWriter(firedb, output)

    g = None

    if geometrifil is None and geometri is None:
        writer.take_all_points()
    else:
        if geometri is not None:
            g = Geometry(geometri)
        else:
            wkt = geometrifil.read()
            g = Geometry(wkt)

        if fra is not None and til is not None:
            observations = firedb.hent_observationer_naer_geometri(
                g, buffer, fra, til)
        else:
            observations = firedb.hent_observationer_naer_geometri(g, buffer)
        writer.take_observations(observations)

    if fixpunkter is not None or fixpunkterfil is not None:
        if fixpunkter is not None:
            fixpunkter_literal = fixpunkter
        else:
            fixpunkter_literal = fixpunkterfil.read()

        fixpunkter_list = [
            pkt.strip() for pkt in fixpunkter_literal.split(",")
        ]
        writer.set_fixed_point_ids(fixpunkter_list)

    parameters = configparser.ConfigParser()
    parameters.read(parameterfil)
    writer.write(True, False, "Created by fire-gama", parameters)
Beispiel #2
0
def test_all_points(firedb: FireDb, tmp_path: Path):
    outfile = tmp_path / "all_points.xml"
    with open(outfile, "w") as output:
        writer = GamaWriter(firedb, output)

        writer.take_all_points()
        writer.set_fixed_point_ids(["K-63-09946"])

        parameters = configparser.ConfigParser()
        parameters.read("fire-gama.ini")
        writer.write(True, False, "test_all_points", parameters)
Beispiel #3
0
def test_all_points(firedb: FireDb, tmp_path: Path):
    outfile = tmp_path / "all_points.xml"
    output = open(outfile, "w")
    writer = GamaWriter(firedb, output)

    writer.take_all_points()
    writer.set_fixed_point_ids(["67e3987a-dc6b-49ee-8857-417ef35777af"])

    parameters = configparser.ConfigParser()
    parameters.read("fire-gama.ini")
    writer.write(True, False, "test_all_points", parameters)
    output.close
Beispiel #4
0
def test_in_polygon(firedb: FireDb, tmp_path: Path):
    outfile = tmp_path / "in_polygon.xml"
    with open(outfile, "w") as output:
        writer = GamaWriter(firedb, output)

        geometry = Geometry(("POLYGON ((10.209 56.155, "
                             "10.209 56.158, "
                             "10.215 56.158, "
                             "10.215 56.155, "
                             "10.209 56.155))"))
        observations = firedb.hent_observationer_naer_geometri(geometry, 5000)
        writer.take_observations(observations)

        writer.set_fixed_point_ids(["K-63-09946"])

        parameters = configparser.ConfigParser()
        parameters.read("fire-gama.ini")
        writer.write(True, False, "test_in_polygon", parameters)
    os.remove(outfile)
Beispiel #5
0
def test_in_polygon(firedb: FireDb, tmp_path: Path):
    outfile = tmp_path / "in_polygon.xml"
    output = open(outfile, "w")
    writer = GamaWriter(firedb, output)

    geometry = Geometry(("POLYGON ((10.209 56.155, "
                         "10.209 56.158, "
                         "10.215 56.158, "
                         "10.215 56.155, "
                         "10.209 56.155))"))
    observations = firedb.hent_observationer_naer_geometri(geometry, 5000)
    writer.take_observations(observations)

    writer.set_fixed_point_ids(["67e3987a-dc6b-49ee-8857-417ef35777af"])

    parameters = configparser.ConfigParser()
    parameters.read("fire-gama.ini")
    writer.write(True, False, "test_in_polygon", parameters)
    output.close
    os.remove(outfile)
Beispiel #6
0
def test_naer_geometry(firedb: FireDb, tmp_path: Path):
    outfile = tmp_path / "near_geometry.xml"
    with open(outfile, "w") as output:
        writer = GamaWriter(firedb, output)

        g = Geometry("POINT (10.200000 56.100000)")
        observations = firedb.hent_observationer_naer_geometri(g, 10000)

        writer.take_observations(observations)

        parameters = configparser.ConfigParser()
        parameters.read("fire-gama.ini")
        writer.write(True, False, "test_near_geometry", parameters)
    os.remove(outfile)
Beispiel #7
0
def test_naer_geometry_time_interval(firedb: FireDb, tmp_path: Path):
    outfile = tmp_path / "near_geometry_time_interval.xml"
    output = open(outfile, "w")
    writer = GamaWriter(firedb, output)

    g = Geometry("POINT (10.200000 56.100000)")
    observations = firedb.hent_observationer_naer_geometri(
        g, 10000, datetime.datetime(2015, 10, 8),
        datetime.datetime(2018, 10, 9))

    writer.take_observations(observations)

    parameters = configparser.ConfigParser()
    parameters.read("fire-gama.ini")
    writer.write(True, False, "test_near_geometry_time_interval", parameters)
    output.close
    os.remove(outfile)