How can set "wait time" in CZML? - cesiumjs

I have some position & time values describing movement of some vehicle. But in some time intervals vehicle wait in some position. I cant figure out how can i set waiting time.?
In the example data provided below : position values corresponding to 40 and 50 are same = (4, 4 ,0) That means vehicle wait 10 second in that position. But it doesn't work because of interpolation.
Ex :
"position":{
"interpolationAlgorithm":"LAGRANGE",
"interpolationDegree":1,
"epoch":"2012-08-04T16:00:00Z",
"cartesian": [
0.0, 0, 0, 0,
10.0, 1 ,1 ,0,
20.0, 2, 2, 0,
30.0, 3, 3, 0,
40.0, 4, 4, 0,
50.0, 4, 4, 0
]
}

After some research I found that we can use "interval" property. Such that :
"position" : [
{
"interval": "2018-08-07T23:50:00Z/2018-08-08T00:09:00Z",
"cartographicDegrees" : [
"2018-08-07T23:50:00Z", 39.8495,43.3802,0,
"2018-08-08T00:00:00Z", 39.8734,43.4129,0,
"2018-08-08T00:09:00Z", 39.8048,43.4324,0
],
"interpolationAlgorithm": "LAGRANGE",
"interpolationDegree": 5
},
{
"interval": "2018-08-08T00:09:00Z/2018-08-08T00:11:00Z",
"cartographicDegrees" : [39.8048,43.4324,0]
},
...

Related

XTB API JSON cannot modify existing trade position

I am using a xAPI Playground for testing, link here:
https://playground.xapi.pro/
I want to edit/modify existing position with command: tradeTransaction
Documentation says to modify existing position I should use "type" as 3 and "cmd" should match existing position (0 for BUY and 1 for SELL)
{
"command": "tradeTransaction",
"arguments": {
"tradeTransInfo": {
"cmd": 1,
"customComment": "Some text",
"expiration": 0,
"order": order_number_as_int ,
"price": open_price_as_double,
"sl": my_double_value,
"tp": my_another_double_value,
"symbol": "f.e. OIL.WTI",
"type": 3,
"volume": 0.01
}
}
}
Error code
{
"status": false,
"errorCode": "SE199",
"errorDescr": "Internal error"
}
All possible data collected from API about existing position:
{'cmd': 1, 'order': 474325736, 'digits': 2, 'offset': 0, 'order2': 474325838, 'position': 474325736, 'symbol': 'OIL.WTI', 'comment': '', 'customComment': '', 'commission': 0.0, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 76.65, 'open_price': 76.57, 'nominalValue': 0.0, 'profit': -3.56, 'volume': 0.01, 'sl': 80.0, 'tp': 70.0, 'closed': False, 'timestamp': 1676665564666, 'spread': 0, 'taxes': 0.0, 'open_time': 1676663063081, 'open_timeString': 'Fri Feb 17 20:44:23 CET 2023', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None},
API documentation is here:
http://developers.xstore.pro/documentation/#tradeTransaction
Ofc I tried every possible value in "cmd" and "type" but it does not help.
Error code sometimes are diffrent, f. e:
{
"command": "tradeTransaction",
"arguments": {
"tradeTransInfo": {
"cmd": 3,
"customComment": "Some text",
"expiration": 0,
"order": 474325838,
"price": 0,
"sl": 0,
"tp": 0,
"symbol": "OIL.WTI",
"type": 3,
"volume": 0.01
}
}
}
Error code:
{
"status": false,
"errorCode": "BE4",
"errorDescr": "remaining nominal must be greater than zero"
}
Any ideas what I can do wrong?
I am in touch with XTB support, still waiting for response.
Thanks in advance for any help!

Regex to pick values from specific json key

My json string:
{
"computed_at": "2022-11-29T08:21:47.904741+00:00",
"data":
{
"2022-11-07":
{
"steps":
[
{
"count": 1853,
"avg_time": null,
"avg_time_from_start": null,
"session_event": "start",
"goal": "start",
"step_label": "Came to Corporate",
"overall_conv_ratio": 1,
"step_conv_ratio": 1
},
{
"count": 741,
"avg_time": 25451,
"avg_time_from_start": 25451,
"time_buckets_from_prev":
{
"lower": 0,
"higher": 0,
"buckets":
[
720,
2,
3,
4,
3,
3,
3,
1,
0,
2,
0,
0,
0,
0,
0
]
},
"time_buckets_from_start":
{
"lower": 0,
"higher": 0,
"buckets":
[
720,
2,
3,
4,
3,
3,
3,
1,
0,
2,
0,
0,
0,
0,
0
]
},
"event": "Viewed Collection Page",
"goal": "Viewed Collection Page",
"step_label": "Viewed Collection Page",
"overall_conv_ratio": 0.39989206691851054,
"step_conv_ratio": 0.39989206691851054
},
{
"count": 174,
"avg_time": 53538,
"avg_time_from_start": 110700,
"time_buckets_from_prev":
{
"lower": 0,
"higher": 0,
"buckets":
[
163,
2,
1,
3,
0,
2,
1,
2,
0,
0,
0,
0,
0,
0,
0
]
},
"time_buckets_from_start":
{
"lower": 0,
"higher": 0,
"buckets":
[
151,
4,
2,
5,
1,
4,
3,
3,
0,
1,
0,
0,
0,
0,
0
]
},
"event": "Product Viewed",
"goal": "Product Viewed",
"step_label": "Product Viewed",
"overall_conv_ratio": 0.09390178089584458,
"step_conv_ratio": 0.23481781376518218
}
],
"analysis":
{
"completion": 174,
"starting_amount": 1853,
"steps": 3,
"worst": 2
}
}
},
"meta":
{
"dates":
[
"2022-11-07"
],
"property_values":
[],
"min_sampling_factor": 1,
"group_by_metadata":
[]
},
"min_sampling_factor": 1
}
I want to extract the values for these particular keys (each of which has 3 instances in the above json string):
count
step_conv_ratio
What is the correct regex so that I will get 1853, 741, 174 for count; and 1, 0.39989206691851054, 0.23481781376518218 for step_conv_ratio?
Unmarshalling this to a Go struct is not ideal, since it has dynamic json field name, so I cannot use a static struct with static json tag to unmarshal. Hence I'm thinking of using regex.
Consider the comments about unmarshalling. Else the regex you are looking for is:
`"count": ([0-9]+)|"step_conv_ratio": ([0-9.]+)`
then the number will be in the second or the third element of the slice that contains the matches (e.g. after FindAllStringSubmatch()) depending on it's a count or a step_conv_ratio.

Is it possible to output a JSON object row by row in Angular?

I have a field "properties" in my table(data type: text). In this field there is a JSON object. Now I want to output it in Angular in a reasonable way as I have shown below. Currently only the JSON format is displayed.
There must be a way to display the attributes of a JSON format row by row, right?
"properties": "{'width': 4, 'height': 14, 'count': 10, 'qm': 63, 'loc_x': 0, 'loc_y': 0, 'loc_x': 1}",
width: 4
height: 14
count: 10
qm: 63
loc_x: 0
loc_y: 0
loc_x: 1
UDATE 1:
<div *ngFor="let property of properties | keyvalue">
{{property.key}}: {{property.value}}
</div>
UPDATE 2:
This is my JSON from the Backend
{
"id": 1,
"formId": 1,
"properties": "{'width': 4, 'height': 14, 'count': 10, 'qm': 63, 'loc_x': 0, 'loc_y': 0, 'loc_x': 1}",
"components": [
{
"id": 1,
"shapeId": 1,
"properties": "{'width': 4, 'height': 14, 'count': 10, 'qm': 63, 'loc_x': 0, 'loc_y': 0, 'loc_x': 1}",
"shapeComponentMaterials": [
{
"id": 1,
"componentId": 1,
},
{
"id": 15,
"componentId": 1,
}
]
},
{
"id": 11,
"shapeId": 1,
"properties": "{'width': 4, 'height': 14, 'count': 10, 'qm': 63, 'loc_x': 0, 'loc_y': 0, 'loc_x': 1}",
"shapeComponentMaterials": [
{
"id": 11,
"componentId": 11,
}
]
}
]
}
This is my shape.ts
export interface Shape {
id?: number;
formId: number;
properties?: string;
components?: Array<Component>;
}
You can make use of Angular's KeyValuePipe to display the data in the desired format:
<div *ngFor="let property of properties | keyvalue">
{{property.key}}:{{property.value}}
</div>
UPDATE - Extending answer as per request
As you have updated your question with the exact API response, here's the method to access the properties property to display it in HTML as required:
accessingProperties = JSON.parse(this.valueFromAPI.properties.replace(/'/g, '"'));
Here's a Stackblitz with this example in live.

jsonb_each to access elements inside objects

I have a JSON column (called "roi") which contains users' Instagram performance. This is the roi column:
{
"data": {
"campaignName": "Master Cosy",
"currency": "GBP",
"reportData": {
"AAAAAAAAAA": {
"id": "0f20d833-d0f-bdb7-19",
"name": "cornish_gregorys",
"thumbnail": "https://sstagram.com/v/t51.2885-19/s320x320/87244862_1017848048596",
"Name": "cornisorys",
"instagramCount": 2319,
"instagramEngagementFactor": 0,
"instagramAuthorised": true,
"hasPosts": true,
"budget": 0,
"derivedFee": 0,
"inventoryItems": [],
"trackedAssetsStats": {
"totalAssets": 9,
"facebook": {
"count": 0
},
"instagram": {
"total": 9,
"stories": 9,
"carousels": 0,
"videos": 0,
"images": 0,
"igtvs": 0
},
"BBBBBBBBBBBBB": {
"id": "d3d30db4-0b453dfc3ae2a09",
"name": "itssdha",
"thumbnail": "https://in9809609728_n.jpg?_nc_ht=instagram.fhel5-1.fna.fbcdn.net&_nc_ohc=Se3ySAoqnFwAX4f6&oeF1623",
"Name": "itsshdha",
"instagramCount": 26700,
"instagramEngagementFactor": 0,
"instagramAuthorised": true,
"hasPosts": true,
"budget": 0,
"derivedFee": 0,
"inventoryItems": [],
"trackedAssetsStats": {
"totalAssets": 5,
"facebook": {
"count": 0
},
"instagram": {
"total": 9,
"stories": 9,
"carousels": 0,
"videos": 0,
"images": 0,
"igtvs": 0}, etc.....
After "reportData" I have the specific names of the users (in this case AAAAAAAA and BBBBBBBBB) and within them the performance of their Instagram accounts. How can I access all the metrics within the object username without having to type the specific username (AAAAAAAA and BBBBBBBBB)
My query is this:
roi -> 'date' -> 'reportData' -> 'AAAAAAA' -> 'instagramCount' -> etc ....
But I need something to 'jump' this part -> 'AAAAAAA' -> and go straight to the metrics, in this case 'instagramCount', etc...
From what I have read I may need to use jsonb_each, does anyone know how to use it?
demos:db<>fiddle
You have several ways.
Use jsonb_each() to expand all users' data: You can create a record per user and than ask for the count afterwards
SELECT
users.value -> 'instagramCount'
FROM
mytable,
jsonb_each(mydata -> 'data' -> 'reportData') as users
Since Postgres 12 you can use JSONpath for that, to achieve the same:
SELECT
jsonb_path_query(mydata, '$.**.instagramCount')
FROM mytable

Convert from ThreeJS geometry format 3 to 4: dealing with faces

I am having some problems with migration from ThreeJS geometry format 3 to 4. More specifically, i would like to manually create a surface in model.json file, but i don't get it to work.
in geometry format 3, the following code creates a single surface:
{
"faces": [1, 0, 1, 2, 3],
"metadata": {
"faces": 1
},
"vertices": [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0]
}
Can some-one help me how to convert this to format 4?
The only example on geometry format 4 i could find was this one: https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4
This is the equivalent code in json-geometry format 4:
{
"vertices": [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0],
"normals": [],
"uvs": [],
"faces": [ 1, 0, 1, 2, 3]
}