spatial element count data structure eg: R-Tree, with filtering

Background: The application is a web map application with a LeafletJS front-end and NodeJS back-end with Postgres database. The application is to be used on both desktops and smartphones/ tablets in the field. The map should visualise ~30K polygons whose number grows by ~3k per year. The data set has insertions and deletions less than once every 12 hours but has queries constantly. At all zooms, a representation of the entire spatial data set should be available. At lower zooms a cluster or heatmap representation is ideal. At high zooms the individual polygons should be visible. The main issue is that the data set count represented by clustering must also be filterable by a finite number of sets each with finite number of options membership (year, type of survey etc.)

A naive implementation would be to calculate the centre/ centroid/ pole-of-inaccessibility of each polygon along with its set options and send these to a standard Leaflet clustering library on the client side to visualise when below a threshold zoom level, and to send the polygons themselves when above a zoom level. The client-controlled filter would iterate through each layer in the cluster or polygon set.

It seems to me that a better cluster would be to build a R-Tree server-side and at each node level include the total child count, then on the client-side each cluster is represented as this child count at the centre of its node’s bounding box. Above the threshold zoom, polygons for that area are also stored in a client-side R-Tree to avoid querying the database for areas that have been traversed more than once.

(A) Is this a sensible data structure and method of representing clusters?

(B) How can it be extended to compute child count of subsets at different levels of zoom, such as calculating the count of every exclusive set at each level? (eg: count of elements in years x1 to x2 and survey type a,b,c, not d)

Number of steps – Count Change Procedure

I don’t know if this is dupp question, i’ve already seen some explanations on why the procedure below is equal to $ \theta(n^d)$ in terms of time complexity, being $ d$ the number of coins. My question here resides on the exact number of steps required by this procedure when, e.g, $ d=2$ .

Being known that for $ d=1$ , the number of subtrees generated is equal to $ (2n+1)$ and that for $ d=2$ , (cc n 2) initially generates two subtrees, (cc n 1) and (cc n-d 2). To get the total number of steps, I know that we have $ 1 + (n/5) + (..) $ . I’m with doubts as how I can express the rest of the expression, more precisely the number of subtrees generated by (cc n 2) with 1 coin as they are subtracted, until it reaches the limit $ (n/5)$ , being $ 5$ the denomination of the coin when there are two types of coins available.

 (define (count-change amount)    (define (cc amount kinds-of-coins)      (cond ((= amount 0) 1)            ((or (< amount 0) (= kinds-of-coins 0)) 0)            (else (+ (cc (- amount                            (first-denomination kinds-of-coins))                         kinds-of-coins)                     (cc amount                         (- kinds-of-coins 1))))))    (define (first-denomination kinds-of-coins)      (cond ((= kinds-of-coins 1) 1)            ((= kinds-of-coins 2) 5)            ((= kinds-of-coins 3) 10)            ((= kinds-of-coins 4) 25)            ((= kinds-of-coins 5) 50)))    (cc amount 5)) 

Can anyone help? Thank you in advance.

How can i count the total logged in time in PHP?

I need to make a website for school with PHP and in this website i need to count how long a person is logged in.

For example you are logged in for 1 minute and you go to another page then you need to see in the top of the page

Logged in for : 3 minuntes 20 secondes

if you refresh the page or go to another one the time needs to be refreshed and show the total amount of time you are logged in

I searched up allot of things but i couldn’t find what i was looking for.

i tried this

<li>Logged in for : <?php echo $  _SESSION['last_login'] ?? ''; ?></li> 

but it shows a couple of numbers and nothing else

COUNT e SUM com 3 tabelas

Eu estou fazendo um sistema de gerenciamento de TI. Tenho 3 tabelas: computers, offices, office_keys

inserir a descrição da imagem aqui

Exemplo:

offices ______________________________________ id      | 1 version | Home & Business 2016   office_keys _______________________________________ id        | 1 office_id | 1 key       | AAAA-BBBB-CCCC-DDDD-EEEE   computers _______________________________________ id            | 1 name          | DESKTOP office_key_id | 1 

O campo quantity da tabela office_keys representa o número de vezes que aquela chave pode ser usada em computadores (office standard).

Eu quero fazer uma query que traga todas as versões do office, a soma da quantidade das keys (quantity) e soma de quantas chaves estão sendo usada (somente a soma).

Por exemplo:

Se eu tiver 4 chaves de office 2016 e 2 computadores utilizando 2 dessas chaves, ou se eu tiver 3 chaves de office 2013 e 3 computadores utilizando essas 3 chaves, quero receber:

Office   |    Quantidade   |   Em uso 2016     |    4            |   2 2013     |    3            |   3 

Tentei fazer isso:

SELECT DISTINCT offices.id, offices.version, SUM(office_keys.quantity) AS quantity, COUNT(computers.id) AS in_use FROM offices LEFT JOIN office_keys ON office_keys.office_id = offices.id LEFT JOIN computers ON computers.office_key_id = office_keys.id GROUP BY offices.id 

Mas a somas não estão certas por causa das linhas duplicadas.

Como posso resolver isso? Obrigado!

How to query external database for Count from Drupal 8

How do I query the below SQL query to an external database table from Drupal 8 custom module,

Select Count(requestID) FROM requestDB.request where request.dateCreated >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) and ek_borrowerID = 111; 

I have configured the settings.php already. Below is the query I tried to build, but it does not work

Database::setActiveConnection('requestDB'); $  db = Database::getConnection(); $  db->select('request')     ->fields('request', array('Count(requestID)'))     ->condition('dateCreated','DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)', '>=')     ->condition('ek_borrowerID','111')     ->execute(); Database::setActiveConnection(); 

What unforeseen consequences come from allowing corpses to count as creatures?

There have been quite a few questions about corpses and creatures, such as here where it is argued a dead creature is still a creature, here where the opposite is argued, and here where resurrecting an animated corpse is up in the air.

My question however, is if you allow spells, and other features, which target creatures to also target corpses (dead creatures), what are some possibly negative or game-ending/breaking effects that would occur from this houserule?

What unforeseen consequences come from allowing corpses to count as creatures?

There have been quite a few questions about corpses and creatures, such as here where it is argued a dead creature is still a creature, here where the opposite is argued, and here where resurrecting an animated corpse is up in the air.

My question however, is if you allow spells, and other features, which target creatures to also target corpses (dead creatures), what are some possibly negative or game-ending/breaking effects that would occur from this houserule?

any path of graph,say (a,b) (a to b) intersects a given path (x,y) at exactly one node.Then, count no. of total possible (a,b)

Let’s denote the sets of vertices in the paths (u,v) and (a,b) by S1 and S2 respectively (a path contains its endpoints too). The path (a,b) intersects perfectly with (u,v) if |S1∩S2|=1, i.e. these paths have exactly one common vertex.

For example in the given graph1]1, let (x,y) = (4,5) and now consider (a,b) as any path of the graph, say (a,b) = (1,3) So, S1 = {4, 1, 2, 5} and S2 = {1, 3} So, S1∩S2 = {1} => |S1∩S2|=1 so for (x,y): all possible (a,b) of the graph will be (4,4),(1,1),(2,2),(5,5),(1,3),(2,6) so the answer will be 6 for (x,y) = (4,5)

So, is there any efficient way to find.

Result count mismatch on search api autocomplete

We are using search api module and search api solr as databse server. We created result page using views and it has expose form. And in the expose form, we enable autocomplete.

The problem is we search search with a word e.g. ‘performance‘, in autocomplete it is suggesting two result ‘performance,‘ with 25 count and ‘performance.‘ with 11 count and when I select one of this and do the search, it’s showing total 41 result. So here is confusing, if ignore the special chars like ‘,’ and ‘.’ here and make the merge, it will become 36 which is not same as total count.

Note: I am doing fulltext search and configured same field in views and autocomplete.

So am I missing anything there or is there any issue? Or is this way it work, it will be big help if anyone could explain here?

Let me know if you need more information.

count all possible paths of length n in an undirected graph with dynamic programming

Given is an infinitely large grid graph. Use dynamic programming to calculate the number of possible paths of a given length n from a given start node, so that fjor every path applies: a) no vertex may be visited twice within it and b) never to go down an edge example of lattice graph for paths of length 2

I found out, that the number of possible paths corresponds to the row sums of the binomial coefficent, times 2 minus the center row, but if n is bigger than 3 other paths emerge which I struggle to include in my dynamic programming solution