Exemple #1
0
class PowerLineSearchFuzzy(Resource):
    def __init__(self):
        self.dao = LinesDao()
        self.userDao = UserDAO()

    def post(self):
        #if (request.data != ""):
        #    data = json.loads(request.data)
        #    token = data['token']
        #    user = self.userDao.verify_token(token, '')
        #    if (not user):
        #         return make_response(jsonify({'error': 'Unauthorized access'}), 401)
        args = parser.parse_args()

        linename = args.get('linename')
        rs = self.dao.query_line_fuzzy(linename)
        if rs == None:
            return make_response(
                jsonify({
                    'error': '根据线路名称查询线路信息失败',
                    'errorcode': 10000000
                }), 401)
        else:
            return json.dumps(rs)

    #else:
    #    return  make_response(jsonify({'error': 'Unauthorized access'}), 401)

    def get(self):
        return self.post()
Exemple #2
0
    def ClassifyPhoto(self,towers,photoPath,date,basefolder):
        #纬度一度的差异 直接计算差异比坐标转换之后再计算虽然在精度上下降了,但是效率上得到了很大的提高
        # 综合考虑之后采用直接通过经度和纬度差异的方式进行计算
        unitLat = 111000.0
        photoCoordinate = self.GetPhotoCoordinate(photoPath)
        if photoCoordinate==None:
            return None
        dis = []
        for towerItem in towers:
            unitLng = unitLat*math.cos(math.radians(photoCoordinate['lat']))
            dLat = (towerItem['tower_lat']-photoCoordinate['lat'])*unitLat*(towerItem['tower_lat']-photoCoordinate['lat'])*unitLat
            dLng = (towerItem['tower_lng']-photoCoordinate['lng'])*unitLng*(towerItem['tower_lng']-photoCoordinate['lng'])*unitLng
            dis.append(math.sqrt(dLat+dLng))
        index = dis.index(min(dis))

        #将文件移动到对应的文件夹下
        daoLine=LinesDao()
        line=daoLine.query_line_fuzzy(towers[index]['tower_linename'])
        filename=os.path.basename(photoPath)

        #构建目标路径
        basePath = '\\'+str(line[0]['lines_voltage'])+'\\'+str(line[0]['lines_id'])+'\\'+str(towers[index]['tower_id'])+'\\'+date+'\\未分类\\'+filename
        distPath= basefolder+basePath

        #移动文件夹
        self.MoveFile(photoPath,distPath)
        return (basePath,index,line[0]['lines_id'])