How declare Estimote array for many beacons - estimote

I see this question Estimote: detecting multiple beacons with ESTBeaconRegion and startRangingBeaconsInRegion?
I try that answer provided but when I made three regions (eg: from that sample code beacon1Region, beacon2Region, beacon3Region) and include that "EstimoteSampleRegion" for each (eg: EstimoteSampleRegion1, EstimoteSampleRegion2, EstimoteSampleRegion3) I can only get first beacon as result (in index 0) when I startRangingBeaconsInRegion.
How can I make this to work? should I list that three estimote sample regions in one array that is all for a single region (eg: "beaconRegion") and then look in that single region for the three beacons with [self.beaconManager startRangingBeaconsInRegion:beaconRegion]?
If yes, what is code that show declare that array with many beacons for one region?
Or should I make three beaconManager Instances and each beacons has its own region? Problem when I do this is I can only see first beacon. not three.

The reason why you get only first beacon is because you are ranging different regions and this is how iOS recognizes what are you looking for.
Even using CoreLocation and one CLLocationManager you will get one beacon in array in delegate method.
You can add ranged beacon to your own array, which can be property in your model, for example.
Or should I make three beaconManager Instances and each beacons has
its own region? Problem when I do this is I can only see first beacon.
not three.
Yes, this can be done this way. You then implement
- (void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region
and that method will be called one time for every beacon manager every 1 second. In current beacons array there will be only one object but after all you get all of your beacons.
And the same as above, you can add ranged beacon to your own array, which can be property in your model, for example.
If your beacons have the same major number (and different minor numbers) you can the use this method:
[self.manager startRangingBeaconsInRegion:[[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:713 identifier:#"Multiple Beacons"]];
after that in
- (void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region
you will get array with more than one beacon inside (of course if you have them near you iOS device).

Related

Google maps sum of unique road distance in given area

I would like to calculate the number of unique kilometers of roadways in my city. More generally, I wish to sum the distance of every road within a bound, for simplicity a rectangle will do.
Is this possible using the Google Maps suite of APIs? If so, how would you go about doing it? If anyone has any resources related to this type of problem, I would be interested in reading them regardless of language (or even solutions with other mapping tools).
Bonus points: A general solution to this problem that can be applied to the pre set "cities" (example) that appear in Google Maps with well defined city limits.
You can use OpenStreetMap to calculate the total road length of a specific country or geographic area. There are multiple solutions available, based on multiple similar questions already asked.
Approach 1 from Total road length in Kilometers for a country at help.openstreetmap.org:
Use the Perl script osm-length-2.pl. There is an example at a mailing list post.
Approach 2 from Actual road length of exported map at help.openstreetmap.org:
Import your data (the planet or an country or area extract) into a PostGIS database, then use the following queries proposed by Frederik Ramm:
SELECT way AS clip
INTO clipping_polygon
FROM planet_osm_polygon
WHERE boundary='administrative' AND admin_level='8' and name='My City';
SELECT name, highway, ST_INTERSECTION(way, clip)
INTO clipped_roads
FROM planet_osm_line, clipping_polygon
WHERE ST_INTERSECTS(way, clip) AND highway IS NOT NULL;
SELECT highway, SUM(ST_LENGTH(way::geography))
FROM clipped_roads
GROUP BY highway;

How do I do Batch Geocoding and get latitude and longitude for multiple intersections

Essentially I have an extensive list of different intersections. My end goal is to create points and lines for Intersection A to Intersection B for each order I have which contains a starting point and ending point. The problems I am running into are as followed:
1). Using API I have only found a way to get lat and long by entering each individual intersection and putting the output in an excel file. But, this will take way too long as I have multiple different intersections. I am looking for a different way to get the lat and long points for all of these maybe something through R or Python but everything I have read uses addresses.
2.) Once I get these lat and long points I want to put this on a map as points and connect the points to make lines for each of the start and end points on an order?
Any kind of help to push me in the right direction would be great.
This is only one of what I'm sure is many answers. Whether or not an API allows intersection geocoding is dependent on the vendor. For instance, the MapQuest API allows you to geocode intersections and will return the geocode type in the response: https://developer.mapquest.com/documentation/samples/geocoding/v1/address/
I did a simple test with this intersections and the first result was an intersection: https://www.mapquestapi.com/geocoding/v1/address?key=KEY&inFormat=kvp&outFormat=json&location=12th+ave+and+speer+blvd%2C+Denver%2C+CO&thumbMaps=false
The first link I provided is a testing console so you can see if it will suit your needs. You would need to filter out your responses to only include results with the type "geocodeQuality": "INTERSECTION"
They support batch geocodes, but I would use the single location geocoder as a test.

print google map route segments

Please tell me how to get a list of the last settlements in the itinerary? that's how it is done at this site
http://ati.su/Trace/default.aspx?EntityType=Trace&City1=3611&City5=1100&WithinCountry=false
(move the site in English via Google Translate), thank you very much for your attention
You may want to look to Google's documentation directly about Geocoded waypoints:
Details about the geocoding of every waypoint, as well as origin and
destination, can be found in the (JSON) geocoded_waypoints array.
These can be used to infer why the service would return unexpected or
no routes.
Elements in the geocoded_waypoints array correspond, by their
zero-based position, to the origin, the waypoints in the order they
are specified, and the destination. [...]
More specifically you would look into types:
types indicates the address type of the geocoding result used for
calculating directions. The following types are returned:
street_address indicates a precise street address.
route indicates a named route (such as "US 101").
intersection indicates a major intersection, usually of two major roads. political indicates a political entity. Usually, this type
indicates a polygon of some civil administration.
neighborhood indicates a named neighborhood
premise indicates a named location, usually a building or collection of buildings with a common name
subpremise indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a
airport indicates an airport.
point_of_interest indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in
another category, such as "Empire State Building" or "Statue of
Liberty."
[...]
Among other types you want to highlight.
Legs also may help you (if there are no waypoints):
Each element in the legs array specifies a single leg of the journey
from the origin to the destination in the calculated route. For routes
that contain no waypoints, the route will consist of a single "leg,"
but for routes that define one or more waypoints, the route will
consist of one or more legs, corresponding to the specific legs of the
journey.
And each leg has a steps array:
Each element in the steps array defines a single step of the
calculated directions. A step is the most atomic unit of a direction's
route, containing a single step describing a specific, single
instruction on the journey. E.g. "Turn left at W. 4th St." The step
not only describes the instruction but also contains distance and
duration information relating to how this step relates to the
following step. For example, a step denoted as "Merge onto I-80 West"
may contain a duration of "37 miles" and "40 minutes," indicating that
the next step is 37 miles/40 minutes from this step.
Where each step has:
start_location contains the location of the starting point of this
step, as a single set of lat and lng fields.
end_location contains the
location of the last point of this step, as a single set of lat and
lng fields.

Using google maps API to find average speed at a location

I am trying to get the current traffic conditions at a particular location. The GTrafficOverlay object mentioned here only provides an overlay on an existing map.
Does anyone know how I can get this data from Google using their API?
It is only theorical, but there is perhaps a way to extract those data using the distancematrix api.
Method
1)
Make a topological road network, with node and edge, something like this:
Each edge will have four attributes: [EDGE_NUMBER;EDGE_SPEED;EDGE_TIME,EDGE_LENGTH]
You can use the openstreetmap data to create this network.
At the begining each edge will have the same road speed, for example 50km/h.
You need to use only the drivelink and delete the other edges. Take also into account that some roads are oneway.
2)
Randomly chose two nodes that are not closer than 5 or 10km
Use the dijsktra shortest path algorithm to calculate the shortest path between this two nodes (the cost = EDGE_TIME). Use your topological network to do that. The output will look like:
NODE = [NODE_23,NODE_44] PATH = [EDGE_3,EDGE_130,EDGE_49,EDGE_39]
Calculate the time needed to drive between the two nodes with the distance matrix api.
Preallocate a matrix A of size N X number_of_edge filled with zero value
Preallocate a matrix B of size 1 X number_of_edge filled with zero value
In the first row of matrix A fill each column (corresponding to each edge) with the length of the edge if the corresponding edge is in the path.
[col_1,col_2,col_3,...,col_39,...,col_49,...,col_130]
[0, 0, len_3,...,len_39,...,len_49,...,len_130] %row 1
In the first row of matrix B put the time calculated with the distance matrix api.
Then select two news node that were not used in the first path and repeat the operation until that there is no node left. (so you will fill the row 2, the row 3...)
Now you can solve the linear equation system: Ax = B where speed = 1/x
Assign the new calculated speed to each edge.
3)
Iterate the point 2) until your calculated speed start to converge.
Comment
I'm not sure that the calculated speed will converge, it will be interesting to test the method.I will try to do that if I got some time.
The distance matrix api don't provide a traveling time more precise than 1 minute, that's why the distance between the pair of node need to be at least 5 or 10 or more km.
Also this method fails to respect the Google's terms of service.
Google does not make available public API for this data.
Yahoo has a feed (example) with traffic conditions -- construction, accidents, and such. A write-up on how to access it is here.
If you want actual road speeds, you will probably need to work with a commercial provider.

Question about tracking user in a map application using cellid

I am trying to understand the concept of cellid (http://www.opencellid.org/api)
As per that, if we send a request
http://www.opencellid.org/cell/get?key=myapikey&mnc=1&mcc=2&lac=200&cellid=234
it will respond with the latitude and longitude.
I was wondering if this can be used from within a google map application for tracking a user or it needs to be used from within a mobile device?
If it can be used from within a web app, what parameters should it use for
mcc: mobile country code (decimal)
mnc: mobile network code (decimal)
lac: locale area code (decimal)
cellid: value of the cell id
E.g., will it work if we know the cell number of the person(e.g., 281 222 6700)
The request is just a lookup in the opencellid database.
It doesn't matter where the information is coming from.
If you know the MMC, MNC, LAC and CellID of a user/mobile device,
the request will return latitude and longitude if the cellID has been found in the DB.
There is no additional information transfered by using the request from within a J2ME app.
MCC+MNC+LAC+CELLID should be a unique identifier of a cell. (afaik those values can change over time,
but they still should be unique.)
More often than not, knowing just the LAC and CellID is sufficient.
However, you can't use this to track based on a number, only by cell tower parameters. Number tracking is a whole different ball game with VRL & HRL lookups which are hard to come by, very expensive ($100+ per lookup) and sometimes even illegal.
Google Maps also uses cell ID lookups to approximate the user's location before GPS kicks in (the translucent circle around a dot is actually data from Cell IDs).
That being said, opencellid has very minimal coverage and little or no updates to the project. Check out some paid players who offer wider coverages:
LocationAPI
Combian