How to un-normalize geo points in order to plot on leaflet - leaflet

Leaflet consists of multiple self worlds. General limit of latitude n longitude is -90 to +90 and -180 to +180 respectively. So for a different number of world in map area i receive {lat: 76.12621315046384, lng: 370.70826412409673}, which i normalize to the limit format and send as a param to server in order to receive points based on an algorithm. However the points that i receive are in normalized format already which will plot on the initial first map only, however i would like to plot them on that number of world on map area from which i retrieved longitude as 370.70826412409673.
I tried getting getting pane, scaleZoom, zoomScale, scale, zoom but nothing seem to work in order to get me the world number or anything that helps me de-normalize the geopoints.

You can use the function getBounds() that gives you the coordinates of the two corners of the current view and/or getCenter(). You can then change your longitude to fit this view.
An other solution is to keep the offset between the normalized and "true" coordinates, and add it back to the answer of your algorithm.

Related

X,Y coordinates with reference points and find lat and long

I have a floor map that is relayed on top of a grid and have the length and width of the floor along with 3 reference points that has x,y, lat, long.
Now I have some x,y that lies within the floor map and need to derive the lat and long for those points.
Is there a way to achieve that? Preferably Java but even a formula would do or some documentation.

Create circle around user inputted point and plot on map with custom latlon points

I have a question about if something is possible using Tableau.
I already have a coastline plotted on one map using custom LatLon coordinates and I would like to take a user inputted Lat and Lon and plot a circle around it with let's say radius 10 and display it on the same map.
I was using this tutorial before to plot a circle:
https://www.crowdanalytix.com/communityBlog/customers-within-n-miles-radius-analysis-using-tableau
But I don't think the same approach can work with user-inputted fields because then it would require restructuring the data..
Okay, a (much smarter LOL) coworker helped me figure this out....
So my goal was to graph distance band (like a distance of 5 miles around a coast) . In order to do this we can use the distance between two coastline points since they are connected by a line, not a curve...From there we can find the perpendicular point a certain distance away and connect those points. Much easier than my circle idea...

Calculate distance between points drawn on different zoomscale

I'm developing an iPhone app where the user chooses an image and then is allowed to draw on it (dots) that maybe stored on different zoomscales (he's allowed to zoom in and out).
I store the location of every point drawn in an array but when I calculate the distance I come to realize the result isn't correct if the points were stored on different zoomscales. Would someone kindly help me with this?
Probably you should store points in normalized unit.
Assuming that you are using UIScrollView for zooming, divide both x and y by current scrollView.zoomScale before storing. When calculating the distance, multiply the distance back by scrollView.zoomScale.

Trouble understanding MKMapPoint(s)

Can anyone point me in the right direction when it comes to understanding MKMapPoint?
I understand that it has to do with laying suface of the globe on a 2D surface. But I don't understand how each "point" is measured?
Can anyone give me an example in code?
There is nothing much to it.. just a structure to display point on a 2D map... here is what the documentation says..
MKMapPoint A point on a two-dimensional map projection.
typedef struct {
double x;
double y; } MKMapPoint;
Fields x The location of the point along the x-axis of the
map. y The location of the point along the y-axis of
the map. Discussion If you project the curved surface of the globe
onto a flat surface, what you get is a two-dimensional version of a
map where longitude lines appear to be parallel. Such maps are often
used to show the entire surface of the globe all at once. An
MKMapPoint data structure represents a point on this two-dimensional
map.
The actual units of a map point are tied to the underlying units used
to draw the contents of an MKMapView, but you should never need to
worry about these units directly. You use map points primarily to
simplify computations that would be complex to do using coordinate
values on a curved surface. By converting to map points, you can
perform those calculations on a flat surface, which is generally much
simpler, and then convert back as needed. You can map between
coordinate values and map points using the MKMapPointForCoordinate and
MKCoordinateForMapPoint functions.
When saving map-related data to a file, you should always save
coordinate values (latitude and longitude) and not map points.
Availability Available in iOS 4.0 and later. Declared In MKGeometry.h
If you want to draw something over a map that has a certain real-world size, for example, a scale, then in your calculations you would multiply any given length in meters with the result of MKMapPointsPerMeterAtLatitude(...) to get the size in MKMapPoint units.
If your map displays only of small portion of the globe, MKMapPointsPerMeterAtLatitude(...) will deliver roughly the same constant value for all the latitudes involved in your map. In this case, you can simply use the latitude in the middle of your map as the argument of this function.
Also read in the documentation that a Mercator projection is used for the transformation. Here is an additional observation: northing (y) axis direction seems to be in reverse direction of standard mercator projections (positive direction is down instead of up).

How to determine if a latitude & longitude is within an ellipse

I have data describing a rotated ellipse (the center of the ellipse in latitude longitude coordinates, the lengths of the major and minor axes in kilometers, and the angle that the ellipse is oriented). I do not know the location of the foci, but assume there is a way to figure them out somehow. I would like to determine if a specific latitude longitude point is within this ellipse. I have found a good way to determine if a point is within an ellipse on a Cartesian grid, but don't know how to deal with latitude longitude points.
Any help would be appreciated.
-Cody O.
The standard way of doing this on a Cartesian plane would be with a ray-casting algorithm. Since you're on a sphere, you will need to use great circle distances to accurately represent the ellipse.
EDIT: The standard ray-casting algorithm will work on your ellipse, but its accuracy depends on a) how small your ellipse is, and b) how close to the equator it is. Keep in mind, you'd have to be aware of special cases like the date line, where it goes from 179 -> 180/-180 -> -179.
Since you already have a way to solve the problem on a cartesian grid, I would just convert your points to UTM coordinates. The points and lengths will all be in meters then and the check should be easy. Lots of matlab code is available to do this conversion from LL to UTM. Like this.
You don't mention how long the axes of the ellipse are in the description. If they are very long (say hundreds of km), this approach may not work for you and you will have to resort to thinking about great circles and so on. You will have to make sure to specify the UTM zone to which you are converting. You want all your points to end up in the same UTM zone or you won't be able to relate the points.
After some more research into my problem and posting in another forum I was able to figure out a solution. My ellipse is relatively small so I assumed it was a true (flat) ellipse. I was able to locate the lat lon of the foci of the ellipse then if the sum of the distances from the point of interest to each focus is less than 2a (the major axis radius), then it is within the ellipse. Thanks for the suggestions though.
-Cody