Tiles not shown on cesium - akka

I created a viewer and added a customized layer (which is provided by myself). I am using the akka map server. My problem is that my map tiles are not displayed, although I can see from the console that cesium has loaded the tiles.
The code looks like this:
var viewer = new Cesium.Viewer("cesiumContainer");
var layers = viewer.scene.imageryLayers;
var through = layers.addImageryProvider(new Cesium.UrlTemplateImageryProvider({
url : 'http://my_ip:8777/modis/ndvi/{z}/{x}/{y}.png',
format: "image/png"
}));
through.alpha = 0.5;
If I change the url to another map such as blackmarble, it loads correctly
(i.e. the tiles are displayed, but the position y must be changed to reverseY). Does any body know why my map can't be loaded on the cesium?

I had found the key point.
Cesium must add CORS add the TMS which you want add it to your layers.
So just add the akka CORS suport,then everything will ok!

Related

How to use #FetchRequest data in Provider struct in iOS 14 Widget [duplicate]

I want to display data fetched from Core Data in a widget. But #FetchRequest doesn’t work on widgets.
As I understand, we have to create an app group and make a shared persistent container.
What I want to know is how to read (fetch) data on widgets from that shared persistent container or simply, how to display data fetched from Core Data in widgets.
First you need to create an AppGroup which will be used to create a Core Data Persistent Container (here is a good explanation how to do it)
Then you need to create your own CoreData stack (an example can be found when you create a new empty project with CoreData enabled).
Accessing Core Data Stack in MVVM application
Assuming you have already created your Core Data model (here called DataModel), you now need to set the container url to your custom shared container location:
Share data between main App and Widget in SwiftUI for iOS 14
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: <your_app_group>)!
let storeURL = containerURL.appendingPathComponent("DataModel.sqlite")
let description = NSPersistentStoreDescription(url: storeURL)
let container = NSPersistentContainer(name: "DataModel")
container.persistentStoreDescriptions = [description]
container.loadPersistentStores { ... }
Now you can get the managedObjectContext from your shared Persistent Container:
let moc = CoreDataStack.shared.managedObjectContext
and perform a fetch request with it (more information here)
let predicate = NSPredicate(format: "attribute1 == %#", "test")
let request = NSFetchRequest<SomeItem>(entityName: "SomeItem")
let result = try moc.fetch(request)
Apart from all the links above I recommend you also read this tutorial about Core Data:
Core Data with SwiftUI Tutorial: Getting Started
Here is a GitHub repository with different Widget examples including the Core Data Widget.
For people who did all the work above, and finally can get the connection to your Core Data (e.g. you can get the count of request), but can't fetch the request, is mostly because that the entity you're fetching contains transformable type, and for some reason this error occurred: Cannot decode object of class, try fix this.

How do I fetch HomeKit values for usage in iOS 14 Widgets?

I am writing a HomeKit app that successfully shows live data from my supported accessories in-app. I can read single values (HMCharacteristic.readValue) or use notifications to stay updated (HMCharacteristic.enableNotification).
Now I want to implement Widgets that show this data on the user's Home Screen. This consists of four steps:
A dynamic Intent fetches all the registered (and supported) Accessories from the HMHomeManager and enables the user to select one of them to be shown on the Widget.
Inside the IntentTimelineProvider's getTimeline function I can then again use the HMHomeManager to retrieve the Accessory I want to display on the Widget (based on the Accessory's UUID which is stored inside the getTimeline's configuration parameter - the Intent).
Still inside the getTimeline function I can choose the Services and Characteristics I need for displaying the Accessory's Widget from the HMHomeManager.
Up until here everything works fine.
However, when I try to read the values from the Characteristics I chose before using HMCharacteristic.readValue, the callback contains an error stating
Error Domain=HMErrorDomain Code=80 "Missing entitlement for API."
The Widget's Info.plist contains the 'Privacy - HomeKit Usage Description' field and the Target has the HomeKit capability.
After some research I came up with the following theory: Obviously the whole WidgetKit API runs my code in background. And it seems like HomeKit does not allow access from a background context. Well, it does allow access to Homes/Services/Characteristics, but it does not allow reading or writing on Characteristics (I guess to make sure App developers use HomeKit Automations and don't try to implement custom automations that are controlled by some background process of their app running on the iPhone).
My (simplified) getTimeline code:
func getTimeline(for configuration: SelectAccessoryIntent, in context: Context, completion: #escaping (Timeline<Entry>) -> ()) {
// id stores the uuid of the accessory that was chosen by the user using the dynamic Intent
if let id = configuration.accessory?.identifier {
// Step 2.: fetch the accessory
// hm is a HMHomeManager
let hm = HomeStore.shared.homeManager
// take a short nap until the connection to the local HomeKit instance is established (otherwise hm.homes will create an empty array on first call)
sleep(1)
let accessories = hm.homes.flatMap({ h in h.accessories })
if let a = accessories.filter({ a in a.uniqueIdentifier.uuidString == id }).first {
// a holds our HMAccessory
// Step 3.: select the characteristic I want
// obviously the real code chooses a specific characteristic
let s: HMService = a.services.first!
let c: HMCharacteristic = s.characteristics.first!
// Step 4.: read the characteristic's value
c.readValue(completionHandler: {err in
if let error = err {
print(error)
} else {
print(c.value ?? "nil")
}
// complete with timeline
completion(Timeline(entries: [RenderAccessoryEntry(date: Date(), configuration: configuration, value: c.value)], policy: .atEnd))
})
}
}
}
}
My questions:
First: Is my theory correct?
If so: What can I do? Are there any entitlements that allow me to access HomeKit in background or similar? Do I need to perform the readValue call elsewhere? Or is it just impossible to use the HomeKit API with WidgetKit with the current versions of HomeKit/WidgetKit/iOS and best I can do is hope they introduce this capability at some point in the future?
If not: What am I missing?

Flex 4 component is created before dataprovider gets data

I have a custom component (List) which gets the dataprovider from external xml which calls a service again.Dataprovider is set to custom list by ID.
For the first time when screen loads the list is generated with data but later after if I refresh the screen the list is loaded with empty because list is getting created before dataprovider gets values from xml and service.
Every time if I run in debug mode I will get the list generated as I will wait till dataprovider gets data..but if I run in normal mode I could see empty list some times.
You can try Binding the Dataprovider to the list. So even if it is updated late it will automatically update the list.
You can use metadata tag something like:
[Bindable]
private var arrayCollection:ArrayCollection;
and update the 'arrayCollection' when you get data dynamically.
Hope it helps.
The data binding could be the solution for your problem.
Other way could be set the dataprovider of the list when the service gets the result
- Call the service
- The service obtains the data
- list.dataProvider = result of the service
Anyway, data binding seems the best solution
[Bindable]
private var arrayCollection:ArrayCollection;
<s:List dataProvider="{arrayCollection}" ....

Trouble replicating demo with my own data. .vtk [

I am trying to replicate this example with my own data.
window.onload = function() {
// create and initialize a 3D renderer
var r = new X.renderer3D();
r.init();
// create a mesh and associate it to the VTK Point Data
var p = new X.mesh();
p.file = 'http://x.babymri.org/?pits.vtk';
I understand you cannot simply point to the local .vtk file. I have read that webgl required the file to be served, so I am now correctly serving it from localhost.
I have placed exactly the same data (as served to the above example) locally and saved it in the file DATA.vtk.
I have modified MIME types inside IIS manager so that .vtk is text/html and when you point to either the raw data's url (in the original example) or my localhost data, they look exactly the same.
However, it still does not work. Specifically, this is my error:
Uncaught TypeError: Cannot read property 'length' of null xtk.js:179
Here is a picture of what I'm talking about...

Facebook Unity3d SDK doesnot include FBUtil and GameStateManager classes

I am trying to integrate facebook sdk in my unity android game. I can not find FBUtil and GameStateManager in SDK downloaded from developer site.
I got the userId using FB.UserId. Also got the response
"sending to Unity OnInitComplete({"access_token":"CAAUCMHNGlZCcBAHJBQAs7AoJNevkZAFbkpSRk60TURemvv4Y6IOu9NXjGcFjFRZAx9RoxwKT4ZBZASs0NLiYTmi4rl7RyWYdtxxhlKkSjoIWiqqDSBdSDKk0OppB2ZB4U6IgtqQs9PM8uNCaNF5xgqWn2c9DDkp4dJc9p38XONKpdwRF7qDHtM","user_id":"100003735696788","opened":true})"
Just after that when I tried to get profile picture of the user, using the code given on developer.facebook.com,
void LoginCallback() {
FB.API (
"/me/picture",
Facebook.HttpMethod.GET,
APICallback
);
}
The response I get is 4 question marks.
????
where is the problem? Please help..
I used this link using WWW in Unity and it worked well.. This is exactly what I did
Once you have the user id, create a WWW object like this:
WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture?type=large");
Then in the LateUpdate I put an IF condition checking if the picture was loaded or not with a bool called loaded to avoid reloading the picture more than once
if (url.isDone && !loaded)
{
loaded = true;
Texture2D textFb2 = new Texture2D(50, 50, TextureFormat.ARGB32, false); //TextureFormat must be DXT5
url.LoadImageIntoTexture(textFb2);
PLANE_OR_QUAD_OBJECT.renderer.material.mainTexture = textFb2;
}
NOTE: url is visible in the whole class as well as loaded
If you need further help with this, let me know!
Normally Facebook picture API should return data with Texture type NOT text
For example, If you use code like #jkgm777 answer,
WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture");
You should get Texture type that can use to replace your texture object in scene.
But If you want to get image url, USE THIS
http://graph.facebook.com/INSERT_USER_ID_HERE/picture?redirect=false
You will get this JSON for response
data: {
url: "{#IMAGE_URL#}",
is_silhouette: false
}