Start updating length (int -> float).
This commit is contained in:
		
							부모
							
								
									85fb193808
								
							
						
					
					
						커밋
						3e6bcb0665
					
				
					7개의 변경된 파일과 19개의 추가작업 그리고 13개의 파일을 삭제
				
			
		|  | @ -31,7 +31,7 @@ public interface Arc { | |||
|     /** | ||||
|      * @return Length of this arc, in meters. | ||||
|      */ | ||||
|     public int getLength(); | ||||
|     public float getLength(); | ||||
| 
 | ||||
|     /** | ||||
|      * @return Minimum time required to travel this arc, in seconds. | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ class ArcBackward implements Arc { | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public int getLength() { | ||||
|     public float getLength() { | ||||
|         return this.originalArc.getLength(); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ class ArcForward implements Arc { | |||
|     private final Node origin, destination; | ||||
| 
 | ||||
|     // Length of the road (in meters). | ||||
|     private final int length; | ||||
|     private final float length; | ||||
| 
 | ||||
|     // Road information. | ||||
|     private final RoadInformation info; | ||||
|  | @ -32,7 +32,7 @@ class ArcForward implements Arc { | |||
|      * @param roadInformation Road information for this arc. | ||||
|      * @param points Points representing this arc. | ||||
|      */ | ||||
|     protected ArcForward(Node origin, Node dest, int length, RoadInformation roadInformation, | ||||
|     protected ArcForward(Node origin, Node dest, float length, RoadInformation roadInformation, | ||||
|             ArrayList<Point> points) { | ||||
|         this.origin = origin; | ||||
|         this.destination = dest; | ||||
|  | @ -53,7 +53,7 @@ class ArcForward implements Arc { | |||
| 
 | ||||
|     @Override | ||||
| 
 | ||||
|     public int getLength() { | ||||
|     public float getLength() { | ||||
|         return length; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ public class GraphStatistics { | |||
|     private final int maximumSpeed; | ||||
| 
 | ||||
|     // Maximum length of any arc on this graph. | ||||
|     private final int maximumLength; | ||||
|     private final float maximumLength; | ||||
| 
 | ||||
|     /** | ||||
|      * Create a new GraphStatistics instance with the given value. | ||||
|  | @ -23,7 +23,7 @@ public class GraphStatistics { | |||
|      * be used to indicate that this graph has no maximum limitation. | ||||
|      * @param maximumLength Maximum length of any arc of the graph. | ||||
|      */ | ||||
|     public GraphStatistics(int maximumSpeed, int maximumLength) { | ||||
|     public GraphStatistics(int maximumSpeed, float maximumLength) { | ||||
|         this.maximumLength = maximumLength; | ||||
|         this.maximumSpeed = maximumSpeed; | ||||
|     } | ||||
|  | @ -39,7 +39,7 @@ public class GraphStatistics { | |||
|     /** | ||||
|      * @return Maximum length of any arc in the graph. | ||||
|      */ | ||||
|     public int getMaximumLength() { | ||||
|     public float getMaximumLength() { | ||||
|         return this.maximumLength; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ public class Node implements Comparable<Node> { | |||
|      *  | ||||
|      * @return The newly created forward arc (origin to destination). | ||||
|      */ | ||||
|     public static Arc linkNodes(Node origin, Node destination, int length, | ||||
|     public static Arc linkNodes(Node origin, Node destination, float length, | ||||
|             RoadInformation roadInformation, ArrayList<Point> points) { | ||||
|         ArcForward arc = new ArcForward(origin, destination, length, roadInformation, points); | ||||
|         origin.addSuccessor(arc); | ||||
|  |  | |||
|  | @ -212,7 +212,7 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader { | |||
|         checkByteOrThrow(254); | ||||
| 
 | ||||
|         // Read successors and convert to arcs. | ||||
|         int maxLength = 0; | ||||
|         float maxLength = 0; | ||||
|         final int copyNbTotalSuccesors = nbTotalSuccessors; // Stupid Java... | ||||
|         observers.forEach((observer) -> observer.notifyStartReadingArcs(copyNbTotalSuccesors)); | ||||
|         for (int node = 0; node < nbNodes; ++node) { | ||||
|  | @ -225,7 +225,13 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader { | |||
|                 int descrNum = this.read24bits(); | ||||
| 
 | ||||
|                 // Length of the arc. | ||||
|                 int length = dis.readUnsignedShort(); | ||||
|                 float length; | ||||
|                 if (getCurrentVersion() < 8) { | ||||
|                     length = dis.readUnsignedShort(); | ||||
|                 } | ||||
|                 else { | ||||
|                     length = dis.readInt() / 1000.0f; | ||||
|                 } | ||||
|                 maxLength = Math.max(length, maxLength); | ||||
| 
 | ||||
|                 // Number of segments. | ||||
|  |  | |||
|  | @ -126,9 +126,9 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh | |||
|             String info = ""; | ||||
| 
 | ||||
|             // Display length | ||||
|             int length = path.getLength(); | ||||
|             float length = path.getLength(); | ||||
|             if (length < 2000) { | ||||
|                 info += String.format("Length = %d meters", length); | ||||
|                 info += String.format("Length = %.1f meters", length); | ||||
|             } | ||||
|             else { | ||||
|                 info += String.format("Length = %.3f kilometers", length / 1000.); | ||||
|  |  | |||
		불러오는 중…
	
		Reference in a new issue