GeoJSON Class — GeoJSON¶
GeoJSON¶
-
class
aerospike.GeoJSON¶ Starting with version 3.7.0, the Aerospike server supports storing GeoJSON data. A Geo2DSphere index can be built on a bin which contains GeoJSON data, enabling queries for the points contained within given shapes using
geo_within_geojson_region()andgeo_within_radius(), and for the regions which contain a point usinggeo_contains_geojson_point()andgeo_contains_point().On the client side, wrapping geospatial data in an instance of the
aerospike.GeoJSONclass enables serialization of the data into the correct type during write operation, such asput(). On reading a record from the server, bins with geospatial data it will be deserialized into aGeoJSONinstance.See also
from __future__ import print_function import aerospike from aerospike import GeoJSON config = { 'hosts': [ ('127.0.0.1', 3000)]} client = aerospike.client(config).connect() client.index_geo2dsphere_create('test', 'pads', 'loc', 'pads_loc_geo') # Create GeoJSON point using WGS84 coordinates. latitude = 28.608389 longitude = -80.604333 loc = GeoJSON({'type': "Point", 'coordinates': [longitude, latitude]}) print(loc) # Alternatively create the GeoJSON point from a string loc = aerospike.geojson('{"type": "Point", "coordinates": [-80.604333, 28.608389]}') # Create a user record. bins = {'pad_id': 1, 'loc': loc} # Store the record. client.put(('test', 'pads', 'launchpad1'), bins) # Read the record. (k, m, b) = client.get(('test', 'pads', 'launchpad1')) print(b) client.close()
-
class
GeoJSON([geo_data])¶ Optionally initializes an object with a GeoJSON
stror adictof geospatial data.
-
aerospike.wrap(geo_data)¶ Sets the geospatial data of the
GeoJSONwrapper class.Parameters: geo_data (dict) – a dictrepresenting the geospatial data.
-
aerospike.unwrap() → dict of geospatial data¶ Gets the geospatial data contained in the
GeoJSONclass.Returns: a dictrepresenting the geospatial data.
-
class
New in version 1.0.53.