Here traffic api closed roads - traffic

I am searching for the latitude/longitude of closed roads.
If I use http://traffic.cit.api.here.com/traffic/6.0/incidents.json?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&quadkey=12020330
I get all warnings with geolocations and flag if the road is closed... but
these geolocations are not precise. On here maps you can see the black lines(the closed roads)
I only need these latitudes/longitudes (of the vertex or only inside of the street and the direction).
At the moment I think the only way to get these coordinates is to ask for the closed roads and get pictures of these areas. And with these pictures we can calculate the geolocation.
But to check all pictures of all closed roads is computationally intensive.
does somebody have a better idea?
Thanks a lot!

The flow endpoint as described here supports an additional responseattributes parameter, this can add the shape and functional class of the road in question. e.g.
http://traffic.cit.api.here.com/traffic/6.1/flow.json?quadkey=QUADKEY&responseattributes=sh,fc&app_id=XXX&app_code=YYY&minjamfactor=7
The incidents endpoint returns data in an industry standard Traffic_message_channel format - this is designed to minimize data sent and therefore does not give exact locations.
http://traffic.cit.api.here.com/traffic/6.0/incidents.json?app_id=XXX&app_code=YYY&bbox=LAT,LNG;LAT,LNG&criticality=critical
Try combining data from them both to get complete traffic information - i.e. road shapes and incident data. I guess for closed roads you are looking at a minjamfactor=7 or greater.

Related

Algorithm to visit 1 node from each group

Example
A intergalactic space explorer wants to visit one planet from each solar system.
The travel time between solar systems is different dependent on what planet you travel from/to due to different technologies. It may be quicker to travel to another planet in the current solar system to catch a transfer. The explorer has to travel to at least one planet from each solar system.
Here is a graphic example
In the graphic we will need to visit at least one from each colour, and can begin/end anywhere. Is there an algorithm to complete this? It's similar to Dijkstra but not quite. I currently have my data in Neo4j but am able to change this.
From the graphic example I can see how to navigate the network but the real life example has close to 1000 groupings and each group has at least 8 nodes.

Designing an algorithm that keeps traffic equally distributed over a network

My question isn't related to how to code a particular thing or any technical programming question. I need help in developing a logic of an algorithm that I am working on which I will be explaining in a bit. I am here because I couldnt think of a better place than stackoverflow to help me out as it has proved the best option in the past. I would like to thank you guys for helping your me out and giving me your precious time.
So here goes my brain teasing algorithm:
Aim :
I am developing an algorithm that aims to equally distribute traffic(cars) over a network. I will be simulating this algorithm to check how it works on some traffic simulator.
To put it visually what I am planning to do I have included this image:
Plotting the traffic network which shows that some roads are populated than the others. Thicker lines indicate roads that have more traffic as compared to others.**
Here are some points to note :
The image represents 8*8 junctions(intersection of roads) and the roads themselves. Not good with my graphic skills so just wanted to make clear that 4 roads meet up to make a junction(not clearly shown in diagram, but you get what I mean).
Notice the directed arrows, those indicate the direction in which the traffic will be moving. For example, the first row indicates the traffic will be moving from right to left. Second row indicates the traffic will move from left to right. Similary, the first column represents that traffic will more from bottom to top etc. If you observe closely, you will notice that I have kept an alternate pattern ie. right to left,then left to right, then again right to left etc. Similar is the case for columns.
No turning of vehicles is allowed. Since, this is the initial stages of my algorithm I have put a restriction that vehicles are not allowed to turn and continue in the direction of the arrow.
This is a loop-around type network. Meaning, the cars after reaching the extremes of the network do not vanish away, they loop around and are fed again into the network. Keep in mind, the cars are fed in the direction of arrow. For example in first row, after the cars leave from the left-most junction, the cars will join in again into the right-most junction. Simply to say, it is some sort of wrapping around or mesh kind of thing.
The traffic is created randomly and as the image suggests thicker the lines, the more traffic on that road and vice-versa.
Important: When at a junction, if we are to allow cars to pass from left to right (horizontally) all the cars moving in vertical direction will have to be stopped (obvious so that they don't crash into each other) and vice-versa.
What I need help in:
Pseudocode/Logic for the algorithm which allows me to equally distribute the traffic in the network (graphically lines of almost the same thickness as per my image). Mathematically, the thickness of the line will be average number of cars that should be on each road so that the whole network is balanced. Roads, should be equally populated, no road should have more traffic than the other (fairness policy).
I wanted to solve the problem using a divide and conquer approach. Meaning, in real world the network will be very big so it is almost impossible to have the information of the whole network with us at any given moment of time.
I want to solve the problems locally and round-wise.
For example, Round 1: Solve 4 junctions at a time and try to equalize the traffic at them.
Round 2: Some other 4 junctions
and so on...
Tip: The effect should propagate as the rounds advances reaching to some optimal solution where the traffic is equally distributed and then we stop the algorithm.
I know this is a long post and I really appreciate anyone who even tried to understand my objective and gave a thought about it.
This idea popped into my head giving because of the growing traffic situations and that there are some roads that are less populated than the others and so equally distribute the cars and take more advantage of the available infrastructure.

Sort POIs by distance from current location

Trover is an awesome app: it shows you a stream of discoveries (POIs) people have uploaded - sorted by the distance from any location you specify (usually your current location). The further you scroll through the feed, the farther away the displayed discoveries are. An indicator tells you quite accurately how far the currently shown discoveries are (see screenshots on Website).
This is different from most other location based apps that deliver their results (POIs) based on fixed regions (e.g. give me all Pizzerias withing a 10km radius) which can be implemented using a single spacial datastructure (or an SQL engine supporting spatial data types). Deliverying the results the way Trover does is considerably harder:
You can query POIs for arbitrary locations. Give Trover a location in the far East of Russia and it will deliver discoveries where the first one is 2000km away and continuously increasing from there.
The result list of POIs is not limited by some spatial range. If you scroll long enough through the feed you will probably see discoveries which are on the other side of the globe.
The above points require a semi-strict ordering of their POIs for any location. The fact that you can scroll down and reload more discoveries implies that they can deliver specific sections of the sorted data (e.g. give me the next 20 discoveries that are at least 100km away from my current location).
It's fast, the fetching and distance indications are instant. The discoveries must be pre-sorted. I don't know how many discoveries they have in their DB but it must be more than what you want to sort ad hoc.
I find these characteristics quite remarkable and wonder how this is implemented. Any suggestions what kind of data-structure, algorithms or caching might be used?
I don't get the question. What do want an answer to?
Edit:
They might use a graph-database where one edge represent the distance between the nodes. That way you can get the distance by the relationships of nearby POIs. You would calculate the distance and create edges to nearby nodes. To get the distance of an arbitrary point you just do a circle-distance calculation, for another node you just add up the edges value as they represent the distance (this is for the case of getting the walking,biking, or car calculation). The adding up might not be the closest way but will give a relative indication which it seems like they use.

Is the stackoverflow community a scale-free or a small world network?

I am a graph/network enthusiast and this just for my curiosity :)
I am trying to model the StackOverflow community as a graph/network. Assume that the people in the SO community are nodes and that the answers given to any of the question establishes a relationship between these nodes. The relationship can be assumed to be directed(link from answer -> question) or undirected. The graph could be weighted and that the weights of the nodes could represented number of vote-ups/downs (normalized on the scale of 0 to 1).
What kind of graph/network does one end up with at any given snapshot of time? Is it scale-free? Is it a small-world? The graph is continuously evolving over a period of time and i would like to understand its structure and dynamics.
Is there a way where can i retrieve this relationship data from - may be SO APIs or some one from SO can help me out with (sample) data?
Clarification edit:
Scale-free network: A network whose degree distribution asymptotically follows a power law Small-world: A network that has sub-networks characterized by presence of connections between almost any two nodes within them and most pairs of nodes are connected by at least one short path.
To the second part of your question:
Is there a way where can i retrieve
this relationship data from - may be
SO APIs or some one from SO can help
me out with (sample) data?
Try these questions instead. There are a lot of plans to implement an API to access SO data. Some things are in change, but there are possibilities to screen-scrape the data or access them via JSON (afaik).
Is there a guide to accessing StackOverflow data programmatically?
What would you want to see in a StackOverflow API?
Are there plans for a StackOverflow API?
Try it out. Good luck!
What kind of graph/network does one end up with at any given snapshot of time? Is it scale-free? Is it a small-world? The graph is continuously evolving over a period of time and i would like to understand its structure and dynamics.
It takes only a few links between remote clusters to turn a random network into a small world one, so it's quite likely to be small world.
As to whether it's scale free, that would require there to be a few posters with lots of answers and many with only one or two. I seem to recall Jeff saying that there were lots with only one question in one of the pod-casts; you might be better off asking the question there rather than here, as he will have the data.

Datastructure for googlemap like application?

I am doing a maprouting application. Several people have suggested me, that I do a datastructure where I split the map in a grid. In theory it sounds really good, but I am not to sure because of the bad performance I get when I implement it.
In the worst case you have to draw every road. If you divide the map in a grid, the sum of roads in all the cells in the grid, will be much larger than if you put all roads in a list.(each cell must have more roads than actually needed if a road goes through it).
If I have to zoom in I can see some smartness in using a grid, but if I keep it in a list I can just decrease the numbers of roads each time I zoom in.
As it is now(by using the list) it is not really fast, so I am all for making it faster. But in practice dividing in a grid makes it slower for me.
Any suggestigion for what datastructure I should be using and/or what I might be doing wrong?
See this question for related information:
What algorithms compute directions from point A to point B on a map?
Somebody who writes this kind of software for a living has answered it.
Also for rendering see:
What is the best way to read, represent and render map data?
I'm not quite sure if you're trying to do routing quick or rendering!
If you want it to go quick, you might be better off organizing your roads in to major and minor roads.
Use the list of minor roads to find a route to the nearest major road.
Use the major roads to get you near the destination.
Then go back to the minor roads to complete the route.
Without a split like this, there are a heck of a lot of roads to search, most of which are quite slow routes.
google does not draw each road every time the screen is refreshed. They used pre-drawn tiles of the map. They can redraw them as needed. e.g. when there is a map update. They even use transparent overlays, stacks of tiles to add and remove layers of details.
Very clever, but very simple.
You may want to look at openlayers javascript library. Free and can do just about anything you need to do with a map.
Maptraction JS is also available - its not as complete as OpenLayers
More optimal then using a grid as your spatial data structure, might be a quadtree because it logarithmically breaks down the map. And from studying the source, my guesstimate is that google uses (that or) a similar data structure.
As for getting directions, you might want to look in to hierarchical path finding to approximate the direction at first and to speed up the process; generic path finding algorithms tend to be quite slow at that level of complexity.

Resources