International Postcode system using Cubic Meters

Addressing the whole world with a simple way to tell a location




This is a proposal for a geolocation system that was first discussed on the web in a public forum and is herein explained.

A matrix/grid of cubes with an edge of 21 million meters is centered on the center of mass of Earth and oriented along its imaginary axis (North-South), with Greenwich/Prime Meridian along the middle of the front. It is a matrix of 9261000000000000000000 (21 million cubed) cubes of one meter cube each.

The number 21 million, interestingly, is the limit of BTC that the bitcoin network will ever have in circulation. Interestingly, 21 million cubed has 22 digits. Using such number of digits we are talking not of billions, not of trillions, not of quadrillions, not of quintillions, but of sixtillions number of cubes. This gives a compact, universal, unambiguous and simple way of expressing any geolocation on Earth, that just like a telephone number can easily be told. It encompasses all geolocations on Earth, including the interior and surrounding of it, and it is a size that is good for that purpose. It is roughly the size of a cube of water that had the same mass of the Earth at normal pressure and temperature (NPT [defined as air at temperature: 20°C (68°F) and pressure: 1 atm (Earth's atmospheric pressure at sea level)]).

The order of the cubes is the following: the first cube is closest to the center of our Matrix of cubes, given that we have eight adjacent cubes there; and so the first (cube 0000000000000000000001) must be on what will be our first layer, approaching Greenwich/Prime Meridian, North and West. Then, the second cube, also on our first layer, is the adjacent cube on the right (facing it from the Greenwich/Prime Meridian). We always go around till we complete the layer. So facing our matrix of cubes from the Greenwich/Prime Meridian we have the following cube numbers:



And so on, till the layer is complete and we move on to the center of the next layer, alternating what will be the next layer to make our counting as natural, even and contiguous as possible. The layers in the counting will be alternating as each is completed in the counting process so that the last two layers will be, namely, the closest one to the Greenwich/Prime Meridian and the one more far away from it, similar to the so called Front Face and Back Face of the Rubik's cube. All of our layers are parallel to those last two, obviously.

A dash may be used to separate the prefix part that will be sufficient for computer systems to give a few auto-complete recommendations of the most likely inhabitable cubes with such prefix. For instance, if the centre of the cube 7636535637373773383976 was the closest to the door of a residential flat within a few miles from you, but the prefix 7636535637 would restrict enough the possibilities of nearby inhabitable cubes, then the Cubic Postcode would be: 7636535637-373773383976. When typing the cube number in a mobile app, you would need only to type 7636535637 to get a single recommendation in the auto-complete options.

This system may reveal itself interesting for real estate where volumetric delimitation is so difficult in any other way. With this proposed system there is no need to define borders using a complicate set of coordinates: you just tell which cubes you are talking about. You can even set a channel in a IRC channel with a cryptographic hash or checksum of a set of sequenced cubes, including if some cubes are in other disjointed areas, using the prefix of that hash for the name of your IRC channel or to create a hashtag for that places that you are talking about. This system may also reveal itself interesting when moving in VR worlds. Imagine saying: "OK Google, cube 9... and as soon as you are saying '9' all cubes that start with '9' are highlighted. And if you would say another digit it would then restrict the number of cubes highlighted, and so on and so forth. If you kept restricting it, the cubes could be so far from you that you could not see them in your field of vision in which case you would see a vector pointing in the direction of its center with the color of that vector representing the distance that such cube is apart from you (ranging from the coolest violet, if it were zero meters apart to the hottest red if it was twenty one million meters apart. Basically you just divide the distance in meters by twenty million meters to get the percentage and find the corresponding color in the visible spectrum of colors, 0% being violet and 100% being red).

So you could be exploring a world using the first digits of cubes to jump from one to another. For instance, if a place reminded you of a specific thing that you liked to explore with cubes that start with 235... you just go on saying "OK Google new cube 235... and it will take you to the closest cube that starts with 235... that you haven't visited before. This way, you could be exploring worlds in a way that you would remember better. For instance, being in a village that makes you think it would be a great place to be in the summer, eating ice cream and with a hat of straw; and it also remembers you of specific friends that used to be around you in summertime during your holidays. This is just an example, naturally many other things could be in your mind, like you could think this would be a great place to live if you were a musician, or any other thing that could cross your mind, for that matter. Whatever you had in mind you could start exploring that world using a specific pattern in the first digits of the next cubes you would pick. So you could just say: "Next 235..." and it would take you to the closest cube that started with 235 in the direction and way you were moving towards. Also you could just say four cubes to make a bezier curve since a bezier curve only needs four points to be specified. The centers of those four cubes would be the four points of your bezier curve. And you could then say the speed at which you wanted that curve to be traveled by. Specifying the bezier curves and their speeds allows one to create trajectories. You could then ask an app like Google Earth to render those travelings at a specific date and time, under any weather/atmospheric circumstances that you wanted... Boom! Just using strings of 22 digits to make bezier curves, deciding the speeds for each of them, etc., and there you were: ready to render real world timelapsing videos as a God-like filmmaker using Google Earth and its state-of-the-art tech.

There is also the real possibility that the spacetime continuum has more than the three spatial dimensions that we live in and that we learn to move physical objects or particles, and waves, into a higher spatial dimension that allow us to observe every single location of the interior of our planet Earth or that we learn to find it out with spiritual development of psychic and/or supernatural abilities and senses we don't have yet developed in the physical universe. There is a great chance that dowsing pendulums using smart tech tracking and communication with supercomputers in a grid with superintelligence will also allow us to sense and detect the composition of every single cube.

On top of that the system can be extended at a specific time to go ad infinitum to smaller or greater scales "microcubing" or "macrocubing" each cube, like in a fractal that can be travelled both to infnitely wide larger places and to infinite wide smaller places, if you can compute them to the desired scale. It might also be interesting to surf a virtual world using a map of cubes you are familiar with. For instance as you get used to move in your town using AR displaying the Cubic Postcode grid of cubes (each labeled with its 22-digits number) you might then use that map of cubes to surf a different world, positioning it as you want - XYZ - in your reference/map of cubes. This may increase the plasticity of your brain and increase your memory and cognitive function as you will be making your brain flex and interconnect more memories interleaving and superimposing different worlds in different layers/areas of your inner worlds representations.

To summarize and conclude: this is an international postcode system using cubic meters. Each postcode location would be quite small, that is, the size of a cubic meter. Each postcode location would be a meter cube in a grid of cubes with an edge of 21 million cubes. This would total 9,261,000,000,000,000,000,000 cubes. All cubes would be numbered, using 22 algarisms ( {21 Million}3 = 22 digits ).

This would have many applications and particularly cool with augmented reality, semantic web and new ways of world mapping for propriety register and real estate. 9,261,000,000,000,000,000,001 to 9,999,999,999,999,999,999 could be codes used for moving items, like telephone numbers, ISBNs, RFIDs, car-registration-number-plates, citizenship-ID or IP addresses. Everyone would get used to these string codes of 22 algarisms.

Many people argue that 22-digits would be hard to remember or communicate without errors. But does anyone know by heart the 16 digits (plus start and expiration dates and security digits) of their credit cards or all the phone numbers in their contacts list? Even without remembering them, it is a simple way of listing them. Also people argue one cannot make money with this system. But people will be able to create monuments of their favorite cubes and worship them. That can certainly be monetised economically. This is a project of great dimension for the whole planet, civilization, and life on Earth. It is a bit like the construction of the Egyptian pyramids. You have to put it into perspective and give it its true dimensions to see the beauty of it. It is a whole new wonder on Earth. A whole new scale and standard for the world. Maybe architects can better see the beauty and true dimension of this project and endeavor.

Note that, no matter where you are on the globe, if you are able to see the edges of the cubes with AR, the cubes where you are will have a special alignment with the Sun, at noon time in London, by Big Ben, (GMT).

The author of this model, Daniel Alexandre, a Portuguese with a Bachelor in Computers Engineering from the London South Bank University - living in London - admits this model and system of geolocation may have had inspiration and influence from The Matrix and Cube movies; and also from the Rubik cube toy and Minecraft videogame.

The number 42 - considered by many people a peculiar number with a special place in literature and maths and even the name of a very well known and successful university in France [https://www.42.fr] that seems to be expanding into an international online school for the serious geek - is also ten factorial divided by the number of seconds in a day. This mysterious discovery is to be attributed to Daniel Alexandre. He is also most well known for his radical activism against bloody bullfighting and vigorous support for animal rights and their well-being. He wrote a manifesto on that subject that was published as a book with ISBN: 972-9098-50-6.

And, of course, you can use a 22-digits Cubic Postcode cube as a #hashtag to tell where about you are or are talking about. Like this one: #3141592653589793238462 (https://www.google.com/maps?q=-47,-66) inspired in the number Pi: 3.?4?5...

Also, the hypocenters of earthquakes may be referenced with their cubes.

Daniel Alexandre has certainly a high profile (at least much higher than the average folks) for being Satoshi Nakamoto - the mysterious creator of bitcoin - since he is a computer scientist and OOP programmer (with a decent knowledge of Concurrency, Multithreading, Basic Networking with sockets and its ports, TCP/IP vs. UDP protocols, and Design Patterns) and did file a patent in the UK in 2007 related to 'digital cash money' that shows some insight into the future and inception of bitcoin [Link 1].
Also, his Paypal account handle is: 'mymondex' which relates to a Mastercard technology (back in 2007) along ideas of a New World Order.

He is a legendary user of the Bitcoin Forum with thousands of posts under two different user accounts, where he digresses about many things like his theory for the evolution of a brain that has a special ability to recognize the salient features of the (3,4,5) Pythagorean triple, where five is the hypotenuse correponding to less pleasant half-tones. There is no other sound reason or better explanation for why our brains evolved to perceive so well the 12 halftones in between the doubling of frequency that constitutes the musical octave. He is fascinated with the (3,4,5) triple, saying that we should be worshiping it to the Cosmos [Link 2].



# Author: Daniel Alexandre, BEng (Hons)
# Collaboration: Vyacheslav Sokolov (https://github.com/TheOsch) & Houcem Chlegou (https://github.com/chesedo)

# Used resources: 
# 1) https://en.wikipedia.org/wiki/ECEF and https://en.wikipedia.org/wiki/Geographic_coordinate_conversion
# 2) https://oeis.org

# cube is the cube number without leading zeros. Enter required value, manually!
# change for whatever you want; 22 digits cube without leading zeros
cube = 3141592653589793238462 # Inspired in PI number. Change to desired  cube!

a = 441000000000000 # a is the constant number of cubes in one layer. And last cube in first layer

cube_projection = (cube % a) # The cube projected on a cube on the first layer. We use the modulus operation. Simple.
half_of_1 = (1/2.0)

n_squareference = (((cube_projection - 1) ** half_of_1) / 2) + 1 # n_squareference is the squareference index number.
n_squareference = int(n_squareference)

# Let's calculate the numbers of cubes in the top-right, bottom-right and bottom-left corners
# of the square number n_squareference
right_top = (2 * (n_squareference - 1)) ** 2 + 2 * n_squareference
right_bottom = right_top + 2 * n_squareference - 1
left_bottom = right_bottom + 2 * n_squareference - 1

# Calculate the Y coordinate
if cube_projection >= right_top and cube_projection <= right_bottom:
    Y_meters = n_squareference
elif cube_projection >= left_bottom:
    Y_meters = -n_squareference + 1
elif cube_projection < right_top:
    Y_meters = cube_projection - right_top + n_squareference
else: # if cube_projection > right_bottom and cube_projection < left_bottom
    Y_meters = right_bottom - cube_projection + n_squareference
Y_meters -= 0.5
    
# Calculate the Z coordinate
if cube_projection <= right_top:
    Z_meters = n_squareference - 1
elif cube_projection >= right_bottom and cube_projection <= left_bottom:
    Z_meters = -n_squareference
elif cube_projection < right_bottom:
    Z_meters = right_top - cube_projection + n_squareference - 1
else: # if cube_projection > left_bottom
    Z_meters = cube_projection - left_bottom - n_squareference
Z_meters += 0.5

n_layer = cube / a
n_layer = int(n_layer)
n_layer += 1

if ((n_layer % 2) != 0 ): # if n_layer is odd
    X_meters = n_layer / float(2) # The XYZ_earth X coordinate in meters if layer is odd

if ((n_layer % 2) == 0 ): # if n_layer is even    
    X_meters =  - (n_layer - 1) / float(2) # The XYZ_earth X coordinate in meters if layer is even
    
print('X_meters: ' , X_meters) 
print('Y_meters: ' , Y_meters)
print('Z_meters: ' , Z_meters)


# Author: Daniel Alexandre, BEng (Hons)
# Collaboration: Vyacheslav Sokolov (https://github.com/TheOsch)
from sys import argv


def coord_round(x):
    '''
    # This function transfers the float coordinate to an integer value.
    
    # It can be replaced in order to handle the case when a coordinate
    # is integer, i.e. the point is between two cubes in some special way.

    # The default implementation just chops out a fractional part of the coordinate
    '''
    return int(x) if x >= 0 else int(x) - 1


# X, Y, Z are the coordinates of a point in ECEF cooredinate system.
# Provide them in a command line ('python xyz2code.py [X] [Y] [Z]')
# or change default values here
if len(argv) == 4:
    X = float(argv[1])
    Y = float(argv[2])
    Z = float(argv[3])
else:
    # These values result in the postal code 3141592653589793238462
    # (inspired by the Pi number)
    X = 3561896.5
    Y = -8402969.5
    Z = -9767161.5


# Transfer the float coordinates to integers.
(x, y, z) = (coord_round(coord) for coord in (X, Y, Z))
print('x, y, z =', x, y, z)

# Let's agree upon some terms:
#
# Layer - a set of cubes sliced by X. 1st Layer is a set of cubes where X in [0, 1);
#         2nd Layer - [-1, 0); 3rd - [1, 2); 4th - [-2, -1) etc. A number of Layer is
#         determined by X coordinate and nothing else. The postal code is ordered by
#         layer by layer. Each layer contains 21 million * 21 million = 441000000000000
#         cubes. In other words, a layer number is a postal code divided by 441000000000000.
# Projection - a projection of a particular layer to layer 1. For example, a projection of
#         cube 441000000000001 is cube 1; a projection of cube 882000000000123 is cube 123.
#         In other words, a projection is a remainder of division of postal code
#         by 441000000000000.
#         A number of cube in a projection is determined by Y and Z but not X
# Square - a set of cubes in projection that form a particular squareference.
#          For example, square 1 is cubes 1,2,3,4;
#          square 2 is cubes 5-16; suare 3 is cubes 17-36 and so on.

# First, let's find a square number.
# The square consists of 4 sides: top, left, right and bottom. All the cubes in left and right
# sides have the same Y coordinate (negative on the left side and positive on the right side,
# but the absolute values are the same. So do top and bottom sides, but the coordinate is Z.
# Thus, the square number is just one of the point's coordinates, Y or Z. Which one?
# Obviously: the Y coordinate can't be more than the coordinate of the right side and less than
# the coordinate of the left one; so do Z coordinate, top and bottom sides.
# Thus, the square number is just a maximum of absolute values of Y and Z

square_number = max(y + 1, z + 1, -y, -z)
print('square_number =', square_number)

# Now we need to calculate the numbers of cubes in the top-left, top-right, bottom-right
# and bottom-left corners of the square we found

left_top = (2 * (square_number - 1)) ** 2 + 1
right_top = left_top + 2 * square_number - 1
right_bottom = right_top + 2 * square_number - 1
left_bottom = right_bottom + 2 * square_number - 1

print('corners =', left_top, right_top, right_bottom, left_bottom)
# Now let's find a number of a cube in the projection

if square_number == - y: # left side
    if square_number == z + 1: # top-left corner
        cube_p = left_top
    else:
        cube_p = z + left_bottom + square_number
elif square_number == y + 1: # right side
    cube_p = right_top + square_number - 1 - z
elif square_number == z + 1: # top side
    cube_p = right_top - square_number - y
else: # square_number == - z, bottom side
    cube_p = right_bottom + square_number - y

print('cube_p =', cube_p)

# Now let's find layer number (decreased by 1 - we need the first layer to have a number 0)

if x >= 0:
    layer_number = x * 2
else:
    layer_number = -x * 2 - 1

# Let's join them 
code = layer_number * 441000000000000 + cube_p

# That's all 
print('code =', code)


# Author: Daniel Alexandre, BEng (Hons)
# Collaboration: Vyacheslav Sokolov (https://github.com/TheOsch)
# Converts between GPS coordinates (Latitude-Longitude-Altitude) and X-Y-Z cartesian coordinates, or vice versa

from __future__ import print_function
import math

RADIUS = 6378137
FLATTENING_DENOM = 298.257223563


def FLATTENING():
    return 1 / FLATTENING_DENOM


def POLAR_RADIUS():
    return RADIUS * (1 - FLATTENING())


def RADIUS_SQRT():
    return RADIUS * RADIUS


def POLAR_RADIUS_SQRT():
    return POLAR_RADIUS() * POLAR_RADIUS()


def ECCENTRICITY2():
    return (2 - FLATTENING()) * FLATTENING()


def ECCENTRICITY():
    return math.sqrt((RADIUS_SQRT() - POLAR_RADIUS_SQRT()) / RADIUS_SQRT())


def ECCENTRICITY_PRIME():
    return math.sqrt((RADIUS_SQRT() - POLAR_RADIUS_SQRT()) / POLAR_RADIUS_SQRT())


print(RADIUS)
print(FLATTENING_DENOM)
print(FLATTENING())
print(POLAR_RADIUS())


def LLAToECEF(lat, lon, alt=0):
    print(lat, lon, alt)
    rlat = lat / 180 * math.pi
    rlon = lon / 180 * math.pi

    slat = math.sin(rlat)
    clat = math.cos(rlat)

    N = RADIUS / math.sqrt(1 - ECCENTRICITY2() * slat * slat)

    x = (N + alt) * clat * math.cos(rlon)
    y = (N + alt) * clat * math.sin(rlon)
    z = (N * (1 - ECCENTRICITY2()) + alt) * slat

    return [x, y, z]


def ECEFToLLA(X, Y, Z):
    p = math.sqrt(X * X + Y * Y)
    theta = math.atan((Z * RADIUS) / (p * POLAR_RADIUS()))

    sinTheta = math.sin(theta)
    cosTheta = math.cos(theta)

    num = Z + ECCENTRICITY_PRIME() * ECCENTRICITY_PRIME() * POLAR_RADIUS() * sinTheta * sinTheta * sinTheta
    denom = p - ECCENTRICITY() * ECCENTRICITY() * RADIUS * cosTheta * cosTheta * cosTheta

    latitude = math.atan(num / denom)
    longitude = math.atan(Y / X)
    N = getN(latitude)
    altitude = (p / math.cos(latitude)) - N

    if X < 0 and Y < 0:
        longitude = longitude - math.pi

    if X < 0 and Y > 0:
        longitude = longitude + math.pi

    return [degrees(latitude), degrees(longitude), altitude]


def getN(latitude):
    sinlatitude = math.sin(latitude)
    denom = math.sqrt(1 - ECCENTRICITY() * ECCENTRICITY() * sinlatitude * sinlatitude)
    N = RADIUS / denom
    return N


def degrees(angle):
    return angle * (180 / math.pi)


[X, Y, Z] = LLAToECEF(10, 12, 20)
print([X, Y, Z])
print(ECEFToLLA(X, Y, Z))