mil.nga.wkb.geom.LineString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wkb Show documentation
Show all versions of wkb Show documentation
Library for writing and reading Well-Known Binary Geometries to and from bytes
package mil.nga.wkb.geom;
import java.util.ArrayList;
import java.util.List;
/**
* A Curve that connects two or more points in space.
*
* @author osbornb
*/
public class LineString extends Curve {
/**
* List of points
*/
private List points = new ArrayList();
/**
* Constructor
*/
public LineString() {
this(false, false);
}
/**
* Constructor
*
* @param hasZ
* has z
* @param hasM
* has m
*/
public LineString(boolean hasZ, boolean hasM) {
super(GeometryType.LINESTRING, hasZ, hasM);
}
/**
* Constructor
*
* @param lineString
* line string to copy
*/
public LineString(LineString lineString) {
this(lineString.hasZ(), lineString.hasM());
for (Point point : lineString.getPoints()) {
addPoint((Point) point.copy());
}
}
/**
* Constructor
*
* @param type
* geometry type
* @param hasZ
* has z
* @param hasM
* has m
*/
protected LineString(GeometryType type, boolean hasZ, boolean hasM) {
super(type, hasZ, hasM);
}
/**
* Get the points
*
* @return points
*/
public List getPoints() {
return points;
}
/**
* Set the points
*
* @param points
* points
*/
public void setPoints(List points) {
this.points = points;
}
/**
* Add a point
*
* @param point
* point
*/
public void addPoint(Point point) {
points.add(point);
}
/**
* Get the number of points
*
* @return number of points
*/
public int numPoints() {
return points.size();
}
/**
* {@inheritDoc}
*/
@Override
public Geometry copy() {
return new LineString(this);
}
}