Exemplo n.º 1
0
 def geneKML_no_leaf(self,
                     col_Tokyo_tree,
                     col_map,
                     col_Tokyo_tree_node,
                     file_name=r'Tokyo.kmz'):
     fkml = open(file_name, 'w')
     paint = ITDKkml(fkml)
     paint.setting_line(line_color='cc00ff00', line_width=0.8)
     paint.setting_point(
         icon_path=
         'http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png',
         point_scale=0.4,
         point_color='ff00ffff')
     paint.head()
     paint.setting_line(line_color='cc0000ff', line_width=1.7)
     paint.setting_point(
         icon_path=
         'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png',
         point_scale=1,
         point_color='cc0000ff')
     for edge in col_Tokyo_tree.find():
         start_edge = col_map.find_one({'node_id': edge['start']})
         end_edge = col_map.find_one({'node_id': edge['end']})
         if start_edge['in'] and end_edge['in']:
             s = col_Tokyo_tree_node.find_one({'node_id': edge['start']})
             e = col_Tokyo_tree_node.find_one({'node_id': edge['end']})
             #这种方法会使叶子节点父节点多次绘制
             if s['connect'] == [] or e['connect'] == []:
                 paint.draw_edge(start=start_edge['new'],
                                 end=end_edge['new'])
             else:
                 paint.draw_orig_edge(start=start_edge['new'],
                                      end=end_edge['new'])
     for node in col_map.find():
         if node['in']:
             docu = col_Tokyo_tree_node.find_one(
                 {'node_id': node['node_id']})
             if len(docu['connect']) < 5:
                 paint.draw_point2(longitude=node['new']['longitude'],
                                   latitude=node['new']['latitude'])
             else:
                 paint.draw_orig_point(longitude=node['new']['longitude'],
                                       latitude=node['new']['latitude'])
         pass
     paint.tail()
     fkml.close()
Exemplo n.º 2
0
    'longitude': 3,
    'latitude': 0
}, {
    'longitude': 1.5,
    'latitude': 2
}]
edge = [[1, 4], [2, 4], [3, 4], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9],
        [7, 10], [10, 11]]
point_original = [[0.2, 0.7], [0.5, 1], [0.7, 0.2], [0.8, 0.6], [1.3, 0.3],
                  [1.4, 0.9], [1.1, 1.1], [1.6, 0.4], [1.7, 0.7], [1.6, 1.2],
                  [2, 1.1]]
#原始位置图
file_name = 'original.kml'
fkml = open(file_name, 'w')
paint = ITDKkml(fkml)
paint.setting_line(line_color='cc00ff00', line_width=0.8)
paint.setting_point(
    icon_path='http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png',
    point_scale=0.4,
    point_color='ff00ffff')
paint.head()
polygon_point_num = len(polygon)
i = 0
while i < polygon_point_num - 1:
    paint.draw_edge(start=polygon[i], end=polygon[i + 1])
    i = i + 1
paint.draw_edge(start=polygon[polygon_point_num - 1], end=polygon[0])
for node in point_original:
    paint.draw_orig_point(longitude=node[0], latitude=node[1])
for e in edge:
    paint.draw_edge(start={'longitude':point_original[e[0]-1][0],'latitude':point_original[e[0]-1][1]},\
Exemplo n.º 3
0
#-*- coding:utf-8 -*-
import pymongo
from Tokyo_logistic_topo.Tokyo_logic import TokyoTopo
from Tokyo_logistic_topo.kml_tool import ITDKkml
client = pymongo.MongoClient()
col_second_node = client['itdk_level_new']['shankou_txt']
file_name = './file/link_shankou.kml'
fkml = open(file_name, 'w')
paint = ITDKkml(fkml)
ggg = TokyoTopo()
paint.setting_line(line_color='ffff3ef3',
                   line_width=1.2,
                   line_hight_start=0,
                   line_hight_end=80000,
                   altitudeMode='relativeToGround')
paint.head()
db_name = ['shankou']
for name in db_name:
    db = client[name]
    col_tree_node = db['tree_node']
    col_map = db['map_logi2loca']
    for node in col_tree_node.find():
        if len(node['connect']) > 5:
            docu = col_map.find_one({'node_id': node['node_id']})
            if docu['in']:
                min_dis = 10000
                min_point = {}
                for second_node in col_second_node.find():
                    dis = ggg.get_distance(start=docu['new'],
                                           end=second_node['new'])
                    if dis < min_dis:
Exemplo n.º 4
0
#-*- coding:utf-8 -*-
from Tokyo_logistic_topo.kml_tool import ITDKkml
polygon_list = []
with open('坐标.txt','r') as f:
    edge_list = []
    content=f.readline()
    while content:
        if content == '\n':
            polygon_list.append(edge_list)
            edge_list = []
        else:
            coor = content.replace('\n','').split('\t')
            print(coor)
            point  = {'longitude':coor[1],'latitude':coor[0]}
            edge_list.append(point)
        content = f.readline()
    polygon_list.append(edge_list)
print(polygon_list[0])
f=open('polygon.kml','w')
instance = ITDKkml(f)
instance.setting_line(line_color='641400FF',line_width=4)
instance.head()
for polygon in polygon_list:
    lenth = len(polygon)
    i = 0
    while i<(lenth-1):
        instance.draw_edge(start=polygon[i],end=polygon[i+1])
        i = i+1
    instance.draw_edge(start=polygon[-1],end=polygon[0])
instance.tail()
Exemplo n.º 5
0
            'longitude': point['longitude'],
            'latitude': point['latitude'],
            'new': point['new'],
            'flag': flag_label
        }
        col_second.insert_one(docu)
        print("insert", city_col, point['_id'], flag_label)
    flag_label = flag_label + 1
#画图,边
iii = TokyoTopo()
filename_KML = './file/日本整个第二层.kml'
f = open(filename_KML, 'w')
paint = ITDKkml(f)
paint.setting_line(line_color='33ffff00',
                   line_hight_start=40000,
                   altitudeMode='absolute',
                   line_hight_end=40000,
                   line_width=1)
#paint.setting_point(icon_path='juanjo_Router.png',point_hight=80000,point_scale=0.5)
paint.head()

for edge in col_edge_degree.find():
    if iii.get_distance(start=edge['start'], end=edge['end']) < 400:
        flag1 = col_second.find_one({
            'longitude': edge['start']['longitude'],
            'latitude': edge['start']['latitude']
        })
        flag2 = col_second.find_one({
            'longitude': edge['end']['longitude'],
            'latitude': edge['end']['latitude']
        })
Exemplo n.º 6
0
 def gene_KML(self, filename_KML, col_txt, rec_range, filename_dire,
              col_edge_degree):
     node_list = []
     node_num = 0
     with open(filename_dire, 'r') as f:
         content = f.readline()
         node_num = int(content.split(' ')[0].split(':')[1])
         print(node_num)
         num = node_num
         content = f.readline()
         while (content and node_num > 0):
             ss = content.replace('\n', '').split(' ')
             node_list.append(ss)
             content = f.readline()
             node_num = node_num - 1
     point_longitude = 0.0
     max_longitude = float(node_list[0][1])
     min_longitude = float(node_list[0][1])
     max_latitude = float(node_list[0][2])
     min_latitude = float(node_list[0][2])
     for i in node_list:
         if float(i[1]) < min_longitude:
             min_longitude = float(i[1])
         if float(i[1]) > max_longitude:
             max_longitude = float(i[1])
         if float(i[2]) < min_latitude:
             min_latitude = float(i[2])
         if float(i[2]) > max_latitude:
             max_latitude = float(i[2])
     point_longitude = (max_longitude + min_longitude) / 2
     point_latitude = (max_latitude + min_latitude) / 2
     orignal_breath_longitude = rec_range['right'] - rec_range['left']
     orignal_breath_latitude = rec_range['top'] - rec_range['bottom']
     longitude_percent = (max_longitude -
                          min_longitude) / orignal_breath_longitude
     latitude_percent = (max_latitude -
                         min_latitude) / orignal_breath_latitude
     bias_longitude = (rec_range['right'] +
                       rec_range['left']) / 2 - point_longitude
     bias_latitude = (rec_range['top'] +
                      rec_range['bottom']) / 2 - point_latitude
     for node in node_list:
         longitude = (float(node[1]) -
                      point_longitude) / longitude_percent + point_longitude
         latitude = (float(node[2]) -
                     point_latitude) / latitude_percent + point_latitude
         col_txt.update_one({'node_id': int(node[0])}, {
             '$set': {
                 'new': {
                     'longitude': longitude + bias_longitude,
                     'latitude': latitude + bias_latitude
                 }
             }
         })
     #生成KML
     f = open(filename_KML, 'w')
     paint = ITDKkml(f)
     paint.setting_line(line_color='ffb40014',
                        line_hight_start=80000,
                        line_hight_end=80000,
                        altitudeMode='relativeToGround',
                        line_width=3)
     paint.setting_point(icon_path='juanjo_Router.png',
                         point_hight=80000,
                         point_scale=0.5)
     paint.head()
     for edge in col_edge_degree.find():
         start_new = col_txt.find_one({
             'longitude':
             edge['start']['longitude'],
             'latitude':
             edge['start']['latitude']
         })
         end_new = col_txt.find_one({
             'longitude': edge['end']['longitude'],
             'latitude': edge['end']['latitude']
         })
         paint.draw_edge(start=start_new['new'], end=end_new['new'])
     for node in col_txt.find():
         paint.draw_point2(longitude=node['new']['longitude'],
                           latitude=node['new']['latitude'])
     paint.tail()
     f.close()
Exemplo n.º 7
0
            }
        }
        col_edge_merge.insert_one(docu)
for edge in col_edge2.find():
    docu = {
        'start': {
            'longitude': edge['start']['longitude'],
            'latitude': edge['start']['latitude']
        },
        'end': {
            'longitude': edge['end']['longitude'],
            'latitude': edge['end']['latitude']
        }
    }
    flag = col_edge_merge.find_one(docu)
    if not flag:
        col_edge_merge.insert_one(docu)
filename_KML = './file/日本整个第二层merge.kml'
f = open(filename_KML, 'w')
paint = ITDKkml(f)
paint.setting_line(line_color='ffb40014',
                   line_hight_start=80000,
                   line_hight_end=80000,
                   line_width=1,
                   altitudeMode='relativeToGround')
#paint.setting_point(icon_path='juanjo_Router.png',point_hight=80000,point_scale=0.5)
paint.head()
for edge in col_edge_merge.find():
    paint.draw_edge(start=edge['start'], end=edge['end'])
paint.tail()
f.close()
Exemplo n.º 8
0
# print('the number of point thats degree is greater than',degree,'is:',col_point_degree.count())
#
col_edge_degree = client['itdkall_info']['edge_location_degree_1000'] #日本度数大于某一点的点所组成的边的集合
# col_edge_degree.drop()
# i=1
# for edge in col_edge.find():
#     flag1 = col_point_degree.find_one({'longitude':edge['start']['longitude'], 'latitude':edge['start']['latitude']})
#     if flag1:
#         flag2 = col_point_degree.find_one({'longitude':edge['end']['longitude'], 'latitude':edge['end']['latitude']})
#         if flag2:
#             if not col_edge_degree.find_one({'start':{'longitude':edge['start']['longitude'],'latitude':edge['start']['latitude']},
#                 'end':{'longitude':edge['end']['longitude'], 'latitude':edge['end']['latitude']}}) and edge['start']['longitude']!=edge['end']['longitude']\
#                     and edge['start']['latitude']!=edge['end']['latitude']:
#                 col_edge_degree.insert_one({'start':{'longitude':edge['start']['longitude'],'latitude':edge['start']['latitude']},'end':{'longitude':edge['end']['longitude'], 'latitude':edge['end']['latitude']}})
#                 print(edge['_id'])
#     print(i)
#     i=i+1
#画图
iii=TokyoTopo()
filename_KML = './file/日本整个第二层1000.kml'
f=open(filename_KML,'w')
paint = ITDKkml(f)
paint.setting_line(line_color= 'ffb40014',line_hight_start=0,line_hight_end=0,line_width=1)
#paint.setting_point(icon_path='juanjo_Router.png',point_hight=80000,point_scale=0.5)
paint.head()
for edge in col_edge_degree.find():
    if iii.get_distance(start=edge['start'],end=edge['end'])<400:
        paint.draw_edge(start=edge['start'],end=edge['end'])
paint.tail()
f.close()
Exemplo n.º 9
0
#-*- coding:utf-8 -*-
import pymongo
from Tokyo_logistic_topo.kml_tool import ITDKkml
from Tokyo_logistic_topo.Tokyo_logic import TokyoTopo
client = pymongo.MongoClient()
col_edge_degree = client['教育科研网']['edge']#边

filename_KML = './教育科研网.kml'
f=open(filename_KML,'w')
paint = ITDKkml(f)
paint.setting_line(line_hight_start=40000,line_hight_end=40000,line_width=5)
#paint.setting_point(icon_path='juanjo_Router.png',point_hight=80000,point_scale=0.5)
paint.head()
for edge in col_edge_degree.find():
    paint.draw_edge(start=edge['start'],end=edge['end'])
paint.tail()
f.close()