{ "info": { "author": "GeoWave Contributors", "author_email": "geowave.python@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# pygw\nThis project aims to provide Python classes that allow users to interact with a GeoWave data store using the same workflows that are available in the programmatic Java API.\n\n## Environment\n- Python >=3,<=3.7\n- A virtualenv with `requirements.txt` installed\n- A running GeoWave Java Gateway\n\n### Installation From Source\n- Clone GeoWave: `git clone https://github.com/locationtech/geowave.git`\n- Navigate to python directory: `cd geowave/python/src/main/python`\n- Set up virtualenv: `virtualenv -p python3 venv`\n- Activate virtualenv: `source venv/bin/activate`\n- Install requirements: `pip install -r requirements.txt`\n\n## Usage\nIn order to use `pygw`, you must have an instance of GeoWave Py4J Java Gateway Server running. The gateway can be started by using the GeoWave command `geowave util python rungateway`.\n\nYou can then import `pygw` classes into your Python environment.\n\n## Example\nThe following is an example of how `pygw` might be used to write and query some feature data:\n```python\nfrom datetime import datetime\n\nfrom shapely.geometry import Point\n\nfrom pygw.store import DataStoreFactory\nfrom pygw.store.rocksdb import RocksDBOptions\nfrom pygw.geotools import SimpleFeatureBuilder\nfrom pygw.geotools import SimpleFeatureTypeBuilder\nfrom pygw.geotools import AttributeDescriptor\nfrom pygw.geotools import FeatureDataAdapter\nfrom pygw.index import SpatialIndexBuilder\nfrom pygw.query import VectorQueryBuilder\n\n# Create a RocksDB data store\noptions = RocksDBOptions()\noptions.set_geowave_namespace(\"geowave.example\")\n# NOTE: Directory is relative to the JVM working directory.\noptions.set_directory(\"./datastore\")\ndatastore = DataStoreFactory.create_data_store(options)\n\n# Create a point feature type\npoint_type_builder = SimpleFeatureTypeBuilder()\npoint_type_builder.set_name(\"TestPointType\")\npoint_type_builder.add(AttributeDescriptor.point(\"the_geom\"))\npoint_type_builder.add(AttributeDescriptor.date(\"date\"))\npoint_type = point_type_builder.build_feature_type()\n\n# Create a builder for this feature type\npoint_feature_builder = SimpleFeatureBuilder(point_type)\n\n# Create an adapter for point type\npoint_type_adapter = FeatureDataAdapter(point_type)\n\n# Create a Spatial Index\nindex = SpatialIndexBuilder().create_index()\n\n# Registering the point adapter with the spatial index to your datastore\ndatastore.add_type(point_type_adapter, index)\n\n# Creating a writer to ingest data\nwriter = datastore.create_writer(point_type_adapter.get_type_name())\n\n# Write some features to the data store\npoint_feature_builder.set_attr(\"the_geom\", Point(1, 1))\npoint_feature_builder.set_attr(\"date\", datetime.now())\nwriter.write(point_feature_builder.build(\"feature1\"))\n\npoint_feature_builder.set_attr(\"the_geom\", Point(5, 5))\npoint_feature_builder.set_attr(\"date\", datetime.now())\nwriter.write(point_feature_builder.build(\"feature2\"))\n\npoint_feature_builder.set_attr(\"the_geom\", Point(-5, -5))\npoint_feature_builder.set_attr(\"date\", datetime.now())\nwriter.write(point_feature_builder.build(\"feature3\"))\n\n# Close the writer\nwriter.close()\n\n# Query the data (with no constraints)\nquery = VectorQueryBuilder().build()\nresults = datastore.query(query)\nfor feature in results:\n print(feature.get_id())\n print(feature.get_default_geometry())\nresults.close()\n```\n## Dev Notes:\n\n### Building a distributable wheel\nTo build a wheel file for `pygw`, simply execute the command `python setup.py bdist_wheel --python-tag=py3` under the active virtual environment. This will create a distributable wheel under the `dist` directory.\n\n### Building API documentation\nThis project has been documented using Python docstrings. These can be used to generate full API documentation in HTML form. To generate the documentation, perform the following steps:\n - Ensure that the GeoWave Py4J Java Gateway Server is running: `geowave util python rungateway`\n - Generate documentation: `pdoc --html pygw`\n\n Note: This command requires that the python virtual environment is active and that the `pygw` requirements have been installed. This will generate API documentation in the `html/pygw` directory.\n\n### Submodule descriptions\nIn general each submodule tries to mimic the behavior of the GeoWave Java API. If there is ever any question about how something should be done with the Python bindings, the answer is most likely the same as how it is done in Java. The difference being that function names use underscores instead of camel case as is the convention in Java. For example if the Java version of a class has a function `getName()`, the Python variant would be `get_name()`.\n\nThe main difference between the two APIs is how the modules are laid out. The Python bindings use a simplified module structure to avoid bringing in all the unnecessary complexity of the Java packages that the Java variants belong to.\n\n#### config\nThe `config` module includes a singleton object of type GeoWaveConfiguration called `gw_config` that handles all communication between python and the Py4J Java Gateway. The module includes several shortcut objects to make accessing the gateway more convenient. These include:\n- *`java_gateway`* Py4J Gateway Object\n- *`java_pkg`*: Shortcut for `java_gateway.jvm`. Can be used to construct JVM objects like `java_pkg.org.geotools.feature.simple.SimpleFeatureTypeBuilder()`\n- *`geowave_pkg`*: Similar to `java_pkg`, serves as a shortcut for `java_gateway.jvm.org.locationtech.geowave`.\n- *`reflection_util`*: Direct access to the Py4J reflection utility.\n\nThese objects can be imported directly using `from pygw.config import `.\n\nNOTE: the GeoWaveConfiguration has an `init()` method. This is INTENTIONALLY not an `__init__` method. Initialization is attempted when the configuration is imported.\n\n#### base\nThe `base` module includes common classes that are used by other modules. This includes the base `GeoWaveObject` class that serves as a python wrapper for a java reference. It also includes a `type_conversions` submodule that can be used to convert Python types to Java types that are commonly used in GeoWave.\n\n#### geotools\nThe `geotools` module contains classes that wrap the functionality of geotools SimpleFeatures and SimpleFeatureTypes. These classes can be used to create feature types, features, and data adapters based on simple features.\n\n#### index\nThe `index` module contains classes that are used in creating spatial and spatial/temporal indices.\n\n#### query\nThe `query` module contains classes that are used in constructing queries and their constraints.\n\n#### store\nThe `store` module contains classes that can be used to establish connections to the various GeoWave backends. Each store type has a submodule which contains a class that can be used to connect to that store type. For example `from pygw.store.accumulo import AccumuloOptions`. The `DataStore` object can be constructed by passing the options object to the `DataStoreFactory.create_data_store()` method.\n\n#### debug.py\nThis exposes a function called `print_obj` that can be used to help with debugging raw java objects. It will print information about the object in question on both the Python side and on the Java server side. There's a `verbose` flag that will give you more information about the object in question.\n\n### Notes:\n- `j_`-prefixed notation : Java reference variables are prefixed with `j_` in order to distinguish them from Python variables\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://locationtech.github.io/geowave/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pygw", "package_url": "https://pypi.org/project/pygw/", "platform": "", "project_url": "https://pypi.org/project/pygw/", "project_urls": { "Documentation": "https://locationtech.github.io/geowave/pydocs/", "Homepage": "https://locationtech.github.io/geowave/", "Source": "https://github.com/locationtech/geowave/tree/master/python/src/main/python" }, "release_url": "https://pypi.org/project/pygw/1.0.0/", "requires_dist": [ "py4j (==0.10.8.1)", "shapely (==1.6)" ], "requires_python": ">=3,<=3.7", "summary": "GeoWave bindings for Python3", "version": "1.0.0" }, "last_serial": 5915464, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "efede8817538e3fcc0e0870e5ed74d44", "sha256": "ea32f4ef2dfd5ab72621462ace3ae84fca8ad1b8cdb21b69913ff2ba41063c4f" }, "downloads": -1, "filename": "pygw-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "efede8817538e3fcc0e0870e5ed74d44", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3,<=3.7", "size": 84354, "upload_time": "2019-10-02T00:04:27", "url": "https://files.pythonhosted.org/packages/6c/0a/079b49bb76176d3bce657017d06ebf180595a9e8324a4a8792d28de7045a/pygw-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f928f5c81b1356094aa5fd81ae9b57bf", "sha256": "f556f53249aa02b01b474fbf039a7d6d8f0db67499cd5f060fe2c8b6a5b518d1" }, "downloads": -1, "filename": "pygw-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f928f5c81b1356094aa5fd81ae9b57bf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3,<=3.7", "size": 38065, "upload_time": "2019-10-02T00:04:31", "url": "https://files.pythonhosted.org/packages/e7/f4/a6c0f1c25ea65d635ebe42c54682748669c381138ff2957e447c61f00f9d/pygw-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "efede8817538e3fcc0e0870e5ed74d44", "sha256": "ea32f4ef2dfd5ab72621462ace3ae84fca8ad1b8cdb21b69913ff2ba41063c4f" }, "downloads": -1, "filename": "pygw-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "efede8817538e3fcc0e0870e5ed74d44", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3,<=3.7", "size": 84354, "upload_time": "2019-10-02T00:04:27", "url": "https://files.pythonhosted.org/packages/6c/0a/079b49bb76176d3bce657017d06ebf180595a9e8324a4a8792d28de7045a/pygw-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f928f5c81b1356094aa5fd81ae9b57bf", "sha256": "f556f53249aa02b01b474fbf039a7d6d8f0db67499cd5f060fe2c8b6a5b518d1" }, "downloads": -1, "filename": "pygw-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f928f5c81b1356094aa5fd81ae9b57bf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3,<=3.7", "size": 38065, "upload_time": "2019-10-02T00:04:31", "url": "https://files.pythonhosted.org/packages/e7/f4/a6c0f1c25ea65d635ebe42c54682748669c381138ff2957e447c61f00f9d/pygw-1.0.0.tar.gz" } ] }