geocell Package

geocell Module

Conversion of GeocellJava to Python.

Uses bit manipulation to create GeocellJava compatible numbers.

geocell.geocell.create(point, resolution)[source]

Create a new geocell and return it and the bounds that describe it.

geocell.geocell.decrease_resolution(geocell, new_resolution)[source]

Return the geocell with a smaller resolution.

Notes

Does not return bounds because multiplying out the current bounds will not reliably recreate the bounds that would have been constructed when starting from scratch. If the bounds are needed, create a new geocell with this resolution.

geocell.geocell.format_geocell(cell, use_direction_chars=True)[source]
geocell.geocell.get_bounds(geocell)[source]

Get the bounds that a geocell represents.

geocell.geocell.get_east(cell)[source]

Get the geocell immediately east of the provided geocell.

Notes

Aligns resolution to end in a longitude value. This simplifies the implementation of the recursive function by avoiding checking whether the resolution ends in a latitude or longitude bit and how that affects the shifts and modifiers.

geocell.geocell.get_north(cell)[source]

Get the geocell immediately north of the provided geocell.

Notes

Aligns resolution to end in a longitude value. This simplifies the implementation of the recursive function by avoiding checking whether the resolution ends in a latitude or longitude bit and how that affects the shifts and modifiers.

geocell.geocell.get_resolution(geocell)[source]
geocell.geocell.get_south(cell)[source]

Get the geocell immediately south of the provided geocell.

Notes

Aligns resolution to end in a longitude value. This simplifies the implementation of the recursive function by avoiding checking whether the resolution ends in a latitude or longitude bit and how that affects the shifts and modifiers.

geocell.geocell.get_west(cell)[source]

Get the geocell immediately west of the provided geocell.

Notes

Aligns resolution to end in a longitude value. This simplifies the implementation of the recursive function by avoiding checking whether the resolution ends in a latitude or longitude bit and how that affects the shifts and modifiers.

geocell.geocell.increase_resolution(geocell, point, bounds, new_resolution)[source]

Increase the resolution of a geocell and return the new geocell and bounds.

geocell_bits Module

Version of geocell using an array of ‘0’ and ‘1’ characters instead of numbers.

Notes

This version is slightly slower than the bit manipulation method, based on timeit results, but is left as a reference. Javascript implementations require this method for high resolutions due to the lack of native support for 64-bit numbers. With resolutions lower than 28, 32-bit numbers can be used to represent the cells using bit manipulation. In many cases, that should be sufficient for mapping purposes.

geocell.geocell_bits.bits_to_geostring(bits)[source]
geocell.geocell_bits.create_geocell_bits(point, resolution)[source]
geocell.geocell_bits.create_geostring(point, resolution)[source]
geocell.geocell_bits.geostring_to_bits(geostring)[source]

geocell_bits_test Module

Tests for Geocell bit string conversion.

class geocell.geocell_bits_test.TestGeomodel(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_to_from()[source]

geocell_test Module

Tests for Geocell functions.

class geocell.geocell_test.TestGeomodel(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_decrease_resolution()[source]
test_east_west_wrapping()[source]
test_formatting()[source]
test_get_bounds()[source]
test_to_from()[source]

geomodel Module

Convert geocells to and from GeoModel type strings.

geocell.geomodel.from_geocell(cell)[source]

Given a geocell, output the roughly equivalent GeoModel string.

Notes

Correspondences are only 1:1 for resolutions that are a multiple of 4, but this function will produce some output no matter what.

geocell.geomodel.to_geocell(geomodel_str)[source]

Construct a geocell from a base 16 string representation.

geomodel_test Module

Tests for GeoModel string conversion and directional movement.

class geocell.geomodel_test.TestGeomodel(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_grid()[source]
test_to_from()[source]
test_wander()[source]

geostring Module

Convert geocells to and from geostrings.

geocell.geostring.create(point, resolution)[source]

Create a geostring without going through geocell.

Faster if no manipulation of the end result is necessary.

geocell.geostring.from_geocell(cell)[source]
geocell.geostring.to_geocell(geostring)[source]
geocell.geostring.verify_geostring(geostring)[source]

geostring_test Module

Tests for Geostring creation and conversion.

class geocell.geostring_test.TestGeomodel(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_to_from()[source]
test_verify()[source]