How to get lat and long from open street map - angular5

I want to get latitude and longitude from open street map in angular when I clicked on the location, but i can't , how I can do it??I used to get this from google map , but now i want to change it to open street map

You need to do it programmatically, there's a section here
https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
you need to know the tile position x/y that you are clicking on (in floating point) and the zoom level (z).
n = 2 ^ zoom
lon_deg = xtile / n * 360.0 - 180.0
lat_rad = arctan(sinh(π * (1 - 2 * ytile / n)))
lat_deg = lat_rad * 180.0 / π
Source: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

You can install JOSM place a singular node and in the bottom left corner of the application, there will be a latitude & longitude display.

Related

How convert wgs 84 to lat/long in SQL Server

I having a little trouble figuring out how to convert between types of coordinates. I have a list of coordinate sets with the following description. I have been searching around and did find some code to do this, but it does not SQL Query.
"Coordinates are always in the WGS84 system. All coordinates a represented as Decimal values x and y.
An example:
Ellipsoid:
wgs84 (world geodetic system 1984)
UTM Zone:
39 - 48E to 54E
UTM Projection:
X, m: 702964.0000 -------> latitude : 27.7818550282488
Y, m: 3074740.0000 -------> longitude : 53.0598812425032
The query should be SQL Server Query.
Well, I need to convert these to long/lat
Anyone who can provide some code for doing this?
Here is a db<>fiddle.
You can probably use the UF_utm_to_lat() function from this previous answer.
Easting northing to latitude longitude
I haven't found suitable t-sql code for this, so I have finally developed a library in .NET to be called from transact sql
Converts WGS84/UTM coordinates to Latitude and Longitude
You can download it from github:
https://github.com/j-v-garcia/UTM2LATITUDE
usage:
SELECT dbo.UTM2LATITUDE(723399.51,4373328.5,'S',30) AS Latitude, dbo.UTM2LONGITUDE(723399.51,4373328.5,'S',30) AS Longitude
result:
39,4805657453054 -0,402592727245112
<param name="XUTM">pos UTM X</param>
<param name="YUTM">pos UTM Y</param>
<param name="LatBand">Latitude band grid zone designation letter (see http://www.dmap.co.uk/utmworld.htm) </param>
<param name="LongBand">Longitude band grid zone designation number (see http://www.dmap.co.uk/utmworld.htm) </param>
This T-SQL was adapted from some JavaScript code supplied by Xander Bakker at ESRI (replace [column_name] with your own geography shape field).
180.0 / PI() * (2.0 * ATAN(EXP(([column_name].Shape.STY / (2.0 * PI() * 6378137.0 / 2.0) * 180.0) * PI() / 180.0)) - PI() / 2.0) as Latitude, -- Convert Y to Latitude
([column_name].Shape.STX / (2.0 * PI() * 6378137.0 / 2.0) * 180.0) as Longitude, -- Convert X to Longitude
I spot checked numerous locations and they were all spot on.

Ground longitude/latitude under a satellite (cartesian coordinates) at a specfic epoch

The script I'm wanting to develop uses the cartesian coordinates (XYZ) from a satellite, and in conjunction with the range, elevation and azimuth from a location, I then take a satellite’s orbital information and get the ground longitude/latitude under that satellite at a given time.
One step further from this: imagne the signal from a satellite piercing the atmosphere at exactly 300km above sea level. At this particular point when altitude is 300km, I need to calculate the ground longitude/latitude.
In the pyemph module there appears to be already a method (ephem.readtle) that can achieve this, but for TLE (two line element) data only. I'd like to use a satellite's cartesian coordinates to develop this. Is there such a method already out there? Or perhaps somebody with experience in this
domain can point me in the right direction.
A similar question already exists referring to ECEF from Azimuth, Elevation, Range and Observer Lat,Lon,Alt, but it's not the same problem.
Here's what I have developed already:
- satellite cartesian coordinates, XYZ
- azimuth, elevation and range of satellite from ground station
- ground station coordinates in lat, long, height above sea level
Here's what I need:
- ground longitude/latitude under a satellite at a specific epoch, and in particular where the piercing point in the atmosphere (the point which the signal from the satellite pierces the atmosphere) is 300km altitude.
I found what I was looking for via this:
def ionospheric_pierce_point(self, dphi, dlambda, ele, azi):
Re = 6378136.3 # Earth ellipsoid in meters
h = cs.SHELL_HEIGHT * 10**3 # Height of pierce point meters, and where maximum electron density is assumed
coeff = Re / (Re + h)
lat_rx = dphi
long_rx = dlambda
# Degrees to radians conversions
ele_rad = np.deg2rad(ele)
azi_rad = np.deg2rad(azi)
lat_rx_rad = np.deg2rad(lat_rx)
long_rx_rad = np.deg2rad(long_rx)
psi_pp = (np.pi / 2) - ele_rad - np.arcsin(coeff * np.cos(ele_rad)) # Earth central angle between user and the Eart projection of the pierce point, in radians
psi_pp_deg = np.rad2deg(psi_pp)
lat_pp = np.arcsin(np.sin(lat_rx_rad)*np.cos(psi_pp) +
np.cos(lat_rx_rad)*np.sin(psi_pp)*np.cos(azi_rad)) # in radians
if (lat_rx > 70 and ((np.tan(psi_pp)*np.cos(azi_rad)) > np.tan((np.pi/2) - lat_rx_rad))) or (lat_rx < -70 and ((np.tan(psi_pp)*np.cos(azi_rad + np.pi)) > np.tan((np.pi/2) + lat_rx_rad))):
long_pp = long_rx_rad + np.pi - np.arcsin((np.sin(psi_pp)*np.sin(azi_rad)) / np.cos(lat_pp))
else:
long_pp = long_rx_rad + np.arcsin((np.sin(psi_pp)*np.sin(azi_rad)) / np.cos(lat_pp))
lat_pp_deg = np.rad2deg(lat_pp)
long_pp_deg = np.rad2deg(long_pp)
return lat_pp_deg, long_pp_deg

Having the latitude and longitude, plotting in 2d, can I use the 3d formula?

This equations takes in latitude and longitude and returns the y and x coordinates :
y = R * cos(latitude) * sin(longitude);
x = R * cos(latitude) * cos(longitude);
example longitude and latitude :
"lat": 19.0733000,
"lon": 82.9479000,
z coordinate does not exist as its 2d.
Now I get some sort of map part displayed but not so correct in most cases, I googled converting from longitude latitude, and as openStreetMap uses Mercator projection, but using I have a separate question, that how to deal with plotting floating point number values of x and y on screen ?
How the formula can be applied ?
And why using the equation I am using is in appropriate ?
No, you cannot use the above formula to plot in a 2d plane. Trying (0N, 0E) gives coordinates (
R, 0) and (0N, 90E) gives coordinates (0, R).
This gis link discusses the Mercator projection: https://gis.stackexchange.com/questions/20686/mercator-projection-problem-with-latitude-formula

How can I create SQL Server Geography polygons that are of a specific size?

I want to create a group of polygons for a city that are 80km x 80km. Given a starting Lat and Long, my thought is I can add 80km to that point so that I get 4 points to create the polygon.
(x,y) -> (x+80km, y) -> (x+80km, y+80km) -> (x, y+80km) -> (x,y)
Where I'm having difficulty is finding a way to calculate the point +80km. I've found the SQL Server Spatial Tools and there is a function
SqlGeography LocateAlongGeog(SqlGeography g, double distance)
But so far I haven't been able to figure out how to use it. I will continue to play with this but if there are any other approaches I can take, or if anyone knows how to properly use this function, I'd be grateful.
Longitude is a "great circle" measure, i.e. if you draw a circle representing a particular longitude round the Earth, it's always a circle whose centre is the centre of the Earth - so to circumnavigate the Earth at a constant longitude, you always travel the same distance:
2 * PI * 6378 /* 6378 is the radius of the Earth in km */
So, moving North (i.e travelling along the same longitude) 80 km will increase your latitude by:
360 * 80 / (2 * PI * 6378)
Latitude is trickier cos the distance travelled when you circumnavigate the Earth at the same latitude changes depending on the latitude at which you're travelling: however, the formula is simple and I looked it up at: http://www.newton.dep.anl.gov/askasci/env99/env086.htm
2 * PI * 6378 * COS(LAT) /* where LAT is your Latitude */
So, if you are at latitude LAT, and move 80km East, you will increase your longitude by:
360 * 80 / (2 * PI * 6378 * COS(LAT))
Couple of things to note:
a) 6378 is only accurate to the nearest km
b) The East/West between your two Northerly points will not be precisely 80km - not significantly different for Latitudes between about 80 degrees North and 80 degrees South - as long as you're not looking for high-precision pinpoint accuracy (which I'm guessing with base measurements of 80 km you're not) it'll do just nicely (and point nicelt at Bing or Google, say)
c) SQL calculates trigonometry functions using radians not degrees - so in SQL your cosine will need to be:
COS(PI * LAT / 180)
HTH and makes some sort of sense

How to find latitude and longitude

I have latitude and longitude of a point.I have to find out the latitude and longitude of another point from a relative distance from the known point.For example point A has some location with latitude and longitude.What is the latitude and longitude after moving 1000m south and 500m west from point A.Is there any direct equation to find this? Thanks in advance
Note the accepted answer is basically the flat earth projection equations:
x = δlon * EarthRadius * cos( lat )
y = δlat * EarthRadius
For better accuracy over larger distances, you should compute the final lat/lon from a typical bearing/range calculation. See the section Destination point given distance and bearing from start point at this website: http://www.movable-type.co.uk/scripts/latlong.html
Instead of looking up an equation you can calculate as follows. Let R be the radius of the Earth. Let a be the current latitude and b be the current longitude. Then if you move δx metres east (negative for west) then δy metres south, calculating the new longitude can be done as follows.
Intersecting a horizontal plane with the Earth at the current latitude will give you a circle of radius R*cos(a). So to convert δx to the change in longitude, you get something like
δlong = δx * 2π / (2π * R * cos(a)) = δx / (R * cos (a))
The change in latitude is easier, since it doesn't depend on the current position. You're always moving around a great circle through the two poles. Then δlat = δy / R. (Of course you need to mod out by 2 π at some point).