Skip to content

Simple Google S2 Geometry Porting. Aimed to convert between latLng and Hilbert curve position for SQL search use.

License

Notifications You must be signed in to change notification settings

countingCrow/simple-s2-port

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

simple-s2-port

Simple Google S2 Geometry Porting. Aimed to convert between latLng and Hilbert curve position for SQL search use.

usage

Put the javascript file where ever you want; Modify the arguments that passed into closure as you need.

To create object:

// stander string
var myS2CellId = new CrowS2CellId('1/22030333332200233030');
// fijl string
var myS2CellId = new CrowS2CellId('F1ij[885539,851769]@20');
// token
var myS2CellId = new CrowS2CellId('3467ff41799');
// 'mysql_token'
var myS2CellId = new CrowS2CellId('122030333332200233030');
// lat, lng, level
var myS2CellId = new CrowS2CellId(24.935570, 121.69994, 20);
// latLng, level
var myS2CellId = new CrowS2CellId({lat:24.935570, lng:121.69994}, 20);
// face, i, j, level
var myS2CellId = new CrowS2CellId(1, 885539, 851769, 20);
// face, [i, j], level
var myS2CellId = new CrowS2CellId(1, [885539, 851769], 20);

Methods:

// return latLng object
myS2CellId.getLatLng();
// return array of latLng object
myS2CellId.getCornerLatLng();
// stander toString result without slash, ex: '122030333332200233030'
myS2CellId.toMysqlToken();
// original source toString, ex: '1/22030333332200233030'
myS2CellId.toString();
// compatibility for jonatkins port toString, ex: 'F1ij[885539,851769]@20'
myS2CellId.toString(true);
// original source token, ex: '3467ff41799'
myS2CellId.toToken();

links

About

Simple Google S2 Geometry Porting. Aimed to convert between latLng and Hilbert curve position for SQL search use.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published