def get_map(): gc.collect() UL_val = [ *map(float, ( UL_corner.get().split(',') ) )] LR_val = [ *map(float, ( LR_corner.get().split(',') ) ) ] zoom_level = zoom.get() name = img_name.get() if not 0 < zoom_level < 21: messagebox.showerror("Value Error!", "Zoom Level must be in range [0, 20]") return False if name == "": name = "map" #print(name) UL_val = Geo.UMTPoint(UL_val[0], UL_val[1], zoom_level) LR_val = Geo.UMTPoint(LR_val[0], LR_val[1], zoom_level) map_ = TR.MapReq(UL_val, LR_val, zoom_level, name=name) print('\n##-----------------------------##\n') print(map_.MAP) map_.RequestTiles() TC.MapImage(map_.MAP.map_width, map_.MAP.map_height, name).open_image()
def move(self): if self.next_pos < len(self.path): while haversine(self.pos, self.path[self.next_pos]) >= 0.010: angle = Geo.calculate_angle(self.pos, self.path[self.next_pos]) self.pos = Geo.calculate_next_point(self.pos, self.walk_distance, angle) self.pos = self.path[self.next_pos] # This line of code bellow MUST NOT BE ABSSENT or there will be unforeseen consequences self.next_pos += 1
def check(groundspeed, bearing, positions): print("Aircraft groundspeed: %f Bearing: %f" % (groundspeed, bearing)) for index, aircraftPos in enumerate(positions): aircraftECEF = Geo.sphericalToECEF(aircraftPos) aircraftECEFVel = Geo.ecefVelocities(aircraftPos, Geo.knotsToKms(groundspeed), bearing) LOSSpeed = Geo.LOSSpeed(satelliteInfos[index]['XYZ'], satelliteInfos[index]['Velocity'], aircraftECEF, aircraftECEFVel) pingRadius = Geo.greatCircleDistance(aircraftPos, satelliteInfos[index]['LatLon']) print(aircraftPos, Geo.KmsToKmh(LOSSpeed), Geo.KmsToKnots(LOSSpeed), Geo.kmToNm(pingRadius))
def gen_rand_points(num_points, bound_rect): point_list = list() for pi in range(0, num_points): point_list.append(Geo.Point2D(random.randint(bound_rect.left, bound_rect.right), random.randint(bound_rect.top, bound_rect.bottom))) return point_list
def calc(pos, bearing): segments = [pos] lastPos = pos for index in range(0, len(satelliteInfos)-1): pingInterval = satelliteInfos[index]['NextPingTimeOffset'] newPos = Geo.greatCircleDestination(lastPos, bearing, Geo.nmToKm((pingInterval/60.0)*aircraftGroundSpeed)) satelliteRange = Geo.greatCircleDistance(newPos, satelliteInfos[index+1]['LatLon']) if math.fabs(satelliteRange - satelliteInfos[index+1]['PingRadius']) < pingRingDiffError * satelliteInfos[index+1]['PingRadius']: if filterUsingDoppler: aircraftECEF = Geo.sphericalToECEF(newPos) aircraftECEFVel = Geo.ecefVelocities(newPos, Geo.knotsToKms(aircraftGroundSpeed), bearing) LOSSpeed = Geo.LOSSpeed(satelliteInfos[index+1]['XYZ'], satelliteInfos[index+1]['Velocity'], aircraftECEF, aircraftECEFVel) * -1.0 if math.fabs(LOSSpeed - satelliteInfos[index+1]['LOSSpeed']) < math.fabs(dopplerDiffError * satelliteInfos[index+1]['LOSSpeed']): segments.append(newPos) lastPos = newPos else: break else: segments.append(newPos) lastPos = newPos else: break if len(segments) == 5: for index in range(1, len(satelliteInfos)): segmentPos = segments[index] ax.scatter(segmentPos[1], segmentPos[0], c=satelliteInfos[index]['Color']) prevSegmentPos = segments[index-1] ax.plot([prevSegmentPos[1], segmentPos[1]], [prevSegmentPos[0], segmentPos[0]])
def GetCloseBySpots(self, *args): #spotList = [] #======================================================================= # for spot in spots: # spotList.append({ 'lat' : spot.lat, 'lng' : spot.lng }) #======================================================================= return { 'CommandName': 'GetCloseBySpots', 'Value' : Geo.getCloseBySpots(args[0]['Value'], args[1]['Value']) }
def __init__(self, upper_left, lower_right, zoom=17, scale=2, size=config.TILE_SIZE, key=0, name='map'): assert isinstance(upper_left, Geo.UMTPoint) and isinstance(lower_right, Geo.UMTPoint),\ "ValueError! Upper_left and Lower_right must be Geo.UMTPoint instances!" self.MAP = Geo.Map(upper_left, lower_right, zoom) self.zoom_level = zoom self.scale = 2 self.tile_size = size self.key = 0 self.map_name = name fm.GoToWorkDir() self.markers = self._add_markers()
def groundCheckGeoSat(groundspeed, bearing, aircraftPos): aircraftECEF = Geo.sphericalToECEF(aircraftPos) aircraftECEFVel = Geo.ecefVelocities(aircraftPos, groundspeed, bearing) LOSSpeed = Geo.LOSSpeed(satelliteGeo['XYZ'], satelliteGeo['Velocity'], aircraftECEF, aircraftECEFVel) print(Geo.KmsToKnots(LOSSpeed), Geo.KmsToKnots(LOSSpeed) * 2.82)
import math import Geo ''' satelliteInfo1940 = { 'LatLon': (1.640,64.520), 'XYZ' : (18140.934782,38066.764468,1206.206412), 'Velocity': (0.001663,-0.000776,-0.001656), 'LOSSpeed': Geo.knotsToKms(-53.74), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1762), 'Color': 'b', 'Elevation': 55.80 } satelliteInfo2040 = { 'LatLon': (1.576,64.510), 'XYZ' : (18147.379654,38064.186790,1159.122617), 'Velocity': (0.001811,-0.000618,-0.024394), 'LOSSpeed': Geo.knotsToKms(-70.87), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1805), 'Color': 'c', 'Elevation': 54.98 } satelliteInfo2140 = { 'LatLon': (1.404,64.500), 'XYZ' : (18154.399609,38061.901891,1032.716137), 'Velocity': (0.001962,-0.000627,-0.045468), 'LOSSpeed': Geo.knotsToKms(-84.20), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1962), 'Color': 'g', 'Elevation': 52.01 } satelliteInfo2240 = { 'LatLon': (1.136,64.490), 'XYZ' : (18161.767618,38059.215141,835.616356), 'Velocity': (0.001981,-0.000841,-0.063437), 'LOSSpeed': Geo.knotsToKms(-97.14), 'NextPingTimeOffset': 91.0, 'PingRadius': Geo.nmToKm(2199), 'Color': 'r', 'Elevation': 47.54 } satelliteInfo0011 = { 'LatLon': (0.589,64.471), 'XYZ' : (18173.906276,38051.980584,433.193954), 'Velocity': (0.001476,-0.001458,-0.082097), 'LOSSpeed': Geo.knotsToKms(-111.18),'NextPingTimeOffset': 0.0, 'PingRadius': Geo.nmToKm(2642), 'Color': 'm', 'Elevation': 39.33 } ''' satelliteInfo1940 = { 'LatLon': (1.640,64.520), 'XYZ' : (18140.934782,38066.764468,1206.206412), 'Velocity': (0.001663,-0.000776,-0.001656), 'LOSSpeed': Geo.knotsToKms(-36.48), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1815), 'Color': 'b', 'Elevation': 54.8 } satelliteInfo2040 = { 'LatLon': (1.576,64.510), 'XYZ' : (18147.379654,38064.186790,1159.122617), 'Velocity': (0.001811,-0.000618,-0.024394), 'LOSSpeed': Geo.knotsToKms(-62.93), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1852), 'Color': 'c', 'Elevation': 54.1 } satelliteInfo2140 = { 'LatLon': (1.404,64.500), 'XYZ' : (18154.399609,38061.901891,1032.716137), 'Velocity': (0.001962,-0.000627,-0.045468), 'LOSSpeed': Geo.knotsToKms(-87.29), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1984), 'Color': 'g', 'Elevation': 51.6 } satelliteInfo2240 = { 'LatLon': (1.136,64.490), 'XYZ' : (18161.767618,38059.215141,835.616356), 'Velocity': (0.001981,-0.000841,-0.063437), 'LOSSpeed': Geo.knotsToKms(-108.42),'NextPingTimeOffset': 91.0, 'PingRadius': Geo.nmToKm(2212), 'Color': 'r', 'Elevation': 47.3 } satelliteInfo0011 = { 'LatLon': (0.589,64.471), 'XYZ' : (18173.906276,38051.980584,433.193954), 'Velocity': (0.001476,-0.001458,-0.082097), 'LOSSpeed': Geo.knotsToKms(-133.83),'NextPingTimeOffset': 0.0, 'PingRadius': Geo.nmToKm(2599), 'Color': 'm', 'Elevation': 40.1 } satelliteInfos = [satelliteInfo1940, satelliteInfo2040, satelliteInfo2140, satelliteInfo2240, satelliteInfo0011] satelliteGeo = { 'LatLon': (0.0,64.5), 'XYZ': (18155.08346350262, 38062.92402631797, 0.0), 'Velocity': (0.0,0.0,0.0)} groundTruth1630 = { 'AircraftLatLon': (2.746700,101.713300), 'AircraftSpeed': Geo.knotsToKms(0.0), 'AircraftTrack' : 230.0 } groundTruth1642 = { 'AircraftLatLon': (2.813056,101.679722), 'AircraftSpeed': Geo.knotsToKms(201.0), 'AircraftTrack' : 327.0 } groundTruth1654 = { 'AircraftLatLon': (3.931600,102.161800), 'AircraftSpeed': Geo.knotsToKms(452.0), 'AircraftTrack' : 25.0 } groundTruth1707 = { 'AircraftLatLon': (5.419167,102.864167), 'AircraftSpeed': Geo.knotsToKms(469.0), 'AircraftTrack' : 25.0 } groundTruths = [groundTruth1630, groundTruth1642, groundTruth1654, groundTruth1707] print(Geo.sphericalToECEFAlt(satelliteGeo['LatLon'], 35800)) '''
def draw_bbox(self, bbox, zoom=16, verbose=False) : sw = Geo.Location(bbox[0], bbox[1]) ne = Geo.Location(bbox[2], bbox[3]) nw = Geo.Location(ne.lat, sw.lon) se = Geo.Location(sw.lat, ne.lon) TL = self.provider.locationCoordinate(nw).zoomTo(zoom) # tiles = TileQueue() cur_lon = sw.lon cur_lat = ne.lat max_lon = ne.lon max_lat = sw.lat x_off = 0 y_off = 0 tile_x = 0 tile_y = 0 tileCoord = TL.copy() while cur_lon < max_lon : y_off = 0 tile_y = 0 while cur_lat > max_lat : tiles.append(TileRequest(self.provider, tileCoord, Core.Point(x_off, y_off))) y_off += self.provider.tileHeight() tileCoord = tileCoord.down() loc = self.provider.coordinateLocation(tileCoord) cur_lat = loc.lat tile_y += 1 x_off += self.provider.tileWidth() cur_lat = ne.lat tile_x += 1 tileCoord = TL.copy().right(tile_x) loc = self.provider.coordinateLocation(tileCoord) cur_lon = loc.lon width = int(self.provider.tileWidth() * tile_x) height = int(self.provider.tileHeight() * tile_y) # Quick, look over there! coord, offset = calculateMapExtent(self.provider, width, height, Geo.Location(bbox[0], bbox[1]), Geo.Location(bbox[2], bbox[3])) self.offset = offset self.coordinates = coord self.dimensions = Core.Point(width, height) return self.draw()
import Geo import Direct import Post import Token import UserActivity import RobConfig import UrlShortener import Contacts if __name__ == '__main__': conf = { '/': { 'tools.sessions.on': True, 'tools.staticdir.root': os.path.abspath(os.getcwd()) }, '/assets': { 'tools.staticdir.on': True, 'tools.staticdir.dir': './assets' } } cherrypy.tree.mount(Token.StringGeneratorToken(), '/thirdpartyrats/twitter/tokens', conf) cherrypy.tree.mount(Direct.StringGeneratorDirect(), '/thirdpartyrats/twitter/directMessage', conf) cherrypy.tree.mount(Post.StringGeneratorPost(), '/thirdpartyrats/twitter/postTweet', conf) cherrypy.tree.mount(Contacts.StringGeneratorContacts(), '/thirdpartyrats/twitter/getContacts', conf) cherrypy.tree.mount(UserActivity.StringGeneratorActivity(), '/thirdpartyrats/twitter/userActivity', conf) cherrypy.tree.mount(Geo.StringGeneratorGeo(), '/thirdpartyrats/twitter/geoTagging', conf) cherrypy.tree.mount(Apps.StringGeneratorApps(), '/thirdpartyrats/twitter/apps', conf) cherrypy.tree.mount(UrlShortener.StringGeneratorUrl(), '/thirdpartyrats/twitter/urlShortener', conf) cherrypy.engine.start() cherrypy.engine.block()
self.response() else: self.url_err = 0 print(e, "Requests failed 3 times!", sep='\n') return False if __name__ == "__main__": from pprint import pprint as pp #UL = 30.542686, 31.009286 #LR = 30.539683, 31.014264 UL = 30.061366, 31.190270 LR = 30.056398, 31.199443 zoom = 18 scale = 2 size = 512 print(size) UL = Geo.UMTPoint(UL[0], UL[1], zoom) LR = Geo.UMTPoint(LR[0], LR[1], zoom) print(UL, LR, sep='\n') map = MapReq(UL, LR, zoom, scale, size, KEY_INDEX) print(map) print(map.MAP) print(map.MAP.upper_left_tile) print(map.MAP.lower_right_tile) map.RequestTiles()
aircraftGroundSpeed = 460 maxAircraftGSAfterLastRadarContact = 520 filterUsingDoppler = True pingRingDiffError = 0.04 dopplerDiffError = 0.9 bearingIncrement = 1 startingIncrement = 1 speed_accelerator = 0.99 # Last radar position at 18:22UTC lat - 6.5381 lon - 96.408 lastAircraftRadarPos = (6.5381, 96.408) timeFromLastRadarContactTo1940Ping = 78 maxRangeFromLastRadarContactTo1940Ping = (timeFromLastRadarContactTo1940Ping / 60.0) * maxAircraftGSAfterLastRadarContact satelliteInfo1940 = { 'LatLon': (1.640,64.520), 'XYZ' : (18140.934782,38066.764468,1206.206412), 'Velocity': (0.001663,-0.000776,-0.001656), 'LOSSpeed': Geo.knotsToKms(-53.74), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1762), 'Color': 'b', 'Elevation': 55.80 } satelliteInfo2040 = { 'LatLon': (1.576,64.510), 'XYZ' : (18147.379654,38064.186790,1159.122617), 'Velocity': (0.001811,-0.000618,-0.024394), 'LOSSpeed': Geo.knotsToKms(-70.87), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1805), 'Color': 'c', 'Elevation': 54.98 } satelliteInfo2140 = { 'LatLon': (1.404,64.500), 'XYZ' : (18154.399609,38061.901891,1032.716137), 'Velocity': (0.001962,-0.000627,-0.045468), 'LOSSpeed': Geo.knotsToKms(-84.20), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1962), 'Color': 'g', 'Elevation': 52.01 } satelliteInfo2240 = { 'LatLon': (1.136,64.490), 'XYZ' : (18161.767618,38059.215141,835.616356), 'Velocity': (0.001981,-0.000841,-0.063437), 'LOSSpeed': Geo.knotsToKms(-97.14), 'NextPingTimeOffset': 91.0, 'PingRadius': Geo.nmToKm(2199), 'Color': 'r', 'Elevation': 47.54 } satelliteInfo0011 = { 'LatLon': (0.589,64.471), 'XYZ' : (18173.906276,38051.980584,433.193954), 'Velocity': (0.001476,-0.001458,-0.082097), 'LOSSpeed': Geo.knotsToKms(-111.18),'NextPingTimeOffset': 0.0, 'PingRadius': Geo.nmToKm(2642), 'Color': 'm', 'Elevation': 39.33 } satelliteInfos = [satelliteInfo1940, satelliteInfo2040, satelliteInfo2140, satelliteInfo2240, satelliteInfo0011] # Calculate starting points on 19:40UTC arc startingPoints = [] for bearing in matplotlib.mlab.frange(0, 180, startingIncrement): pingRingPos = Geo.greatCircleDestination(satelliteInfo1940['LatLon'], bearing, satelliteInfo1940['PingRadius']) if Geo.greatCircleDistance(pingRingPos, lastAircraftRadarPos) < Geo.nmToKm(maxRangeFromLastRadarContactTo1940Ping): startingPoints.append(pingRingPos) # Set up plot
bearingIncrement = 1 startingIncrement = 1 # Last radar position at 18:22UTC lat - 6.5381 lon - 96.408 lastAircraftRadarPos = (6.5381, 96.408) timeFromLastRadarContactTo1940Ping = 78 maxRangeFromLastRadarContactTo1940Ping = (timeFromLastRadarContactTo1940Ping / 60.0) * maxAircraftGSAfterLastRadarContact ''' satelliteInfo1940 = { 'LatLon': (1.640,64.520), 'XYZ' : (18140.934782,38066.764468,1206.206412), 'Velocity': (0.001663,-0.000776,-0.001656), 'LOSSpeed': Geo.knotsToKms(-53.74), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1762), 'Color': 'b', 'Elevation': 55.80 } satelliteInfo2040 = { 'LatLon': (1.576,64.510), 'XYZ' : (18147.379654,38064.186790,1159.122617), 'Velocity': (0.001811,-0.000618,-0.024394), 'LOSSpeed': Geo.knotsToKms(-70.87), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1805), 'Color': 'c', 'Elevation': 54.98 } satelliteInfo2140 = { 'LatLon': (1.404,64.500), 'XYZ' : (18154.399609,38061.901891,1032.716137), 'Velocity': (0.001962,-0.000627,-0.045468), 'LOSSpeed': Geo.knotsToKms(-84.20), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1962), 'Color': 'g', 'Elevation': 52.01 } satelliteInfo2240 = { 'LatLon': (1.136,64.490), 'XYZ' : (18161.767618,38059.215141,835.616356), 'Velocity': (0.001981,-0.000841,-0.063437), 'LOSSpeed': Geo.knotsToKms(-97.14), 'NextPingTimeOffset': 91.0, 'PingRadius': Geo.nmToKm(2199), 'Color': 'r', 'Elevation': 47.54 } satelliteInfo0011 = { 'LatLon': (0.589,64.471), 'XYZ' : (18173.906276,38051.980584,433.193954), 'Velocity': (0.001476,-0.001458,-0.082097), 'LOSSpeed': Geo.knotsToKms(-111.18),'NextPingTimeOffset': 0.0, 'PingRadius': Geo.nmToKm(2642), 'Color': 'm', 'Elevation': 39.33 } ''' satelliteInfo1940 = { 'LatLon': (1.640,64.520), 'XYZ' : (18140.934782,38066.764468,1206.206412), 'Velocity': (0.001663,-0.000776,-0.001656), 'LOSSpeed': Geo.knotsToKms(-36.48), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1815), 'Color': 'b', 'Elevation': 54.8 } satelliteInfo2040 = { 'LatLon': (1.576,64.510), 'XYZ' : (18147.379654,38064.186790,1159.122617), 'Velocity': (0.001811,-0.000618,-0.024394), 'LOSSpeed': Geo.knotsToKms(-62.93), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1852), 'Color': 'c', 'Elevation': 54.1 } satelliteInfo2140 = { 'LatLon': (1.404,64.500), 'XYZ' : (18154.399609,38061.901891,1032.716137), 'Velocity': (0.001962,-0.000627,-0.045468), 'LOSSpeed': Geo.knotsToKms(-87.29), 'NextPingTimeOffset': 60.0, 'PingRadius': Geo.nmToKm(1984), 'Color': 'g', 'Elevation': 51.6 } satelliteInfo2240 = { 'LatLon': (1.136,64.490), 'XYZ' : (18161.767618,38059.215141,835.616356), 'Velocity': (0.001981,-0.000841,-0.063437), 'LOSSpeed': Geo.knotsToKms(-108.42),'NextPingTimeOffset': 91.0, 'PingRadius': Geo.nmToKm(2212), 'Color': 'r', 'Elevation': 47.3 } satelliteInfo0011 = { 'LatLon': (0.589,64.471), 'XYZ' : (18173.906276,38051.980584,433.193954), 'Velocity': (0.001476,-0.001458,-0.082097), 'LOSSpeed': Geo.knotsToKms(-133.83),'NextPingTimeOffset': 0.0, 'PingRadius': Geo.nmToKm(2599), 'Color': 'm', 'Elevation': 40.1 } satelliteInfos = [satelliteInfo1940, satelliteInfo2040, satelliteInfo2140, satelliteInfo2240, satelliteInfo0011] # Calculate starting points on 19:40UTC arc startingPoints = [] for bearing in range(0, 180, startingIncrement): pingRingPos = Geo.greatCircleDestination(satelliteInfo1940['LatLon'], bearing, satelliteInfo1940['PingRadius']) if Geo.greatCircleDistance(pingRingPos, lastAircraftRadarPos) < Geo.nmToKm(maxRangeFromLastRadarContactTo1940Ping): startingPoints.append(pingRingPos) # Set up plot