Zoom map to include all marker points [YMKPoint], YandexMapsMobile Swift? - ios

How can I zoom map to include all marker point into visible area?
I have an array of points, was trying to configure BoundingBox(), but have no idea how to set/find southWest and northEast values from [YMKPoint].
.cameraPosition(with: .init(southWest: ?, northEast: ?))

I do not have a ready code for you, but hope this will help.
As you have an array of all the [YMKPoint] from that array you need to filter all the points which belong to the southWest zone & northEast zone.
See below statement that will help you to filter the points:
Latitude: Positive values indicate north latitude and negative values indicate south latitude.
Longitude: Positive values indicate east longitude, and negative values indicate west longitude.
After filtering the array based on two zones, you need to sort the array based on the points which is far for both the zones southWest & northEast.
Once array is sorted you will be able to create a BoundingBox by selecting first point from both the sorted array of zones.
See this image to understand how the co-ordinates are placed on the map using a graph.

Related

Get bounding box from array of points

I have a Rails 5 API only project. I have nodes that have latitude/longitude details stored on them. I am using the Rails Geokit gem to do some of the other geographic work.
I want to return to the consuming client the bounding box that contains all of the points contained in an array. Is there a simple way to do this? Most of the examples show you using an already known bounding box, not generating one.
All you need in order to determine the bounding box for a set of coordinates is the min and max of both latitude and longitude, i.e. the extreme west, east, north, and south values. From these you can construct the southwest and northeast points that span the bounding box.
Now I'm not familiar with geokit, so I don't know the class name of a coordinate, but you should be able to translate that to the correct class name (I'm calling it Point):
points = [...] # List of nodes
west, east = points.map(&:longitude).minmax
south, north = points.map(&:latitude).minmax
sw = Point.new(longitude: west, latitude: south)
ne = Point.new(longitude: east, latitude: north)

Gmaps4Rails: Plot markes/pointers randomly within a given range

Given latitude and longitude of a location say 27.1231 and 72.3454 how do I randomly plot points within a circle of radius say 10km with the above lat and log as the center?
It's somewhat similar to this (?)
EDIT
It's a geocoder question and not a Gmaps4rails one
How to get the co-ordinates of random points within a given range?
you may use google.maps.geometry.spherical.computeOffset with random distance and heading

show nearest places with 1km radius from user lat and longitudes

I recently stated working on gps maps. I have a database with list of lat and longitudes. when a user access my web app, I want to display places with in 1km or specified radius from user point.
I tried using mysql query
SELECT * FROM Locations
WHERE (latitude between MINLATITUDE and MAXLATITUDE )
and (longitude between MINLONGITUDE and MAXLONGITUDE)
but it displays lat and longitudes between min and max, could some one tell me how to show lat and longitudes which are only with in 1km radius from user point.
Thanks.
For distances around 1km, Haversine is overkill. Use the much simpler equirectangular projection to get familiar x and y. Remember, the formula below lat and lon are IN RADIANS. The distance, d, is in km because the radius of the earth (R) is in km. And lat/lon are in radians (yes, I said it again). This eliminates several trig functions compared to Haversine which should make your queries faster.
var R = 6371; // radius of the earth in km
var x = (lon2-lon1) * Math.cos((lat1+lat2)/2);
var y = (lat2-lat1);
var d = Math.sqrt(x*x + y*y) * R; // distance in km
Now, this is a web app so I'm going to assume that Santa (north pole) and the people at the Antarctica station will not use your app. With this assumption, you can organize your lat/lon points in your database on longitude. So, if someone has a lon of -76.1, you know that longitudes in your database that are less than -78 degrees are farther than 1 km. You also know longitudes greater than -74 degrees are far away as well. This will reduce the number of points you need to check in your database.

convert longitude and latitude to x,y based location

Based on Instructions on how to display and clear a route on a map by using a location document
the routing use x,y Based Location.
my question : how to convert longitude and latitude to x,y based location to be able to use them to route in BB maps.
thanks
The X and Y values in the location document specified by your link are latitude and longitude respectively in degrees multiplied by 10,000.

Given a latitude, longitude and heading, how can I determine the lat/lon that is x meters from that point?

I have a series of lat/lon which represents the center of some object. I need to draw a line through this point that is x meters on either side of the center and it needs to be perpendicular to the heading (imagine a capital T)
Ultimately I want to get the lat/lon of this line's endpoints.
Thanks!
The basic calculation is in this similar question's answer: Calculate second point knowing the starting point and distance. Calculate the points for the two headings perpendicular to the main heading the distance away you want.
Have a look at: Core Location extensions for bearing and distance
With those extensions and two points on the initial line you should be able to get the bearing, add/subtract pi/2 and find points to either side like this:
double bearing = [bottomOfT bearingInRadiansTowardsLocation:topOfT];
CLLocation *left = [topOfT newLocationAtDistance:meters
alongBearingradians:bearing+M_PI/2];
CLLocation *right = [topOfT newLocationAtDistance:meters
alongBearingradians:bearing-M_PI/2];

Resources