I want to plot lines between (distant) points on an Openlayers 3 map (which uses Open Street Map tiles). I want the lines to be seen as curves, as with flight paths, since they should take the shortest real world surface path: a geodesic (a great circle segment).
Is this possible?
Would I need to interpolate the points along the geodesic (how?) and plot a bunch of line segments, or is there an easier way? Is there something built in I can't find, or a library for it?
Looking at OL3's Flight Animation Example, it appears to be possible using the arc.js plugin: “A great circle arc between two airports is calculated using arc.js and then the flight paths are animated with postcompose. The flight data is provided by OpenFlights (a simplified data set from the Mapbox.js documentation is used).”
Related
Using Emgu CV I have extracted a set of closed polygons from the contours in an image of a road network. The polygons represent road outlines. The result is shown below, plotted over an OpenStreetMaps map (the polygons in 'pixel' form from Emgu CV have been converted to latitude/longitude form to be plotted).
Set of polygons representing road outlines:
I would now like to compute the Voronoi diagram of this set of polygons, which will help me find the centerline of the road. But in Emgu CV I can only find a way to get the Voronoi diagram of a set of points. This is done by finding the Delaunay triangulation of the set of points (using the Subdiv2D class) and then computing the voronoi facets with GetVoronoiFacets.
I have tried computing the Voronoi diagram of the points defined by all the polygons in the set (each polygon is a list of points), but this gives me an extremely complicated Voronoi diagram, as one might expect:
Voronoi diagram of set of points:
This image shows a smaller portion of the first picture (for clarity, since it is so convoluted). Indeed some of the lines in the diagram seem to represent the road centerline, but there are so many other lines, it will be tough to find a criterion to extract the "good" lines.
Another potential problem that I am facing is that, as you should be able to tell from the first picture, some polygons are in the interior of others, so we are not in the standard situation of a set of disjoint closed polygons. That is, sometimes the road is between the outer boundary of one polygon and the inner boundary of another.
I'm looking for suggestions as to how to compute the Voronoi graph of the set of polygons using Emgu CV (or Open CV), hopefully overcoming this second problem I've outlined as well. I'm also open to other suggestions for how to acheive this without using Emgu CV.
If you already have polygons, you can try computing the Straight Skeleton.
I haven't tried it, but CGAL has an implementation. Note that this particular function license is GPL.
A possible issue may be:
The current version of this CGAL package can only construct the
straight skeleton in the interior of a simple polygon with holes, that
is it doesn't handle general polygonal figures in the plane.
Probably there are workarounds for that. For example you can include all polygons in a bigger rectangle (this way the original polygons will be holes of the new rectangle). This may not work well if the original polygons have holes. To solve that, you could execute the algorithm for each polygon with holes and then put all polygons in a rectangle, removing all holes and execute the algorithm again.
I'd like to implement Measure functionality on openstreet map. Measure is adding two points on a map and find the distance between those points.
For that I referred https://github.com/danstowell/openstreetmap-website/commits/jsrouting-contextmenu
It will work fine except water area/region on openstreet map. In my case I am rendering my own maps on my project, so this is not work for me.
I am using below Environment:
Environment : Rails 4 and Ruby 2
Anyone know about it?
How do I implement measure functionality on my map?
Is there any other ways to implement this?
Not sure on the specifics relating to OSM, however assuming that you can convert the points to geodetic points then you can use the haversine or vincenty formulas to get the great circle distance:
http://www.movable-type.co.uk/scripts/latlong.html
OSM uses a spherical Mercator projection. If all you have are 2d Cartesian (projected) coordinates then you will need to convert these to geodetic coordinates.
If you also need to take into account terrain then this gets more complex but maybe OSM provides something for this that gives heights along a transect line.
I'm looking for a way to detect if a set of points/coordinates have any intersecting lines.
A little setup, I'm drawing a polygon using UIBezierPath on an overlay to a map. This all works. I'm able to reduce the map points down using a point reducing algorithm, and I'm left with a simple looking polygon that renders on my map just fine. FWIW, I'm using Google Maps SDK.
My problem is that it is possible for the user to draw a polygon with self intersecting lines (which is a problem for what I am doing). I need to be able to do one of 3 things.
Remove the intersecting points in the array. (Clip off the bow tie pieces)
Detect if my points have this bow tie (I'll just tell them to redraw a new polygon)
If possible (which I don't think it is), prevent the path from drawing the bow tie in the first place.
I mostly see the bow tie when the polygon self closes and the end point is slightly underlapping the start point. So when the polygon closes and renders into map coordinates on the map, I get a tiny bow tie that messes with an internal API.
Is there anything out there that will work using map coordinates? I've seen some fixes for regular CGPoints, but nothing that will take map coordinates. I would prefer to do this check on my polygon after it has gone through my reducer as it leaves many less points to check. Performance is an issue, and would prefer not to iterate over hundreds of points directly coming off the UIBezierPath. Any help would be appreciated.
I don't know about the Google Maps SDK or the UIBezierPath. I assume that you are given a polygon in the 2D plane and you would like to automatically detect where the polygon intersects itself (if it does).
Perhaps the easiest way to do this is checking all pairs of edges whether they intersect or not. You can check this in O(n2) time where n is the number of edges, as there are n*(n-1)/2 pairs of edges. For a given pair of edges, here are the details how to do it:
How to check if two given line segments intersect?
Nothing extraordinary but the details do require attention.
A more sophisticated algorithm is the plane sweep algorithm:
Line segment intersection, starting at slide 25
Line Segment Intersection Using a Sweep Line Algorithm
I want to have a pac-man like game where the characters can move only in a certain path, preferably, with the option to have curved paths as well. What's the correct way to achieve that?
You can use splines to model this. The levels would be made up by a set of 2d-points and each player/bot would always be on his way from one point to another. Splines also handle curved paths.
In games Catmull-Rom splines are often used. If you google Catmull-Rom splines you can find theory, pseudo code or implementation of Catmull-Rom in just about any language.
I want to start a project that uses a very basic form of optical music recognition.
For those who understand sheet music: Unlike other OMR projects, the only information which needs to be extracted is the order and pitch values of each note in a bar. Quarter notes, half notes and whole notes need to be distinguished. Shorter notes can acceptably be interpreted as quarter notes. Dots on notes can be ignored. Dynamics markings are not important
For everyone: Strictly speaking I need to find the locations of each of the following...
... in a sample image like this...
I have no experience in image processing so a basic, conceptual explanation of what technique or set of techniques are used to achieve this would be greatly appreciated.
I would do the following:
Extract the line locations using Hough transform. (You get the angle as well). Crop each group of lines (5 lines), and process individually.
For each group of lines, you know the angle of the lines, so you can get the locations of the vertical small lines that separate the bars. Search again in Hough space, but with specific angle. (The original + 90). Crop each bar and process individually.
For each bar, use template matching on the possible notes (Quarter, Half,etc..)
I did something similar to your work and trust me it is a complete mess.
Howeverr, for the pitch for each note you extract the head from the rest and calculate the baricentre and compare its position to the position of lines calculated with Hough transform as already said (assuming that the lines are already straight: if not i think you can use the Fourier Transform).
For the duration you need a classification algorithm.