获取四环内的企业

#背景:公司要拿到在四环内的企业名单   企业有坐标

 

from matplotlib.path import Path
import pymysql

# 测试
db = pymysql.connect(
    host='192.168.0.205',
    user='twopro',
    password='ovQM+4XP9fZv+gV3)ZoS3FAF',
    database='twopro',
    charset='utf8',
    port=3306
)



def myselect(): c = db.cursor() # 执行SQL命令 c.execute("SELECT id,name,gaodex,gaodey from t_enterprise WHERE gaodex !='0.0' OR gaodey !='0.0'") for i in range(c.rowcount + 1): record = c.fetchall() # record 为tuple类型 return record c.close() db.close() #四环获取到的坐标 coords = Path([(113.536154, 34.812172), (113.532206, 34.836973), (113.531862, 34.839298), (113.539415, 34.838241), (113.547054, 34.836621), (113.55538, 34.83641), (113.560272, 34.835564), (113.566624, 34.835282), (113.571859, 34.83486), (113.576838, 34.834719), (113.579927, 34.834437), (113.593918, 34.834719), (113.603703, 34.83648), (113.622156, 34.840496), (113.630653, 34.84275), (113.633142, 34.842891), (113.644987, 34.845638), (113.649794, 34.845286), (113.658119, 34.84592), (113.671938, 34.844581), (113.682238, 34.844088), (113.687645, 34.844088), (113.700691, 34.843666), (113.71554, 34.84275), (113.7176, 34.841904), (113.728672, 34.839016), (113.745924, 34.833239), (113.757769, 34.827533), (113.772274, 34.823517), (113.776995, 34.822812), (113.797422, 34.822601), (113.814245, 34.822248), (113.828579, 34.821403), (113.827635, 34.80738), (113.828321, 34.799839), (113.827721, 34.790746), (113.824459, 34.780525), (113.817421, 34.765155), (113.813644, 34.748161), (113.811584, 34.742025), (113.810984, 34.732432), (113.811756, 34.725026), (113.811499, 34.713456), (113.811842, 34.703366), (113.812357, 34.689393), (113.812271, 34.684735), (113.813129, 34.670195), (113.820854, 34.652263), (113.815618, 34.64965), (113.807808, 34.648874), (113.766573, 34.648098), (113.749063, 34.638495), (113.717821, 34.644991), (113.690699, 34.64951), (113.662889, 34.644991), (113.612421, 34.651205), (113.563669, 34.659112), (113.533113, 34.669561), (113.513887, 34.687065), (113.497751, 34.713316), (113.482302, 34.740686), (113.464106, 34.818515), (113.480242, 34.839933), (113.531397, 34.837679)]) for x in range(0, len(myselect())): a = coords.contains_point((float(myselect()[x][2]), float(myselect()[x][3]))) if a == True: with open('abcd.txt', 'a+') as f: f.write(str(myselect()[x][0]) + ' ' + str(myselect()[x][1]) + ' ' + str(myselect()[x][2]) + ' ' + str( myselect()[x][3]) + '\n') else: pass # a = coords.contains_point((113.51264,34.793511)) # print(a)

 

上一篇:数据结构算法——1017. 座位分配


下一篇:实战 Java 16 值类型 Record - 1. Record 的默认方法使用以及基于预编译生成