Java Code Examples for com.vividsolutions.jts.geom.MultiPoint#getNumGeometries()

The following examples show how to use com.vividsolutions.jts.geom.MultiPoint#getNumGeometries() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WKTWriter.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 *  Converts a <code>MultiPoint</code> to &lt;MultiPoint Text&gt; format, then
 *  appends it to the writer.
 *
 *@param  multiPoint  the <code>MultiPoint</code> to process
 *@param  writer      the output writer to append to
 */
private void appendMultiPointText(MultiPoint multiPoint, int level, Writer writer)
  throws IOException
{
  if (multiPoint.isEmpty()) {
    writer.write("EMPTY");
  }
  else {
    writer.write("(");
    for (int i = 0; i < multiPoint.getNumGeometries(); i++) {
      if (i > 0) {
        writer.write(", ");
        indentCoords(i, level + 1, writer);
      }
      writer.write("(");
      appendCoordinate(((Point) multiPoint.getGeometryN(i)).getCoordinate(), writer);
      writer.write(")");
   }
    writer.write(")");
  }
}
 
Example 2
Source File: JTSHelper.java    From xyz-hub with Apache License 2.0 5 votes vote down vote up
/**
 * Create GeoJSON MultiPoint coordinates.
 */
public static MultiPointCoordinates createMultiPointCoordinates(MultiPoint geom) {
  if (geom == null) {
    return null;
  }

  int len = geom.getNumGeometries();
  MultiPointCoordinates multiPointCoordinates = new MultiPointCoordinates(len);

  for (int i = 0; i < len; i++) {
    multiPointCoordinates.add(createPointCoordinates((Point) geom.getGeometryN(i)));
  }

  return multiPointCoordinates;
}
 
Example 3
Source File: GamaKmlExport.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public void addMultiPoint(final Placemark pm, final MultiPoint mpoint, final double height) {
	final int ng = mpoint.getNumGeometries();
	final MultiGeometry mg = pm.createAndSetMultiGeometry();
	for (int gx = 0; gx < ng; gx++) {
		final de.micromata.opengis.kml.v_2_2_0.Point kmlpoint = mg.createAndAddPoint();
		fillPoint(kmlpoint, (Point) mpoint.getGeometryN(gx), height);
	}
}
 
Example 4
Source File: PdfContext.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
private void drawGeometry(Geometry g, SymbolInfo symbol) {
	if (g instanceof MultiPolygon) {
		MultiPolygon mpoly = (MultiPolygon) g;
		for (int i = 0; i < mpoly.getNumGeometries(); i++) {
			drawGeometry(mpoly.getGeometryN(i), symbol);
		}
	} else if (g instanceof MultiLineString) {
		MultiLineString mline = (MultiLineString) g;
		for (int i = 0; i < mline.getNumGeometries(); i++) {
			drawGeometry(mline.getGeometryN(i), symbol);
		}
	} else if (g instanceof MultiPoint) {
		MultiPoint mpoint = (MultiPoint) g;
		for (int i = 0; i < mpoint.getNumGeometries(); i++) {
			drawGeometry(mpoint.getGeometryN(i), symbol);
		}
	} else if (g instanceof Polygon) {
		Polygon poly = (Polygon) g;
		LineString shell = poly.getExteriorRing();
		int nHoles = poly.getNumInteriorRing();
		drawPathContent(shell.getCoordinates());
		for (int j = 0; j < nHoles; j++) {
			drawPathContent(poly.getInteriorRingN(j).getCoordinates());
		}
		template.closePathEoFillStroke();
	} else if (g instanceof LineString) {
		LineString line = (LineString) g;
		drawPathContent(line.getCoordinates());
		template.stroke();
	} else if (g instanceof Point) {
		Point point = (Point) g;
		drawPoint(point.getCoordinate(), symbol);
		template.fillStroke();
	}
}
 
Example 5
Source File: MultiPointWriter.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public void writeObject(Object o, GraphicsDocument document, boolean asChild) throws RenderException {
	MultiPoint mp = (MultiPoint) o;
	for (int i = 0; i < mp.getNumGeometries(); i++) {
		document.writeElement("use", i == 0 && asChild);
		Point p = (Point) mp.getGeometryN(i);
		document.writeAttribute("x", p.getX());
		document.writeAttribute("y", p.getY());
	}
}