How to copy original GeoJSON properties when using supercluster - deck.gl

I am using supercluster library with deck.gl. I have a GeoJSON which contains custom properties object. I use the data in properties to define which icon to display.
However when using supercluster library, I create cluster instance like this
const index = new Supercluster({ maxZoom: 16, radius: props.sizeScale * Math.sqrt(2) })
index.load(data)
Where data are features of a GeoJSON. Whenever I then load this data using index.getClusters( ... ) the properties object is replaced with data from supercluster library and I cannot access my original properties anymore.
Is there a way to retain my original properties on GeoJSON objects created via supercluster?

Related

Connect custom element to dataset in wix & corvid

Is there a way of using a dataset query inside of a custom element. On the support page (https://support.wix.com/en/article/custom-element-faqs) its says the following:
'Can I Connect Custom Elements to Data in a Collection?
Yes, you can connect custom elements to collections using Corvid's Data and Dataset APIs.'
But I don't know how to do it. I have have tried importing wixData from wix-data at the top of my custom element however this stops my custom element from displaying.
I need to create checkboxes based on the number of items in a dataset. I have been able to create the checkboxes based on a static array in the custom element but want to do it based on the dataset so I don't have to manually keep changing the array in the custom element.
Below is what I need in my custom element.
import wixData from 'wix-data';
wixData.query('testdata')
.limit(1000)
.find()
.then(results => {
console.log(results.items)
});
You need to pass the Number of checkbox via attribute. Doc link
$w('#customElementId').setAttribute('checkboxs-count', 5 );
Then on the custom element you need to listen for the attribute change.
And update the UI based on that.
Here is a pseudo code
wixData module only exist on the Wix codebase.
You need to import the data from the database using wixDatae and pass the data to custom element via setAttribute. like this
// page code
import wixData from 'wix-data';
wixData.query('testdata')
.limit(1000)
.find()
.then(results => {
// got the data from the database now pass the data to custom element using setAttribute method
$w('#customElementId').setAttribute('checkboxs-count', results.length );
});
And You need to write the custom element code to create the checkboxes and you can listen if the checkbox change and update the database via .on() method on the custom element selector.
so, the page code should look like this.
$w('#customElementId').on('checkbox-change', (event) => {
console.log(`Checkbox Number ${event.detail.number} changed. Update Wix Database` );
});
Hope this explain how to communicate database with custom element.

Update dynamic object (using QThread) image from C++ to QML

I have a problem with my assignment.
After receiving data in real time, I can create and show 1 moving object image on a background from C++ to qml using ImageProvider (this is simple and done). However, my assignment requirements: "Click on button to generate dynamically a number of object moving independently (example 3 objects, but it should not be fixed). So I decided to create 3 threads for each item, each thread will be received data and update to image separately. However, my problem is:
In qml file, I must declare a code segment for update a image such:
Image {
id: id_image
source: "image/MyImageProvider/id_image
cache: false
function reload(){
source = "";
source = "image/MyImageProvider/id_image"
}
Connections {
target: MyObject
onSignal_reload:{
id_image.reload()
}
}
How could I do the similar thing when I can not know number of object in advanced? Anyone have idea? Thanks.
You could put the Image Item into a Repeater.
Then subclass the QAbstractItemModel and use this as model for the Repeater.
Take a look at the example at
http://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html

Vue.js $set on array element does not trigger notification

I have a Vue instance whose data contains an array of objects. I display this data in a table without issue.
Upon clicking the table rows, I set a "selected" property on the corresponding data object using:
key.$set('testing', testing);
Upon setting this value, I add a custom css class the the table row, without issue.
However, if I do a simple output of the entire array of objects at the bottom of the page (such as below), it doesn't get updated to reflect the new "testing" attribute I have added.
{{ gridData | json }}
I was able to reproduce my question using some modified vue.js example code in this JSFiddle:
https://jsfiddle.net/wdmatl/531axrtt/
Notice when you click on rows of data, you either see "testing" or "not testing". But this new object data isn't reflected in the json at the bottom of the page. Why not?

comparing sorted or removed rows in dojox.grid.EnhancedGrid to dojo.data.ItemFileWriteStore

I've scoured the dojo documentation, stack overflow, as well as thoroughly explored the EnhancedGrid object itself with firebug, and I'm not finding answers.
I have an enhanced grid that I populate with values for the user to sort on and basically create a selection set (using indirectSelection plugin). They then have a button to zoom to the selected items on a map.
The problem is, when sorting columns, it doesn't change the order of the items in the store itself, where I'm keeping an object inside each item that tells me how to zoom on the map, so I have no way to reconcile the grid.selection.selected array indices with the store._arrayOfAllItems indices.
edit: Note that I'm stuck using Dojo 1.6 as it's baked into the API I'm using.
Have a look at Dojo Object Store Tutorial.
You can set an idProperty to a Store, e.g.:
var employeeStore = new dojo.store.Memory({data:employees, idProperty: "name"});
Then you can operate the store with that id property using the get method like this:
// add a new employee
employeeStore.add({name:"George", department:"accounting"});
// remove Bill
employeeStore.remove("Bill");
// retrieve object with the name "Jim"
var jim = employeeStore.get("Jim");
Instead of using store._arrayOfAllItems. That way your grid.selection object will contain your id's values instead of array indexes (provided that your grid's store property is your store). This is the part that I'm guessing will work because I know for sure that the new dojo's dgrid does it that way, which I encourage you to use it BTW.
Hope it helps,

ExtJS 4: Add children tree nodes to a non-Root node dynamically?

I am trying to add children tree nodes to a non-Root node dynamically when it's selected.
This is how I implemented it:
First, I populate my tree with a TreeStore then to dynamically add children tree nodes, I handle it on the itemexpand event in tree Controller.
//pThis is a NodeInterface obj of the selected node
itemexpand: function (pThis, pEOpts) {
//type is an attribute that I added so that I know what type of node that got selected
if (pThis.raw.type === 'Staff' && !pThis.hasChildNodes()) {
var staffNodeAry = [{text:"Teachers", type:"ChildStaff", leaf: false},
{text:"Principals", type:"ChildStaff", leaf: false}];
pThis.appendChild(staffNodeAry);
}
}
This worked quite good because I am able to see both "Teachers" and "Principals" node under "Staff" type but there are 2 issues that I found so far:
1) There's this error on the console:
Uncaught TypeError: Cannot read property 'internalId' of undefined
I don't know why but if anyone could enlighten that would be great.
2) When I expand either "Teachers" and "Principals", the NodeInterface obj that's returned by itemexpand has an undefined raw object.
So I couldn't do this: pThis.raw.type
From my understanding, I don't need to create a new TreeStore to add any new children nodes, I thought that by creating an array of objects that adhere to NodeInterface should be enough but I might be wrong.
If anyone could point me to the right direction, that would be great.
Handi
More info:
What I did was actually following the ExtJs 4 documentation so I believe this is a bug on ExtJs 4 framework.
I also tested this with Extjs-4.1.0-rc3 and it also produced the same error.
I have resolved this issue changing the event itemexpand with the event afteritemexpand. I have no documentation to justify this. The debugger says to me that the view listen for the itemexpand event and do something that goes wrong if add a node manually...
For the question number 2: you have no raw object because it is created by the reader of the store after the load operation. So if you add a node by hand the raw object does not exists.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Model-property-raw
The documentation for .appendChild() functions says:
node : Ext.data.NodeInterface/Ext.data.NodeInterface[]
The node or Array of nodes to append
And you are trying to append an array of 2 objects, but they are not "NodeInterface" instances. So you should create them properly like so:
var nodeToAppend1 = pThis.createNode({text:"Teachers", type:"ChildStaff", leaf: false});
pThis.appendChild(nodeToAppend1);
I remember making the same mistake a year ago, so I hope this helps.
I think it happens because your Ext.TreePanel working asyncroniously. So add process is:
Append Child, add virtual child leaf to your tree, with red mark in corner
Call store's create api
Receive response, if it success=true, change with virtual
The goal of changing is set internakId property, so you can add new child only after this change happens. I think better is write some recursive function and bind it to store's added event
tree.getStore().on('update', addChild);
or
tree.getStore().load({
success: function() {
addChild()
});