org.locationtech.jts.io
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.locationtech.jts.io(Showing top 15 results out of 315)

origin: com.h2database/h2

/**
 * Get the value in Well-Known-Text format.
 *
 * @return the well-known-text
 */
public String getWKT() {
  return new WKTWriter(3).write(getGeometryNoCopy());
}
origin: com.h2database/h2

public Geometry getGeometryNoCopy() {
  if (geometry == null) {
    try {
      geometry = new WKBReader().read(bytes);
    } catch (ParseException ex) {
      throw DbException.convert(ex);
    }
  }
  return geometry;
}
origin: com.h2database/h2

private static byte[] convertToWKB(Geometry g) {
  boolean includeSRID = g.getSRID() != 0;
  int dimensionCount = getDimensionCount(g);
  WKBWriter writer = new WKBWriter(dimensionCount, includeSRID);
  return writer.write(g);
}
origin: com.h2database/h2

/**
 * Get or create a geometry value for the given geometry.
 *
 * @param s the WKT representation of the geometry
 * @return the value
 */
public static ValueGeometry get(String s) {
  try {
    Geometry g = new WKTReader().read(s);
    return get(g);
  } catch (ParseException ex) {
    throw DbException.convert(ex);
  }
}
origin: com.h2database/h2

/**
 * Get or create a geometry value for the given geometry.
 *
 * @param s the WKT representation of the geometry
 * @param srid the srid of the object
 * @return the value
 */
public static ValueGeometry get(String s, int srid) {
  try {
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), srid);
    Geometry g = new WKTReader(geometryFactory).read(s);
    return get(g);
  } catch (ParseException ex) {
    throw DbException.convert(ex);
  }
}
origin: locationtech/jts

private MultiPoint readMultiPoint() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Point[] geoms = new Point[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Point))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPoint");
  geoms[i] = (Point) g;
 }
 return factory.createMultiPoint(geoms);
}
origin: locationtech/jts

public void testReadGeometryCollection() throws Exception {
  assertEquals("GEOMETRYCOLLECTION (POINT (10 10), POINT (30 30), LINESTRING (15 15, 20 20))", writer.write(reader.read("GEOMETRYCOLLECTION (POINT (10 10), POINT (30 30), LINESTRING (15 15, 20 20))")));
  assertEquals("GEOMETRYCOLLECTION (POINT (10 10), LINEARRING EMPTY, LINESTRING (15 15, 20 20))", writer.write(reader.read("GEOMETRYCOLLECTION (POINT (10 10), LINEARRING EMPTY, LINESTRING (15 15, 20 20))")));
  assertEquals("GEOMETRYCOLLECTION (POINT (10 10), LINEARRING (10 10, 20 20, 30 40, 10 10), LINESTRING (15 15, 20 20))", writer.write(reader.read("GEOMETRYCOLLECTION (POINT (10 10), LINEARRING (10 10, 20 20, 30 40, 10 10), LINESTRING (15 15, 20 20))")));
  assertEquals("GEOMETRYCOLLECTION EMPTY", writer.write(reader.read("GEOMETRYCOLLECTION EMPTY")));
}
origin: locationtech/jts

public long readLong()
 throws IOException
{
 stream.read(buf8);
 return ByteOrderValues.getLong(buf8, byteOrder);
}
origin: locationtech/jts

static List loadWKT(String filename) throws Exception {
 WKTReader rdr = new WKTReader();
 WKTFileReader fileRdr = new WKTFileReader(filename, rdr);
 return fileRdr.read();
}
origin: locationtech/jts

 public void testReadNaN() throws Exception {
  assertEquals("POINT (10 10)", writer.write(reader.read("POINT (10 10 NaN)")));
  assertEquals("POINT (10 10)", writer.write(reader.read("POINT (10 10 nan)")));
  assertEquals("POINT (10 10)", writer.write(reader.read("POINT (10 10 NAN)")));
}

origin: locationtech/jts

private MultiPolygon readMultiPolygon() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Polygon[] geoms = new Polygon[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Polygon))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPolygon");
  geoms[i] = (Polygon) g;
 }
 return factory.createMultiPolygon(geoms);
}
origin: org.locationtech.jts/jts-core

private MultiLineString readMultiLineString() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 LineString[] geoms = new LineString[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof LineString))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiLineString");
  geoms[i] = (LineString) g;
 }
 return factory.createMultiLineString(geoms);
}
origin: org.locationtech.jts/jts-core

private MultiPolygon readMultiPolygon() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Polygon[] geoms = new Polygon[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Polygon))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPolygon");
  geoms[i] = (Polygon) g;
 }
 return factory.createMultiPolygon(geoms);
}
origin: locationtech/jts

private MultiLineString readMultiLineString() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 LineString[] geoms = new LineString[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof LineString))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiLineString");
  geoms[i] = (LineString) g;
 }
 return factory.createMultiLineString(geoms);
}
origin: org.locationtech.jts/jts-core

private MultiPoint readMultiPoint() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Point[] geoms = new Point[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Point))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPoint");
  geoms[i] = (Point) g;
 }
 return factory.createMultiPoint(geoms);
}
org.locationtech.jts.io

Most used classes

  • WKTReader
    Converts a geometry in Well-Known Text format to a Geometry.WKTReader supports extracting Geometry o
  • WKBReader
    Reads a Geometryfrom a byte stream in Well-Known Binary format. Supports use of an InStream, which a
  • WKBWriter
    Writes a Geometry into Well-Known Binary format. Supports use of an OutStream, which allows easy use
  • WKTWriter
    Writes the Well-Known Text representation of a Geometry. The Well-Known Text format is defined in th
  • ParseException
    Thrown by a WKTReader when a parsing problem occurs.
  • GMLReader,
  • GMLWriter,
  • KMLWriter,
  • WKBHexFileReader,
  • GeoJsonReader,
  • GeoJsonWriter,
  • GMLHandler,
  • AverageZFilter,
  • ByteArrayInStream,
  • ByteOrderDataInStream,
  • ByteOrderValues,
  • InStream,
  • OutStream,
  • WKBReaderTest

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)