I'm trying to use the Using Positioning API to search for the latitude and longitude of a given point, however I only have MCC, MNC, TimeAdvance, LAC, Cell_ID, and Signal Power. How can I use this data to fetch the location?
I tried to use as below but did not return any data.
{
"gsm": [
{
"mcc": 724,
"mnc": 10,
"lac": 2397,
"cid": 453,
"nmr": [{ "bsic": "0", "bcch": "0" }]
},
{
"mcc": 724,
"mnc": 10,
"lac": 2397,
"cid": 3045,
"nmr": [{ "bsic": "0", "bcch": "0" }]
}
]
}
Im using cURL.
Thanks
This response means that you have sent a valid request for which the API cannot determine a location.
I have tried to find the cell towers in your request using various cell tower databases and I could not find them anywhere. If they do exist they are most likely not in our (or any) database at this point.
Related
by doing a GET-Request, I am receiving routing informations from the HERE Routing API:
https://router.hereapi.com/v8/routes?apikey=MY_API_KEY&destination=52.530394,13.400683&origin=52.530728,13.383833&return=polyline,travelSummary&transportMode=truck&&vehicle[speedCap]=30&spans=names,length,duration,speedLimit
Now I want to find the coordinates for example in the middle of the route with respect to the total time. So I the example below, the total duration is 274 seconds. How can I find out, on which position I will be after 137 seconds? (In real application these times are much longer. Here, for simplicity and for a small JSON file size, I have chosen only a short distance)
First, I thought of adding starting and ending coordinates of the spans, however it seems not to be possible with the API.
Second, I thought of using the polyline. From that I receive a lot of coordinates, however I don't see a possiblity to connect one of these coordinates to a certain duration of travel.
Is there any way how I can get the information I am looking for with the HERE Routing API or with any PHP calculation?
{
"routes": [
{
"id": "90be4eb8-d0ba-47f8-9954-9be444576a17",
"sections": [
{
"id": "bfd32e45-662b-4b7e-a297-21eeee09dd68",
"type": "vehicle",
"departure": {
"time": "2021-12-11T23:42:04+01:00",
"place": {
"type": "place",
"location": {
"lat": 52.5307744,
"lng": 13.3838015
},
"originalLocation": {
"lat": 52.5307279,
"lng": 13.383833
}
}
},
"arrival": {
"time": "2021-12-11T23:46:38+01:00",
"place": {
"type": "place",
"location": {
"lat": 52.5303982,
"lng": 13.4006967
},
"originalLocation": {
"lat": 52.5303939,
"lng": 13.4006829
}
}
},
"travelSummary": {
"duration": 274,
"length": 1338,
"baseDuration": 264
},
"polyline": "BGslnmkDyn8wZ8CmL4Iof0F0U8BoGsEoQwCsJsEkSoBoG8BsJsE0U8BgK8BoLoB4IoB0KoBoLoBkNwC8a8B0UoB0UoBkNsEgtBkDsd8BsTkDgZsEgtB4D0jBgFwvBoG46B8B8QwCoV8BwMgFgtBUwHkD8akDgeU4NoB4XAkIoB0ZoB8pBU0K8Boa8B0PkDkS7GkD3I0F3DwC7foa7G0Fzeoaze0ZvTiQ",
"spans": [
{
"offset": 0,
"names": [
{
"value": "Invalidenstraße",
"language": "de"
}
],
"length": 189,
"duration": 31,
"speedLimit": 13.8888893
},
{
"offset": 11,
"names": [
{
"value": "Invalidenstraße",
"language": "de"
}
],
"length": 872,
"duration": 184,
"speedLimit": 8.333334
},
{
"offset": 44,
"names": [
{
"value": "Brunnenstraße",
"language": "de"
}
],
"length": 277,
"duration": 59,
"speedLimit": 8.333334
}
],
"transport": {
"mode": "truck"
}
}
]
}
]
}
Using the information in the spans object is definitely the way to go. What you need is to break up the spans into as many pieces as possible. You can do that by adding these values to the parameter in your request:
&spans=duration,length,segmentId,names,speedLimit,dynamicSpeedInfo,baseDuration,typicalDuration,segmentRef
You'll see that the response includes a list of spans identified by the offset attribute, which tells you what coordinate in your polyline that span refers to. This means that you want to know what is the offset (coordinate index) where the sum of span durations is 137.
This procedure will get you the best approximation to the middle of the route relative to travel time:
Loop through the list of spans and sum the value in the duration attribute; the loop should stop when the sum is equal or greater than the desired duration (137 in your example).
Get the value of the offset attribute, and add 1.
Decode your polyline, and get the coordinates at the index that is equal to the number you got in step 2 (offset + 1).
For the route in your example, the span that meets the condition in step 1 is offset=31, so you're interested in the coordinates at index 32 from your polyline.
I'm trying to get all the services with a code different than 0, I don't find any way to do it without doing multiple queries.
Here's the data i'm trying to query, thanks in advance for the help
"hits": [
{
"_index": "database_index",
"_type": "system",
"_id": "AV03gG7B3dd3_xKqi09H",
"_score": 1,
"_source": {
"name_id": "BOX",
"room_id": "63190",
"event": "SysMonitor",
"data": {
"ip": "192.168.60.25 \n",
"ns": "192.168.0.1\n",
"uptime": "3:12"
},
"services": {
"apache2": 1,
"gw-flash": 0,
"appmgr": 0,
"watchdog": 2,
"gui": 0,
"usb": 0,
"internet": 0
},
This is a classic fulltext search example, where one could write a very complicated query to cover this or you could optimize this on index time and thus have very cheap queries. If you change your data model to have a field that contains all the services that have a value of 0 or 1, you could easily search for that, i.e.
services_zero: [gwflash, appmgr]
services_one: [ apache2 ]
Suddenly your query can easily search or aggregate against those fields.
Not saying that this will perfectly fit your use-case, but I think it is worth to rethink the data modelling strategy here.
im trying to figure out what the easiest way would be. i have a to do an api call for data i get a json file in return but im trying to parse the data to php so that my website would just pull from the database. do i have to create all the same fields that the api call is using for instance name gender age height. and then do i name it something else so i can call from my webpage. because in order to get a nfl player it gives me a 16 digit code and i want it just to be say tom brady
i have used javascript to pull the data but dont know what to do from there
"players": [{
"name": "Kyle Rudolph",
"jersey": "82",
"last_name": "Rudolph",
"first_name": "Kyle",
"abbr_name": "K.Rudolph",
"preferred_name": "Kyle",
"birth_date": "1989-11-09",
"weight": 265.0,
"height": 78,
"status": "A01",
"id": "1059e9dc-97df-4643-9116-883a0573d8b1",
"position": "TE",
"birth_place": "Cincinnati, OH, USA",
"high_school": "Elder (OH)",
"college": "Notre Dame",
"college_conf": "Independent",
"rookie_year": 2011,
"draft": {
"year": 2011,
"round": 2,
"number": 43,
"team": {
"name": "Vikings",
"market": "Minnesota",
"alias": "MIN",
"id": "33405046-04ee-4058-a950-d606f8c30852"
}
},
John, you don't have to use the same names. Once your PHP receives data from the API, parse it into whatever names you want, ignore the values you don't need etc... For example, suppose the API gives you a first and last name, but in your database you only care about full name. As another example, if the API gives you player weight in pounds but you need it in kilograms:
$api_result = file_get_contents($url);
$api_data = json_decode($api_result);
$name = "$api_data->last, $api_data->first"
$weight = $api_data->weight * 0.454; //convert pounds to kg for storage
Now you can store $name and $weight in your DB as you like. When your website pulls data from your backend, the shape of the data produced by the API doesn't matter because you stored it in the shape that is most helpful to your application
So they have this JSON and i need specific items to get e.g. promotions:
{
"currency": "USD",
"code": 200,
"sales_list": [
{
"date": "2012-05-21",
"country": "JP",
units:{
app: {
downloads: 10,
updates: 1,
},
iap: {
sales: 3,
refunds: 5,
promotions:1
},
},
revenue: {
app: {
downloads “100.98”,
refunds: “-10.00”,
promotions: “1.00”
},
iap: {
sales: “30.00”,
refunds: “-1.00”,
},
ad: "1000.00"
},
}],
“iap_sales”:[
{
"date": "2012-05-21",
"country": "JP",
“iap”: “com.iap1”,
units:{
sales: 3,
refunds: 5,
},
revenue: {
sales: "30.09",
refunds: "1.21",
},
}],
"page_index": 1,
}
How do i get the to the promotions?
I tried to use this:
$json_data = connect(t_url);
$data = json_decode($json_data);
return $data->sales_list[0]->units[0]->app[0]->promotions;
but is it even effective/ efficient?
Also im having a hard time getting data from appannie. i always get authorization problem or bad request. If bad request it means im in though right?
I use the terminal to test curl and my url like:
curl --basic --user email : password "http:/www.appannie.com/v1/accounts/acntnum/..."
they suggested this since they have authentication. There are time i get bad request but i think im in unlike unauthorized access error.
They also suggest other forms like the authethication should be basic+base 64 of ur eadd and password. But I don't know where to use it.
Any suggestions to convert this into php curl request?
The aim is to save user entered JSON into a database. Now, before someone jumps at me, I know json, I know mysql and I know all the links inbetween.
The issue is: I need to safely store the ENTIRE JSON feed in a single cell in the table.
The background: this function will be a temp fix for a tool, that is needed asap but will require a lot of time. The temp fix will allow the system to go live with minimal code.
Users will create a GOOGLE maps style here ( http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html)
and have the JSON made for them
[
{
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "water",
"stylers": [
{ "visibility": "on" }
]
},{
"featureType": "transit.line",
"elementType": "geometry.fill",
"stylers": [
{ "visibility": "on" },
{ "hue": "#ff3300" },
{ "color": "#ff0000" },
{ "weight": 0.7 }
]
},{
"featureType": "transit.station.rail",
"stylers": [
{ "visibility": "on" },
{ "color": "#0000ff" },
{ "weight": 4.6 }
]
},{
}
]
The site will then just call the JSON and apply it using jQuery later on. What would my ''best practice'' method be at doing this.
To answer your specific question, I would agree with the poster 'tom' that you should use a TEXT column.
However, I think for ease of use, you should also use prepared statements. If you create a prepared insert statement, you can then pass in the JSON directly. This will be the best representation in your database of the exact JSON (no annoying slashes) - AND be the safest. Please don't forget to do this step - its very important!
Since MySQL doesn't have a dedicated JSON column type, I would just store the JSON in an unbounded TEXT column. Just make sure you always check for valid JSON on write.