[英]Arduino Uno or php
我想使用Google Maps API获取地理位置坐标,将其发送到Arduino Uno,然后将消息解析为一个浮点数数组。
我已经使用strok()
有,
作为分隔符,但我无法解析的文字和括号中的短信。
Sent from your Twilio trial account - (43.39114023431447, -80.40987968444824)(43.387210701009224, -80.41219711303711)(43.38602555366178, -80.38970947265625)
我只需要将坐标解析为一个float
数组。
我使用strok()函数自行解决了
{
const char *delim = "("; //a '(' is the delimiter
const char *delim1 = ",";
const char *delim3 = ")";
char *text;
char *firstItem;
char *secondItem;
char *thirdItem;
char *fourthItem;
char *fivethItem;
char *sixthItem;
char *seventhItem;
char *eighthItem;
text = strtok(password,delim);
firstItem = strtok(NULL,delim1);
secondItem = strtok(NULL,delim3);
secondItem++;
thirdItem = strtok(NULL,delim1);
thirdItem++;
fourthItem = strtok(NULL,delim3);
fourthItem++;
fivethItem = strtok(NULL,delim1);
fivethItem++;
sixthItem = strtok(NULL,delim3);
sixthItem++;
polyX[0] = atof(firstItem);
polyY[0] = atof(secondItem);
polyX[1] = atof(thirdItem);
polyY[1] = atof(fourthItem);
polyX[2] = atof(fivethItem);
polyY[2] = atof(sixthItem);
memset (password,NULL,sizeof(password));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.