def fencekml(self, layername): '''set a layer as the geofence''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #for each point in the layer, add it in for layer in self.allayers: if layer.key == layername: #clear the current fence self.fenceloader.clear() if len(layer.points) < 3: return self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component #send centrepoint to fence[0] as the return point bounds = mp_util.polygon_bounds(layer.points) (lat, lon, width, height) = bounds center = (lat+width/2, lon+height/2) self.fenceloader.add_latlon(center[0], center[1]) for lat, lon in layer.points: #add point self.fenceloader.add_latlon(lat, lon) #and send self.send_fence()
def __init__(self, key, points, layer, colour, linewidth): SlipObject.__init__( self, key, layer, ) self.points = points self.colour = colour self.linewidth = linewidth self._bounds = mp_util.polygon_bounds(self.points)
def fence_draw_callback(self, points): '''callback from drawing a fence''' self.fenceloader.clear() if len(points) < 3: return self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component bounds = mp_util.polygon_bounds(points) (lat, lon, width, height) = bounds center = (lat + width / 2, lon + height / 2) self.fenceloader.add_latlon(center[0], center[1]) for p in points: self.fenceloader.add_latlon(p[0], p[1]) # close it self.fenceloader.add_latlon(points[0][0], points[0][1]) self.send_fence() self.have_list = True
def __init__(self, key, points, layer, colour, linewidth, arrow=False, popup_menu=None): SlipObject.__init__(self, key, layer, popup_menu=popup_menu) self.points = points self.colour = colour self.linewidth = linewidth self.arrow = arrow self._bounds = mp_util.polygon_bounds(self.points) self._pix_points = [] self._selected_vertex = None self._has_timestamps = False
default=1.0, help="tile download delay") parser.add_option("--boundary", default=None, help="region boundary") parser.add_option("--debug", action='store_true', default=False, help="show debug info") (opts, args) = parser.parse_args() lat = opts.lat lon = opts.lon ground_width = opts.width if opts.boundary: boundary = mp_util.polygon_load(opts.boundary) bounds = mp_util.polygon_bounds(boundary) lat = bounds[0] + bounds[2] lon = bounds[1] ground_width = max( mp_util.gps_distance(lat, lon, lat, lon + bounds[3]), mp_util.gps_distance(lat, lon, lat - bounds[2], lon)) print(lat, lon, ground_width) mt = MPTile(debug=opts.debug, service=opts.service, tile_delay=opts.delay, max_zoom=opts.max_zoom) if opts.zoom is None: zooms = range(mt.min_zoom, mt.max_zoom + 1) else: zooms = [opts.zoom]
def __init__(self, key, points, layer, colour, linewidth): SlipObject.__init__(self, key, layer, ) self.points = points self.colour = colour self.linewidth = linewidth self._bounds = mp_util.polygon_bounds(self.points)
parser.add_option("--width", type='float', default=1000.0, help="width in meters") parser.add_option("--service", default="YahooSat", help="tile service") parser.add_option("--zoom", default=None, type='int', help="zoom level") parser.add_option("--max-zoom", type='int', default=19, help="maximum tile zoom") parser.add_option("--delay", type='float', default=1.0, help="tile download delay") parser.add_option("--boundary", default=None, help="region boundary") parser.add_option("--debug", action='store_true', default=False, help="show debug info") (opts, args) = parser.parse_args() lat = opts.lat lon = opts.lon ground_width = opts.width if opts.boundary: boundary = mp_util.polygon_load(opts.boundary) bounds = mp_util.polygon_bounds(boundary) lat = bounds[0]+bounds[2] lon = bounds[1] ground_width = max(mp_util.gps_distance(lat, lon, lat, lon+bounds[3]), mp_util.gps_distance(lat, lon, lat-bounds[2], lon)) print lat, lon, ground_width mt = MPTile(debug=opts.debug, service=opts.service, tile_delay=opts.delay, max_zoom=opts.max_zoom) if opts.zoom is None: zooms = range(mt.min_zoom, mt.max_zoom+1) else: zooms = [opts.zoom] for zoom in zooms: tlist = mt.area_to_tile_list(lat, lon, width=1024, height=1024, ground_width=ground_width, zoom=zoom)