| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package uk.me.parabola.imgfmt.app.trergn; |
| 18 |
|
| 19 |
import java.io.IOException; |
| 20 |
import java.io.OutputStream; |
| 21 |
|
| 22 |
import uk.me.parabola.imgfmt.app.ImgFileWriter; |
| 23 |
import uk.me.parabola.imgfmt.app.Label; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public abstract class MapObject { |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
private Subdivision subdiv; |
| 40 |
|
| 41 |
|
| 42 |
private Label label; |
| 43 |
|
| 44 |
|
| 45 |
private int type; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
private int deltaLong; |
| 50 |
private int deltaLat; |
| 51 |
|
| 52 |
private ExtTypeAttributes extTypeAttributes; |
| 53 |
|
| 54 |
|
| 55 |
private int number; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public abstract void write(ImgFileWriter file); |
| 63 |
|
| 64 |
public abstract void write(OutputStream stream) throws IOException; |
| 65 |
|
| 66 |
protected int getDeltaLat() { |
| 67 |
return deltaLat; |
| 68 |
} |
| 69 |
|
| 70 |
protected int getDeltaLong() { |
| 71 |
return deltaLong; |
| 72 |
} |
| 73 |
|
| 74 |
public void setLabel(Label label) { |
| 75 |
this.label = label; |
| 76 |
} |
| 77 |
|
| 78 |
public int getType() { |
| 79 |
return type; |
| 80 |
} |
| 81 |
|
| 82 |
public void setType(int type) { |
| 83 |
this.type = type; |
| 84 |
} |
| 85 |
|
| 86 |
public boolean hasExtendedType() { |
| 87 |
return hasExtendedType(type); |
| 88 |
} |
| 89 |
|
| 90 |
public static boolean hasExtendedType(int type) { |
| 91 |
return type >= 0x010000; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
public void setLatitude(int lat) { |
| 101 |
Subdivision div = getSubdiv(); |
| 102 |
|
| 103 |
int diff = div.roundLatToLocalShifted(lat); |
| 104 |
|
| 105 |
setDeltaLat(diff); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
public void setLongitude(int lon) { |
| 115 |
Subdivision div = getSubdiv(); |
| 116 |
|
| 117 |
int diff = div.roundLonToLocalShifted(lon); |
| 118 |
|
| 119 |
setDeltaLong(diff); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
protected void setDeltaLat(int deltaLat) { |
| 124 |
assert deltaLat >= -0x8000 && deltaLat <= 0x7fff : "deltaLat = " + deltaLat; |
| 125 |
this.deltaLat = deltaLat; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
protected void setDeltaLong(int deltaLong) { |
| 130 |
assert deltaLong >= -0x8000 && deltaLong <= 0x7fff : "deltaLong = " + deltaLong; |
| 131 |
this.deltaLong = deltaLong; |
| 132 |
} |
| 133 |
|
| 134 |
public Subdivision getSubdiv() { |
| 135 |
return subdiv; |
| 136 |
} |
| 137 |
|
| 138 |
protected void setSubdiv(Subdivision subdiv) { |
| 139 |
this.subdiv = subdiv; |
| 140 |
} |
| 141 |
|
| 142 |
public Label getLabel() { |
| 143 |
return label; |
| 144 |
} |
| 145 |
|
| 146 |
protected byte[] getExtTypeExtraBytes() { |
| 147 |
return (extTypeAttributes != null)? extTypeAttributes.getExtTypeExtraBytes(this) : null; |
| 148 |
} |
| 149 |
|
| 150 |
public void setExtTypeAttributes(ExtTypeAttributes eta) { |
| 151 |
extTypeAttributes = eta; |
| 152 |
} |
| 153 |
|
| 154 |
public String toString() { |
| 155 |
return "Type=" + type + ", l=" + label; |
| 156 |
} |
| 157 |
|
| 158 |
public int getNumber() { |
| 159 |
return number; |
| 160 |
} |
| 161 |
|
| 162 |
public void setNumber(int number) { |
| 163 |
this.number = number; |
| 164 |
} |
| 165 |
} |