I am working with the Android project. I want to draw the route between two points which is showed public transport routes like bus and train, not the shortest route. I am using google direction API and google map API.
I want to just make it like google map where they show the suggestion of bus and times like this when we choose locations.
is there any special API for public transport route?
you can use mode parameter in directions api like this
https://maps.googleapis.com/maps/api/directions/json?
origin=place_id:ChIJ685WIFYViEgRHlHvBbiD5nE
&destination=place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y
&mode=transit
&key=YOUR_API_KEY
Travel Modes When you calculate directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. The following travel modes are supported:
driving (default) indicates standard driving directions using the
road network.
walking requests walking directions via pedestrian paths &
sidewalks (where available).
bicycling requests bicycling directions via bicycle paths &
preferred streets (where available).
transit requests directions via public transit routes (where
available). If you set the mode to transit, you can optionally
specify either a departure_time or an arrival_time. If neither time
is specified, the departure_time defaults to now (that is, the
departure time defaults to the current time). You can also optionally
include a transit_mode and/or a transit_routing_preference.
Related
I am trying to do modeling using Anylogic pedestrian library where an agent (A) will communicate with another agent (B) only if the other agent is within certain vision angles and arc radius of A. The conventional way of communication is to define certain distance based communication where the distance defined forms a sphere around the agent. But I want to model that the agent will not be able to communicate with other agents who are not within his vision angle (like a conical projection & certain distance). For example, the agent should not be able to communicate with others who are behind him. How I can do this?
Also, I am trying to model individual agents behavior (those abovementioned pedestrian agents) through agents statechart. Unfortunately, agent states aren't changing based on communication in my model. Is it due to using pedestrian library? Can we model pedestrian agents behaviour by statechart?
It would be a great help if someone can answer those questions.
you can use just a polygonal node or area and use it like this:
if you want to evaluate if a pedestrian or agent is in the field of vision, you need to get x and y for that agent and do:
if(fieldOfVision.contains(x,y))
//communicate with that dude
I was building a prototype of vehicle routing application using google maps and optaplanner. I change the distance based scoring to duration based scoring, where the duration value was calculated using distance / avg speed of vehicle.
Now I want to add traffic jam variable into my application. The traffic jam variable was implemented as additional duration value from the current location to another location (I using a map of location and double just like distance variable in RoadLocation class). When I tried it to run it, the result was always same with the previous one. Here is the result from the first run :
I draw some red line to represent the traffic jam, and then try to re-run the solving phase. Here is the second result:
The result was the same with the previous one. My questions is, what the best method to apply the traffic jam variable into vehicle routing problem? Does anyone has any experience adding this variable? Any comment and suggestion will be appreciated.
Thanks and regards.
This paragraph is just an introduction. If you wanna skip it, do it. ;-)
I have implemented a similar approach with traffic jams, but it was not a real-time system. The solution runs every X minutes, which is absolutely fine.
That gave me the benefit for pre-calculating the ways and routes for the complete road network, before the actual optaPlanner calculation starts.
This saves time for the real calculation of optaPlanner.
The network consists of vertexes and arcs. For each arc you'll have a weight.
Here starts the real deal for you.
Let's assume that you implement a Dijkstra or A-Star algorithm for the precalculation step for all places and how to get there. These way finding algorithm is seleting the arc with the lowest "travelling" costs. For each arc/road, which would be blocked, we assume a distance of DOUBLE.MAX_VALUE. This value can be interpreted as "not driveable" or drastically said: This connection between two vertexes even doesn't exist for the current solution finding process. So the way finding algorithm will simply skip this road. For every driveable road, we calculate the real costs, e.g. distance or take an approximation out of experience.
The optaplanner process itself just uses the precalculated way finding mechanism, e.g. compares the calculated distances for getting from place A to place B.
For setting the distance variable to DOUBLE.MAX_VALUE you can decide between user based information, information of other providers like google or admin based rules. As my experience goes along with user based content vs. admin based actions, I can recommend both ways.
Let's discuss the user based action: The user can have the same set of GUI actions as the admin for flagging a way as "jammed". For the next optaPlanner iteration the flag is going to be involved. If you have GPS data of your users you can get the approximate velocity. For each intervall of the GPS measurement you can calculate that velocity. If the velocity is on a road (not a crossing), and below a defined minimum velocity (let's say 1mph or 2 kmh), then you can ask the user if it's a traffic jam or not via popup OR block that road automatically without asking the user. If you chose the popup dialog then a lot of different users have to vote "yes" within a defined time slot, e.g. half an hour, then the road get's blocked. You can resolve the traffic jam, when a lot of users drive the road again and send the GPS coordinates of that road.
The main advantage of the automatic approach is, that you'll have a system based approach with a low error rate.
If you take the manual approach via admin, then you have to take care of implementing a GUI for displaying the roads and enabling/disabling the blocked attribute for a road.
I'm developing an Android app, but I'm not sure how to do the next thing: there is one biking route that we've chosen. The users should get directions for continuing along this biking road.
So Google Directions should stay on my route and not choose a road that is not within my route to get to the end of the biking road.
Any idea how this could be done?
If I understand you right, you wanna have a route from Google Directions, which should match your determined route.
Well, it could be hard to manage that because Directions is designed to find the shortest path between two points. One way is to use the option of waypoints, to limit the suggestions of the API. Simple said, don't use just a origin and a destination. Use as much waypoints as you have to between the origin and the destination to get the nearest route possible.
Getting the exact route as you think of it is just big luck.
I would like to develop an Android application that allows users (pedestrians) to follow an automatically generated route.
Users would specify how far they wish to walk, whether they must return to their stating position, avoid hills, dangerous roads, not cross any roads, how fast they walk on avergae, etc.
i have been searching for a java based library or service that generates a route but have failed.
can anyone recommend a java library that will automatically generate a route?
Interesting idea. I've never seen any library or available implementation that matches your requirements exactly. What you are attempting to do, though, is basic route optimization.
Look at some combination of the google directions API (https://developers.google.com/maps/documentation/directions/) and a set of pre-defined (that you set up) waypoints around the city. The waypoints represent nodes in your "graph" and the edges are routes between them. Waypoints have coordinates so you can map them. Then you assign weight (preference) to each edge and use google to calculate the distance between the waypoints. Extract the routes that match your distance preference and then pick the one with the best "weight" preference.
I'm new to Android development and am creating an app that allows a User to create a Geo fence around a specific location for reminders. For example: Making a geofence around a grocery store to remind the user as he enters to pick up Orange Juice.
Does anyone know of a tutorial that could help in developing something like this?
AFAIK there are no tutorials for geofencing, but it's pretty simple (assuming you want a circular fence).
This tutorial will tell you how to get the user's location
Any of these links will show you how to calculate the distance between their current location and the centerpoint for their fence
Calculate their distance from the center at regular intervals. I'd let them set the interval through a settings screen and start with a default around five minutes because anything more than that is a hefty battery drain. Store that distance every time you get it.
If their last distance compared to their new distance crosses the boundary, perform your action. For instance, I worked on an app that would alert a parent if the child left a friend's house or arrived at school.
An new API called Proxim.io was recently developed that serves your purpose. The website is www.proxim.io. Here is a quote from the developer documentation:
Proxim.io is a platform for delivering relevant messages to your application users. Messages that are delivered based on real-time location, topics of interest, and geo-triggers. Messages can be delivered to a device via Push, or can be routed to a software system through an API (Web Events).