def poly_style(self,kml,Style): # need to not attach if 3d shape!!! # or change mapnik to ignore polygon symbolizers put on line geometries #if hasattr(s.PolyStyle,'color'): poly = None if hasattr(Style.PolyStyle,'color'): ogr_ds = ogr.Open(kml) if not ogr_ds: sys.exit('Sorry this KML: %s\n\n is not a valid datasource, there are no layers!' % kml) lyr = ogr_ds.GetLayer(0) gname = self.get_geom_type(lyr) if 'poly' in gname: c_ = Style.PolyStyle.color #print c_ # lxml bug! if c_ == 0: c_ = '00000000' poly = mapnik.PolygonSymbolizer(utils.kml_hex_to_mapnik_color(c_)) elif hasattr(Style.PolyStyle,'fill'): if Style.PolyStyle.fill == 0: pass # no fill elif hasattr(Style.Polystyle,'outline'): pass # todo return poly
def line_style(self,Style): if hasattr(Style.LineStyle,'width'): width = float(Style.LineStyle.width) else: width = 1 # better default? # TOD - if no width - just ignore? if hasattr(Style.LineStyle,'color'): c_ = Style.LineStyle.color #print c_ # lxml bug! print '########### try .text here (line 289)' if c_ == 0: c_ = '00000000' color = utils.kml_hex_to_mapnik_color(c_) else: color = mapnik.Color('gray') stroke = mapnik.Stroke(color,width) # need to handle opacity... #stroke.opacity = .5 return mapnik.LineSymbolizer(stroke)