Updating a CZML property after the property is declared - cesiumjs

I'm trying to update some properties (namely "semiMinorAxis" and "semiMajorAxis") from a packet previously declared in a czml file.
The way I attempt to do this, is by overwriting the values of "semiMinorAxis" and "semiMajorAxis".
That is: between 12:00:00 and 13:00:00, ellipse_1 has a size of 300000, and between 13:00:00 and 14:00:00, it has a size of 600000.
Here is how I'm trying to do this in a simple csml:
[
{
"id" : "document",
"name" : "name",
"version" : "1.0",
"clock":
{
"interval": "2010-02-04T12:00:00Z/2010-02-04T14:00:00Z",
"currentTime": "2010-02-04T12:00:00Z",
"multiplier": 100
}
},
// I create ellipse_1
{
"id" : "ellipse_1",
"name" : "ellipse_1 (61.0666922, -107.9917071)",
"availability" : "2010-02-04T12:00:00Z/2010-02-04T13:00:00ZZ",
"position" : {
"cartographicDegrees" : [-107.9917071,61.0666922, 0.0]
},
"ellipse" : {
"semiMinorAxis" : 300000,
"semiMajorAxis" : 300000,
"height" : 0.0,
"material" : {
"solidColor" : {
"color" : {
"rgba" :[151,20,150, 255]
}
}
}
}
},
// I reuse the id and only change the values that I want the change
{
"id" : "ellipse_1"
},
"ellipse" : {
"interval" : "2010-02-04T13:00:00Z/2010-02-04T14:00:00ZZ",
"semiMinorAxis" : 600000,
"semiMajorAxis" : 600000
}
}
]
another option seems to be doing it this way:
{
"id" : "ellipse_1",
"name" : "ellipse_1 (61.0666922, -107.9917071)",
"availability" : "2010-02-04T12:00:00.00Z/2010-02-04T14:00:00.00Z",
"position" : {
"cartographicDegrees" : [-137.9917071,51.0666922, 0.0]
},
"ellipse" : [
{
"interval" : "2010-02-04T12:00:00.00Z/2010-02-04T13:00:00.00Z",
"semiMinorAxis" : 300000,
"semiMajorAxis" : 300000,
"height" : 200000.0,
"material" : {
"solidColor" : {
"color" : {
"rgba" :[253,152,38, 255]
}
}
}
},
{
"interval" : "2010-02-04T13:00:00.00Z/2010-02-04T14:00:00.00Z",
"semiMinorAxis" : 600000,
"semiMajorAxis" : 600000,
"height" : 200000.0,
"material" : {
"solidColor" : {
"color" : {
"rgba" :[253,152,38, 255]
}
}
}
}
]
}
By the way, here is the script to view it:
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({url : 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer'
}),
baseLayerPicker : false,
animation : true,
timeline : true,
});
var dataSourcePromise = Cesium.CzmlDataSource.load('../Apps/oscar.czml');
viewer.dataSources.add(dataSourcePromise);
viewer.flyTo(dataSourcePromise).then(function(result){
});
</script>
Unfortunately, these are clearly not the way to update values of an object in a csml file. Am I missing something obvious?
Thanks!

Related

file_get_contents('php://input'); is not working

$json = file_get_contents('php://input');
is not returning any result
sample JSON I was supposed to get from my payment gateway is here (sorry I couldn't post sample code here please see comment)
https://uat-paco.s3.ap-southeast-1.amazonaws.com/HTML-based-docs/CorePaymentAPI/2022-04-25-Et01x9/APIs/Payment.html#_inline_response_202_data
{
"version" : "1.0.0",
"apiResponse" : {
"responseMessageID" : "fadaba8f-b02c-4ff4-a8f0-2e5ce9873185",
"responseToRequestMessageID" : "e952828c-6d19-4a08-92e4-1bc47e1945a2",
"responseCode" : "PC-B050000",
"responseDescription" : "Success",
"responseDateTime" : "2016-08-29T09:12:34.001+0000",
"responseTime" : 2400,
"marketingDescription" : "Payment is success. Thank you for purchase."
},
"data" : {
"paymentIncompleteResult" : {
"officeGroupId" : "string",
"officeId" : "string",
"transactionDateTime" : "2016-08-29T09:12:34.001+0000",
"orderNo" : "684105191128073630",
"productDescription" : "URRT55",
"invoiceNo2C2P" : "FPX054658",
"pspReferenceNo" : "W32UPVAPCP260543864232",
"controllerInternalID" : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
"paymentStatusInfo" : {
"paymentStatus" : "A",
"paymentStep" : "PA",
"lastUpdatedDTTM" : "2016-08-29T09:12:35.001+0000"
},
"paymentType" : "CC-VI",
"paymentExpiryDateTime" : "2016-08-30T23:59:59.999+0000",
"channelCode" : "WEBPAY",
"agentCode" : "FPX_SBIA",
"mcpFlag" : "N",
"mcpDetails" : {
"mcpType" : "DCC",
"fxRate" : {
"fxRate" : 32.9,
"markUp" : 1.2,
"convertedAmount" : {
"amountText" : "000000006135",
"currencyCode" : "USD",
"decimalPlaces" : 2,
"amount" : 61.349694
},
"fxProviderId" : "FXP0001",
"fxDate" : "2016-08-29T09:12:34.001+0000"
}
},
"merchantIdForMCP" : "4572325756",
"transactionAmount" : {
"amountText" : "000000999950",
"currencyCode" : "THB",
"decimalPlaces" : 2,
"amount" : 9999.5
},
"settlementAmount" : {
"amountText" : "000000999950",
"currencyCode" : "THB",
"decimalPlaces" : 2,
"amount" : 9999.5
},
"customFieldList" : [ {
"fieldName" : "ExternalID5",
"fieldValue" : "AMADEUS"
} ],
"aresACSChallenge" : {
"transStatus" : "C",
"acsURL" : "https://uatemvco.2c2p.com/challenge",
"creq" : "Base64url encoded form data"
},
"authentication3DSVersion" : "2.1.0",
"availablePaymentTypes" : [ "CC-VI", "CC-CA" ],
"untokenizedStoredCardList" : [ {
"storedCardUniqueID" : "string",
"isExpired" : true,
"cardNumber" : "401200XXXXXX3335",
"cardExpiryMMYY" : "1124",
"cvvCode" : "123",
"payerName" : "Attasit Txxxxxx",
"issuerBankCountry" : "TH",
"issuerBankName" : "JPMORGAN CHASE BANK N.A."
} ]
},
"paymentPage" : {
"paymentPageURL" : "https://demo-paco.2c2p.com/payment/form",
"validTillDateTime" : "2016-08-29T09:12:34.001+0000"
}
}
}

JSON Parsing Issue Swift - Dictionary

I'm trying to retrieve the data from this dictionary and for some reason I cannot seem to acquire it. I'm new to parsing JSON so apologies if this is rough.
let temp = json["list"].arrayValue.map({$0["main"].dictionaryValue})
print(temp[0])
Here I am setting a value equal to the dictionary from the JSON. However, I know I need to add the key's value that I'm searching for. To be clear, I am searching for the "temp" key which in the example is equal to 28.19999...
Here is an example of the JSON:
"list" : [
{
"dt" : 1641524400,
"main" : {
"humidity" : 68,
"sea_level" : 1014,
"temp_max" : 29.260000000000002,
"feels_like" : 28.199999999999999,
"temp_min" : 28.199999999999999,
"grnd_level" : 1004,
"temp" : 28.199999999999999,
"temp_kf" : -0.58999999999999997,
"pressure" : 1014
},{
"dt" : 1641546000,
"main" : {
"pressure" : 1009,
"feels_like" : 20.93,
"temp_max" : 27.100000000000001,
"temp" : 27.100000000000001,
"humidity" : 83,
"grnd_level" : 999,
"sea_level" : 1009,
"temp_min" : 27.100000000000001,
"temp_kf" : 0
},
"sys" : {
"pod" : "n"
},
"pop" : 0.41999999999999998,
"wind" : {
"deg" : 354,
"speed" : 5.4100000000000001,
"gust" : 10.58
},
"visibility" : 6695,
"weather" : [
{
"main" : "Snow",
"id" : 600,
"description" : "light snow",
"icon" : "13n"
}
],
"snow" : {
"3h" : 0.26000000000000001
},
"clouds" : {
"all" : 100
},
"dt_txt" : "2022-01-07 09:00:00"
},
{
"dt" : 1641556800,
"main" : {
"temp_min" : 26.82,
"humidity" : 90,
"pressure" : 1008,
"temp_kf" : 0,
"temp" : 26.82,
"feels_like" : 18.879999999999999,
"sea_level" : 1008,
"temp_max" : 26.82,
"grnd_level" : 998
},
"sys" : {
"pod" : "n"
},
"pop" : 0.97999999999999998,
"wind" : {
"deg" : 310,
"gust" : 14.359999999999999,
"speed" : 7.5199999999999996
}]
Found my answer:
let temp = json["list"].arrayValue.map({$0["main"]["temp"].stringValue})

mongodb map reduce value undefined

I have following collection in mongodb-
> db.games.find().pretty();
{
"_id" : ObjectId("5db06c02e08772b58596ec72"),
"name" : "Cricket",
"genre" : "sport",
"rating" : 10
}
{
"_id" : ObjectId("5db06c02e08772b58596ec73"),
"name" : "Football",
"genre" : "sport",
"rating" : 100,
"achievement" : "champion",
"games" : [
{
"score" : 20
},
{
"score" : 30
},
{
"score" : 22
},
{
"score" : 145
}
]
}
{
"_id" : ObjectId("5db06c02e08772b58596ec74"),
"name" : "Ludo",
"genre" : "indoor",
"rating" : 1
}
{
"_id" : ObjectId("5db06c02e08772b58596ec75"),
"name" : "Badminton",
"genre" : "indoor",
"rating" : 60,
"games" : [
{
"score" : 34
},
{
"score" : 12
},
{
"score" : 50
}
]
}
{
"_id" : ObjectId("5db06c02e08772b58596ec76"),
"name" : "Swimming",
"genre" : "water",
"rating" : 50
}
{
"_id" : ObjectId("5db06c02e08772b58596ec77"),
"name" : "Running",
"genre" : "atheletics",
"rating" : 70
}
{
"_id" : ObjectId("5db06c02e08772b58596ec78"),
"name" : "Shotput",
"genre" : "atheletics",
"rating" : 66
}
I want to sum of scores for each game in the collection. For this I am trying to implement map reduce as follows -
> db.games.mapReduce( function(){emit(this.name,this.score)}, function(key,values) {return Array.sum(values)}, {out:"out_scores"});
{
"result" : "out_scores",
"timeMillis" : 330,
"counts" : {
"input" : 7,
"emit" : 7,
"reduce" : 0,
"output" : 7
},
"ok" : 1
}
But the values in the resulting collection as undefined as follows -
db.out_scores.find().pretty();
{ "_id" : "Badminton", "value" : undefined }
{ "_id" : "Cricket", "value" : undefined }
{ "_id" : "Football", "value" : undefined }
{ "_id" : "Ludo", "value" : undefined }
{ "_id" : "Running", "value" : undefined }
{ "_id" : "Shotput", "value" : undefined }
{ "_id" : "Swimming", "value" : undefined }
I am expecting sum of values of scores for each game. What am I doing wrong here?
Perhaps this query might help?
db.games.aggregate(
[
{ $unwind: { path: "$games", preserveNullAndEmptyArrays: true }},
{ $group: {
_id: "$name",
score: { $sum: "$games.score" }
}}
])
Results:
{ "_id" : "Shotput", "score" : 0 }
{ "_id" : "Running", "score" : 0 }
{ "_id" : "Ludo", "score" : 0 }
{ "_id" : "Swimming", "score" : 0 }
{ "_id" : "Badminton", "score" : 96 }
{ "_id" : "Football", "score" : 217 }
{ "_id" : "Cricket", "score" : 0 }
** If still want to use mapreduce...**
The root problem is nested data. Need to refer to the data from the games.score perspective. The mapping function of map reduce requires this logic.
db.games.mapReduce( function(){
var sum_of_score = 0;
if (this.games != undefined) {
for (var i=0; i<this.games.length; i++) {
sum_of_score += this.games[i].score;
}
}
emit(this.name, sum_of_score)
}, function(key, values) { }, {out:"out_scores"});
Query:
db.out_scores.find()
Results:
{ "_id" : "Badminton", "value" : 96 }
{ "_id" : "Cricket", "value" : 0 }
{ "_id" : "Football", "value" : 217 }
{ "_id" : "Ludo", "value" : 0 }
{ "_id" : "Running", "value" : 0 }
{ "_id" : "Shotput", "value" : 0 }
{ "_id" : "Swimming", "value" : 0 }

Update deeply nested array in mongodb

I am trying to update field value in mongoose.
{
"_id" : ObjectId("5b62c772efedb6bd3f0c983a"),
"projectID" : ObjectId("0000000050e62416d0d75837"),
"__v" : 0,
"clientID" : ObjectId("00000000996b902b7c3f5efa"),
"inspection_data" : [
{
"pdf" : null,
"published" : "N",
"submissionTime" : ISODate("2018-08-02T08:57:08.532Z"),
"userID" : ObjectId("00000000cac68e3bc04643f7"),
"insSummary" : "inspected areas",
"insName" : "Infotech",
"_id" : ObjectId("5b62c772fa02622a18655e7b"),
"published_date" : ISODate("2018-08-02T08:57:22.041Z"),
"locationAspects" : [
{
"aspectname" : "Ground floor",
"_id" : ObjectId("5b62c772fa02622a18655e80"),
"comments" : [
{
"_id" : ObjectId("5b62c772fa02622a18655e81"),
"images" : [
{
"path" : "/uploads/inspection/00000000996b902b7c3f5efa/images/1533200242005-IpjLKH4XFWNEcHXa.png",
"img_name" : "1533200242005-IpjLKH4XFWNEcHXa.png",
"title" : "Fan",
"id" : "1"
},
{
"path" : "/uploads/inspection/00000000996b902b7c3f5efa/images/1533200242008-YN8IlA5yrMn3cBnn.png",
"img_name" : "1533200242008-YN8IlA5yrMn3cBnn.png",
"title" : "Box",
"id" : "2"
}
],
"comment" : [
"comment4"
],
"recommendation" : ""
}
]
}]
}
Here I want to update a title Fan in image array as table fan.
I tried $set but I don't know how to do for my db structure.
Kindly give some solution to this
**Updated:**
I tried this code:
mongo.inspection.update({"projectID" : mongoose.Types.ObjectId(req.body.project_id) },
{ "$set": {
"inspection_data.$[e1].locationAspects.$[e2].comments.$[e3].images.$[e4].title" : "TableFan"
}},
{ "arrayFilters": [
{ "e1._id": mongoose.Types.ObjectId(req.body.insId)},
{ "e2._id": mongoose.Types.ObjectId(req.body.aspectId)},
{ "e3._id": mongoose.Types.ObjectId(req.body.commentId)},
{ "e4.id": "1" }
]},function(err,response){
if(err){
console.log("error")
}
else{
console.log('Updated')
console.log(response)
}
})
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
Its showing updated but in my db there is no change. Is any mistake I did ?
You can try with arrayFilters in mongodb
var mongoose = require('mongoose')
Temp.update(
{ "_id" : mongoose.Types.ObjectId("5b62c772efedb6bd3f0c983a") },
{ "$set": {
"inspection_data.$[e1].locationAspects.$[e2].comments.$[e3].images.$[e4].title": "TableFan"
}},
{ "arrayFilters": [
{ "e1._id": mongoose.Types.ObjectId("5b62c772fa02622a18655e7b") },
{ "e2._id": mongoose.Types.ObjectId("5b62c772fa02622a18655e80") },
{ "e3._id": mongoose.Types.ObjectId("5b62c772fa02622a18655e81") },
{ "e4.id": "1" }
]}
)
Note: You have to cast _id to ObjectId

mongoDB limit the number of entries scanned

I'm trying mongoDB and I need translate this following SQL query.
SELECT * FROM infos_cli
WHERE MATCH(denomination) AGAINST('cafe')
WHERE code_postal LIKE '34%'
My full text index definition:
db.infos_cli.createIndex(
{ "code_postal": 1,
"denomination": "text"
},
{default_language: "french"},
{name: "indexSerch"}
)
And my query in mongoDb:
db.infos_cli.find({code_postal : /34/, $text: {$search: "cafe"}})
But it's not working.
Can anyone explain how I've to do ?
In this case please create separate index for postal field and for text search
db.articles.createIndex({ author : 1}) //postal... in your case
db.articles.createIndex({
"denomination" : "text"
}, {
default_language : "french"
}, {
name : "indexSerch"
})
my query
db.getCollection('articles').find({
$text : {
$search : "coffee",
$language : "french"
}
}).explain()
Result shows that there is TEXT phase and IXSCAN which is desired!
result from explain:
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "testCode.articles",
"indexFilterSet" : false,
"parsedQuery" : {
"$text" : {
"$search" : "coffee",
"$language" : "french",
"$caseSensitive" : false,
"$diacriticSensitive" : false
}
},
"winningPlan" : {
"stage" : "TEXT",
"indexPrefix" : {},
"indexName" : "denomination_text",
"parsedTextQuery" : {
"terms" : [
"coffe"
],
"negatedTerms" : [],
"phrases" : [],
"negatedPhrases" : []
},
"inputStage" : {
"stage" : "TEXT_MATCH",
"inputStage" : {
"stage" : "TEXT_OR",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"_fts" : "text",
"_ftsx" : 1
},
"indexName" : "denomination_text",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 1,
"direction" : "backward",
"indexBounds" : {}
}
}
}
},
"rejectedPlans" : []
},
"serverInfo" : {
"host" : "gbernas3-lt",
"port" : 27017,
"version" : "3.2.0",
"gitVersion" : "45d947729a0315accb6d4f15a6b06be6d9c19fe7"
},
"ok" : 1
}
any comments welcome!