Cesium - Range Error: Invalid Array Length on Validated geoJson - geojson

I am attempting to load the following geoJson file in a test app based on the standard HelloWorld sample app.
{
"type": "FeatureCollection",
"generator": "overpass-turbo",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
"timestamp": "2016-09-12T19:22:48Z",
"features": [
{
"type": "Feature",
"id": "way/442106309",
"properties": {
"#id": "way/442106309",
"addr:city": "Ottawa",
"addr:housenumber": "999",
"addr:postcode": "H8G8F9",
"addr:street": "My Road",
"building": "apartments",
"building:levels": "3",
"levels": "3"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-75.7337391,
45.3783003
],
[
-75.7335222,
45.378383
],
[
-75.7335439,
45.3784096
],
[
-75.733525,
45.3784206
],
[
-75.7335406,
45.3784375
],
[
-75.7335003,
45.378453
],
[
-75.7335867,
45.378543
],
[
-75.7338474,
45.3784262
],
[
-75.7337391,
45.3783003
]
]
]
}
}]}
I am loading this using the following code:
var dataSource = Cesium.GeoJsonDataSource.load('../data/kirkwood.json').then(function(data) {
viewer.dataSources.add(data);
viewer.zoomTo(data);
}
This results in the following error message:
An error occurred while rendering. Rendering has stopped.
RangeError: Invalid array length
RangeError: Invalid array length
at updateFrustums (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:155215:36)
at createPotentiallyVisibleSet (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:155389:13)
at executeCommandsInViewport (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:155943:9)
at updateAndExecuteCommands (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:155841:17)
at render (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:156177:9)
at Scene.render (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:156215:13)
at CesiumWidget.render (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:164962:25)
at render (http://127.0.0.1:8081/Build/CesiumUnminified/Cesium.js:164364:32)
I am confused, as the geoJson validates just fine using http://geojson.io and http://geojsonlint.com
Could anyone offer some helpful suggestions?
Thanks!

The error you've shown here is unfortunately kind of a catch-all error from the inside of the Cesium render loop. It's one that crops up anytime an invalid object introduces an invalid bounding sphere into the list of visible objects. Sadly this error isn't thrown when the bad object is first added to the list. The error doesn't get thrown until Cesium's render loop attempts to render all the objects, with a bad object included. The bad object is discovered long after its creation routines are gone from the call stack, and as such the error doesn't pinpoint where things first went wrong. The bottom of the call stack just asks for the next frame to render, meaning the code that introduced the problem has already completed and returned.
That said, the code you've shown here does work for me in Cesium 1.25. It shows a yellow polygon on a particular building. But, some of the variable names here look wrong to me, suggesting you may be mis-using them in other parts of your code that you haven't shown here. In particular, dataSource is really a Promise, not a real DataSource, and data is the real dataSource. So, I suggest a rename:
var dataSourcePromise = Cesium.GeoJsonDataSource.load('../data/kirkwood.json').then(
function(dataSource) {
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource);
}
);
This code isn't any different from what you posted, but what you posted works fine on my machine. What I've done here is rename some variables in case you were trying to use them elsewhere, creating problems. This should hopefully make it clear that you can't use dataSourcePromise as an actual DataSource.
If you haven't found the problem after applying this re-factoring, you may need to either post here or remove any additional code you have that is adding objects to be rendered in Cesium. The error makes it clear that some kind of invalid object has been added to the render loop.

Related

Twilio Autopilot SMS not accepting media image type

I wrote a task a while back that would run a collect flow and collect an image using the model on the docs for doing so (https://www.twilio.com/docs/autopilot/actions/collect#questions). It ran flawlessly, and I tested it to make sure it ran as expected.
I made a new account using the company email to migrate my work over, and continue implementing the code, and eventually reached the portion where I needed to integrate that media collection. I used the same code, but it didn't work. The collect flow keeps on triggering the validate portion and telling me that it isn't an accepted type. I have tried it using the exact code from before as well as the exact image, but it still isn't working. The only thing I can think of is if the phone number was set up differently somehow. The message logs show the image as sent and looks fine and I can't find any differences other than that.
Is there anything that might be causing this? Here is the code for reference
{
"actions": [
{
"collect": {
"name": "image_collect",
"questions": [
{
"question": "Please upload an image",
"name": "image",
"type": "Twilio.MEDIA",
"validate": {
"on_failure": {
"messages": [
{
"say": "We do not accept this format. Please send another image."
}
]
},
"allowed_types": {
"list": [
"image/jpeg",
"image/gif",
"image/png",
"image/bmp",
"application/pdf"
]
}
}
}
],
"on_complete": {
"redirect": "https://4894-100-33-3-193.ngrok.io/image_processing"
}
}
}
]
}
Generally, media size causes this issue, just make sure the file size is within the limits.
For more info - https://www.twilio.com/docs/sms/accepted-mime-types

Extracting specific values from a dictionary in iOS Shortcuts to display in a Choose from List menu?

I have a REST endpoint that returns a body that looks like this:
"posts": [
{
"message": "This is another message",
"created": "2019-12-27 21:33:54+10",
"items": [...],
"tags": [...],
"toot_id": "12345"
},
{
"message": "This is a message",
"created": "2019-12-26 20:42:15+10",
"items": [...],
"tags": [...],
"toot_id": "12344"
}
]
I want to extract just the message and toot_id fields and use a "Choose from List" action to display the message text, and upon selection pass the corresponding toot_id of the chosen message to the next action. Unfortunately I'm greatly struggling with how to do this... I know Javascript and TypeScript and can handle this sort of thing in those languages with no problems, but iOS's Shortcuts app is thwarting me. I've got as far as a "Repeat with each item" with the posts key as a result of hitting my REST endpoint, but I'm stuck as to how to continue from there, and I'm not clear on whether I should be setting the various actions inside the loop to "as Text" or "as Dictionary" either.
Thanks!
This is a screenshot of how I got it to work in a similar situation.
The key for me was the combination of "Get dictionary from Input" (use the variable), "Set Dictionary Value", and then "Set Variable". Trying to do "Set Dictionary Value" on the variable directly (in one step) never worked.

Dart Services API: how to access the /fixes through the API service?

I am looking at:
https://github.com/dart-lang/dart-services
And am trying to adapt the example given (https://dartpad.dartlang.org/2a7fd9328e0a567ee79b) to pull back information from '/api/dartservices/v1/fixes' rather than '/api/dartservices/v1/analyze'.
Apologies, if I am missing something obvious here but changing the path in the example to:
"https://dart-services.appspot.com/api/dartservices/v1/fixes";
returns an error. Does anyone know how I can get the information from '/api/dartservices/v1/fixes rather than '/api/dartservices/v1/analyze'? Or does anyone have an example of this working?
Thanks.
Sending a POST request to https://dart-services.appspot.com/api/dartservices/v1/fixes with the data the DartPad example sends yields the error message "Missing parameter: 'offset'".
Looking at the discovery doc for the service https://dart-services.appspot.com/api/discovery/v1/apis/dartservices/v1/rest I see both analyze and fixes operations take a SourceRequest:
"SourceRequest": {
"id": "SourceRequest",
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "The Dart source.",
"required": true
},
"offset": {
"type": "integer",
"description": "An optional offset into the source code.",
"format": "int32"
},
"strongMode": {
"type": "boolean",
"description": "An optional signal whether the source should be processed in strong mode"
}
}
offset is not marked as required so maybe there is a bug in the implementation of fixes wrt that parameter.
To make the DartPad example work, change:
Map m = {'source': textArea.value};
to
Map m = {'source': textArea.value, 'offset': 0};

Error in Google SDTT: "All values provided for url must point to the same page."

I am trying to create some JSON-LD structured data for a list of products on an ecom-site but I am getting an error when using Google's Structured Data Testing Tool.
So far, I have this:
{
"#context": "http://schema.org",
"#type": "OfferCatalog",
"name": "Fresh Fruit",
"itemListElement": [
{
"#type": "ListItem",
"position": 1,
"item":
{
"#type": "Offer",
"price": "1.20",
"priceCurrency": "GBP",
"availability": "http://schema.org/InStock",
"url": "http://example.com/green-apples/",
"itemOffered": {
"#type": "Product",
"name": "Green Apples",
"url": "http://example.com/green-apples/"
}
}
}
]
}
Mostly it validates, but the Google tool throws the following error:
All values provided for url must point to the same page.
The error highlights line 11 ("#type": "Offer",).
The URL fields seem to be clashing with the #context declaration, because if I change the context to either a non-url string or http://example.com, it validates (although, this obviously causes its own issues). (This has been shown to be a red-herring, in the comments below)
What am I missing here? It feels like something blindingly obvious.
I think it is connected with pushing of accelerated mobile pages and its structured data.
Please check my thoughts here: All values provided for URL must point to the same page. My guess was about the problem in Google’s SDTT
So, to fix the problem with your structure data, please use the correct version of ItemList (there are Separately and Combined marked up ItemLists, please check here):
If your items are on the same page, please use the version with items
inside, the Combined one.
Otherwise, if you point to different pages inside and your items are
not on one page, please DON’T put item element with type and other
description inside, the Separately marked up one.
Now it's 2018.
Answer by Yash Pal above is close, but not quite right.
This is not an error from Google validator tools.
The error is valid and you need to fix it.
You use the "Single Page" approach ( there are two approaches "Summary page" and "Single page" )
For "Single Page" approach, you need each URL to be exactly same, and each of them should have "an anchor".
The Google developer doc clearly mentioned it.
I wrote the explanation details there
If your page contains some links to another page, then you should use "Summary Page" approach and it had different data structure ( much simpler one, I think )
I think the issues occurs when we mix two list types i.e Summary page + multiple full details pages and A single, all-in-one-page list.
Google stated on page - https://developers.google.com/search/docs/guides/mark-up-listings
If this is a summary page, the ListItem should include only the type,
position, and url properties.
If this is an all-in-one-page list, the ListItem should include all the additional schema.org properties for the data type that it describes (for example, Recipe or Course objects).
But Google should consider eCommerce category's product listing where people display numbers of product with more than 3 properties on summery page and these are obvious for eCommerce, like price and image are 2 important item on product listing page except the 3 listed above.
So we need to raise this issue with Google to address the concern.
No, it is NOT an error in Google's SDTT,
I have helped many people fix their structured data, including dynamic arrays. Read the instructions. Google clearly states "All values for the URL must point to the same page". Think about it, Google is trying to tell you something.
That something means this "Hey you are using a different item list from the example we provided, your item list has more than two item".
The solution:
Use anchors! Voila!
Please use this example snippet and you cannot go wrong. And another tip; use the Fetch Url option from SDTT:
<script type="application/ld+json">
/*structerd data markup compiled by http://www.iwanross.co.za */
{
"#context": "http://schema.org",
"#type": "ItemList",
"itemListElement": [
{
"#type": "ListItem",
"position": 1,
"item": {
"#type": "Recipe",
"url": "https://www.smokingchimney.com/#beetroot",
"name": "Beetroot Side Salad for the braai",
"image": "http://www.smokingchimney.com/recipe-pages/images/1x1/Beetroot-Salad-
for-the-Braai-800x451.jpg",
"author": {
"#type": "Person",
"name": "Marna Ross"
},
"datePublished": "2018-10-05"
}
},
{
"#type": "ListItem",
"position": 2,
"item": {
"#type": "Recipe",
"url": "https://www.smokingchimney.com/#carrot",
"name": "Carrot Cake",
"image": "http://www.smokingchimney.com/recipe-pages/images/16x9/carrot-cake-
recipe-picture-1024x576.jpg",
"author": {
"#type": "Person",
"name": "Marna Ross"
},
"datePublished": "2018-10-05"
}
},
{
"#type": "ListItem",
"position": 3,
"item": {
"#type" : "Recipe",
"url":"https://www.smokingchimney.com/#overnight",
"name": "Overnight Steak Marinade",
"image": "http://www.smokingchimney.com/recipe-pages/images/1x1/Overnight-steak-
marinade-700x465.png",
"author": {
"#type": "Person",
"name": "Marna Ross"
},
"datePublished": "2009-10-05"
}
}
]
}
</script>
It is surely an error in the validator. I checked with the examples google provided: https://developers.google.com/search/docs/guides/mark-up-listings .
If you click on the 2nd example you will see that it has the same error.
The error is shown even if you use 1 item:
{
"#context": "http://schema.org",
"#type": "ItemList",
"itemListElement": [
{
"#type": "ListItem",
"position": 1,
"item": {
"#type": "Recipe",
"url": "http://example.com/desserts/pies/#apple-pie",
"name": "Apple Pie",
"image": "https://example.com/300px-Apple_pie.jpg",
"author": {
"#type": "Person",
"name": "Carol Smith"
},
"datePublished": "2009-11-05"
}
}
]
}
you don't need to anchor every URL, you can add parameters to the URL as well ?i=1
like:
https://website.com/d/link?i=1
https://website.com/d/link?i=2
....
Use type OfferCatalog instead of ItemList. https://schema.org/OfferCatalog

Obj. C - how to deal with wrong written JSON

I obtained some badly written JSON file that's totally not readable through any AFNetworking and/or any other JSON serializing library. I must underline that I am not able to force to change it on server-side so I have to parse it as is.
Unfortunately it has some minor errors (I will paste small part of it):
locations = [{
"city": "Tokio",
(...)
"link": "http://somethig.com",
"text": "Mon-Fr.",
}, {
(... same repeated mistakes, but they're not regular)
}]
Aaand to parse it correctly in XCode i need to change it to correct format e.g.:
{
"locations": [{
"city": "Tokio",
(...)
"link": "http://somethig.com",
"text": "Mon-Fr."
}, {
(...)
}]
}
Do you have any idea how to deal with that?
If I will have to write my own parser - please advice me how to. Any help will be appreciated. I download this JSON from http link.
It looks like the API is sending you a string of JavaScript code. In JavaScript, you would use JSON.stringify() to convert the object to valid JSON. Here's an example from an interactive node.js shell:
> locations = [{
... "city": "Tokio",
... "link": "http://somethig.com",
... "text": "Mon-Fr.",
... }]
[ { city: 'Tokio', link: 'http://somethig.com', text: 'Mon-Fr.' } ]
> JSON.stringify(locations)
'[{"city":"Tokio","link":"http://somethig.com","text":"Mon-Fr."}]'
If you really can't change this on the server side, you might try creating a hidden UIWebView, adding the JavaScript, calling JSON.stringify(), and extracting the result. However, this will use many more resources than are needed. It would be much better (in terms of computing power, memory, and your time) to have the API call JSON.stringify() and send you a valid JSON string.
You could also try porting some of json3.js to Objective-C or Swift. I would start with the section beginning // Public: `JSON.stringify`. if you attempt this.

Resources