mapillary / mapillary-python-sdk

A Python 3 library built on the Mapillary API v4 to facilitate retrieving and working with Mapillary data.
MIT License
37 stars 15 forks source link

API Adapters #58

Closed Rubix982 closed 3 years ago

Rubix982 commented 3 years ago

Adapters to help to deal on a high level with the APIs. Provides easy method, preprocessing steps, range value checking, mapping layers to zoom values and such, exception handling. Quoting from the DocString of vector_tiles.py,

    """Adapter model for dealing with the VectorTiles API, through the DRY principle. The
    VectorTilesAdapter class can be instantiated in the controller modules, providing an
    abstraction layer that uses the Client class, endpoints provided by the APIv4 under
    `/config/api/vector_tiles.py`.

    It performs parsing, handling of layers, properties, and fields to make it easier to
    write higher-level logic for extracting information, and lets developers to focus only
    on writing the high-level business logic without having to repeat the process of parsing
    and using libraries such as `mercantile`, 'vt2geojson' and others, caring only about inputs/outputs

    Usage::
        >>> VectorTilesAdapter().fetch_layer(layer="image", zoom=14, longitude=longitude,
                latitude=latitude,
            )
        >>> VectorTilesAdapter().fetch_layer(layer="sequence", zoom=10, longitude=longitude,
                latitude=latitude,
            )
        >>> VectorTilesAdapter().fetch_layer(layer="overview", zoom=3, longitude=longitude,
                latitude=latitude,
            )            
    """

This is for making future work easier by focusing only on the inputs, and the outputs. The vector_tiles.py and entities.py, will depend on client, making use of the correct endpoints as dictated by layers and such.

In the 3rd commit, I've added an example of how it can be used with the 2nd requirement easily to remove lower-level logic.

Feedback required over,

It should close #13 on merge.

Complete functionality blocked by the waiting-on-merge-of #38

Rubix982 commented 3 years ago

@OmarMuhammedAli review needed over this.

OmarMuhammedAli commented 3 years ago

@OmarMuhammedAli review needed over this.

Will review today!

Rubix982 commented 3 years ago

Self merging.