How do I count the total number of times a node appears is a collection of ways? - openstreetmap

This query returns all of the vehicle roadways in a certain bounding box (bbox):
"""
nwr["highway"="(motorway|trunk|primary|secondary|tertiary|(motorway|trunk|primary|secondary)_link)"]({{bbox}});out geom;
"""
Each Way is a collection of nodes. I would like to aggregate the total count of each Node across all Ways and Relations. I would presume that any Node with more than 1 count is an intersection between two distinct vehicle roads. What is the Overpass QL query for this?
Thanks!

Related

What is the best way to query for locations between two concentric circles via Overpass query?

The difference between two sets, obtained using two around queries - is this the right approach?
nw(around:20000,15.8433,74.4969)->.small;
nw(around:60000,15.8433,74.4969)->.big;
(area.big; - area.small;)->.mid;
(
nw[tourism=attraction](area.mid);
nw[historic=memorial](area.mid);
nw[amenity=place_of_worship](area.mid);
nw[water=lake](area.mid);
);
out geom;
Basically, I need tourist locations between 20 and 60 km from a certain place.
I tried using difference between result set of 'around' clause.
I am not sure if my approach is right and efficient.

to group my results by varying distances from an object

I created a successful query that counts the number of objects + average the prices of the counted objects. the query looks like this:
select count (product_id), avg (price)
from current_table
Now, I want to group the results by DISTANCE column that is already exist in the table BUT IN PARTICULAR DISTANCE GROUPING like this:
groups of 0-10 km, 10-20 km, 20-30 km etc. lets say about 10 different distance groups.
How can I do it?
thanks!!!!

Algolia search only by distance

Is it possible to rank search results based solely on proximity (and other filters) to a specific point and ignore the custom ranking formula (likes)?
For example, I'd like to rank results closest to times square strictly by distance and for the query to not care about the likes attribute.
I suppose the likes attributes is one of you own.
You can do what you need by removing the attribute like from the custom ranking.
If you need 2 way to search, you can do a replica index, with the same data but a different ranking formula: https://www.algolia.com/doc/guides/ranking/sorting/?language=go#multiple-sorting-strategies-for-an-index

Complex SELECT in Tarantool

There is two spaces, named e.g. Company and Cars. Space Company has company id (primary index) and geolocation (point) fields (secondary index). Space Cars has car (primary index) and companies (array of all companies where this car can be rented). I need to get top 10 Companies in specified rectangle where specific car can be rented. What is the (if I can say so) best solution to achieving this?
Here I need to combine spatial and non-spatial indexes in order to get result. My search plan is to look for car tuple and get all companies (there may be 1000 of them), and then in another space to filter 10 of the within specified rectangle.
My use case is something similar to this (not rent-a-car use case), but all logic is same. There will be much more Companies than cars (millions of Companies and 300-500k of Cars). How to optimize my plan in order to get these infos, what indexes to use, etc.? There need to be spatial and non-spatial conditions for one select, as you see.
I think the best strategy for this type of index would be to map your cars to points in another dimension, sufficiently far apart from each other. E.g. if your typical search is within a few square kilometers, make sure each car "coordinate" is at least a few dozen kilometers away from the nearest neighbour car. Then you can use our multi-dimensional RTREE index for the search.

Database solution to store and aggregate vectors?

I'm looking for a way to solve a data storage problem for a project.
The Data:
We have a batch process that generates 6000 vectors of size 3000 each daily. Each element in the vectors is a DOUBLE. For each of the vectors, we also generate tags like "Country", "Sector", "Asset Type" and so on (It's financial data).
The Queries:
What we want to be able to do is see aggregates by tag of each of these vectors. So for example if we want to see the vectors by sector, we want to get back a response that gives us all the unique sectors and a 3000x1 vector that is the sum of all the vectors of each element tagged by that sector.
What we've tried:
It's easy enough to implement a normalized star schema with 2 tables, one with the tagging information and an ID and a second table that has "VectorDate, ID, ElementNumber, Value" which will have a row to represent each element for each vector. Unfortunately, given the size of the data, it means we add 18 million records to this second table daily. And since our queries need to read (and add up) all 18 million of these records, it's not the most efficient of operations when it comes to disk reads.
Sample query:
SELECT T1.country, T2.ElementNumber, SUM(T2.Value)
FROM T1 INNER JOIN T2 ON T1.ID=T2.ID
WHERE VectorDate = 20140101
GROUP BY T1.country, T2.ElementNumber
I've looked into NoSQL solutions (which I don't have experience with) but seen that some, like MongoDB allow for storing entire vectors as part of a single document - but I'm unsure if they would allow aggregations like we're trying efficiently (adding each element of the vector in a document to the corresponding element of other documents' vectors). I read the $unwind operation required isn't that efficient either?
It would be great if someone could point me in the direction of a database solution that can help us solve our problem efficiently.
Thanks!