def make_simple_boundary(name, n=1): b = Boundary() b.geom = MultiPolygon(make_simple_polygon(n)) b.name = name b.category = "Unknown" b.sort_order = 1 b.save() return b
def setupTreemapEnv(): def local_render_to_response(*args, **kwargs): from django.template import loader from django.http import HttpResponse hr = HttpResponse(loader.render_to_string(*args, **kwargs)) if hasattr(args[1], 'dicts'): hr.request_context = args[1].dicts return hr django.shortcuts.render_to_response = local_render_to_response instance = make_instance(is_public=True) create_stewardship_udfs(instance) make_user_with_default_role(instance, 'jim') commander = make_commander_user(instance, 'commander') make_apprentice_user(instance, 'apprentice') n1geom = MultiPolygon(Polygon( ((0, 0), (100, 0), (100, 100), (0, 100), (0, 0)))) n2geom = MultiPolygon( Polygon(((0, 101), (101, 101), (101, 200), (0, 200), (0, 101)))) n1 = Boundary(name="n1", category='blah', sort_order=4, geom=n1geom) n2 = Boundary(name="n2", category='blah', sort_order=4, geom=n2geom) n1.save() n2.save() s1 = Species(otm_code="s1", genus="testus1", species="specieius1", cultivar='', instance=instance) s2 = Species(otm_code="s2", genus="testus2", species="specieius2", cultivar='', instance=instance) s3 = Species(otm_code="s3", genus="testus2", species="specieius3", cultivar='', instance=instance) s1.is_native = True s1.fall_conspicuous = True s1.flower_conspicuous = True s1.palatable_human = True s2.is_native = True s2.fall_conspicuous = False s2.flower_conspicuous = True s2.palatable_human = False s2.has_wildlife_value = True s3.has_wildlife_value = True s1.save_with_user(commander) s2.save_with_user(commander) s3.save_with_user(commander) return instance
def add_anonymous_boundary(request): request_dict = json.loads(request.body) srid = request_dict.get('srid', 4326) polygon = Polygon(request_dict.get('polygon', []), srid=srid) if srid != 3857: polygon.transform(3857) b = Boundary.anonymous(polygon) b.save() return {'id': b.id}
def setupTreemapEnv(): def local_render_to_response(*args, **kwargs): from django.template import loader from django.http import HttpResponse httpresponse_kwargs = {'mimetype': kwargs.pop('mimetype', None)} hr = HttpResponse( loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) if hasattr(args[1], 'dicts'): hr.request_context = args[1].dicts return hr django.shortcuts.render_to_response = local_render_to_response instance = make_instance(is_public=True) create_stewardship_udfs(instance) make_user_with_default_role(instance, 'jim') commander = make_commander_user(instance, 'commander') make_apprentice_user(instance, 'apprentice') n1geom = MultiPolygon(Polygon( ((0, 0), (100, 0), (100, 100), (0, 100), (0, 0)))) n2geom = MultiPolygon( Polygon(((0, 101), (101, 101), (101, 200), (0, 200), (0, 101)))) n1 = Boundary(name="n1", category='blah', sort_order=4, geom=n1geom) n2 = Boundary(name="n2", category='blah', sort_order=4, geom=n2geom) n1.save() n2.save() s1 = Species(otm_code="s1", genus="testus1", species="specieius1", cultivar='', instance=instance) s2 = Species(otm_code="s2", genus="testus2", species="specieius2", cultivar='', instance=instance) s3 = Species(otm_code="s3", genus="testus2", species="specieius3", cultivar='', instance=instance) s1.is_native = True s1.fall_conspicuous = True s1.flower_conspicuous = True s1.palatable_human = True s2.is_native = True s2.fall_conspicuous = False s2.flower_conspicuous = True s2.palatable_human = False s2.has_wildlife_value = True s3.has_wildlife_value = True s1.save_with_user(commander) s2.save_with_user(commander) s3.save_with_user(commander) return instance
def make_anonymous_boundary(n=1): b = Boundary.anonymous(make_simple_polygon(n)) b.save() return b