update manhattan grid example

This commit is contained in:
rolux 2012-04-13 23:18:40 +02:00
parent 7166d86666
commit 11aa611a58

View file

@ -8,7 +8,7 @@ Avenue A) and Zero St (a.k.a. Houston St). Avenues east of Zero Ave, just as
Streets south of Zero St, have negative numbers. Broadway, which will split not Streets south of Zero St, have negative numbers. Broadway, which will split not
only Manhattan but the entire globe into an eastern and a western hemisphere, only Manhattan but the entire globe into an eastern and a western hemisphere,
retains its orientation, but is adjusted slightly so that it originates at the retains its orientation, but is adjusted slightly so that it originates at the
intersection of Zero & Zero. From there, Broadway, Zero Ave and Zero Street intersection of Zero & Zero. From there, Broadway, Zero Avenue and Zero Street
continue as perfectly straight equatorial lines. All three will intersect once continue as perfectly straight equatorial lines. All three will intersect once
more, exactly halfway, in the Indian Ocean, (southwest of Australia), at the more, exactly halfway, in the Indian Ocean, (southwest of Australia), at the
point furthest from Manhattan.<br><br> point furthest from Manhattan.<br><br>
@ -16,9 +16,9 @@ As subsequent avenues remain exactly parallel to Zero Ave, and subsequent
streets exactly parallel to Zero St, they form smaller and smaller circles streets exactly parallel to Zero St, they form smaller and smaller circles
around the globe. The northernmost and southernmost streets are small circles around the globe. The northernmost and southernmost streets are small circles
in Central Asia (east of the Caspian Sea) and the southern Pacific (near Easter in Central Asia (east of the Caspian Sea) and the southern Pacific (near Easter
Island), the westernmost and easternmost avenues are circles in the North Island), the westernmost and easternmost avenues small circles in the North
Pacific (west of Hawaii) and the South Atlantic (near St. Helena). These four Pacific (west of Hawaii) and the South Atlantic (near St. Helena). These four
extreme points are the North Pole, South Pole, West Pole and East pole of the extreme points are the North Pole, South Pole, West Pole and East Pole of the
coordinate system. coordinate system.
*/ */
@ -28,10 +28,9 @@ coordinate system.
Include the Image module. Include the Image module.
*/ */
Ox.load('Image', function() { Ox.load('Image', function() {
//'Etoile': {lat: 48.87377, lng: 2.29505}
/* /*
Ox.EARTH_CIRCUMFERENCE (40075016.68557849) is a built-in constant Ox.EARTH_CIRCUMFERENCE (40075016.68557849) is a built-in constant.
*/ */
var C = Ox.EARTH_CIRCUMFERENCE, var C = Ox.EARTH_CIRCUMFERENCE,
/* /*
@ -58,8 +57,8 @@ Ox.load('Image', function() {
Ox.getBearing returns the bearing, in degrees, from one lat/lng pair to Ox.getBearing returns the bearing, in degrees, from one lat/lng pair to
another. To make sure that avenues and streets cross at an exact right another. To make sure that avenues and streets cross at an exact right
angle, we first calculate the bearing of a line that cuts the upper angle, we first calculate the bearing of a line that cuts the upper
western quadrant of Columbus Circle in half, then subtract 45 degrees western quadrant of Columbus Circle in half, then add 45 degrees for
for the direction of the avenues and add 45 degrees for the direction the direction of the avenues and subtract 45 degrees for the direction
of the streets. of the streets.
*/ */
bearing = ( bearing = (
@ -67,6 +66,7 @@ Ox.load('Image', function() {
+ Ox.getBearing(points['5 & 59'], points['8 & 59']) + Ox.getBearing(points['5 & 59'], points['8 & 59'])
) / 2 + 180, ) / 2 + 180,
bearings = { bearings = {
// fixme: Ox.mod ?
avenues: (bearing + 45) % 360, avenues: (bearing + 45) % 360,
streets: (bearing - 45) % 360 streets: (bearing - 45) % 360
}, },
@ -120,8 +120,8 @@ Ox.load('Image', function() {
bearings.streets bearings.streets
); );
/* /*
The second intersection of 0th Ave, 0th St and Broadway is half of the The second intersection of Zero Avenue, Zero Street and Broadway is half of
Earth's circumference away from the first one, in any direction. the Earth's circumference away from the first one, in any direction.
*/ */
points['-0 & -0'] = Ox.getPoint( points['-0 & -0'] = Ox.getPoint(
points['0 & 0'], points['0 & 0'],
@ -130,12 +130,12 @@ Ox.load('Image', function() {
); );
/* /*
Now that we have constructed the origin, we can calculate the bearing of Now that we have constructed the origin, we can calculate the bearing of
Broadway, which runs from 0th & 0th through Columbus Circle. Broadway, which runs from Zero & Zero through Columbus Circle.
*/ */
bearings.broadway = Ox.getBearing(points['0 & 0'], points['8 & 59']), bearings.broadway = Ox.getBearing(points['0 & 0'], points['8 & 59']),
/* /*
Also, we can construct the poles, each of which is a quarter of Earth's Also, we can construct the poles, each of which is a quarter of Earth's
circumference away from 0th & 0th. circumference away from Zero & Zero.
*/ */
poles = { poles = {
north: Ox.getPoint(points['0 & 0'], C / 4, bearings.avenues), north: Ox.getPoint(points['0 & 0'], C / 4, bearings.avenues),
@ -161,8 +161,8 @@ Ox.load('Image', function() {
/* /*
Now we calculate circles for Broadway, Avenues and Streets. Ox.getCircle Now we calculate circles for Broadway, Avenues and Streets. Ox.getCircle
returns an array of lat/lng pairs that form a circle around a given point, returns an array of lat/lng pairs that form a circle around a given point,
with a given radius and a given precision (the circle will have with a given radius and a given precision, so that the circle will have
<code>Math.pow(2, precision)</code> segments). <code>Math.pow(2, precision)</code> segments.
*/ */
lines = { lines = {
/* /*
@ -232,7 +232,7 @@ Ox.load('Image', function() {
/* /*
<code>getASByLatLng</code> takes lat/lng and returns avenue/street. To <code>getASByLatLng</code> takes lat/lng and returns avenue/street. To
compute the avenue, we subtract the point's distance from the West Pole, in compute the avenue, we subtract the point's distance from the West Pole, in
avenues, from the total number of avenues, to compute the street, we avenues, from the total number of avenues. To compute the street, we
subtract the point's distance from the North Pole, in avenues, from the subtract the point's distance from the North Pole, in avenues, from the
total number of streets. We also return the bearing of the avenues at this total number of streets. We also return the bearing of the avenues at this
point (which form a right angle with the line from the point to the West point (which form a right angle with the line from the point to the West