示例#1
0
	def mm(self, points):

		bbox = self.calculate_bbox_for_points(points)

		if self.method == 'bbox':
			bbox = self.adjust_bbox(bbox, .5)

		self.bbox = bbox

		dims = ModestMaps.Core.Point(self.width, self.height)
		sw = ModestMaps.Geo.Location(bbox[0], bbox[1])
		ne = ModestMaps.Geo.Location(bbox[2], bbox[3])

		provider = ModestMaps.builtinProviders[ 'MICROSOFT_AERIAL' ]()

		if self.method == 'bbox':
			mm_obj = ModestMaps.mapByExtentZoom(provider, sw, ne, self.zoom)
		else:
			mm_obj = ModestMaps.mapByExtent(provider, sw, ne, dims)

		self.mm_provider = provider
		self.mm_obj = mm_obj
		self.mm_markers = modestMMarkers.modestMMarkers(self.mm_obj)

		return True
示例#2
0
    def draw (self, **kwargs) :

        polys = []
        donuts = []
        children = []
        
        # Fetch the current shapefile
    
        req = Flickr.API.Request(method='flickr.places.getInfo', woe_id=kwargs['woeid'], sign=False)
        res = self.api.execute_request(req)

        (polys, allpoints) = self.munge_place(ET.parse(res))

        # Fetch donut hole shapes
        
        if opts.donuts :
            req = Flickr.API.Request(method='flickr.places.getShapeHistory', woe_id=kwargs['woeid'], sign=False)
            res = self.api.execute_request(req)

            et = ET.parse(res)
    
            for shp in et.findall(".//shape") :

                if shp.attrib['is_donuthole'] == '1' :
                    (donuts, ignore) = self.munge_place(shp)
                    break

        # Fetch children
        
        if opts.children :
            req = Flickr.API.Request(method='flickr.places.getChildrenWithPhotosPublic', woe_id=kwargs['woeid'], sign=False)
            res = self.api.execute_request(req)

            et = ET.parse(res)
        
            for pl in et.findall(".//place") :
                woeid = pl.attrib['woeid']
            
                subreq = Flickr.API.Request(method='flickr.places.getInfo', woe_id=woeid)
                subres = self.api.execute_request(subreq)

                (child_polys, child_points) = self.munge_place(ET.parse(subres))
                
                if len(child_polys) > 0 :
                    children.append(child_polys)

        # Draw the map

        bbox = self.calculate_bbox_for_points(allpoints)
        dims = ModestMaps.Core.Point(int(kwargs['width']), int(kwargs['height']))
        sw = ModestMaps.Geo.Location(bbox[0], bbox[1])
        ne = ModestMaps.Geo.Location(bbox[2], bbox[3])
    
        provider = ModestMaps.builtinProviders[kwargs['provider']]()
        
        mm_obj = ModestMaps.mapByExtent(provider, sw, ne, dims)
        mm_img = mm_obj.draw()
            
        # Draw the shapes

        markers = modestMMarkers.modestMMarkers(mm_obj)

        # The bounding box?

        if kwargs['bbox'] :
            mm_img = markers.draw_bounding_box(mm_img, allpoints, colour=(1, 0, .005), opacity_fill=.1)
            
        # The current shape of WOE ID

        mm_img = markers.draw_polylines(mm_img, polys)

        # Donut holes
        
        if len(donuts) :
            mm_img = markers.draw_polylines(mm_img, donuts, colour=(.005, 0, 1))

        # Child WOE IDs
        
        if len(children) :
            for ch in children :
                mm_img = markers.draw_polylines(mm_img, ch, colour=(255,255,255), no_fill=True)

        # sssshhhh.....
        # mm_img = markers.draw_points(mm_img, allpoints, colour=(.005, 0, 1))
        
        # Happy
        
        self.mm_img = mm_img