Ejemplo n.º 1
0
func httpDeal(w http.ResponseWriter, req *http.Request) {
	req.ParseForm()

	lng, lngGot := req.Form["lng"]
	lat, latGot := req.Form["lat"]
	if lngGot != true || latGot != true {
		io.WriteString(w, "{\"errno\":1,\"errmsg\":\"bad param\"}")
		return

	}
	lngf, _ := strconv.ParseFloat(lng[0], 64)
	latf, _ := strconv.ParseFloat(lat[0], 64)
	poi := pg.Poiobj{Lng: lngf, Lat: latf}

	matchedpgo := pg.Pgobj{}
	ret := pg.PolygensMatch(&poi, &pgoall, &matchedpgo)
	if ret == true {

		io.WriteString(w, "{\"errno\":0,\"data\":{\"id\":\""+matchedpgo.Id+"\",\"name\":\""+matchedpgo.Name+"\",\"extinfo\":\""+matchedpgo.Extinfo+"\"}}")
	} else {
		io.WriteString(w, "{\"errno\":10,\"errmsg\":\"not matched\"}")
	}

	pl("get request:", "lng:", lng, ", lat:", lat)

	/*
	   lng := strconv.ParseFloat(req.Form.Get("lng"), 64)
	   lat := strconv.ParseFloat(req.Form.Get("lat"), 64)
	   w.Write("lng:"+req.Form.Get("lng"))
	   pl(lng, lat)
	*/

}
Ejemplo n.º 2
0
func doCheck(poi *pg.Poiobj, pgoall *[]*pg.Pgobj) {

	matchedpgo := pg.Pgobj{}

	ret := pg.PolygensMatch(poi, pgoall, &matchedpgo)
	pl("checking: ", poi)
	if ret == true {
		pl("matched:", matchedpgo)
	} else {
		pl("not matched")
	}

	pl("==================")

}