Exemplo n.º 1
0
 def get_bounds(self):
     rc = GeoRect()
     rc.left = Angle.degrees(180)
     rc.right = Angle.degrees(-180)
     rc.top = Angle.degrees(-90)
     rc.bottom = Angle.degrees(90)
     for wp in self.__list:
         rc.left = min(rc.left, wp.location.lon)
         rc.right = max(rc.right, wp.location.lon)
         rc.top = max(rc.top, wp.location.lat)
         rc.bottom = min(rc.bottom, wp.location.lat)
     return rc
Exemplo n.º 2
0
 def get_bounds(self):
     rc = GeoRect()
     rc.left = Angle.degrees(180)
     rc.right = Angle.degrees(-180)
     rc.top = Angle.degrees(-90)
     rc.bottom = Angle.degrees(90)
     for wp in self.__list:
         rc.left = min(rc.left, wp.location.lon)
         rc.right = max(rc.right, wp.location.lon)
         rc.top = max(rc.top, wp.location.lat)
         rc.bottom = min(rc.bottom, wp.location.lat)
     return rc
Exemplo n.º 3
0
    def __init__(self, left = 0, right = 0, top = 0, bottom = 0):
        if isinstance(left, Angle):
            self.left = left
        else:
            self.left = Angle.degrees(left)
            
        if isinstance(right, Angle):
            self.right = right
        else:
            self.right = Angle.degrees(right)

        if isinstance(top, Angle):
            self.top = top
        else:
            self.top = Angle.degrees(top)

        if isinstance(bottom, Angle):
            self.bottom = bottom
        else:
            self.bottom = Angle.degrees(bottom)
Exemplo n.º 4
0
    def __init__(self, left=0, right=0, top=0, bottom=0):
        if isinstance(left, Angle):
            self.left = left
        else:
            self.left = Angle.degrees(left)

        if isinstance(right, Angle):
            self.right = right
        else:
            self.right = Angle.degrees(right)

        if isinstance(top, Angle):
            self.top = top
        else:
            self.top = Angle.degrees(top)

        if isinstance(bottom, Angle):
            self.bottom = bottom
        else:
            self.bottom = Angle.degrees(bottom)
Exemplo n.º 5
0
def convert(template, working_dir):
    if not "NAME" in template:
        print "Template file has no NAME specified!"
        return

    if ((not "LATMIN" in template) or (not "LATMAX" in template)
            or (not "LONMIN" in template) or (not "LONMIN" in template)):
        print "Template file has no bounds specified!"
        return

    name = template["NAME"]

    lkm_file = os.path.join(working_dir, name + ".LKM")
    xcm_file = os.path.join(working_dir, name + ".xcm")

    if not os.path.exists(lkm_file):
        print "LKM file \"" + lkm_file + "\" does not exist!"
        return

    m = MapGenerator()
    m.SetBoundsSeperatly(
        Angle.degrees(float(template["LATMIN"].replace(",", "."))),
        Angle.degrees(float(template["LATMAX"].replace(",", "."))),
        Angle.degrees(float(template["LONMIN"].replace(",", "."))),
        Angle.degrees(float(template["LONMAX"].replace(",", "."))))
    m.AddTerrain(9)

    credits = []
    credits.append(
        "Topology data \xa9 OpenStreetMap contributors (http://www.openstreetmap.org), CC-BY-SA (http://creativecommons.org/licenses/by-sa/2.0/)"
    )
    credits.append(
        "Topology data conversion \xa9 LK8000 project (http://www.lk8000.it)")
    m.AddInformationFile(name, "Paolo Ventafridda <*****@*****.**>",
                         credits)

    lkm = zipfile.ZipFile(lkm_file, "r")
    needed_files = []
    for file in lkm.namelist():
        # Don't add coast_area shapefile to the XCM file
        if file.lower().startswith("coast_area."): continue
        # Don't add info.txt to the XCM file
        # -> we will create our own...
        if file.lower() == "info.txt": continue
        needed_files.append(file)

    if needed_files == []:
        print "LKM file \"" + lkm_file + "\" is empty!"
        return

    # Create temporary folder
    temp_dir = mkdtemp()
    # Extract LKM contents to temporary folder
    print "Extracting \"" + lkm_file + "\" ..."
    lkm.extractall(temp_dir, needed_files)
    lkm.close()

    # Remove coast_area shapefile from topology file
    update_topology_file(temp_dir)

    # Delete old XCM file if exists
    if os.path.exists(xcm_file):
        os.unlink(xcm_file)

    # Create new XCM file
    print "Creating \"" + xcm_file + "\" ..."
    xcm = zipfile.ZipFile(xcm_file, "w")
    for file in needed_files:
        compress = zipfile.ZIP_DEFLATED
        # Don't compress shapefiles
        if ((file.lower().endswith(".dbf")) or (file.lower().endswith(".prj"))
                or (file.lower().endswith(".shp"))
                or (file.lower().endswith(".shx"))):
            compress = zipfile.ZIP_STORED

        xcm.write(os.path.join(temp_dir, file), file, compress)
    xcm.close()

    # Delete temporary files
    print "Deleting temporary files ..."
    for file in needed_files:
        os.unlink(os.path.join(temp_dir, file))
    os.rmdir(temp_dir)

    # Add terrain to XCM file
    m.Create(xcm_file, True)
Exemplo n.º 6
0
 def __init__(self,
              lon = Angle.degrees(0),
              lat = Angle.degrees(0)):
     self.lon = lon
     self.lat = lat