update docs and comments
This commit is contained in:
		
							parent
							
								
									103d955300
								
							
						
					
					
						commit
						c65239853a
					
				
							
								
								
									
										28
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								README.md
									
									
									
									
									
								
							@ -16,6 +16,34 @@ var cell = S2.S2Cell.FromLatLng(latlng, level);
 | 
				
			|||||||
cell.getNeighbors();  // [ cellLeft, cellDown, cellRight, cellUp ]
 | 
					cell.getNeighbors();  // [ cellLeft, cellDown, cellRight, cellUp ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cell.getLatLng();     // { lat: 40.2574448, lng: -111.7089464 }
 | 
					cell.getLatLng();     // { lat: 40.2574448, lng: -111.7089464 }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var key = cell.toHilbertQuadkey();
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Previous and Next
 | 
				
			||||||
 | 
					-----------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You can get the previous and next S2CellId from any given Key:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1. Convert from Lat/Lng to Key (Face and Hilbert Curve Quadtree)
 | 
				
			||||||
 | 
					2. Get the Previous or Next Key
 | 
				
			||||||
 | 
					3. Convert the Key to an Id (uint64 string)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					var key = S2.latLngToKey(40.2574448, -111.7089464);
 | 
				
			||||||
 | 
					var id = S2.toId(key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var nextKey = S2.nextKey(key);
 | 
				
			||||||
 | 
					var nextId = S2.toId(nextKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var prevKey = S2.prevKey(key);
 | 
				
			||||||
 | 
					var prevId = S2.toId(prevKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// See it
 | 
				
			||||||
 | 
					console.log(prevKey);
 | 
				
			||||||
 | 
					console.log(key);
 | 
				
			||||||
 | 
					console.log(nextKey);
 | 
				
			||||||
 | 
					console.log(nextId);
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
convert Cell Id to Quadkey
 | 
					convert Cell Id to Quadkey
 | 
				
			||||||
 | 
				
			|||||||
@ -375,6 +375,8 @@ S2.latLngToKey = S2.latLngToQuadkey = function (lat, lng, level) {
 | 
				
			|||||||
  //
 | 
					  //
 | 
				
			||||||
  // S2.idToLatLng(id)
 | 
					  // S2.idToLatLng(id)
 | 
				
			||||||
  // S2.keyToLatLng(key)
 | 
					  // S2.keyToLatLng(key)
 | 
				
			||||||
 | 
					  // S2.nextFace(key)     // prevent wrapping on nextKey
 | 
				
			||||||
 | 
					  // S2.prevFace(key)     // prevent wrapping on prevKey
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // .toKeyArray(id)  // face,quadtree
 | 
					  // .toKeyArray(id)  // face,quadtree
 | 
				
			||||||
  // .toKey(id)       // hilbert
 | 
					  // .toKey(id)       // hilbert
 | 
				
			||||||
@ -382,6 +384,7 @@ S2.latLngToKey = S2.latLngToQuadkey = function (lat, lng, level) {
 | 
				
			|||||||
  // .toId(key)       // uint64 (as string)
 | 
					  // .toId(key)       // uint64 (as string)
 | 
				
			||||||
  // .toLong(key)     // long.js
 | 
					  // .toLong(key)     // long.js
 | 
				
			||||||
  // .toLatLng(id)    // object? or array?, or string (with comma)?
 | 
					  // .toLatLng(id)    // object? or array?, or string (with comma)?
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
  // maybe S2.HQ.x, S2.GPS.x, S2.CI.x?
 | 
					  // maybe S2.HQ.x, S2.GPS.x, S2.CI.x?
 | 
				
			||||||
  return S2.S2Cell.FromLatLng({ lat: lat, lng: lng }, level).toHilbertQuadkey();
 | 
					  return S2.S2Cell.FromLatLng({ lat: lat, lng: lng }, level).toHilbertQuadkey();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user