2009年4月8日星期三

gps数据转换

    上学期实习的时候写了个小程序,将 GPS数据(.msc)直接转为 KML 文件。
    这学期有用那些GPS,数据是一样的,然后顺手就转了,还整理了一下,放到网上了。
    http://haxk.alwaysdata.net/gps.html
    效果貌似还不错。

适用机型:
麦哲伦GPS315
航路点 500个,可直观显示最近9个航路点 
航线 20条可反向航线,每条航线包含30个航路点 
航迹点 1200个,实时记录航迹,可沿航迹返回 
坐标系 75个,有BJ-54平面直角坐标选项 
坐 标 60个,中国地区60座大、中城市坐标
 
接收性能

接收机 并行12通道  
定位时间 热启动 15s
冷启动 45s
自动定位 60s  
数据更新率 1次/秒,连续  
定位精度 10-15mRMS,1-5m(差分)RMS 
速度精度 0.1节 RMS  
最大高度 17,500m 
最大速度 951mph 
接 口 NMEA0183和RTCM 104 
天线 内置高灵敏度全向天线 

 转换程序:
# -*-coding:utf-8 -*-
#名称:gps.py
#功能:转化GPS数据文件为kml数据文件
#作者:刘志辉
#时间:2008-11-14

import string
import os,sys
import re

thispath = os.path.abspath(sys.argv[0])
thisdir = thispath[:-6]
filenames=os.listdir(thisdir)

for f in filenames:
    print f
    if f[-4:]==".msc":
        tfile=open(f,'r')
        kname='ms_'+f[:-4]+'.kml'
        out="""
        
        
            """+kname+"""
            1
            
                
                    normal
                    #sn_ylw-pushpin
                
                
                    highlight
                    #sh_ylw-pushpin
                
            
            
            
            
            
            """
        polyline=''
        for line in tfile.readlines():    
            if len(line)>30 and len(line)<50:
                a=line[:13]
                b=line[14:28]
                c=line[30:]
                d=c.split(',')
                name=d[1]
                out=out+"""
                """+name+"""
                
                    118.7499833331466
                    32.05334166674683
                    0
                    828.0772645067254
                    0
                    7.951386703658792e-015
                
                #msn_ylw-pushpin
                
                    """+b+','+a+""",0
                
            
            """
            if len(line)>60:
                a=line[:13]
                b=line[15:29]
                polyline=polyline+b+','+a+",4 "
        out=out+"""
                GPS_route
                
                    118.74998333335
                    32.05334166665
                    0
                    828.0771856532319
                    0
                    0
                
                #sn_ylw-pushpin3
                
                    1
                    relativeToGround
                    
                    """+polyline+"""
                
            
        
        """
        tfile.close()
        file=open(kname,'w')
        file.writelines(out)
        file.close()
print "OK!"         

1 条评论:

  1. .msc文件是什么格式的?rinex还是二进制的?

    回复删除