示例#1
0
func main() {
	gominatim.SetServer("http://nominatim.openstreetmap.org/")

	//Get by a Querystring
	qry := gominatim.SearchQuery{
		Q: "Hamburg",
	}
	resp, _ := qry.Get() // Returns []gominatim.Result
	fmt.Printf("Found location: %s (%s, %s)\n", resp[0].DisplayName, resp[0].Lat, resp[0].Lon)

	//Get by City
	qry = gominatim.SearchQuery{
		City: "Berlin",
	}
	resp, _ = qry.Get()
	fmt.Printf("Found location: %s (%s, %s)\n", resp[0].DisplayName, resp[0].Lat, resp[0].Lon)

	//Reverse Geocoding
	rqry := gominatim.ReverseQuery{
		Lat: "52.5170365",
		Lon: "13.3888599",
	}
	rresp, _ := rqry.Get()
	fmt.Printf("Found %s\n", rresp.DisplayName)
}
示例#2
0
文件: void.go 项目: momo-aux/void
func main() {
	log.Println("Entering the void.")
	log.Println("\tLoad configuration...")
	err := LoadConfig()
	log.Println("\tEstablishing connection to mongo DB...")
	mng, err := mgo.Dial(config.MongoServer)
	mongo = mng
	if err != nil {
		log.Fatal("Could not connect to mongodb!")
	}
	// Prepare REST-backend
	log.Println("\tInitializing REST-Backend...")
	wsContainer := restful.NewContainer()
	wsContainer.Router(restful.CurlyRouter{})
	BuildingResource{}.Register(wsContainer)
	UserResource{}.Register(wsContainer)
	CommentResource{}.Register(wsContainer)
	InvitationResource{}.Register(wsContainer)
	AuthResource{}.Register(wsContainer)
	ViewResource{}.Register(wsContainer)
	StaticResource{}.Register(wsContainer)

	InitializeAdmin()

	//Initialize Gominatim
	log.Println("\tInitializing gominatim")
	gominatim.SetServer("http://open.mapquestapi.com/nominatim/v1")

	// Bring up the http server
	port := strconv.Itoa(config.WebPort)
	log.Println("\tStarting up the HTTP-Server on port " + port)
	server := &http.Server{Addr: ":" + port, Handler: wsContainer}
	//	Addr: fmt.Sprintf(":%d", args["port"].(int)),
	log.Fatal(server.ListenAndServe())
}