Using OSM and EPSG:4326 with openlayers increase latitude in near 90 degrees. Why? - coordinates

I am using openLayers and creating a OSM base layer. By default the layer use EPSG:900913 and the coordinates are in meters. I want to use coordinates in degrees with EPSG:4326 so I initilize layer with:
base_layer.addOptions({ sphericalMercator: true,
projection: new OpenLayers.Projection('EPSG:4326')}, true);
Now the map uses degrees but have the next problem: The point with latitude 37.296 and longitude -5.929 (http://www.openstreetmap.org/?lat=37.296&lon=-5.929&zoom=12&layers=Q# and the same coordinates in Google Maps) appears to me (moving map and executing map.getCenter() in firebug) in lat. -49.75, lon. -5.929.
Why? How can I use an OSM layer with same degrees coordinates as in openstreetmap.org and as are returned by nominatim.openstreetmap.org?

You can't just claim the layer is EPSG:4326 when the tiles you are displaying are actually rendered in EPSG:3857. That is nonsensical.
I'm not quite clear on what you are trying to do here to be honest, but it may help to set displayProjection to EPSG:4326 which will cause OpenLayers to use degrees when it is communicating values to/from the user.
If you want to to read or set the map location in code then you will need to reproject the value you get from getCenter or give to setCenter yourself by calling the transform method on the location value.

Related

Instantiate a pyephem EarthSatellite from positional coordinates without a TLE

I have the position of a satellite at a given time, in altitude/latitude/longitude coordinates.
I'd like to calculate the azimuth/elevation from an observer on earth (given in lat/long) to this satellite at that position.
The ephem.EarthSatellite object only operates on TLEs and a desired timestamp. Is there anyway to instantiate a satellite from positional coordinates? Maybe with a different ephem.Body type?
No, there is no way to create your own objects with Earth-fixed coordinates in PyEphem. You might want to take a look at its replacement that I am writing, though, called Skyfield — you should be able to create a Topos object with any lat / lon / elevation you want, and then observe it from any other location you define with a Topos and get an alt / az back.

Anything in Leaflet that is similar to isLocationOnEdge() from Google Maps?

Google Maps has the function isLocationOnEdge(point, polyline, tolerance) that takes a tolerance value in degrees and uses it to determine whether a point falls near a polyline.
Is there anything similar in Leaflet(or some plug-in) that does the same thing?
A handful library for such operation is Turf.
For your case, a simple approach would be to:
Create a polygon out of your polyline using turf.buffer with appropriate "tolerance" (Turf takes a distance at Earth surface, or degrees).
Check whether your point is within that polygon or not using turf.inside.
Unfortunately, turf.buffer is only an approximation, it does not takes geodesy into account… therefore for big tolerance you will have a deformed shape.
An exact method could be to:
Use instead turf.pointOnLine to find the nearest point of the polyline.
turf.distance to measure the distance between those 2 points, and compare with your tolerance (or even just Leaflet latLng.distanceTo, but you would have to convert GeoJSON points back to Leaflet LatLngs).

What is the projection used by MKMapView?

I am storing a number of point features inside a SQLite database for display inside of MKMapView and I would like to precompute and store coordinates in the the projection of the map instead of in lat/lon (for index/performance reasons). However, I am creating this database externally (in Python), so I cannot simply use the MKMapPointForCoordinate() function. What is the projection used by MKMapView? The documentation states that it is a mercator projection but it does not appear to be the web mercator projection that I expected. How can I compute an X/Y coordinate from a Lat/Lon ?
Personally I feel you're approaching the problem from the wrong angle - you say don't want to store latitude/longitude co-ordinates for 'index/performance reasons'. What are these reasons?
Storage, indexing, and querying of geographic coordinates inside of a database is not an unusual problem. They are simply two decimal numbers, making indexing and querying very straightforward.
Apple also tell you only to save co-ordinates rather than MKMapPoints in their own documentation:
When saving map-related data to a file, you should always save coordinate values (latitude and longitude) and not map points.
Perhaps you could share some of the issues you're having saving co-ordinates to a database?
I'm pretty sure it is webmercator because the overlay tiles I have produced are in that projection and they fit. But like other conmenters said, you're advised to store them in lat/long. If you want to query results in a grid lat/long provide a pretty good starting point. The grid isn't square as you leave the equator but it is rectangular.

google earth model transformation

I would like to add placemarks to parts of collada geometry in google earth. To do this I need to translate the geometry coordinates in the xml to match the transformation to the model in google earth. Given longitude latitude and orientation how do I translate geometry coordinate to match the google earth transformation?
I believe models are located on the earth using only 1 coordinate which is used to position the 'center' of the model. How that is determined I am not sure, and might even depend on the kind/shape of the model.
The coordinate is easily found in the kml structure for the model which is referenced here
http://code.google.com/apis/kml/documentation/models.html
Determining how far a certain part of your geometry is from the middle might be very complex but here is an example of some code that will provide you the distance between two points.
http://earth-api-utility-library.googlecode.com/svn/trunk/extensions/examples/ruler.html
It is based upon the google earth extensions (gex) library
http://code.google.com/p/earth-api-utility-library/
Perhaps you could use SketchUp to help determine the location of your points of interest within the geometry?
http://sketchup.google.com/

Why points above 85N or below -85S are not shown on the iPhone map?

I need to represent on the map (iPhone) some points such as (88, 60) or (90, 55), but the custom annotations representing these points get deallocated. I also noticed that these points are not actually displayed on the google map, they are somehow above the visible map. This happens for any point that is above 85 deg. N latitude or -85 deg. S latitude.
I know it's a really old post, but just to answer your question.
Most (allmost all) commercial maps are displayed in the mercator projection. This is what you see in mapKit or on google maps. This means that the latitude and longitude lines run horizontal and vertical.
If you would change this to for instance polar project (world from the top) it would become way to difficult to calculate the postion of objects because the lat and long lines converge rapidly...
So it's just for ease of use....