I have been trying to reconcile the coordinates returned by the matching geometry and the nodes in each leg when doing a match call with annotations=true overview=full and geometries=geojson.
I would like to understand how to align the node IDs with the lat/lon of a coordinate geometry.
My understanding is that there is a 1:1 mapping between the coordinates and the nodes in the legs.
I have tried "simplifying" the node IDs returned in the annotations by doing the following:
Append the first leg annotations to your result.
Repeat the following for each extra leg:
a. Trim the first two nodes from the start of the next leg annotation to append
b. Append the trimmed leg annotation to your result
Then I remove the locations returned by the waypoints from the coordinates in the geometry. After, I try to line up the simplified node IDs with the remaining coordinates. However, this method end up with a couple (and sometimes a few) extra points which we aren't able to explain or figure out how to filter out.
Anyone have a more reliable method for solving this? Appreciate all the help. Thanks!
Related
Hi all im a newbie to the qgis and pyqgis, as i mentioned in the question i have two condtions:
Condition 1:
I want result something like this
condition 2:
i want something like this
Basically i want to match the edge of two shapefiles i tried creating start point and endpoint and shortest line between them but it didn't help me.
I will be thankful if anyone guide me how to solve this . Thank You
My English is not very good, but I can provide the idea of what I did before
Algorithms require you to write your own
The line is actually composed of several points
So you need to find the head and tail coordinates of the line is a list[0] and list[-1]
You need to write code to calculate the distance between two coordinates and change the coordinates of the line attributes
Iterate over each coordinate using the coordinates of list[0] and list[-1]
Assuming that the coordinates of list[0] and line B are the closest, modify the coordinates of lineB to list[0]
Finally, some parts need to be corrected. For example, you need to exclude the coordinate comparison with the other end of the line.
Hope it helps you
So i need to create a border mesh from 2 different pointsets that have their own length. The "mesh" needs to be a list of polygons that are sorted clockwise, the polygons can contain any number of points.
image of problem
I used to do this by looping through the points in the outer set, and for each point I would connect it to the closest point of the inner set. After that I would make faces with 4 points out of the lines I made. This worked perfectly.
But now we run into the problem that the outer point set no longer has the same length as the inner set. So our current approach will no longer work.
if someone could help me in the right direction or with an example on how to achieve this that would be greatly appreciated
Using OSRM API, I found the coordinates of the intersections along a route.
I want to know what are the corresponding node IDs.
Is there any API to find the node IDS from the coordinate points?
Is there any API to find the node IDS from the coordinate points?
Yes. You need to pass annotations=nodes as additional query parameter. routes[i].legs[j].annotations.nodes will be an array of OSM IDs that you can use to link the data with OSM.
Linking this to the coordinates in the step is a little bit complicated: You would need to concatenate all RouteStep.geometry and remove the duplicated coordinates (steps[i].geometry[-1] == steps[i+1].geometry[0]).
I would like to find all highway way member nodes in a certain radius. I cannot see how to do this without using intersection, however, that is not in the API. For example I have this:
[out:json];
way(around:25, 50.61193,-4.68711)["highway"];>->.a;
(node(around:25, 50.61193,-4.68711) - .a);
out;
Result set .a contains the nodes I want but also nodes outside the radius - potentially a large number if the ways are long. I can find all the nodes inside the radius I don't need, as returned by the complete query above. Now I can always perform a second around query and do the intersection of the two result sets outside of Overpass. Or I can do another difference:
[out:json];
way(around:25, 50.61193,-4.68711)["highway"];>->.a;
(node(around:25, 50.61193,-4.68711) - .a)->.b;
(node(around:25, 50.61193,-4.68711) - .b);
out;
This gives the result I want but can it be simplified? I'm certain I'm missing something here.
Indeed, your query can be simplified to an extent that we don't need any difference operator at all. I would recommend the following approach:
We first query for all nodes around a certain lat/lon position and a given radius.
Based on this set of nodes we determine all ways, which contain some of the previously found nodes (-> Hint: that's why we don't need any kind of intersection or difference!).
Using our set of highway ways we now look again for all nodes of those ways within a certain radius of our lat/lon position.
In Overpass QL this reads like:
[out:json];
node(around:25, 50.61193,-4.68711);
way(bn)[highway];
node(w)(around:25, 50.61193,-4.68711);
out;
Try it on Overpass Turbo
I have a table that contains a bunch of Earth coordinates (latitude/longitude) and associated radii. I also have a table containing a bunch of points that I want to match with those circles, and vice versa. Both are dynamic; that is, a new circle or a new point can be added or deleted at any time. When either is added, I want to be able to match the new circle or point with all applicable points or circles, respectively.
I currently have a PostgreSQL module containing a C function to find the distance between two points on earth given their coordinates, and it seems to work. The problem is scalability. In order for it to do its thing, the function currently has to scan the whole table and do some trigonometric calculations against each row. Both tables are indexed by latitude and longitude, but the function can't use them. It has to do its thing before we know whether the two things match. New information may be posted as often as several times a second, and checking every point every time is starting to become quite unwieldy.
I've looked at PostgreSQL's geometric types, but they seem more suited to rectangular coordinates than to points on a sphere.
How can I arrange/optimize/filter/precalculate this data to make the matching faster and lighten the load?
You haven't mentioned PostGIS - why have you ruled that out as a possibility?
http://postgis.refractions.net/documentation/manual-2.0/PostGIS_Special_Functions_Index.html#PostGIS_GeographyFunctions
Thinking out loud a bit here... you have a point (lat/long) and a radius, and you want to find all extisting point-radii combinations that may overlap? (or some thing like that...)
Seems you might be able to store a few more bits of information Along with those numbers that could help you rule out others that are nowhere close during your query... This might avoid a lot of trig operations.
Example, with point x,y and radius r, you could easily calculate a range a feasible lat/long (squarish area) that could be used to help rule it out if needless calculations against another point.
You could then store the max and min lat and long along with that point in the database. Then, before running your trig on every row, you could Filter your results to eliminate points obviously out of bounds.
If I undestand you correctly then my first idea would be to cache some data and eliminate most of the checking.
Like imagine your circle is actually a box and it has 4 sides
you could store the base coordinates of those lines much like you have lines (a mesh) on a real map. So you store east, west, north, south edge of each circle
If you get your coordinate and its outside of that box you can be sure it won't be inside the circle either since the box is bigger than the circle.
If it isn't then you have to check like you do now. But I guess you can eliminate most of the steps already.