论坛风格切换切换到宽版
  • 50319阅读
  • 200回复

安卓手机卫星跟踪APP——ZhuiXing——试用版发布 [复制链接]

上一主题 下一主题
离线BI3OJW
发帖
195
只看该作者 60楼 发表于: 2016-09-21

软件升级了,可以在线更新星历。可以选星,可以保存用户设置和上一次选的卫星。
软件有bug,除研究外请勿下载。
手机追星 ZhuiXing.apk (779 K) 下载次数:245
角度有几度的误差,不清楚问题在哪。有能力的同学可以帮忙看看,源码在下一楼。
软件初次运行在SD卡根目录生成配置文件lilacsat.txt,可以手动修改。如果有配置文件则自动读取,如果格式不对会闪退。请删除后重试。
星历下载地址用了http://www.celestrak.com/NORAD/elements/amateur.txt
请保持网络畅通。
软件的出错处理机制不太完善。有异常请删除SD卡根目录下lilacsat.txt和amateur.txt后重试。
欢迎纠错拍砖。但我不一定能解决。
(想必你们都看出来了,我是个拖延症比较严重的业余码农。)

[ 此帖被BI3OJW在2018-08-03 17:22重新编辑 ]
离线BI3OJW
发帖
195
只看该作者 61楼 发表于: 2016-09-21
package com.example.zhuixing;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity implements SensorEventListener {

    // 主程序声明区
    private String strURL = "http://www.celestrak.com/NORAD/elements/amateur.txt";

    private ImageView iv_canvas;
    private Bitmap baseBitmap;
    private Canvas canvas;
    private Paint paint0;
    private Paint paint1;

    private SensorManager aSensorManager;
    private SensorManager mSensorManager;
    // 需要两个Sensor
    private Sensor accelerometer; // 加速度传感器
    private Sensor magnetic; // 地磁场传感器
    private TextView text1;
    private TextView text2;
    private TextView text3;
    String xlsat;// 卫星名
    String xingli0 = "LILACSAT 2";// 星历名称
    String xingli1 = "1 40908U 15049K   16263.84597852  .00001065  00000-0  64316-4 0  9992";// 第1行星历
    String xingli2 = "2 40908  97.4618 268.7280 0017983  67.1962 293.1166 15.12705779 55293";// 第2行星历
    double yhjd = 115.0 / 180 * Math.PI;// 用户经度
    double yhwd = 38.5 / 180 * Math.PI;// 用户纬度
    double haiba = 50;// 海拔
    double cipianjiao = -5;// 磁偏角
    double xxpl0 = 437.2;/// 下行频率
    double sxpl0 = 144.35;// 上行频率
    // ****************************************************************
    String timep;// 确定平近点角的时间
    double qingjiao;// 轨道倾角
    double chijing;// 升交点赤经
    double pianxinlv; // 轨道偏心率
    double jddfj;// 近地点幅角
    double pjdj;// 平近点角
    double mrrxqs; // 每日绕行圈数
    double juli;// 卫星到用户的距离
    double xxpl1;// 下行频率 多普勒
    double sxpl1;// 上行频率 多普勒
    long timeN0;// 时间基准,计算距移率用
    float[] accelerometerValues = new float[3];
    float[] magneticFieldValues = new float[3];
    float[] accelerometerValuesA = new float[3];
    float[] magneticFieldValuesA = new float[3];
    float[] Azmvalues = new float[3];
    float[] R1 = new float[9];
    String xiaoxi = "...";

    @Override

    // 程序初始化
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // 主程序运行开始
        Update();// ***************************************************************
        text1 = (TextView) findViewById(R.id.textView1);
        text2 = (TextView) findViewById(R.id.textView2);
        text3 = (TextView) findViewById(R.id.textView3);
        iv_canvas = (ImageView) findViewById(R.id.imageView1);

        // 初始化一个画笔
        paint0 = new Paint();
        paint0.setStrokeWidth(2);
        paint0.setColor(Color.BLACK);
        paint0.setStyle(Paint.Style.STROKE);
        paint1 = new Paint();
        paint1.setStrokeWidth(2);
        paint1.setColor(Color.RED);
        paint1.setStyle(Paint.Style.FILL);

        // canvas.drawLine(1, 1, 100, 100, paint);
        // 实例化传感器管理者
        aSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        accelerometer = aSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        magnetic = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);

        juli = 0; // 用户到卫星距离
        timeN0 = 0; // 计算距移率的基准
        /*
         * yhjd = 115.0 / 180 * Math.PI; yhwd = 38.5 / 180 * Math.PI; cipianjiao
         * = -5; xxpl0 = 437.2; sxpl0 = 144.35; timep = "16242.81038550";
         * qingjiao = 97.4613 / 180 * Math.PI;// 轨道倾角 chijing = 248.1546 / 180 *
         * Math.PI;// 升交点赤经 pianxinlv = 0.0017609;// 轨道偏心率 jddfj = 133.3891 /
         * 180 * Math.PI;// 近地点幅角 pjdj = 226.8810 / 180 * Math.PI;// 平近点角 mrrxqs
         * = 15.12660259;// 每日绕行圈数
         */

    }

    protected void onResume() {
        // TODO Auto-generated method stub
        // 注册监听
        aSensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, magnetic, SensorManager.SENSOR_DELAY_NORMAL);
        super.onResume();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        // 解除注册
        aSensorManager.unregisterListener(this);
        mSensorManager.unregisterListener(this);
        super.onPause();
    }

    public void onSensorChanged(SensorEvent event) {

        // TODO Auto-generated method stub
        synchronized (this) {
            float[] tmpvalues = new float[3];
            tmpvalues[0] = event.values[0];
            tmpvalues[1] = event.values[1];
            tmpvalues[2] = event.values[2];

            if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
                accelerometerValues = tmpvalues;

            }
            if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
                magneticFieldValues = tmpvalues;

            }

            calculateOrientation();// 调用计算程序,每次传感器返回数据都调用。
        }

    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
        // TODO Auto-generated method stub
        // 传感器精度变化时
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        // 创建目录菜单 弹出个settings
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    // 计算程序,核心代码
    private void calculateOrientation() {
        accelerometerValuesA[0] = (float) (accelerometerValuesA[0] * 0.9 + accelerometerValues[0] * 0.1);
        accelerometerValuesA[1] = (float) (accelerometerValuesA[1] * 0.9 + accelerometerValues[1] * 0.1);
        accelerometerValuesA[2] = (float) (accelerometerValuesA[2] * 0.9 + accelerometerValues[2] * 0.1);

        magneticFieldValuesA[0] = (float) (magneticFieldValuesA[0] * 0.95 + magneticFieldValues[0] * 0.05);
        magneticFieldValuesA[1] = (float) (magneticFieldValuesA[1] * 0.9 + magneticFieldValues[1] * 0.1);
        magneticFieldValuesA[2] = (float) (magneticFieldValuesA[2] * 0.9 + magneticFieldValues[2] * 0.1);
        // 滤波后显示10次平均值数据。
        SensorManager.getRotationMatrix(R1, null, accelerometerValues, magneticFieldValues);
        SensorManager.getOrientation(R1, Azmvalues);

        // 要经过一次数据格式的转换,转换为度 加上磁偏角(cipianjiao_)。
        Azmvalues[0] = Math.round(((float) Math.toDegrees(Azmvalues[0]) + 360 + cipianjiao) % 360);
        Azmvalues[1] = Math.round(-1 * (float) Math.toDegrees(Azmvalues[1]));
        Azmvalues[2] = (float) Math.toDegrees(Azmvalues[2]);
        // =======================================================================
        //
        // 计算卫星数据的核心代码
        // BI3OJW,2016-9
        // 好像是没有bug了。需要关注UTC时间与当地时间的问题。
        //
        // =======================================================================
        Date date = new Date();// 获取当前时间
        SimpleDateFormat from = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String times = from.format(date); // 按设置时间格式
        long timeN = date.getTime();// 获取当前时间
        long timeNd = timeN - timeN0;// 计算时间差(和上一次计算时)用于距移率
        timeN0 = timeN;
        // 计算当前儒略历timeNow
        double timeNow = (double) (timeN) / 1000 / 3600 / 24 + 2440587.5;
        // timeNow=2457344.83898148;
        // 计算平近点角时儒略历timeJ星历生成时。前两位为年份,后面为日期。
        String nian = timep.substring(0, 2);
        String ri = timep.substring(2);
        int ye = Integer.valueOf(nian) + 2000;
        int a = (int) (ye / 100);
        int b = (int) (2 - a + a / 4);
        // (星历生成时的)年份的儒略历直接+后面的日期(小数形式)
        double timeJ = (int) (365.25 * (ye + 4716)) + (int) (30.6001 * 2) + 1 + b - 1524.5 + Double.valueOf(ri);
        /// 轨道根数
        double t = (timeJ - 2451545) / 36525;
        double hengxingshi = 280.46061837 + 360.98564736629 * (timeJ - 2451545) + 0.000387933 * t * t
                - t * t * t / 38710000;
        double cfqjd = (360 - hengxingshi % 360) / 180 * Math.PI;// 春分圈地理经度, 弧度
        double GM = 398603000000000.0;
        double wxjsd = mrrxqs * 2 * Math.PI / 24 / 3600;// 卫星角速度, 弧度每秒
        double banchangzhou = Math.pow(GM / wxjsd / wxjsd, 0.333333333333);// 半长轴
        double dqbj = 6378137.0 + haiba;// 地球半径
        double gjddsj = timeJ - pjdj / 2 / Math.PI / mrrxqs;// 过近地点时间
        double sjcjdd = timeNow - gjddsj;// 时间差 过近地点
        double sjcxl = timeNow - timeJ;// 时间差 星历
        double jddfjbhl = 4.97 * Math.pow((dqbj / banchangzhou), 3.5) * (5 * Math.pow(Math.cos(qingjiao), 2) - 1)
                / Math.pow((1 - Math.pow(pianxinlv, 2)), 2);// 近地点幅角变化率
        double xzjddfj = jddfj + sjcxl * jddfjbhl / 180 * Math.PI;// 修正后
                                                                    // 的近地点幅角(弧度制)
        double gjddhqs = (sjcjdd * mrrxqs) % 1;// 过近地点后圈数
        double sspjdj = gjddhqs * Math.PI * 2;// 实时平近点角,弧度
        // double pjdjE=Math.acos(
        // (pianxinlv+Math.cos(sspjdj))/(1+pianxinlv*Math.cos(sspjdj))
        // );//弧度
        double zjdjS = 2 * Math.atan(Math.sqrt((1 + pianxinlv) / (1 - pianxinlv)) * Math.tan(sspjdj / 2));// 真近点角,弧度
        double wxfj = (xzjddfj + zjdjS + 2 * Math.PI) % (2 * Math.PI);// 卫星幅角,弧度
        double xiuzheng1 = 0;
        if ((wxfj > 0.5 * Math.PI) & (wxfj < Math.PI))
            xiuzheng1 = Math.PI;
        if ((wxfj > Math.PI) & (wxfj < 1.5 * Math.PI))
            xiuzheng1 = -1 * Math.PI;
        double wxxzjdbl = Math.atan(Math.cos(qingjiao) * Math.tan(wxfj)) + xiuzheng1;// 卫星旋转经度变量
        double gdpmjdl = -9.95 * Math.pow(dqbj / banchangzhou, 3.5) * Math.cos(qingjiao)
                / Math.pow(1 - pianxinlv * pianxinlv, 2) * Math.PI / 180;// 轨道平面进动率
        double wxjd = ((chijing + cfqjd + wxxzjdbl - sjcxl * 360.98563 / 180 * Math.PI + sjcxl * gdpmjdl + Math.PI)
                % (Math.PI * 2) + Math.PI * 2) % (Math.PI * 2) - Math.PI;
        double wxwd = Math.asin(Math.sin(qingjiao) * Math.sin(wxfj));
        double dxj = Math
                .acos(Math.sin(yhwd) * Math.sin(wxwd) + Math.cos(yhwd) * Math.cos(wxwd) * Math.cos(yhjd - wxjd));// 地心角
        double dxjlr = banchangzhou * (1 - pianxinlv * Math.cos(sspjdj));
        double Elv = Math.atan((dxjlr * Math.cos(dxj) - dqbj) / dqbj / Math.sin(dxj));// 用户仰角,度数单位
        double jdc = (wxjd - yhjd + 2 * Math.PI) % (2 * Math.PI);
        double wdyz = yhwd * Math.cos(jdc);
        double Azm = (Math.asin(Math.sin(jdc) * Math.sin((0.5 * Math.PI - wxwd)) / Math.sin(dxj)) + 2 * Math.PI)
                % (2 * Math.PI);
        if (wxwd < wdyz) {
            Azm = (Math.PI * 3 - Azm) % (2 * Math.PI);
        }
        double juli0 = juli;// 上次计算的距离
        juli = Math.sqrt(dqbj * dqbj + dxjlr * dxjlr - 2 * dqbj * dxjlr * Math.cos(dxj));
        double jyl = (juli - juli0) / timeNd * 1000;// 距移率
        double dplxs = 300000000 / (300000000 + jyl);
        xxpl1 = xxpl0 * dplxs;
        sxpl1 = 2 * sxpl0 - sxpl0 * dplxs;
        // 计算完直接显示在text2里面。
        text1.setText("当前时间:" + times);
        text2.setText("手机方位角:" + Math.round(Azmvalues[0]) + "\t仰    角:" + Math.round(Azmvalues[1]) + "\n卫星方位角:"
                + Math.round(Azm * 180 / Math.PI) + "\t仰      角:" + Math.round(Elv * 180 / Math.PI) + "\n卫星经度:"
                + Math.round(wxjd * 180 / Math.PI) + "\t卫星纬度:" + Math.round(wxwd * 180 / Math.PI) + "\n用户经度:"
                + ((double)Math.round(yhjd * 18000 / Math.PI))/100 + "\t用户纬度:" + ((double)Math.round(yhwd * 18000 / Math.PI))/100 + "\n距离:"
                + Math.round(juli) + "\t距移率:" + (double) Math.round(jyl) + "\n下行频率:"
                + (double) Math.round(xxpl1 * 10000) / 10000 + "\t上行频率:" + (double) Math.round(sxpl1 * 10000) / 10000
                + "\n当前儒略历:" + timeNow);

        text3.setText(xiaoxi);// 传递消息

        // 画个瞄准镜显示目标x,目标y
        long mubiaoX = Math.round(Azm * 180 / Math.PI) - Math.round(Azmvalues[0]);
        if (mubiaoX < -180) {
            mubiaoX = mubiaoX + 360;
        }
        if (mubiaoX > 180) {
            mubiaoX = mubiaoX - 360;
        }
        long mubiaoY = Math.round(Azmvalues[1]) - Math.round(Elv * 180 / Math.PI);

        if (baseBitmap != null) {
            baseBitmap = Bitmap.createBitmap(150, 150, Bitmap.Config.ARGB_8888);
            canvas = new Canvas(baseBitmap);
            canvas.drawColor(Color.WHITE);
            iv_canvas.setImageBitmap(baseBitmap);
        }
        if (baseBitmap == null) {
            baseBitmap = Bitmap.createBitmap(150, 150, Bitmap.Config.ARGB_8888);
            canvas = new Canvas(baseBitmap);
            canvas.drawColor(Color.WHITE);
        }
        canvas.drawCircle(75 + mubiaoX, 75 + mubiaoY, 10, paint1);
        canvas.drawCircle(75, 75, 20, paint0);
        canvas.drawCircle(75, 75, 70, paint0);
        canvas.drawLine(75, 0, 75, 150, paint0);
        canvas.drawLine(0, 75, 150, 75, paint0);
        iv_canvas.setImageBitmap(baseBitmap);

        // 核心代码结束了。=====================================================
    }

    // 位置设置
    public void SetHomeClick(View v) {
        LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate(R.layout.setxml, null);
        final EditText editText11 = (EditText) textEntryView.findViewById(R.id.editText11);
        final EditText editText12 = (EditText) textEntryView.findViewById(R.id.editText12);
        final EditText editText13 = (EditText) textEntryView.findViewById(R.id.editText13);
        final EditText editText14 = (EditText) textEntryView.findViewById(R.id.editText14);
        final EditText editText15 = (EditText) textEntryView.findViewById(R.id.editText15);
        final EditText editText16 = (EditText) textEntryView.findViewById(R.id.editText16);
        editText11.setText(String.valueOf(((double)Math.round(yhjd * 18000 / Math.PI)) / 100));
        editText12.setText(String.valueOf(((double)Math.round(yhwd * 18000 / Math.PI) )/ 100));
        editText13.setText(String.valueOf(Math.round(haiba)));
        editText14.setText(String.valueOf(Math.round(cipianjiao)));
        editText15.setText(String.valueOf((double) Math.round(xxpl0 * 10000) / 10000));
        editText16.setText(String.valueOf((double) Math.round(sxpl0 * 10000) / 10000));

        AlertDialog.Builder ad1 = new AlertDialog.Builder(this);
        ad1.setTitle("用户设置:");
        ad1.setIcon(android.R.drawable.ic_dialog_info);
        ad1.setView(textEntryView);
        ad1.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int i) {
                yhjd = Double.valueOf(editText11.getText().toString()) / 180 * Math.PI;// 用户经度
                yhwd = Double.valueOf(editText12.getText().toString()) / 180 * Math.PI;// 用户纬度
                haiba = Double.valueOf(editText13.getText().toString());// 海拔
                cipianjiao = Double.valueOf(editText14.getText().toString());// 磁偏角
                xxpl0 = Double.valueOf(editText15.getText().toString());// 下行频率
                sxpl0 = Double.valueOf(editText16.getText().toString());// 上行频率
                File f = null;
                f = new File("/sdcard/lilacsat.txt");// 这是对应文件名
                // f.delete();
                try {
                    String tmp0;
                    tmp0 = xingli0 + "\n" + xingli1 + "\n" + xingli2 + "\n" + editText11.getText().toString() + "\n"
                            + editText12.getText().toString() + "\n" + editText13.getText().toString() + "\n"
                            + editText14.getText().toString() + "\n" + editText15.getText().toString() + "\n"
                            + editText16.getText().toString() + "\n";
                    FileOutputStream fout = new FileOutputStream(f);
                    byte[] bytes = tmp0.getBytes();
                    fout.write(bytes);
                    fout.close();
                    Toast.makeText(MainActivity.this, "已保存用户参数!", 1000).show();
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

        });
        ad1.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int i) {
            }
        });
        ad1.show();// 显示对话框/

    }

    // 下载星历
    public void DownloadClick(View v) {

        // getFile(strURL);

        Thread newThread; // 声明一个子线程
        newThread = new Thread(new Runnable() {
            @Override
            public void run() {
                // 这里写入子线程需要做的工作
                try {
                    getDataSource(strURL);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                // Toast.makeText(MainActivity.this, "创建线程", 1000).show();
            }
        });
        newThread.start(); // 启动线程
    }

    protected void getDataSource(String strPath) throws Exception {
        // TODO Auto-generated method stub
        // Toast.makeText(MainActivity.this, "下载星历文件核心线程", 2500).show();
        // text3.setText("stream null??");
        xiaoxi = "正在下载,请稍后……";
        URL myURL = new URL(strPath);
        URLConnection conn = myURL.openConnection();
        conn.connect();
        InputStream is = conn.getInputStream();
        if (is == null) {
            return;
            // text3.setText("stream is null");
        }
        // text3.setText("stream is NOT null");
        File myTempFile = new File("/sdcard/amateur.txt");
        FileOutputStream fos = new FileOutputStream(myTempFile);
        byte buf[] = new byte[128];
        do {
            int numread = is.read(buf);
            if (numread <= 0) {
                break;
            }

            fos.write(buf, 0, numread);
            xiaoxi = "已下载amateur.txt!";

        } while (true);

        try {
            is.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

    // 选择卫星******选择卫星******选择卫星******选择卫星******选择卫星******
    public void SatelliteClick(View v) {
        File f = null;
        f = new File("/sdcard/amateur.txt");// 这是对应文件名
        if (!(f.exists())) {
            Toast.makeText(MainActivity.this, "没有星历文件amateur.txt", 1000).show();
            return;
        }
        InputStream in = null;
        try {
            in = new BufferedInputStream(new FileInputStream(f));
        } catch (FileNotFoundException e3) {
            // TODO Auto-generated catch block
            e3.printStackTrace();
        }
        BufferedReader br = null;
        try {
            br = new BufferedReader(new InputStreamReader(in, "gb2312"));
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        String tmp;

        ArrayList<String> list = new ArrayList<String>();

        try {
            while ((tmp = br.readLine()) != null) {
                list.add(tmp);
            }
            br.close();
            in.close();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        final String[] xinglit0 = new String[list.size() / 3];
        final String[] xinglit1 = new String[list.size() / 3];
        final String[] xinglit2 = new String[list.size() / 3];
        for (int j = 0; j < (list.size() / 3); j++) {

            xinglit0[j] = list.get(j * 3);
            xinglit1[j] = list.get(j * 3 + 1);
            xinglit2[j] = list.get(j * 3 + 2);
        }

        new AlertDialog.Builder(this).setTitle("请选择卫星").setIcon(android.R.drawable.ic_dialog_info)
                .setSingleChoiceItems(xinglit0, 0, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        xingli0 = xinglit0[which];
                        xingli1 = xinglit1[which];
                        xingli2 = xinglit2[which];
                        xlsat = xingli0;
                        timep = xingli1.substring(18, 32);
                        qingjiao = Double.valueOf(xingli2.substring(8, 16)) / 180 * Math.PI;// 轨道倾角
                        chijing = Double.valueOf(xingli2.substring(17, 25)) / 180 * Math.PI;// 升交点赤经
                        pianxinlv = Double.valueOf("0." + xingli2.substring(26, 33));// 轨道偏心率
                        jddfj = Double.valueOf(xingli2.substring(34, 42)) / 180 * Math.PI;// 近地点幅角
                        pjdj = Double.valueOf(xingli2.substring(43, 51)) / 180 * Math.PI;// 平近点角
                        mrrxqs = Double.valueOf(xingli2.substring(52, 63));// 每日绕行圈数
                        xiaoxi = ("已载入星历:" + xlsat + "\n星历时间:" + timep + "\n轨道倾角:" + qingjiao * 180 / Math.PI
                                + "\n升交点赤经:" + chijing * 180 / Math.PI + "\n轨道偏心率:" + pianxinlv + "\n近地点幅角:"
                                + jddfj * 180 / Math.PI + "\n平近点角:" + pjdj * 180 / Math.PI + "\n每日绕行圈数:" + mrrxqs);
                        Toast.makeText(MainActivity.this, "你选择了: " + xingli0, 1000).show();
                        File f = null;
                        f = new File("/sdcard/lilacsat.txt");// 这是对应文件名

                        try {// 写入配置文件
                            String tmp0;
                            tmp0 = xingli0 + "\n" + xingli1 + "\n" + xingli2 + "\n"
                                    + String.valueOf(((double)Math.round(yhjd * 18000 / Math.PI)) / 100) + "\n"
                                    + String.valueOf(((double)Math.round(yhwd * 18000 / Math.PI)) / 100) + "\n"
                                    + String.valueOf(Math.round(haiba)) + "\n" + String.valueOf(Math.round(cipianjiao))
                                    + "\n" + String.valueOf((double) Math.round(xxpl0 * 10000) / 10000) + "\n"
                                    + String.valueOf((double) Math.round(sxpl0 * 10000) / 10000) + "\n";
                            FileOutputStream fout = new FileOutputStream(f);
                            byte[] bytes = tmp0.getBytes();
                            fout.write(bytes);
                            fout.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                    }

                }).setNegativeButton("取消", null).show();

    }

    // 结束程序
    public void FinishClick(View v) {
        finish();
    }

    // 程序初始化时,读取记录文件,没有lilacsat文件就创建一个。
    public void Update() {

        // String urlStr="http://lilacsat.hit.edu.cn/tle/lilacsat.txt";

        File f = null;
        f = new File("/sdcard/lilacsat.txt");// 这是对应文件名
        if (!(f.exists())) {
            try {// 写入配置文件
                String tmp0;
                tmp0 = xingli0 + "\n" + xingli1 + "\n" + xingli2 + "\n"
                        + String.valueOf(((double)Math.round(yhjd * 18000 / Math.PI)) / 100) + "\n"
                        + String.valueOf(((double)Math.round(yhwd * 18000 / Math.PI)) / 100) + "\n"
                        + String.valueOf(Math.round(haiba)) + "\n" + String.valueOf(Math.round(cipianjiao)) + "\n"
                        + String.valueOf((double) Math.round(xxpl0 * 10000) / 10000) + "\n"
                        + String.valueOf((double) Math.round(sxpl0 * 10000) / 10000) + "\n";
                FileOutputStream fout = new FileOutputStream(f);
                byte[] bytes = tmp0.getBytes();
                fout.write(bytes);
                fout.close();
            } catch (Exception e) {
                e.printStackTrace();
            }

            Toast.makeText(MainActivity.this, "首次运行并创建配置文件!", 1000).show();
        }
        InputStream in = null;
        try {
            in = new BufferedInputStream(new FileInputStream(f));
        } catch (FileNotFoundException e3) {
            // TODO Auto-generated catch block
            e3.printStackTrace();
        }
        BufferedReader br = null;
        try {
            br = new BufferedReader(new InputStreamReader(in, "gb2312"));
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        String tmp;

        try {
            // while((tmp=br.readLine())!=null){
            tmp = br.readLine();
            xingli0 = tmp;
            xlsat = tmp;
            // 在这对tmp操作
            tmp = br.readLine();
            xingli1 = tmp;
            timep = tmp.substring(18, 32);
            tmp = br.readLine();
            xingli2 = tmp;
            qingjiao = Double.valueOf(tmp.substring(8, 16)) / 180 * Math.PI;// 轨道倾角
            chijing = Double.valueOf(tmp.substring(17, 25)) / 180 * Math.PI;// 升交点赤经
            pianxinlv = Double.valueOf("0." + tmp.substring(26, 33));// 轨道偏心率
            jddfj = Double.valueOf(tmp.substring(34, 42)) / 180 * Math.PI;// 近地点幅角
            pjdj = Double.valueOf(tmp.substring(43, 51)) / 180 * Math.PI;// 平近点角
            mrrxqs = Double.valueOf(tmp.substring(52, 63));// 每日绕行圈数
            tmp = br.readLine();
            yhjd = Double.valueOf(tmp) / 180 * Math.PI;// 用户经度
            tmp = br.readLine();
            yhwd = Double.valueOf(tmp) / 180 * Math.PI;// 用户纬度
            tmp = br.readLine();
            haiba = Double.valueOf(tmp);// 海拔
            tmp = br.readLine();
            cipianjiao = Double.valueOf(tmp);// 磁偏角
            tmp = br.readLine();
            xxpl0 = Double.valueOf(tmp);// 下行频率
            tmp = br.readLine();
            sxpl0 = Double.valueOf(tmp);// 上行频率

            br.close();
            in.close();
            xiaoxi = ("已载入星历:" + xlsat + "\n星历时间:" + timep + "\n轨道倾角:" + qingjiao * 180 / Math.PI + "\n升交点赤经:"
                    + chijing * 180 / Math.PI + "\n轨道偏心率:" + pianxinlv + "\n近地点幅角:" + jddfj * 180 / Math.PI + "\n平近点角:"
                    + pjdj * 180 / Math.PI + "\n每日绕行圈数:" + mrrxqs);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

        }

    }

}
离线张湧
发帖
43
只看该作者 62楼 发表于: 2016-10-08
非常感谢楼主,楼主辛苦了
离线bfl-tt
发帖
256
只看该作者 63楼 发表于: 2016-10-09
为BI3OJW点赞!!
离线bd9cr
发帖
1202
只看该作者 64楼 发表于: 2016-10-18
记号,下载试试

内容来自Android手机客户端

离线bd7jnn
发帖
319
只看该作者 65楼 发表于: 2016-10-26
楼主辛苦了!感谢分享!
离线bg4hyk
发帖
1837
只看该作者 66楼 发表于: 2016-10-27
楼主好人。已下载
欢迎加入 快乐无线电GLHAM 224850911QQ群
离线bg3gp
发帖
270
只看该作者 67楼 发表于: 2016-10-27
谢谢楼主
离线BH3NEK
发帖
1366
只看该作者 68楼 发表于: 2016-11-03
为BI3OJW点赞!!!
呼号:BH3NEK
直频:145.100MHz  
中继: 439.125MHz-8 亚音103.5  
          147.925MHz-3.8 无亚音
          437.535-5 亚音 136.5
APRS:144.640
承德ham微信号:CDHAM01


QTH:河北承德开发区
离线shenxi
发帖
121
只看该作者 69楼 发表于: 2016-11-13
电脑管家报有病毒。
自由摄影人
http://newices.poco.cn
QQ 82399070
无线电呼号 BG4XYS
唯一的HAM与摄影QQ群: 29146675
离线BI3OJW
发帖
195
只看该作者 70楼 发表于: 2016-11-15
回 shenxi 的帖子
shenxi:电脑管家报有病毒。 (2016-11-13 21:52) 

我用360检测没问题啊。
代码是公开的,有能力的朋友可以试着编译一下。
报病毒的话,有可能是误报或者我的开发平台有问题。
你用的是PC端还是手机端的电脑管家?
离线BI3OJW
发帖
195
只看该作者 71楼 发表于: 2016-11-15
VirSCAN.org Scanned Report :
Scanned time   : 2016-11-15 08:51:09
Scanner results: 0%的杀软(0/32)报告发现病毒
File Name      : ZhuiXing.apk
File Size      : 796834 byte
File Type      : application/jar
MD5            : c40c0cd913176ee46b111d082d50bdb9
SHA1           : 40c63b8c9cbdd30ee81e4e5de2b3c6d27a4f4032
Online report  : http://r.virscan.org/report/d4e22e743e64d87981c2e3b24fb27a83

Scanner        Engine Ver      Sig Ver           Sig Date    Time   Scan result
antiy          AVL SDK 2.0                      1970-01-01     5    Found nothing                
asquared       9.0.0.4799     9.0.0.4799        2015-03-08     2    Found nothing                
avast          161113-0       4.7.4             2016-11-13     32   Found nothing                
avg            2109/12869     10.0.1405         2016-11-08     1    Found nothing                
baidu          2.0.1.0        4.1.3.52192       2.0.1.0        8    Found nothing                
baidusd        1.0            1.0               2014-04-02     1    Found nothing                
bitdefender    7.58879        7.90123           2015-01-16     1    Found nothing                
clamav         22399          0.97.5            2016-10-20     1    Found nothing                
drweb          5.0.2.3300     5.0.1.1           2016-11-14     45   Found nothing                
fortinet       40.554, 40.554,5.4.233           2016-11-09     1    Found nothing                
fprot          4.6.2.117      6.5.1.5418        2016-02-05     19   Found nothing                
fsecure        2015-08-01-02  9.13              2015-08-01     22   Found nothing                
gdata          25.8610        25.8610           2016-10-12     11   Found nothing                
ikarus         1.06.01        V1.32.31.0        2016-11-08     39   Found nothing                
jiangmin       16.0.100       1.0.0.0           2016-11-14     48   Engine oversweep4            
kaspersky      5.5.33         5.5.33            2014-04-01     32   Found nothing                
kingsoft       2.1            2.1               2013-09-22     7    Found nothing                
mcafee         8254           5400.1158         2016-08-11     53   Found nothing                
nod32          1777           3.0.21            2015-06-12     4    Found nothing                
panda          9.05.01        9.05.01           2016-11-14     5    Found nothing                
pcc            12.886.07      9.500-1005        2016-11-08     9    Found nothing                
qh360          1.0.1          1.0.1             1.0.1          3    Found nothing                
qqphone        1.0.0.0        1.0.0.0           2015-12-30     1    Found nothing                
quickheal      14.00          14.00             2016-11-14     3    Found nothing                
rising         26.28.00.01    26.28.00.01       2016-07-18     5    Found nothing                
sophos         5.32           3.65.2            2016-10-10     22   Found nothing                
symantec       20151230.005   1.3.0.24          2015-12-30     1    Found nothing                
tachyon        9.9.9          9.9.9             2013-12-27     8    Found nothing                
thehacker      6.8.0.5        6.8.0.5           2016-11-10     3    Found nothing                
tws            17.47.17308    1.0.2.2108        2016-11-14     16   Found nothing                
vba            3.12.29.3 beta 3.12.29.3 beta    2016-11-08     55   Found nothing                
virusbuster    15.0.985.0     5.5.2.13          2014-12-05     60   Found nothing                
======================================================================================

刚刚用在线检测,没发现有问题。
离线bg7enb
只看该作者 72楼 发表于: 2016-11-17
已經下載使用。。感謝
离线BI3OJW
发帖
195
只看该作者 73楼 发表于: 2016-11-17
今天又测试了一下,腾讯的手机管家确实会报病毒。
http://m.qq.com/security_lab/scans_online.jsp


百度的在线检测没发现。
http://scan.safe.baidu.com/html/scan.html

360的在线监测没有结果。
http://scan.shouji.360.cn/

安全管家检测安全。
http://www.anguanjia.com/?c=check

网秦手机病毒监测安全。
http://scan.nq.com/

可能某个模块的特征和腾讯病毒库的特征附上了。作为开发者,我不解释了。
在线BA7CK
发帖
74820
只看该作者 74楼 发表于: 2016-11-17
离线BG1SQT
发帖
74
只看该作者 75楼 发表于: 2016-11-19
野外手动追星利器,不错,赞一个

个人认为手机上把软件追星精度做好了就OK,至于云台自动控制等,应该是没有必要。因为既然有云台,就得有电源,带个笔记本电脑更容易,现成的跟踪软件。

另外,楼主测试过没有,电台发射状态下射频信号对手机角度指示的影响?不知道手机指示角度是不是类似电子罗盘,我家里用的是直川的电子罗盘,发射时就被干扰,只能在云台控制程序上解决了。
会员号:66530
呼号:BG1SQT
900M:13683052923
QQ:30264572
离线BI3OJW
发帖
195
只看该作者 76楼 发表于: 2016-11-19
回 BG1SQT 的帖子
BG1SQT:野外手动追星利器,不错,赞一个[表情]
个人认为手机上把软件追星精度做好了就OK,至于云台自动控制等,应该是没有必要。因为既然有云台,就得有电源,带个笔记本电脑更容易,现成的跟踪 .. (2016-11-19 11:38) 

我用的小米2A手机,测试没发现有影响,不过迄今为止还没上星通联过,惭愧。

我这个手机本身指示方向就不是特别准。

一般电子罗盘是检测磁场大小,不知用铜箔或铝箔包一下,是否能屏蔽电磁干扰。

另外,八木天线中轴应该是零电位点,动动位置看有无效果?
离线BG1SQT
发帖
74
只看该作者 77楼 发表于: 2016-11-19
回 BI3OJW 的帖子
BI3OJW:我用的小米2A手机,测试没发现有影响,不过迄今为止还没上星通联过,惭愧。
我这个手机本身指示方向就不是特别准。
....... (2016-11-19 13:07) 

有了你这款手机软件,野外手台打卫星很方便,FM通联相对简单,频移问题不需要多考虑,快了,哈哈

我的天线架起来有几年了,用的也是前面提到过的金属云台,架上去以后才发现电子罗盘受干扰,没试过屏蔽行不行。

罗盘位置我倒是调过,放在U段中间受V段干扰,反之一样,所以干脆就放UV中间连接杆上了,我是单U单V八木,自制的HB9CV,U7V4。我现在只拿电子罗盘在接收时做方向校准,通联时以转动时间计算角度,也不是很精确,不过,能通联的几颗卫星在SSB下都试过,没问题,呵呵
会员号:66530
呼号:BG1SQT
900M:13683052923
QQ:30264572
离线BI3OJW
发帖
195
只看该作者 78楼 发表于: 2016-11-22
搞定。经反馈给腾讯,已经洗白了。腾讯的效率还是不错的。
http://m.qq.com/security_lab/scans_online.jsp

http://bbs.m.qq.com/thread-68660-1-1.html
离线bg7qa
发帖
872
只看该作者 79楼 发表于: 2016-11-24
祝贺楼主开发成功!顶楼主的分享、开源精神!
BG7QA  广西、河池
键盘手谈汇(KHC)  QQ群:293739567