source: subversion/applications/lib/libosm/Client.h @ 11745

Last change on this file since 11745 was 11745, checked in by nienhueser, 11 years ago

Encapsulate Object::tags and add more documentation

File size: 2.0 KB
Line 
1#include <string>
2#include <curl/curl.h>
3
4namespace OSM
5{
6
7/**
8 * I/O. Handles reading from and writing to OSM servers
9 */
10class Client
11{
12public:
13        /**
14         * Constructor
15         * @param urlbase Server URL base (parameters are added automatically)
16         */
17        Client(const std::string& urlbase);
18
19        /**
20         * Change user/password used to login to the OSM server
21         * @param user Username for HTTP authentification
22         * @param pass Password for HTTP authentification
23         */
24        void setLoginDetails(const std::string& user, const std::string& pass);
25
26        /**
27         * Access data of the given type for the given bounding box
28         * @param apicall API string to identify wanted objects - e.g. "map" or "node" or "way" or "relation" or "*"
29         * @param west Longitude of the left (westernmost) side of the bounding box
30         * @param south Latitude of the bottom (southernmost) side of the bounding box
31         * @param east Longitude of the right (easternmost) side of the bounding box
32         * @param north Latitude of the top (northernmost) side of the bounding box
33         * @return Server output, OSM XML if all goes well
34         */
35        std::string grabOSM(const char *apicall, double west, double south,
36                        double east, double north);
37
38        /**
39         * Access data from the OSM server
40         * @param apicall Second part of the url. The URL used will be urlbase/apicall,
41         * where urlbase is the parameter set in the constructor
42         * @return Server output, OSM XML if all goes well
43         */
44        std::string grabOSM(const char *apicall);
45
46        /**
47         * Write data to the OSM server
48         * @param apicall Second part of the url. The URL used will be urlbase/apicall,
49         * where urlbase is the parameter set in the constructor
50         * @param data Data to post to the OSM server
51         * @return Server output
52         */
53        std::string putToOSM(char* apicall, char* data);
54
55private:
56        std::string urlbase, username, password;
57
58        std::string grab(const char *url);
59        std::string doGrab(CURL *curl, const char *url);
60        static size_t responseCallback(void *ptr, size_t size, size_t nmemb,
61                        void *d);
62        static size_t putCallback(void *bufptr, size_t size, size_t nitems,
63                        void *userp);
64};
65
66}
Note: See TracBrowser for help on using the repository browser.