Ordering cheat sheet

Non-strict orders: ≤

The symbol ≤ denotes a generalization of “less than or equal”, and it defines either a partial or total ordering over a set P (in the table below a,b ∈ P):

Constraint (Non-strict) partial order (Non-strict) total order
Reflexivity: a ≤ a x x
Antisymmetry: if a ≤ b and b ≤ a then a = b x x
Transitivity: if a ≤ b and b ≤ c then a ≤ c x x
Totality: either a ≤ b or b ≤ a x

Strict orders: <

The symbol < denotes a generalization of “less than”, and it defines either a partial or total ordering over a set P (in the table below a,b ∈ P):

Constraint (Strict) partial order (Strict) total order
Irreflexivity: ¬(a < a) x x
Asymmetry: if a < b then ¬(b < a) x x
Transitivity: if a < b and b < c then a < c x x
Totality: either a < b or b < a x

Note the difference between asymmetry and antisymmetry.

Type of relation Constraint
Asymmetric relation if a < b then ¬(b < a)
Antisymmetric relation
(two equivalent definitions)
if a ≤ b and b ≤ a then a = b
if a ≠ b then ¬(b ≤ a)

Metrics cheat sheet

Question: When can a distance function d(x,y) be called metric, pseudo-metric, quasi-metric or semi-metric?

Constraint Metric Pseudo Quasi Semi
Non-negativity: d(x,y) ≥ 0 x x x x
Identity of indiscernibles: d(x,y)=0 ⇒ x=y x x x
Symmetry: d(x,y) = d(y,x) x x x
Triangle inequality: d(x,z) ≤ d(x,y)+d(y,z) x x x

Table derived from Wikipedia article on metric spaces: http://en.wikipedia.org/wiki/Metric_(mathematics)

Pyramidal tile cache cheat sheet

This table lists the number of total tiles for increasing zoom-level in a tile cache. The tile cache is assumed to be pyramidal: \left|z_{i}\right| = n \Rightarrow \left|z_{i+1}\right| = n \dot 4.

level 1: 1 tile
level 2: 5 tiles
level 3: 21 tiles
level 4: 85 tiles
level 5: 341 tiles
level 6: 1,365 tiles
level 7: 5,461 tiles
level 8: 21,845 tiles
level 9: 87,381 tiles
level 10: 349,525 tiles
level 11: 1,398,101 tiles
level 12: 5,592,405 tiles
level 13: 22,369,621 tiles
level 14: 89,478,485 tiles
level 15: 357,913,941 tiles
level 16: 1,431,655,765 tiles
level 17: 5,726,623,061 tiles
level 18: 22,906,492,245 tiles
level 19: 91,625,968,981 tiles
level 20: 366,503,875,925 tiles
level 21: 1,466,015,503,701 tiles

Google fusion tables cheat sheet

See below for commands using the Fusion Tables API. Example table is the oldschool message wall public table. Note that examples are shown first without the required url-encoding.

Authenticating: Getting the auth token

To authenticate you may use the following test account myjdoe.

  • account: myjdoe@gmail.com
  • password: JoesSecret

Response:

SID=DQAAAHcAAAD90F7mQKULu7fY44z-maGyaTBElaKsaBvypHqU88b7mqVU93Lyf_1sr7ZbxSosjx2e6dT4LSOswAYG3fzAFVjQ-Z8VBS7-oloLNfNZF3A9qMhhI-cpDxoUe_3SUfdUsTfmk34a4wnkok4im77J-vBM5OqmMxLTE8JaDlylHgG2RA
LSID=DQAAAHoAAADkmXi_iKlUyVI_tuZ7n__6R9PkF3jIior9YnbO5a6lYFtNXxez2Ymw3sXbHKU48IwWhztVfDVUBF4UcCuH2rs3v6s5M1-duCG8gXaJph0oJByr3_Rj9olzm9Zlo5JKgcOiSNN38PY0jnONuuqR2G22KT-meIls05soufg8GEX-Xg
Auth=DQAAAHoAAAA3fDq7sZbeekb_x96Z7icle8VzWyucA50O2HnzUxbG_Y_PfaLfv5HmljUvNJoN1Owrgei796p-LGX-3l1KDRacWF_QhhSpAusdAVgSvxVlqrsJAc52Wu0CFb60_m19AwbbnLjd-CvIy-A-gwBI2Oi0O29lEU0qeL-JMOmiq_UtuQ

Auth is the token.

To make an authenticated POST request use the following header: Authorization: GoogleLogin auth=DQAAAHoAAA... which includes the token.

Query with SELECT

Querying data is done with HTTP GET and the SELECT command. Does not require authentication for public, exportable tables like the oldschool message wall public table.

Select all rows

http://www.google.com/fusiontables/api/query?sql=SELECT * FROM 380584

Try it.

Select rows with WHERE clause

http://www.google.com/fusiontables/api/query?sql=SELECT Message FROM 380584 WHERE User='Kostas'

Try it.

Select rows with spatial clause

http://www.google.com/fusiontables/api/query?sql=SELECT * FROM 380584 WHERE ST_INTERSECTS(Geo, CIRCLE(LATLNG(55.67892,12.58338),5000))

Try it.

Add data with INSERT

Adding rows of data is done with HTTP POST and the INSERT command. Requires authentication.

Notice we are using the token retrieved in the authentication step.

Response:

rowid
401

Get column names with DESCRIBE

Discovering column names is done with HTTP POST and the DESCRIBE command. Requires authentication.

Notice we are using the token retrieved in the authentication step.

Response:

column id,name,type
col0,User,string
col4,Message,string
col5,Geo,location

Client libraries by Google

To help create the API calls, you can use the client libraries developed and shared by Google instead of curl.

Libraries exist for the following languages:

Client libraries
Java gdata-java-client
Javascript gdata-javascript-client
.NET google-gdata
PHP Distributed as part of zend.
Python gdata-python-client
Objective C gdata-objectivec-client