📄 jave-ppp.txt
字号:
//*** ppos.java
//*** 09 july 10:22a
import java.io.*;
import java.text.*;
import java.text.DecimalFormat;
public class ppos {
//*** read a Rinex obs file -- output point position in outfile
//*** y2k code fails after 2079
//*** assumes all gps, no glonass
//*** debug -- add solid earth tide
//*** globals
private static final double pi = Math.PI;
private static final double gpspi = 3.1415926535898e0; //*** exactly
private static final double RAD = 180.0/Math.PI; //*** radians to deg
private static final double sol = 299792458.0; //*** exactly
private static final double f1 = 1575.42e6;
private static final double f2 = 1227.60e6;
private static final double w1 = sol/f1;
private static final double w2 = sol/f2;
private static final double we = 7.2921151467e-5; //*** rad/sec
private static final double gm = 3.986005e14;
private static final double bigf = -4.442807633e-10;
private static final int mxprn= 32; //*** 38 are possible
private static final double dnull= 1.0e31;
private BufferedReader in = null; //*** obs file
private BufferedReader in2 = null; //*** nav file
private BufferedReader inp = null; //*** precise orbit
private BufferedWriter outBW = null;
private Rinx rinStuf = null;
private Gtime tStuf = null;
private Modes myModes = null;
//*** end of globals
public static void main( String args[] ){
ppos p = new ppos();
p.mymain(); //*** real work done here <=======<<<<<
}//*** endmain
//***********************************************************************
void mymain() {
//*** do the deed!!!!!!!!!!!!!!!!!!!!
//*** y2k code fails after 2079
String inFileName=null,in2FileName=null,inpFileName=null;
Pos svPos,rxPos;
BCset myBCS =null;
SP3set mySP3 =null;
RVec myV =null;
String myString;
String subField;
double val;
//*** get the Rinex file names
System.out.print("Enter the RINEX obs filename: ");
try {
inFileName=readln(); //*** read a line
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
System.out.print("Enter the RINEX nav filename: ");
try {
in2FileName=readln(); //*** read a line
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
rinStuf =new Rinx(); //*** rinex file parms
tStuf =new Gtime(); //*** time handler
myModes =new Modes(); //*** mode handler
//*** query for precise orbit
System.out.print("Precise orbit? : ");
try {
myString= readln(); //*** read a line
subField = myString.substring(0, 1);
if(subField.equalsIgnoreCase("y")){
myModes.putpOrb(true);
System.out.print("Enter the SP3 orbit filename: ");
try {
inpFileName=readln(); //*** read a line
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
}else{
myModes.putpOrb(false);
}
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
//*** open files
openFiles(inFileName, in2FileName, inpFileName);
//*** query for frequency treatment
System.out.print("2 frequency? : ");
try {
myString= readln(); //*** read a line
subField = myString.substring(0, 1);
if(subField.equalsIgnoreCase("y")){
myModes.putdFreq(true);
}else{
myModes.putdFreq(false);
}
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
//*** query for broadcast iono
if(!myModes.isdFreq()){
System.out.print("Broadcast ionosphere? : ");
try {
myString= readln(); //*** read a line
subField = myString.substring(0, 1);
if(subField.equalsIgnoreCase("y")){
myModes.putbIon(true);
}else{
myModes.putbIon(false);
}
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
}
//*** query for tropo model
System.out.print("Tropo? : ");
try {
myString= readln(); //*** read a line
subField = myString.substring(0, 1);
if(subField.equalsIgnoreCase("y")){
myModes.putTrop(true);
}else{
myModes.putTrop(false);
}
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
//*** query for vert cutoff angle
System.out.print("Vert cut (deg) : ");
try {
myString= readln(); //*** read a line
if(myString.length() <=0){
val=-1.0;
}else{
val = Double.valueOf(myString.trim()).doubleValue();
if(val >= 90.0) val=-1.0;
myModes.putvCut(val);
}
}
catch (IOException e) {
System.err.println("error in input line ... \n" + e.toString());
System.exit(1);
}
//*** echo options
System.out.print("Options =");
if(myModes.isdFreq()) System.out.print(" 2 freq");
if(myModes.isbIon() ) System.out.print(" b-iono");
if(myModes.isTrop() ) System.out.print(" tropo");
if(myModes.ispOrb() ) System.out.print(" precise");
System.out.println(".");
//*** loop over all lines
rxPos = doObsHeader(); //*** ref. time and pos. set
rxPos.xyzgeo();
System.out.print ("gla=" + (rxPos.getGlaGP()*RAD));
System.out.print (" glo=" + (rxPos.getGloGP()*RAD));
System.out.println(" eht=" + rxPos.getEhtGP());
myBCS = new BCset(in2, tStuf); //*** load nav file
in2=null; //*** close nav file
if(myModes.ispOrb()){
mySP3 = new SP3set(inp, tStuf); //*** load precise orbit
inp=null; //*** close precise orbit
}
doObsData(rxPos, myBCS, mySP3); //*** finish obs file
try {outBW.flush();}
catch (IOException e) {
System.err.println("error in output flush");
System.exit(1);
}
in =null; //*** close obs file
outBW=null; //*** close output file
}
//***********************************************************************
private Pos doObsHeader(){
//*** loop over obs file header
String myString;
String typeField;
Pos rxPos=null;
try {
while( (myString=in.readLine()) != null ){
typeField=myString.substring(60,myString.length());
typeField=typeField.trim();
if( typeField.equals("# / TYPES OF OBSERV") ){
processTypes(myString);
}
else if( typeField.equals("TIME OF FIRST OBS") ){
processT0(myString);
}
else if( typeField.equals("APPROX POSITION XYZ") ){
rxPos = processXYZ(myString); //*** for b-cast iono
}
else if( typeField.equals("END OF HEADER") ){
return rxPos;
}
}
}
catch (IOException e) {
System.err.println("Error in copy\n" + e.toString());
System.exit(1);
}
return rxPos;
}
private void processTypes(String myString){
//*** extract index for data types
String typeField;
int ntypes;
typeField = myString.substring(0,6);
ntypes = Integer.parseInt(typeField.trim());
rinStuf.putNdat(ntypes);
//*** parse the data types
for(int i=1; i<=rinStuf.getNdat(); i++){
typeField = myString.substring(6*(i+1)-2, 6*(i+1));
rinStuf.putKind(typeField, i);
}
}
private void processT0(String myString){
//*** extract start time
String typeField;
int iyr,imo,idy,ihr,imn;
double sec;
typeField = myString.substring( 0, 6);
iyr = Integer.parseInt(typeField.trim());
typeField = myString.substring( 6,12);
imo = Integer.parseInt(typeField.trim());
typeField = myString.substring(12,18);
idy = Integer.parseInt(typeField.trim());
typeField = myString.substring(18,24);
ihr = Integer.parseInt(typeField.trim());
typeField = myString.substring(24,30);
imn = Integer.parseInt(typeField.trim());
typeField = myString.substring(30,42);
sec = Double.valueOf(typeField.trim()).doubleValue();
//*** initialize mjd0
tStuf.setjd0(iyr, imo, idy);
}
private Pos processXYZ(String myString){
//*** extract approx position
String typeField;
double x,y,z;
typeField = myString.substring( 0,14);
x = Double.valueOf(typeField.trim()).doubleValue();
typeField = myString.substring(14,28);
y = Double.valueOf(typeField.trim()).doubleValue();
typeField = myString.substring(28,42);
z = Double.valueOf(typeField.trim()).doubleValue();
return new Pos(x, y, z);
}
private void doObsData(Pos rxPos, BCset myBCS, SP3set mySP3){
//*** loop over remaining lines (obs file data)
String myString;
String subField;
int iyr,imo,idy,ihr,imn;
int nsats, iprn=0, iprnget=0, nobs;
double ntot=0, nc1=0, nboth=0, nvmask=0, ndrop=0;
boolean lc1; //*** flag for count of c1's
double sec,tsec,tsecx;
double p1,p2,l1,l2,c1;
double va;
RVec myV;
PosD newPos; //*** point positions/dop's
//*** internal ordering P1,P2,L1,L2,C1,D1,D2 (1-7)
double data[] = new double[8]; //*** store data (fortan index)
int iprns[] = new int [13]; //*** store prns (fortan index)
double p1s[] = new double[13]; //*** store p1 (fortan index)
double p2s[] = new double[13]; //*** store p2 (fortan index)
int kprns[] = new int [13]; //*** store kept prns(ftn indx)
double dval;
//*** process the data
try {
//*** loop over all the data records (post-header)
while( (myString=in.readLine()) != null ){
//*** epoch header processing here
subField = myString.substring( 0, 3);
iyr = Integer.parseInt(subField.trim());
if (iyr < 80) {iyr=iyr+2000;} //*** y2k
else if(iyr <= 99) {iyr=iyr+1900;} //*** fail 2080
else {System.exit(1);}
subField = myString.substring( 3, 6);
imo = Integer.parseInt(subField.trim());
subField = myString.substring( 6, 9);
idy = Integer.parseInt(subField.trim());
subField = myString.substring( 9,12);
ihr = Integer.parseInt(subField.trim());
subField = myString.substring(12,15);
imn = Integer.parseInt(subField.trim());
subField = myString.substring(15,26);
sec = Double.valueOf(subField.trim()).doubleValue();
tsec=tStuf.civjts(iyr, imo, idy, ihr, imn, sec);
subField = myString.substring(29,32);
nsats = Integer.parseInt(subField.trim());
//*** get sat prn's (note: assumes no glonass)
for (int i=1; i<=nsats; i++){
subField = myString.substring(3*i+30, 3*i+32);
iprns[i] = Integer.parseInt(subField.trim());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -