Ejemplo n.º 1
0
def pois(request):
	"""
	Returns geojson with Points of Points of interests with given type.
	Geojson has these properties:
	* has_photo
	* has_article
	Request parameters:
	* type - type of points
	"""
	type_ = int(request.GET['type'])
	pois = Poi.objects.filter(type__exact=type_).exclude(active__exact=False)
	resp = render_to_geojson(pois, settings.SNP_SRID, properties=('has_photo', 'has_article'))
	return HttpResponse(resp, mimetype='application/json')
Ejemplo n.º 2
0
	def _generate_data_source_from_json(self, query_set, **kwargs):
		"""Generates DataSource based on json generated with render_to_geojson() shortcut.
		Has the same parameters as render_to_geojson()
		"""
		json = render_to_geojson(query_set, **kwargs)
		json_fname = '%s/test_poi_render_to_json%s.geojson' % (self.TMP_DIR, int(time.time()))
		self.geojson = json

		json_file = open(json_fname, 'w')
		try:
			json_file.write(json)
		finally:
			json_file.close()
		return DataSource(json_fname)
Ejemplo n.º 3
0
def ownership(request):

    # Get the current user form the request
    # @todo Move this filter to model
    qs = VgOwners.objects.filter(activated=True)
    bbox = ast.literal_eval(
        '(%s)' % (request.GET.get('bbox', '-160, -89, 160, 89')))
    polygon = Polygon.from_bbox(bbox)
    polygon.set_srid(4326)
    polygon.transform(900913)
    json = render_to_geojson(
        qs,
        projection=4326,
        properties=[('name', 'name'), ('theme', 'theme')],
        #extent=polygon
    )

    return HttpResponse(json, content_type=u'application/json')
Ejemplo n.º 4
0
def ownership(request):

    # Get the current user form the request
    # @todo Move this filter to model
    qs = VgOwners.objects.filter(activated=True)
    bbox = ast.literal_eval('(%s)' %
                            (request.GET.get('bbox', '-160, -89, 160, 89')))
    polygon = Polygon.from_bbox(bbox)
    polygon.set_srid(4326)
    polygon.transform(900913)
    json = render_to_geojson(
        qs,
        projection=4326,
        properties=[('name', 'name'), ('theme', 'theme')],
        #extent=polygon
    )

    return HttpResponse(json, content_type=u'application/json')
Ejemplo n.º 5
0
def snppath(request):
	"""
	Returns geojson with StringLines of SNP path intersecting with bbox.
	"""
	try:
		geom_simplify = int(request.GET['simplify'])
	except KeyError:
		geom_simplify = None
	try:
		bbox = map(lambda x: float(x), request.GET['bbox'].split(','))
		bbox_poly = Polygon.from_bbox(bbox)
		bbox_poly.srid = settings.SNP_SRID
		to_srid = Path.objects.all()[0].the_geom.srid
		bbox_poly.transform(to_srid)
	except (KeyError, IndexError):
		bbox_poly = None
	resp = render_to_geojson(Path.objects.all(), settings.SNP_SRID, geom_simplify, bbox_poly,
				 properties=())
	return HttpResponse(resp, mimetype='application/json')