summaryrefslogtreecommitdiff
path: root/src/main/java/com/benburwell/planes/data/Runway.java
blob: ad578338a440fc8897d650f93e1fcb82fd9905ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package com.benburwell.planes.data;

import org.apache.commons.csv.CSVRecord;

/**
 * @author ben
 */
public class Runway extends AbstractCSVReader {
    private int id;
    private int airportId;
    private String airportIdent;
    private Integer length;
    private Integer width;
    private String surface;
    private boolean lighted;
    private boolean closed;
    private String leIdent;
    private Double leLatitude;
    private Double leLongitude;
    private Double leElevation;
    private Double leHeading;
    private Integer leDisplacedThreshold;
    private String heIdent;
    private Double heLatitude;
    private Double heLongitude;
    private Double heElevation;
    private Double heHeading;
    private Integer heDisplacedThreshold;

    @Override
    public void readRecord(CSVRecord record) {
        this.id = Integer.valueOf(record.get("id"));
        this.airportId = Integer.valueOf(record.get("airport_ref"));
        this.airportIdent = record.get("airport_ident");
        try {
            this.length = Integer.valueOf(record.get("length_ft"));
        } catch (NumberFormatException e) {}
        try {
            this.width = Integer.valueOf(record.get("width_ft"));
        } catch (NumberFormatException e) {}
        this.surface = record.get("surface");
        this.lighted = record.get("lighted").equals("1");
        this.closed = record.get("closed").equals("1");
        this.leIdent = record.get("le_ident");
        try {
            this.leLatitude = Double.valueOf(record.get("le_latitude_deg"));
        } catch (NumberFormatException e) {}
        try {
            this.leLongitude = Double.valueOf(record.get("le_longitude_deg"));
        } catch (NumberFormatException e) {}
        try {
            this.leElevation = Double.valueOf(record.get("le_elevation_ft"));
        } catch (NumberFormatException e) {}
        try {
            this.leHeading = Double.valueOf(record.get("le_heading_degT"));
        } catch (NumberFormatException e) {}
        try {
            this.leDisplacedThreshold = Integer.valueOf(record.get("le_displaced_threshold_ft"));
        } catch (NumberFormatException e) {}
        this.heIdent = record.get("he_ident");
        try {
            this.heLatitude = Double.valueOf(record.get("he_latitude_deg"));
        } catch (NumberFormatException e) {}
        try {
            this.heLongitude = Double.valueOf(record.get("he_longitude_deg"));
        } catch (NumberFormatException e) {}
        try {
            this.heElevation = Double.valueOf(record.get("he_elevation_ft"));
        } catch (NumberFormatException e) {}
        try {
            this.heHeading = Double.valueOf(record.get("he_heading_degT"));
        } catch (NumberFormatException e) {}
        try {
            this.heDisplacedThreshold = Integer.valueOf(record.get("he_displaced_threshold_ft"));
        } catch (NumberFormatException e) {}
    }

    public boolean isDrawable() {
        return !this.isClosed() && (this.getLeLatitude() != null) && (this.getLeLongitude() != null) && (this.getHeLatitude() != null) && (this.getHeLongitude() != null);
    }

    public int getId() {
        return id;
    }

    public int getAirportId() {
        return airportId;
    }

    public String getAirportIdent() {
        return airportIdent;
    }

    public Integer getLength() {
        return length;
    }

    public Integer getWidth() {
        return width;
    }

    public String getSurface() {
        return surface;
    }

    public boolean isLighted() {
        return lighted;
    }

    public boolean isClosed() {
        return closed;
    }

    public String getLeIdent() {
        return leIdent;
    }

    public Double getLeLatitude() {
        return leLatitude;
    }

    public Double getLeLongitude() {
        return leLongitude;
    }

    public Double getLeElevation() {
        return leElevation;
    }

    public Double getLeHeading() {
        return leHeading;
    }

    public Integer getLeDisplacedThreshold() {
        return leDisplacedThreshold;
    }

    public String getHeIdent() {
        return heIdent;
    }

    public Double getHeLatitude() {
        return heLatitude;
    }

    public Double getHeLongitude() {
        return heLongitude;
    }

    public Double getHeElevation() {
        return heElevation;
    }

    public Double getHeHeading() {
        return heHeading;
    }

    public Integer getHeDisplacedThreshold() {
        return heDisplacedThreshold;
    }
}