39 #include <curl/curl.h>
45 const std::string& server_password,
const std::string& mesh_layer)
46 : server_url_(server_url)
47 , server_username_(server_username)
48 , server_password_(server_password)
49 , mesh_layer_(mesh_layer)
66 mesh_filters_[channel] = std::make_pair(min_value, max_value);
72 attr[
"name"] = attribute_name;
81 filter[
"attribute_name"] = mesh_filter.first;
82 filter[
"min_val"] = mesh_filter.second.first;
83 filter[
"max_val"] = mesh_filter.second.second;
87 attr[
"filters"] = filters;
99 request[
"boundingbox"] = json_bb;
100 request[
"attribute"] = attr;
102 Json::FastWriter fast_writer;
103 return fast_writer.write(request);
106 bool parseByteDataString(std::string
string,
char& type,
unsigned long& size,
unsigned long& width,
char*& data)
108 if (
string.length() < 10)
114 const char* body =
string.c_str();
116 size = *
reinterpret_cast<const unsigned long*
>(body + 1);
117 width = *
reinterpret_cast<const unsigned long*
>(body + 9);
118 data =
reinterpret_cast<char*
>(
const_cast<char*
>(body + 17));
132 if (str && str->size() > 17)
135 unsigned long size, width;
142 float* float_data =
reinterpret_cast<float*
>(data);
144 memcpy(channel.dataPtr().get(), float_data, size * width *
sizeof(
float));
162 if (str && str->size() > 17)
165 unsigned long size, width;
172 unsigned int* index_data =
reinterpret_cast<unsigned int*
>(data);
174 memcpy(channel.dataPtr().get(), index_data, size * width *
sizeof(
lvr2::Index));
197 std::cout <<
"channel " << name << std::endl;
206 if (str && str->size() > 17)
209 unsigned long size, width;
216 float* float_data =
reinterpret_cast<float*
>(data);
218 memcpy(channel.get().dataPtr().get(), float_data, size * width *
sizeof(
float));
236 if (str && str->size() > 17)
239 unsigned long size, width;
246 unsigned int* index_data =
reinterpret_cast<unsigned int*
>(data);
248 memcpy(channel.get().dataPtr().get(), index_data, size * width *
sizeof(
lvr2::Index));
266 if (str && str->size() > 17)
269 unsigned long size, width;
276 unsigned char* uchar_data =
reinterpret_cast<unsigned char*
>(data);
278 memcpy(channel.get().dataPtr().get(), uchar_data, size * width *
sizeof(
unsigned char));
308 curl_global_init(CURL_GLOBAL_ALL);
310 curl = curl_easy_init();
313 curl_global_cleanup();
317 std::string post_body =
buildJson(channel);
318 curl_easy_setopt(curl, CURLOPT_URL,
server_url_.c_str());
320 struct curl_slist* list = curl_slist_append(list,
"Content-Type: application/json");
322 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
323 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_body.c_str());
324 curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
326 curl_easy_setopt(curl, CURLOPT_USERPWD, usr_pwd.c_str());
328 unique_ptr<std::string> result = std::make_unique<std::string>();
329 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
writeFunction);
330 curl_easy_setopt(curl, CURLOPT_WRITEDATA, result.get());
332 CURLcode res = curl_easy_perform(curl);
335 std::cout <<
"error" << std::endl;
336 curl_easy_cleanup(curl);
340 curl_easy_cleanup(curl);