Created
April 12, 2020 01:54
-
-
Save Ghost-Programmer/82b56767e6f2b0cf67587acfee2bf09d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package name.mymiller.geo; | |
import java.util.function.Consumer; | |
/** | |
* Class used to represent a line between points on the GeoPath | |
* | |
* @author jmiller | |
*/ | |
public class GeoLine implements GeoShape { | |
/** | |
* GeoLocation the GeoLine start. | |
*/ | |
private final GeoLocation from; | |
/** | |
* GeoLocation the GeoLine ends at. | |
*/ | |
private final GeoLocation to; | |
/** | |
* Constructor taking two GeoLocation to form the line between | |
* | |
* @param from Starting GeoLocation | |
* @param to Ending GeoLocation | |
*/ | |
public GeoLine(final GeoLocation from, final GeoLocation to) { | |
this.from = from; | |
this.to = to; | |
} | |
/** | |
* Call for each step in the Geo Line | |
* | |
* @param action Action to perform. | |
*/ | |
@Override | |
public void forEach(Consumer<? super GeoLocation> action) { | |
this.getGeoPath().forEach(action); | |
} | |
/** | |
* @return Return the From GeoLocation | |
*/ | |
public GeoLocation getFrom() { | |
return this.from; | |
} | |
@Override | |
public GeoPath getGeoPath() { | |
final GeoPath path = new GeoPath(); | |
path.add(this.getFrom()); | |
path.add(this.getTo()); | |
return path; | |
} | |
/** | |
* @return Return the To GeoLocation | |
*/ | |
public GeoLocation getTo() { | |
return this.to; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment