예제 #1
0
def state2(req):
	req.content_type = 'application/vnd.google-earth.kml+xml'
	db = senDB(table="zipca", dbconfig=dbconfig)
	s = senGraph(db)
	s.g.vs["name"] = s.g.vs["id"]
	s.g.vs["layout"] = [[x["lng"], x["lat"]] for x in s.g.vs]
	rng = [min(s.g.vs["cnt"]), max(s.g.vs["cnt"])]
	s.g.vs["size"] = [(int)(round(float(x-rng[0])/(rng[1]-rng[0])*65+35,0)) for x in s.g.vs["cnt"]]

	return s.KML(scale=None)
예제 #2
0
def zipcode(req):
	info = req.form
	if 'b' in info:		
		bbox = [float(x) for x in info["b"].split("|")]
	
	req.content_type = 'application/vnd.google-earth.kml+xml'
	db = senDB(table=["zipcode","zip"], bbox=bbox, dbconfig=dbconfig)
	s = senGraph(db)
	s.g.vs["name"] = s.g.vs["id"]
	s.g.vs["layout"] = [[x["lng"], x["lat"]] for x in s.g.vs]
	rng = [min(s.g.vs["cnt"]), max(s.g.vs["cnt"])]
	s.g.vs["size"] = [(int)(round(float(x-rng[0])/(rng[1]-rng[0])*65+35,0)) for x in s.g.vs["cnt"]]

	return s.KML(scale=None)
예제 #3
0
def zipcode3(req):
	info= req.form
	if 'BBOX' in info:
		bbox2 = [float(x) for x in info["BBOX"].split(",")]
		bbox = [bbox2[1], bbox2[0], bbox2[3], bbox2[2]]
	else:
		bbox = [37, -122, 37.5, -121.5]

	#req.content_type = 'application/vnd.google-earth.kml+xml'
	db = senDB(table=["zipcode","zip"], bbox=bbox, dbconfig=dbconfig)
	if len(db.vList)>0 and len(db.vList)<400:
		s = senGraph(db)
		s.g.vs["name"] = s.g.vs["id"]
		s.g.vs["layout"] = [[x["lng"], x["lat"]] for x in s.g.vs]
		rng = [min(s.g.vs["cnt"]), max(s.g.vs["cnt"])]
		s.g.vs["size"] = [(int)(round(float(x-rng[0])/(rng[1]-rng[0])*65+35,0)) for x in s.g.vs["cnt"]]

		return s.KML(scale=None, edgeDraw=False)
	else:
		return """<?xml version="1.0" encoding="UTF-8"?>
            <kml xmlns="http://www.opengis.net/kml/2.2"> 
                <Document>
                    <name></name>
                    <description>
                    </description>

	   <Placemark>
	   <name>VC</name>
	   <description><![CDATA[
	   		%d <br/>
			BBOX_IN  = %s <br/>
			BBOX_OUT = %s
		]]></description>
	   <Point>
		   <coordinates>%.6f,%.6f</coordinates>
	   </Point>
	   </Placemark>
	   </Document>
	   </kml>""" %(len(db.vList), str(bbox2), str(bbox), bbox2[0], bbox2[1])