用于与位置交互的python实用程序

ctodd-python-lib-location的Python项目详细描述


Christopher H.Todd的用于与位置交互的Python库

ctodd python库位置项目负责管理位置信息、地理编码地址和获取方向。

目录

依赖关系

Python包

  • 地理编码器==1.38.1
  • 请求数==2.22.0
  • 街道地址==0.4.0
  • usaddress==0.5.10

address_helpers.py

地址助手。此库用于与地址字符串/dict交互并转换/处理这些地址。

功能:

def convert_string_address_to_dict(address_string, expected_fields=None):
    """
    Purpose:
        Parse a string into an address dict with specific fields
    Args:
        address_string (String): Raw address string to try and parse
        expected_fields (List): List of fields that are needed to be parsed to be
            considered successful
    Return:
        parsed_address (Dict): Dict of the parsed address with fields that could be
            determined from a string
    """
def parse_address_using_lib_usaddress(address_string):
    """
    Purpose:
        Use the usaddress library to parse a string into a dict
    Args:
        address_string (String): Raw address string to try and parse
    Return:
        parsed_address (Dict): Dict of the parsed address with fields that could be
            determined from a string
    """
def parse_address_using_lib_streetaddress(address_string):
    """
    Purpose:
        Use the street-address library to parse a string into a dict
    Args:
        address_string (String): Raw address string to try and parse
    Return:
        parsed_address (Dict): Dict of the parsed address with fields that could be
            determined from a string
    """

mapquest_helpers.py

地图任务助手此库用于包装MapQuest API调用并处理身份验证

功能:

def get_mapquest_api_key(public_key_file="~/.mapquest/public_key.txt"):
    """
    Purpose:
        Get the mapquest API from the environment
    Args:
        public_key_file (String): filename of the public key token file
    Return:
        mapquest_api_key (String): MapQuest public key
    """
def get_directions_between_two_addresses(mapquest_api_key, address_1, address_2):
    """
    Purpose:
        Get directions between two addresses

        Leverages Mapquest API:
            https://developer.mapquest.com/documentation/directions-api/route/get/
    Args:
        address_1 (String): Address to use as start point of travel
        address_2 (String): Address to use as end destination of travel
    Return:
        directions (Dict): Dict of the directions between the two locations
    """

示例脚本

用于测试和与库交互的示例可执行python脚本/模块。这些示例显示了库的用例,可以用作与库一起开发的模板,也可以用作一次性开发工作

parse_addresses.py

    Purpose:
        Parse some set addresses

    Steps:
        - Parse Args
        - Call libs to parse addresses

    function call:
        python3.6 parse_addresses \
            [-h] \
            --addresses ADDRESSES

    example script call:
        python3.6 example_usage/parse_addresses.py \
            --address="REDACTED" \
            --address="REDACTED"

get_directions_between_addresses.py

    Purpose:
        Get Directions between two addresses.

    Steps:
        - Parse Args
        - Call libs to get directions from args
        - Parse directions for some valuable information

    function call:
        python3.6 get_directions_between_addresses.py \
            [-h] \
            --start-address START_ADDRESS \
            --end-address END_ADDRESS

    example script call:
        python3.6 example_usage/get_directions_between_addresses.py \
            --start-address="REDACTED" \
            --end-address="REDACTED"

注释

  • 依赖于f-string符号,它仅限于python3.6。通过重构删除这些内容,可以使用python3.0.x到3.5.x进行开发

待办事项

  • UnitTest框架已就位,但缺少测试

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Hibernate:合并并删除,而不是从数据库中删除实体对象   java如何在WebFilter中有条件地从Mono返回?   java调用mysql c3p0函数   可执行jar Java jar文件加载错误:无法找到或加载主类。类导致的错误:java。lang.ClassNotFoundException:某些东西。班   java如何减少/更改爬网后的延迟?   从其他语言(如Java、PHP、Perl、Python等)调用C/C++代码的最佳方式是什么?   java如何模拟影响对象的void返回方法   当我试图在ubuntu上启动JavaScala时,它抛出了一个异常   java如何正确输出游戏   理解java和C++背景下的JavaScript原型   oracle如何将Java函数转换为postgresql函数   多线程为什么我的java服务器程序在超时后不退出?   java如何使listView中的按钮在单击时工作?   试图将这个嵌套的java forloop转换为python,但我不知道如何转换。有没有一种方法可以像这样为循环执行if语句?   java幂函数在计算器中的应用   如何在java中滚动浏览mysql数据库   在Spring Boot应用程序的JUnit测试中,java没有符合自动连线JPA存储库要求的bean   java如何使用扩展类的JPanel对象?