Finding the world center on blank SVG maps available on wikipedia - geolocation

I need to plot geo locations (lat, lon) on svg maps just like it's done in this demo: http://people.opera.com/danield/svg/where-am-i.svg
I however have 3 blank maps not displaying the whole world. One of them is http://en.wikipedia.org/wiki/File:BlankMap-USA-states-Canada-provinces,_HI_closer.svg
There is seldom or no information about it on the web. I have been looking for a while but it seems like knowledge of the maps is required. I noticed the demo mentioned above first finds the world center, then multiply by a factor. How it's done is not really explained.
And as far as the world center, I wonder if I can find it on a map that's only displaying part of it.
Thanks a lot in advance for any help.

The problem is that the coordinates used to build the SVG are not lat/long. Using the "world center" as (0,0) is a useful convention (place where the prime meridian meets the equator), but it will not allow for a very precise placement due to projection issues.
In your case, the line of latitude between Canada and the US combined with the longitude between Manitoba and Saskatchewan could be used as your "world center" (0,0) coordinate. Find out what the actual lat/long of that point is, then express other lat/long pairs relative to that one.
Again, I should restate that this is not a precise way of locating points, and there will be error especially when you get closer to the edges of the map.

Related

Calculate SceneKit SCNVector4 rotation from longitude/latitude coordinates of a sphere?

I'm working on a SceneKit project in Objective-C, trying to rotate a sphere (representing a planet) so that a point at a given longitude/latitude coordinate is facing "forward" (i.e. that point moves to the {0,0} position). So for example, we're looking at Earth's {0,0} point, off the coast of Africa, but I need to know what rotation vector would have us looking at {37,-122}, aka San Francisco. Ideally, the planet would remain "naturally" oriented, with north remaining generally "up" from our perspective, but that's flexible.
I've got the animation working and I can rotate to a given longitude OR latitude using SCNVector4, but as soon as I try to rotate to a given longitude AND latitude, it gets wildly messed up. So I've been doing some research, and I've found some resources that seem to do exactly what I need, but to be honest they're a bit beyond me. I'm a complete newbie in the world of trigonometry and matrices, and it seems there's no way around this problem without them.
Can anyone help me understand how these concepts can take Lat/Long coordinates, and calculate a SCNVector4? A method for creating a SCNVector4 based on the desired Lat/Long would be perfect, but even just help with calculating the components individually would be greatly appreciated!

Calculate angle between three GPS coordinates

perhaps this is a simple question.
I have 3 GPS coordinates (one is the current user location). What I want now is to calculate the angle between the user location and the two GPS coordinates. Imagine the user location in the center of the two other points, the three points can be seen as a triangle. And I want to calculate the angle at the user location.
I hope someone can help me because I have no idea how to do this with spherical coordinates like the GPS coordinates I have.
THX - nekro
For short distances (less than 100km, say) you can safely ignore the spherical nature of the calculation and treat the problem as a 2 cartesian coordinate problem. For large distances the spherical geometry gets pretty gnarly. I could probably figure it out, but I don't want to think that hard right now.
Edit:
All you need to do is to convert both coordinates to KM, and then treat it as a cartesian problem. (At a small scale, you can ignore the curved nature of the "lines" and treat them as normal cartesian grid lines, since the curvature is small enough to ignore at that scale)
The distance per degree of latitude is constant. The distance for a degree of longitude changes based on latitude.
Do a google search on "KM per degree of longitude" and find a link that explains it clearly. Here's one: http://www.colorado.edu/geography/gcraft/warmup/aquifer/html/distance.html
You could use thessien polygons and calculate the geometry on those from a strictly GIS perspective. If you have qgis or arcgis this should be fairly simple. These packages offer APIs which might suit your needs.
You're essentially doing two calculations (bearing to (or from) current position to two other positions) and not crosstrack (distance from a great circle line between to other points).
However, both can be found in Ed William's Aviation Formulary which has the most comprehensive collection of formulas for spherical calculations I've found.
You would be looking for "Course between points" which is listed as:
tc1=mod(atan2(sin(lon1-lon2)*cos(lat2),
cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon1-lon2)), 2*pi)

How to implement measure functionality on map

I'd like to implement Measure functionality on openstreet map. Measure is adding two points on a map and find the distance between those points.
For that I referred https://github.com/danstowell/openstreetmap-website/commits/jsrouting-contextmenu
It will work fine except water area/region on openstreet map. In my case I am rendering my own maps on my project, so this is not work for me.
I am using below Environment:
Environment : Rails 4 and Ruby 2
Anyone know about it?
How do I implement measure functionality on my map?
Is there any other ways to implement this?
Not sure on the specifics relating to OSM, however assuming that you can convert the points to geodetic points then you can use the haversine or vincenty formulas to get the great circle distance:
http://www.movable-type.co.uk/scripts/latlong.html
OSM uses a spherical Mercator projection. If all you have are 2d Cartesian (projected) coordinates then you will need to convert these to geodetic coordinates.
If you also need to take into account terrain then this gets more complex but maybe OSM provides something for this that gives heights along a transect line.

area calculation using lat/long in UIMapview

I am trying to find area of MKPolygonView object added to MapView. Apple documentation has method distanceFromLocation: to find distance between edges of MKPolygonView object. But I could not find anything to calculate area of the overlay.
Does Apple have any documented method for finding area?
Concerning the comments on the question post, the Earth is not a perfect sphere either. In fact, it's not a perfect anything, so "correct" answers aren't possible. What matters is how accurate of an approximation you need. Also, are you interested in a mean sea level type measurement, or do you want the actual contours of the ground (for example if your polygon is put over a mountain, then the same exact size polygon is put over some plains, should the result you calculate be the same or different)?
Depending on how big your polygon is, and which measurement you're looking for, a 2D approximation can be pretty accurate (the smaller the polygon, the closer you'll get). Something to keep in mind, if you want your area in something like square feet, the distance between two longitudinal lines is not constant (63 deg west and 62 deg west are closer (in feet) somewhere in Alaska than they are at the equator). You might have to do a unit conversion to handle this depending on how big your polygon is (or if your polygon could be placed anywhere). If you can't do the 2D approximation, I'm not even sure how you'd do that.
When I did this, I did the 2D approx, and I had to do the unit conversion. If that's the way you go, I can try to dig up some of my old notes and the links I used to get you started.

Finding the center point of a city

We are purchasing a database of zip codes and their corresponding Lat/Long. I want to store cities in a separate table with a lat/long point representing the center of the city. Can I calculate that based on taking all of the zips that belong to that city, getting the min/max points for each direction, and taking the center point of the resulting rectangle?
Is there a more accurate method? I want to avoid purchasing another DB. We haven't purchased the full DB yet so I can't just try it and compare the results to Google Maps.
Well actually ZIP codes do not always encompass cities. Zip codes are arbitrary regions used to defined postal addresses.
Edit: Not always your assumption that the sum of all ZIP Codes will correspond to the city boundary or will retrieve you the correct centroid.
Your best bet is to get a countys table with spatial data in it.
In PostGIS a simple ST_Centroid(GeometryField) would suffice to get you the centroid of a polygon. That works out for any type of polygons.
If you are in the US, probably exists a public county/cities/states dataset availuable on the internet. Consider GIS tools for doing this work.
Would that be very helpful? That might give you something that approximates the geographic center, but normally when you talk about the center of the city, you are talking about the town square, or the commercial center, or the historical center.
Go to google maps for example. If you search for New York, it will take you directly to Times Square. Isn't that really what you expect if you search for the center of that City.
Well, the center of a city is impossible to calculate exactly, as there are probably as many views on what the center is as there are people...
Instead of using just the min/max points of the zip code areas, you could get the average of all positions, that would give you a more weighted position.
If you have an approximate number of people for each zip code you could use that as weight for the points, that would give you a "gravital center" of the population.
City Hall is always used to define the city center, used by the National Transportation and Highways division, all globes and maps.
I would use the average value of the four coordinates of the four borders of the town as the geographical center, using the Google map.

Resources