def make_annotations(mapid): for x in range(10): m = Map.objects.get(id=mapid) Annotation(map=m, title='ann %s %s' % (mapid, x), content='content', the_geom=make_point(-100 + (10 * x), 40)).save()
def make_annotations(self, mapobj, cnt=100): point = make_point(5, 23) for a in xrange(cnt): # make sure some geometries are missing geom = point if cnt % 2 == 0 else None # make the names sort nicely by title/number Annotation.objects.create(title='ann%2d' % a, map=mapobj, the_geom=geom).save()
def full_clean(self): self._my_errors = {} geom = self.data.get('geometry', None) if geom: if isinstance(geom, basestring): try: json.loads(geom) except ValueError: self._my_errors['geometry'] = 'Invalid JSON' elif isinstance(geom, dict): geom = json.dumps(geom) else: self._my_errors['geometry'] = 'geometry should be string or dict' self.data['the_geom'] = geom lat, lon = self.parse_float('lat'), self.parse_float('lon') if all([lat, lon]): self.data['the_geom'] = make_point(lon, lat) self._convert_time('start_time') self._convert_time('end_time') super(AnnotationForm, self).full_clean() self._errors.update(self._my_errors)
def full_clean(self): self._my_errors = {} geom = self.data.get('geometry', None) if geom: if isinstance(geom, basestring): try: json.loads(geom) except ValueError: self._my_errors['geometry'] = 'Invalid JSON' elif isinstance(geom, dict): geom = json.dumps(geom) else: self._my_errors[ 'geometry'] = 'geometry should be string or dict' self.data['the_geom'] = geom lat, lon = self.parse_float('lat'), self.parse_float('lon') if all([lat, lon]): self.data['the_geom'] = make_point(lon, lat) self._convert_time('start_time') self._convert_time('end_time') super(AnnotationForm, self).full_clean() self._errors.update(self._my_errors)
def make_annotations(mapid): for x in range(10): m = Map.objects.get(id=mapid) Annotation(map=m, title='ann %s %s' % (mapid, x), content='content', the_geom=make_point(-100 + (10 *x), 40)).save()