1

Getting Invalid Result with report/get_result_map

Topic: Getting Invalid Result with report/get_result_map

I am using the PHP/Wialon interface and seeking to generate a map PNG from recent tracker messages and believe I am making the right calls in the right sequence, but am getting an Invalid Result (error:3) from the report/get_result_map call.

From a quick scan of my sample code, can someone please advise what I am doing wrong?

Many thanks!

<?php
// Login to wialon using token
$result = $wialon_api->login($token);
$json = json_decode($result, true);
$sid = $json['eid'];
// SID returned ok


// get unit ID (only one on account)
$params='{"spec":{"itemsType":"avl_unit","propName":"sys_id","propValueMask":"*","sortType":"sys_id"},"force":1,"flags":1,"from":0,"to":0}';
$result = $wialon_api->call('core_search_items',$params);
$srch_res=json_decode($result);
$unit_id = $srch_res->items[0]->id;
// Unit ID returned ok


// Get 20 recent messages from unit 
$params='{"itemId":'.$unit_id.',"lastTime":0,"lastCount":20,"flags":65281,"flagsMask":0,"loadCount":20}';
$result = $wialon_api->call('messages_load_last',$params);
$msg_data=json_decode($result);
$first_t=$msg_data->messages[0]->t;
// 20 recent messages returned ok, majority with location data


// Clean up report buffer
$params='{}';
$result = $wialon_api->call('report_cleanup_result',$params);
$msg_data=json_decode($result);
// Gives Error:0 = OK


// Create track layer using create_messages_layer
$params='{"layerName":"JoeTracker", "itemId":'.$unit_id.', "timeFrom":'.$first_t.', "timeTo":0, "tripDetector":0, "trackColor":"#0000FF", "trackWidth":5, "arrows":1, "points":1, "pointColor":"#FF0000", "annotations":1, "flags":16}';
$result = $wialon_api->call('render_create_messages_layer',$params);
$msg_data=json_decode($result);
// Result: string(295) "{"name":"JoeTracker","bounds":[51.591087,-0.150262,51.591316,-0.15005],"units":[{"id":14507980,"msgs":{"count":20,"first":{"time":1514997426,"lat":51.5911331177,"lon":-0.150049999356},"last":{"time":1515000138,"lat":51.5912284851,"lon":-0.150261998177}},"mileage":198.178266576,"max_speed":1}]} " 


// Init graphic layer
$params='{"layerName":"JoeTracker","enable":1}';
$result = $wialon_api->call('render_enable_layer',$params);
$msg_data=json_decode($result);
// Gives Enabled:1 = OK


// Get map png
$params='{"width":600,"height":600}';
$result = $wialon_api->call('report_get_result_map',$params);
$msg_data=json_decode($result);
// Gives Error:3 = "Invalid result"
?>
2

Getting Invalid Result with report/get_result_map

(edited by rual 05/01/2018 12:34:20)

Re: Getting Invalid Result with report/get_result_map

Creating layers not creates report result. Creating layers will only affect tiles that returned from /avl_render. See an example https://sdk.wialon.com/playground/demo/unit_track

To use report/get_result_map you need to do exec_report.

You can use custom template with, for, example, Trip Routes table:

{"n":"unit_trips","l":"Trips","c":"","cl":"","cp":"","s":"[\"render_trips\"]","sl":"[\"Trip routes\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0}

And then use get_result_map.

Full list of tables, that affect rendered image you can view in Wialon Hosting. In report template settings there are Map output, that you can configure and then fetch resulting tables by get_report_data.

3

Getting Invalid Result with report/get_result_map

Re: Getting Invalid Result with report/get_result_map

Thanks rual.

Looking at exec_report, it appears I need to have an existing resource created, but when trying to use core/create_resource with my userId (and flags:8192), I get error:2014.  Is this an issue with access rights or something else?

// Create resource
$params='{"creatorId":'.$uid.',"name":"drcrep","dataFlags":8192}';
$result = $wialon_api->call('core_create_resource',$params);
$srch_res=json_decode($result);
4

Getting Invalid Result with report/get_result_map

Re: Getting Invalid Result with report/get_result_map

d.r.combes wrote:

Thanks rual.

Looking at exec_report, it appears I need to have an existing resource created, but when trying to use core/create_resource with my userId (and flags:8192), I get error:2014.  Is this an issue with access rights or something else?

// Create resource
$params='{"creatorId":'.$uid.',"name":"drcrep","dataFlags":8192}';
$result = $wialon_api->call('core_create_resource',$params);
$srch_res=json_decode($result);

2014 says, that you are already have an resource. See your account id (bact field in the user).

5

Getting Invalid Result with report/get_result_map

Re: Getting Invalid Result with report/get_result_map

OK, but when I use the 'bact' value I get Error:6 = "Unknown error", which is a bit difficult to diagnose!

Am I correct in using the '8192' flags value to create a 'reporttemplates' resource?  However, trying any other flag value makes no difference, I still get error:6

6

Getting Invalid Result with report/get_result_map

Re: Getting Invalid Result with report/get_result_map

d.r.combes, you already have resource and it's id is "bact" field in user.
You don't need to create new resource. You can try to execute report over this resource.

Head of Wialon Local Department
Gurtam