def run(): """ 需要: gloV.LNG_MIN gloV.LNG_MAX gloV.LAT_MIN gloV.LAT_MAX gloV.gridId gloV.incomeList 初始化赋值了: gloV.communityData gloV.communityValid gloV.communityIsVilla gloV.communityIsBefore2000 gloV.communityGridId gloV.communitySummary 修改了: gloV.communityOutput """ # -------------------- Get communityDataAll -------------------- # 运行 readDiskData() 之后拥有的变量: # gloV.communityVariableNameStr # gloV.communityVariableName # gloV.communityVariableNamePosition # gloV.communityOutput # gloV.communityDataAll noSave = readDiskData() if noSave == 'NO_SAVE.': return noSave gloV.communityData = [] gloV.communityGridId = [] gloV.communityValid = {} gloV.communityIsVilla = [] gloV.communityIsBefore2000 = [] for i in gloV.communityVariableName: gloV.communityValid[i] = [] gloV.communityOutput[0].append('是否别墅') gloV.communityOutput[0].append('是否早于2000年竣工') gloV.communityOutput[0].append('Type') gloV.communityOutput[0].append('GridId') gloV.communityOutput[0].append('GenerateTime') for i in gloV.communityDataAll: if Main.is_valid(i[0]) and Main.is_valid(i[1]): if Main.is_right_city(i[0], i[1], gloV.communityVariableName, i, gloV.communityVariableNamePosition): tmpDataStr = [] # 处理 gloV.communityData tmpData = [] for j in range(0, len(i)): tmpData.append(i[j]) tmpDataStr.append(str(i[j])) if j == 2: if Main.is_valid(i[j]) and Main.get_income(i[j]) != 0: gloV.communityValid["区县"].append(Main.get_income(i[j])) elif Main.is_valid(i[j]): gloV.communityValid[gloV.communityVariableName[j]].append(i[j]) gloV.communityData.append(tmpData) # 处理 gloV.communityGridId lngId = int((i[0] - gloV.LNG_MIN) / gloV.lngLeap) latId = int((i[1] - gloV.LAT_MIN) / gloV.latLeap) gloV.communityGridId.append(gloV.gridId[latId][lngId]) # 处理 gloV.communityIsVilla villaVariableList = ['小区类型', '小区特点', '建筑类别', '建筑结构'] villa = False for k in villaVariableList: if k in gloV.communityVariableName and '别墅' in i[gloV.communityVariableNamePosition[k]]: villa = True break if villa: gloV.communityIsVilla.append(1) tmpDataStr.append('是') else: gloV.communityIsVilla.append(0) tmpDataStr.append('否') # 处理 gloV.communityIsBefore2000 if '竣工时间' in gloV.communityVariableName: tmpDate = i[gloV.communityVariableNamePosition['竣工时间']] if Main.is_valid(tmpDate) and tmpDate.year < 2000: gloV.communityIsBefore2000.append(1) tmpDataStr.append('是') else: gloV.communityIsBefore2000.append(0) tmpDataStr.append('否') else: gloV.communityIsBefore2000.append(0) tmpDataStr.append('否') # 处理 gloV.communityOutput tmpDataStr.append('社区') tmpDataStr.append(str(gloV.gridId[latId][lngId])) tmpDataStr.append(gloV.generateTime) gloV.communityOutput.append(tmpDataStr) if len(gloV.communityData) == 0: return 'NO_DATA.' # ---------- 社区数据归一化, 计算"综合评分" gloV.communitySummary = Main.compute_summary('<社区>', gloV.communityVariableNameStr, gloV.communityVariableName, len(gloV.communityData), gloV.communityValid, gloV.communityDataType, "no-write") computeCommunity() return 0
def computeCommunity(): """ 需要: gloV.communitySummary 初始化赋值了: gloV.communityScore 修改了: gloV.communityOutput """ communityIncome = [] communityRongjilv = [] communityPrice = [] communityFamily = [] communityScoreTmp = [] paraPaySum = gloV.paraPayIncome + gloV.paraPayPrice + gloV.paraPayRongjilv for i in range(0, len(gloV.communityData)): tmpData = gloV.communityData[i] # ---对4列参与计算的数据Zoom # 人均可支配收入 if Main.is_valid(tmpData[2]) and Main.get_income(tmpData[2]) > 0: communityIncome.append(Main.zoom_data(Main.get_income(tmpData[2]), gloV.communitySummary[5][2], gloV.communitySummary[4][2])) else: communityIncome.append(0) # 容积率 if Main.is_valid(tmpData[3]): communityRongjilv.append(Main.zoom_rongjilv(tmpData[3])) else: communityRongjilv.append(0) # 均价 if Main.is_valid(tmpData[4]): communityPrice.append(Main.zoom_data(tmpData[4], gloV.communitySummary[5][4], gloV.communitySummary[4][4])) else: communityPrice.append(0) # 现有户数 if Main.is_valid(tmpData[5]): communityFamily.append(Main.zoom_family(tmpData[5], gloV.communitySummary[5][5], gloV.communitySummary[4][5])) else: communityFamily.append(0) communityScoreTmp.append(gloV.paraCommunityPay * (gloV.paraPayIncome * communityIncome[i] + gloV.paraPayPrice * communityPrice[i] + gloV.paraPayRongjilv * communityRongjilv[i]) / paraPaySum + gloV.paraCommunityFamily * communityFamily[i]) # ---计算社区评分 gloV.communityScore = [] gloV.communityOutput[0].append("Score") communityScoreMin = min(communityScoreTmp) communityScoreMax = max(communityScoreTmp) for i in range(0, len(communityScoreTmp)): gloV.communityScore.append(Main.zoom_data(communityScoreTmp[i], communityScoreMin, communityScoreMax)) gloV.communityOutput[i + 1].append(str(Main.zoom_data(communityScoreTmp[i], communityScoreMin, communityScoreMax)))