def test_geo_feature_style(self): geomap = GeoMap(self.doc, self.doc.REQUEST) geo_feature_style = geomap.geo_feature_style self.assertEqual( geo_feature_style['marker_image'], "http://nohost/plone/++resource++collective.js.leaflet/images/marker-icon.png", 'Incorect default marker image url') registry = getUtility(IRegistry) registry['collective.geo.settings.interfaces.IGeoFeatureStyle.linewidth'] = float(3.0) manager = IGeoFeatureStyle(self.doc, None) manager.set('use_custom_styles', False) manager.set('linewidth', float(11.0)) self.doc.reindexObject(idxs=['zgeo_geometry', 'collective_geo_styles']) geomap = GeoMap(self.doc, self.doc.REQUEST) geo_feature_style = geomap.geo_feature_style self.assertEqual(geo_feature_style["linewidth"], 3.0) manager.set('use_custom_styles', True) self.doc.reindexObject(idxs=['zgeo_geometry', 'collective_geo_styles']) geomap = GeoMap(self.doc, self.doc.REQUEST) geo_feature_style = geomap.geo_feature_style self.assertEqual(geo_feature_style["linewidth"], 11.0)
def get_feature_styles(context): fields = [i for i in getFields(IGeoFeatureStyle)] manager = IGeoFeatureStyle(context, None) use_custom_styles = getattr(manager, 'use_custom_styles', False) if not use_custom_styles: registry = getUtility(IRegistry) manager = registry.forInterface(IGeoFeatureStyle) styles = {'use_custom_styles': use_custom_styles} for name in fields: styles[name] = getattr(manager, name, None) return styles
def geo_feature_style(self): fields = [i for i in getFields(IGeoFeatureStyle)] manager = IGeoFeatureStyle(self.context, None) use_custom_styles = getattr(manager, 'use_custom_styles', False) if not use_custom_styles: manager = utils.geo_styles(self.context) styles = {'use_custom_styles': use_custom_styles} for name in fields: styles[name] = getattr(manager, name, None) styles['marker_image'] = get_marker_image(self.context, styles['marker_image']) return styles