Commit 1eb2e790 authored by Kaitlyn's avatar Kaitlyn
Browse files

Reformatted code to pep8 standards

parent f69891e6
Loading
Loading
Loading
Loading
+133 −125
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import urllib.request


class planetary_maps:

    def __init__(self, targetName):
        self.target_name = targetName
        self.layers = []
@@ -54,9 +55,11 @@ class planetary_maps:
        for i, target in enumerate(targets):
            current_target = targets[i]
            if current_target['name'].lower() == self.target_name:
                self.dmajor_radius = float(current_target['aaxisradius']) * 1000.0
                self.dminor_radius = float(current_target['caxisradius']) * 1000.0
                break;
                self.dmajor_radius = float(
                    current_target['aaxisradius']) * 1000.0
                self.dminor_radius = float(
                    current_target['caxisradius']) * 1000.0
                break

    def create_layers(self):

@@ -75,7 +78,6 @@ class planetary_maps:
                                continue
                            self.map_layers['overlays'].append(current_layer)

        
        for layer in self.map_layers['base']:
            if layer['projection'] == 'cylindrical':
                wms_layer = WMSLayer(
@@ -122,26 +124,27 @@ class planetary_maps:
                    lng = -180 + (abs(lng) % 180)

            if self.gui.get_longitude_range().value == "0 to 360":
                lng += 180;
            
                lng += 180

            if self.gui.get_lat_domain().value == "Planetographic":
                converted_latitude = Math.radians(lat)
                converted_latitude = Math.atan(((self.dmajor_radius / self.dminor_radius)**2) * (Math.tan(converted_latitude)))
                converted_latitude = Math.atan(
                    ((self.dmajor_radius / self.dminor_radius)**2) * (Math.tan(converted_latitude)))
                converted_latitude = Math.degrees(converted_latitude)
                lat = converted_latitude

                
            if self.gui.get_longitude_direction().value == "Positive West":
                if(self.gui.get_longitude_range().value == "-180 to 180"):
                    lng *= -1
                else:
                    lng = Math.fabs(lng - 360)

            self.gui.get_lat_lon_label().value = "Lat, Lon: "+ str(round(lat, 2)) + ", " + str(round(lng, 2))
            self.gui.get_lat_lon_label().value = "Lat, Lon: " + \
                str(round(lat, 2)) + ", " + str(round(lng, 2))

    def create_map(self):
        self.planet_map = Map(layers=tuple(self.layers), center=(0, 0), zoom=1, crs='EPSG4326')
        self.planet_map = Map(layers=tuple(self.layers),
                              center=(0, 0), zoom=1, crs='EPSG4326')

        draw_control = DrawControl()
        draw_control.polyline = {
@@ -184,10 +187,14 @@ class planetary_maps:
        draw_control.on_draw(self.handle_draw)
        self.gui.get_wkt_button().on_click(self.handle_WKT_button)

        self.range_control = WidgetControl(widget=self.gui.get_longitude_range(), position='topright')
        self.lat_control = WidgetControl(widget=self.gui.get_lat_domain(), position='topright')
        self.direction_control = WidgetControl(widget=self.gui.get_longitude_direction(), position='topright')
        self.label_control = WidgetControl(widget=self.gui.get_lat_lon_label(), position='bottomright')
        self.range_control = WidgetControl(
            widget=self.gui.get_longitude_range(), position='topright')
        self.lat_control = WidgetControl(
            widget=self.gui.get_lat_domain(), position='topright')
        self.direction_control = WidgetControl(
            widget=self.gui.get_longitude_direction(), position='topright')
        self.label_control = WidgetControl(
            widget=self.gui.get_lat_lon_label(), position='bottomright')

        self.planet_map.add_control(draw_control)
        self.planet_map.add_control(LayersControl(position='topright'))
@@ -213,7 +220,8 @@ class planetary_maps:
        try:
            g1 = shapely.wkt.loads(wktString)
            g2 = geojson.Feature(geometry=g1, properties={})
            geo_json = GeoJSON(data=g2, style = {'color': 'yellow', 'opacity':1, 'weight':1.9, 'fillOpacity':0.5})
            geo_json = GeoJSON(data=g2, style={
                               'color': 'yellow', 'opacity': 1, 'weight': 1.9, 'fillOpacity': 0.5})
            self.planet_map.add_layer(geo_json)
        except:
            self.gui.get_wkt_text_box().value = "Invalid WKT String"
@@ -259,7 +267,8 @@ class planetary_maps:
                    jsonp = json.loads(url.read())

                    # Sort features by diameter
                    jsonp['features'] = sorted(jsonp['features'], key = lambda feature: feature["properties"]["diameter"]) 
                    jsonp['features'] = sorted(
                        jsonp['features'], key=lambda feature: feature["properties"]["diameter"])
                    geo_json = GeoJSON(data=jsonp, name="Show Feature Names")
                    geo_json.point_style = {
                        'fillOpacity': 1,
@@ -365,4 +374,3 @@ class planetary_gui:

    def get_longitude_range(self):
        return self.longitude_range
            
 No newline at end of file