/*
 Author:    Tz-Yang Tang
            Carlos Icaza-Estrada
 */

import wdcor.WorldCoords;


public class GECLdatatypes
{
    // member variables
    String name;   // used in hash table
    String type;    
    String dists;

    float coord_longitude;
    float coord_latitude;
    String coord_elev;

    String place_title;

	String StructShape;
    float leftup_coord_lo;
    float leftup_coord_la;    
    float leftdn_coord_lo;
    float leftdn_coord_la;    
    float righup_coord_lo;   
    float righup_coord_la;       
    float righdn_coord_lo;
    float righdn_coord_la;    
    float struct_hi;  
    float east_lo, east_la, north_lo, north_la, west_lo, west_la, south_lo, south_la;
    
    String ovyurl;
    float ovyrotat;
    
    float[] linelon = new float[100];
    float[] linelat = new float[100];
    String[] lineelv = new String[100];
    int lineIndex;
	
	int int_value; //for int
	float float_value;
	String string_value;
    
    PerspectType minePersp = new PerspectType(); 
	
	Ply_3D read3Dfile = new Ply_3D();
    
 // constructor   
    public GECLdatatypes(){
    	name="default";
		type="default";
		dists="0ft";
		coord_longitude = 0.0f;
		coord_latitude = 0.0f;
		coord_elev = "default";
		place_title = "default";
		lineIndex = 0;
		int_value = 0;
		float_value = 0.0f;
		string_value = "defualt";
    	}
 
 // member functions
    
    public String getname(){
    	return name;
    	}
    public void setname(String tempstr){
    	name = tempstr;
    	}

    public String gettype(){
    	return type;
    	}
    public void settype(String tempstr){
    	type = tempstr;
    	}

    public String getdists(){
    	return dists;
    	}
    public void setdists(String tempstr){
    	dists = tempstr;
    	}
    	
    public void setcoord(float lon,float lat,String el){
    	coord_longitude = lon;
    	coord_latitude = lat;
    	coord_elev = el;
    	}	
    	
   	public float getlon(){
    	return coord_longitude;
    	}	 	
    	
   	public float getlat(){
    	return coord_latitude;
    	}	 	 	
   
   	public String getelv(){
    	return coord_elev;
    	}	 	 	
    	
   	public void cpy(GECLdatatypes tempgecl){
   		coord_longitude=tempgecl.getlon();
   		coord_latitude=tempgecl.getlat();
   	    coord_elev=tempgecl.getelv();
   		} 	
    	
    public void settitle(String tempstr){
    	place_title = tempstr;
    	}		
    	
    public String gettitle(){
    	return place_title;
    	}		
    	
    public void setshape(String tempstr){
    	StructShape = tempstr;
    	}		
    	
    public String getshape(){
    	return StructShape;
    	}			
    
     public void setsquare(float leng,float heig){
 
    	double earthradius=3963.189 * 5280;
    	float radius = (float) Math.asin((leng/2)/earthradius);
    	float degree = (float) Math.toDegrees(radius);
 
   		leftup_coord_lo = coord_longitude -degree;
    	leftup_coord_la = coord_latitude +degree;
    	
    	leftdn_coord_lo = coord_longitude -degree;
    	leftdn_coord_la = coord_latitude -degree;
    	
    	righup_coord_lo = coord_longitude +degree;
    	righup_coord_la = coord_latitude +degree;
    	
    	righdn_coord_lo = coord_longitude +degree;
		righdn_coord_la = coord_latitude -degree;
    	
    	struct_hi=heig;
    	}		
    		
     public void setrect(float leng,float width,float heig){
     	// the default length is in feet
    	double earthradius=3963.189  * 5280;  // 1 mile = 5280 ft
    	float radiusL = (float) Math.asin((leng/2)/earthradius);
    	float radiusW = (float) Math.asin((width/2)/earthradius);
    	float degreeL = (float) Math.toDegrees(radiusL);    	
    	float degreeW = (float) Math.toDegrees(radiusW);    	
    	
    	leftup_coord_lo = coord_longitude -degreeL;
    	leftup_coord_la = coord_latitude +degreeW;
    	
    	leftdn_coord_lo = coord_longitude -degreeL;
    	leftdn_coord_la = coord_latitude -degreeW;
    	
    	righup_coord_lo = coord_longitude +degreeL;
    	righup_coord_la = coord_latitude +degreeW;
    	
    	righdn_coord_lo = coord_longitude +degreeL;
		righdn_coord_la = coord_latitude -degreeW;
    	
    	struct_hi=heig;
    	}	   		
    		
    	public float getlfuplo(){
    	return leftup_coord_lo;
    	}	 		
    	public float getlfupla(){
    	return leftup_coord_la;
    	}	 		
    	public float getlfdnlo(){
    	return leftdn_coord_lo;
    	}	 		
    	public float getlfdnla(){
    	return leftdn_coord_la;
    	}	 	
    	public float getrtuplo(){
    	return righup_coord_lo;
    	}	 		
    	public float getrtupla(){
    	return righup_coord_la;
    	}	 	    	
    	public float getrtdnlo(){
    	return righdn_coord_lo;
    	}	 		    		
    	public float getrtdnla(){
    	return righdn_coord_la;
    	}	 	    	
	
    	public float getstrhi(){
		// Get structure height    
    	return struct_hi;
    	}	 	
    	
     public void setoverlay(GECLdatatypes o1,GECLdatatypes o2,GECLdatatypes o3,GECLdatatypes o4){
    	
    	leftup_coord_lo = o1.getlon();
    	leftup_coord_la = o1.getlat();
    	
    	righup_coord_lo = o2.getlon();
    	righup_coord_la = o2.getlat();
    	
    	righdn_coord_lo = o3.getlon();
		righdn_coord_la = o3.getlat();
    	
    	leftdn_coord_lo = o4.getlon();
    	leftdn_coord_la = o4.getlat();
    	
    	}	   		    	
     
    // Set Triangle
    /*public static void settriangle(double leng,int heig){
	
        double dir = Math.toRadians(120.00); //turn degrees into radians for use with trig functions
	
        double cond_factor= (69.1105 * 5280.00) ;
        double long_const = ( leng / cond_factor ) * ( Math.cos(dir) );
        double lat_const  = ( leng / cond_factor ) * ( Math.sin(dir) );
        north_lo  = (float) coord_longitude;
        north_la  = (float) (coord_latitude + ( ( leng / Math.sqrt(3.00) ) / cond_factor ));
	
        right_lo = (float)(north_lo + long_const);
        right_la = (float) (north_la - lat_const);
	
        left_lo = (float) (north_lo - long_const);
        left_la = (float) (north_la - lat_const);
        struct_hi=heig;
    } */  
    	
   	public void seturl(String tmp){
    	ovyurl = tmp;
    	}	   		    	
    public String geturl(){
    	return ovyurl;
    	}	   	
    public void setrotat(float tmp){
   		ovyrotat = tmp;
    	}	   		    	
    public float getrotat(){
   		return ovyrotat;
    	}	   		    		
    	
     public void setpersp(PerspectType tmpobj){
   		minePersp=tmpobj;
   		minePersp.SetPersp();
    	}	   		    	
    	
    public void insert(GECLdatatypes tmpobj){
    	linelon[lineIndex] = tmpobj.getlon();
    	linelat[lineIndex] = tmpobj.getlat();
    	lineelv[lineIndex] = tmpobj.getelv();
    	lineIndex++;
    	}
    	
    public int getLineNum(){
    return lineIndex;
    }
    	
    public float getLineArraylon(int tmp){
    return linelon[tmp];
    }	
    	
    public float getLineArraylat(int tmp){
    return linelat[tmp];
    }		
    
    public String getLineArrayelv(int tmp){
    return lineelv[tmp];
    }
    
    
	public void setCityCoords(WorldCoords tmp){
		
	 coord_longitude=(float) 	tmp.longitude;
    coord_latitude = (float)	tmp.latitude;	
		
    }
	
	
	public void setIntValue(int tempint){
    	int_value = tempint;
    	}
	public int getIntValue(){
    	return int_value;
    	}
	public void setFloatValue(float tempfloat){
    	float_value = tempfloat;
    	}
	public float getFloatValue(){
    	return float_value;
    	}
	public void setStringValue(String tempstring){
    	string_value = tempstring;
    	}
	public String getStringValue(){
    	return string_value;
    	}
	public void navigate(float lon, float lat, float dist, int dir )
	{	//assuming distance is given in feet
        double tmp;
        tmp = Math.toRadians(dir); //turn degrees into radians for use with trig functions
        double whatever;
        whatever= 69.1105*5280; //360.0 / ( Math.PI * (3963.189 * 5280.00));
        float cond_factor = (float)whatever;
        coord_longitude = lon + ( (dist / cond_factor) * ((float) Math.cos(tmp) ));
        coord_latitude  = lat + ( (dist / cond_factor) * ((float) Math.sin(tmp) ));
    }
}
