tile38

作者: hehehehe | 来源:发表于2022-08-05 12:39 被阅读0次
    import asyncio
    from pyle38 import Tile38
    
    tile38 = Tile38(url="redis://localhost:9851", follower_url="redis://localhost:9851")
    
    key = "fleet"
    
    
    async def setset():
        for x in range(0, 100, 1):
            for y in range(0, 100, 1):
                obj = {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [x / 10, x / 10]},
                    "properties": {"xy": str(x / 10) + str(y / 10)},
                }
                res = await tile38.set("fleet", str(x / 10) + str(y / 10)).object(obj).exec()
                print(res.dict())
    
    
    async def getget():
        response = await tile38.follower() \
            .within("fleet") \
            .circle(5, 3, 1000000) \
            .asObjects()
        print(response.dict())
    
    
    if __name__ == '__main__':
        # asyncio.run(setset())
        asyncio.run(getget())
    
    
    import json
    from pathlib import Path
    from urllib.parse import quote_plus
    
    import redis
    import pandas as pd
    import polars as pl
    import yaml
    
    client = redis.Redis(host='localhost', port=9851)
    
    
    def set_one(row):
        obj = {
            "type": "Feature",
            "geometry": json.loads(row[2]),
            "properties": {"aoi_name": row[1]},
        }
        result = client.execute_command('SET', 'aoi', row[0], 'object', json.dumps(obj, ensure_ascii=True))
        print(result)
        return row
    
    
    def aoi_set():
        from_database = ""
        from_user = ""
        from_pw = ""
        from_host = "192.168.160.12"
        from_port = "15450"
        pg_conn = f"postgresql://{from_user}:{quote_plus(from_pw)}@{from_host}:{from_port}/{from_database}"
    
        pl_df = pl.read_sql("select aoi_id,aoi_name,st_asgeojson(aoi_geom) as geom "
                            "from poi_hn_aoi where ad_name = '津南区' ", pg_conn)
        print(pl_df.shape)
    
        pl_df.apply(lambda row: set_one(row))
    
    
    def test_tile38():
        # insert data
        # result = client.execute_command('SET', 'fleet', 'truck', 'POINT', 33.32, 115.423)
        # print result
        # print(result)
        # get data
        print(client.execute_command('GET', 'aoi', 'aased'))
        result = client.execute_command('within', 'aoi', 'circle', 38.992402272677, 117.385439524524, 200)
        # print(result[1][0][1])
        for i in result[1]:
            print(json.loads(i[1])['properties'])
        print(client.execute_command('stats', 'aoi'))
        # print(client.execute_command('drop', 'aoi'))
    
    
    if __name__ == '__main__':
        test_tile38()
        # aoi_set()
        # set_one()
    
    
    

    相关文章

      网友评论

          本文标题:tile38

          本文链接:https://www.haomeiwen.com/subject/dnrpwrtx.html