def update_georeferenceable_objects(context, new_ct): g_marker = queryUtility(IGeoMarkerUtility) if not g_marker: return ct = getToolByName(context, 'portal_catalog') query = {'object_provides': 'collective.geo.geographer.interfaces.IGeoreferenceable'} pt = [item.portal_type for item in ct.searchResults(query)] olds_pt = list(set(pt)) adds = [] for new in new_ct: if new in olds_pt: olds_pt.remove(new) else: adds.append(new) if len(olds_pt) == 0 and len(adds) == 0: return nb_items, bad_items = g_marker.update(context, adds, olds_pt) updated = u'%d %s' % (nb_items, _(u'objects updated.')) if not bad_items: message = updated else: message = u'%s, %d %s: %s' % (updated, len(bad_items), _(u'update(s) on object(s) failed'), ','.join(bad_items), ) pu = getToolByName(context, 'plone_utils') pu.addPortalMessage(message)
def __call__(self, context): terms = [] for term in self.terms: terms.append( vocabulary.SimpleVocabulary.createTerm(term[0], term[0], _(term[1]))) return vocabulary.SimpleVocabulary(terms)
def __call__(self, context): terms = [] for term in self.terms: terms.append(vocabulary.SimpleVocabulary.createTerm(term[0], term[0], _(term[1]))) return vocabulary.SimpleVocabulary(terms)
class IGeoManager(Interface): """ Interface for shape management """ wkt = schema.Text( title=_(u"Shape in WKT format"), description=_(u"Insert below the shape coordinates in WKT format."), required=False ) def isGeoreferenceable(self): """Check if an object is isGeoreferenceable """ def getCoordinates(self): """Return the coordinates assigned to an object """ def setCoordinates(self): """set coordinates to an object
return False def verifyWkt(self, data): try: from shapely import wkt geom = wkt.loads(data) except ImportError: from pygeoif.geometry import from_wkt geom = from_wkt(data) return geom manageCoordinates = wrap_form( GeoShapeForm, label=_(u"Coordinates"), description=_(u"Modify geographical data for this content") ) class ShapeMapWidget(MapWidget): mapid = "geoshapemap" _layers = ["shapeedit"] @property def js(self): return ( """ jq(window).bind('map-load', function(e, map) { var layer = map.getLayersByName('Edit')[0]; var elctl = new OpenLayers.Control.WKTEditingToolbar(layer, {wktid: '%s'});