All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mil.nga.wkb.geom.MultiPolygon Maven / Gradle / Ivy

Go to download

Library for writing and reading Well-Known Binary Geometries to and from bytes

There is a newer version: 1.0.6
Show newest version
package mil.nga.wkb.geom;

import java.util.List;

/**
 * A restricted form of MultiSurface where each Surface in the collection must
 * be of type Polygon.
 * 
 * @author osbornb
 */
public class MultiPolygon extends MultiSurface {

	/**
	 * Constructor
	 */
	public MultiPolygon() {
		this(false, false);
	}

	/**
	 * Constructor
	 * 
	 * @param hasZ
	 *            has z
	 * @param hasM
	 *            has m
	 */
	public MultiPolygon(boolean hasZ, boolean hasM) {
		super(GeometryType.MULTIPOLYGON, hasZ, hasM);
	}

	/**
	 * Constructor
	 * 
	 * @param multiPolygon
	 *            multi polygon to copy
	 */
	public MultiPolygon(MultiPolygon multiPolygon) {
		this(multiPolygon.hasZ(), multiPolygon.hasM());
		for (Polygon polygon : multiPolygon.getPolygons()) {
			addPolygon((Polygon) polygon.copy());
		}
	}

	/**
	 * Get the polygons
	 * 
	 * @return polygons
	 */
	public List getPolygons() {
		return getGeometries();
	}

	/**
	 * Set the polygons
	 * 
	 * @param polygons
	 *            polygons
	 */
	public void setPolygons(List polygons) {
		setGeometries(polygons);
	}

	/**
	 * Add a polygon
	 * 
	 * @param polygon
	 *            polygon
	 */
	public void addPolygon(Polygon polygon) {
		addGeometry(polygon);
	}

	/**
	 * Get the number of polygons
	 * 
	 * @return number of polygons
	 */
	public int numPolygons() {
		return numGeometries();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Geometry copy() {
		return new MultiPolygon(this);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy