Tabnine Logo
com.vividsolutions.jts.io
Code IndexAdd Tabnine to your IDE (free)

How to use com.vividsolutions.jts.io

Best Java code snippets using com.vividsolutions.jts.io (Showing top 20 results out of 792)

origin: opentripplanner/OpenTripPlanner

public Geometry unmarshal(String val) throws Exception {
  return new WKTReader(GeometryUtils.getGeometryFactory()).read(val);
}
public String marshal(Geometry val) throws Exception {
origin: zendesk/maxwell

@Override
public Object asJSON(Object value, MaxwellOutputConfig config) {
  Geometry geometry = null;
  if ( value instanceof Geometry ) {
    geometry = (Geometry) value;
  } else if ( value instanceof byte[] ) {
    byte []bytes = (byte[]) value;
    // mysql sprinkles 4 mystery bytes on top of the GIS data.
    bytes = Arrays.copyOfRange(bytes, 4, bytes.length);
    final WKBReader reader = new WKBReader();
    try {
      geometry = reader.read(bytes);
    } catch ( ParseException e ) {
      throw new RuntimeException("Could not parse geometry: " + e);
    }
  } else {
    throw new RuntimeException("Could not parse geometry column value: " + value);
  }
  return geometry.toText();
}
origin: com.vividsolutions/jts

public int readInt()
 throws IOException
{
 stream.read(buf4);
 return ByteOrderValues.getInt(buf4, byteOrder);
}
public long readLong()
origin: com.vividsolutions/jts

/**
 *  Returns the Well-known Text representation of this <code>Geometry</code>.
 *  For a definition of the Well-known Text format, see the OpenGIS Simple
 *  Features Specification.
 *
 *@return    the Well-known Text representation of this <code>Geometry</code>
 */
public String toText() {
 WKTWriter writer = new WKTWriter();
 return writer.write(this);
}
origin: com.vividsolutions/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: com.vividsolutions/jts

private void writeInt(int intValue, OutStream os) throws IOException
{
 ByteOrderValues.putInt(intValue, buf, byteOrder);
 os.write(buf, 4);
}
origin: com.vividsolutions/jts

/**
 *  Converts a <code>Geometry</code> to its Well-known Text representation.
 *
 *@param  geometry  a <code>Geometry</code> to process
 */
public void write(Geometry geometry, Writer writer)
 throws IOException
{
 writeFormatted(geometry, false, writer);
}
origin: com.vividsolutions/jts

/**
 * Converts a byte array to a hexadecimal string.
 * 
 * @param bytes
 * @return a string of hexadecimal digits
 * 
 * @deprecated
 */
public static String bytesToHex(byte[] bytes)
{
 return toHex(bytes);
}
origin: com.vividsolutions/jts

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

public double readDouble()
 throws IOException
{
 stream.read(buf8);
 return ByteOrderValues.getDouble(buf8, byteOrder);
}
origin: com.vividsolutions/jts

private void checkTriangleSize(Coordinate[] pts)
{
  String loc = "";
  if (pts.length >= 2)
    loc = WKTWriter.toLineString(pts[0], pts[1]);
  else {
    if (pts.length >= 1)
      loc = WKTWriter.toPoint(pts[0]);
  }
  // Assert.isTrue(pts.length == 4, "Too few points for visited triangle at " + loc);
  //com.vividsolutions.jts.util.Debug.println("too few points for triangle at " + loc);
}
 
origin: com.vividsolutions/jts

private void writeByteOrder(OutStream os) throws IOException
{
 if (byteOrder == ByteOrderValues.LITTLE_ENDIAN)
  buf[0] = WKBConstants.wkbNDR;
 else
  buf[0] = WKBConstants.wkbXDR;
 os.write(buf, 1);
}
origin: com.vividsolutions/jts

/**
 * Creates a new stream based on the given buffer.
 * 
 * @param buffer the bytes to read
 */
public ByteArrayInStream(final byte[] buffer) {
  setBytes(buffer);
}
origin: com.vividsolutions/jts

private void indentCoords(int coordIndex,  int level, Writer writer)
 throws IOException
{
 if (coordsPerLine <= 0
   || coordIndex % coordsPerLine != 0)
  return;
 indent(level, writer);
}
origin: com.vividsolutions/jts

 public String toString()
 {
   return WKTWriter.toLineString(pt[0], pt[1]);
 }
}
origin: com.vividsolutions/jts

/**
 * Reads a byte value
 *
 * @return the byte read
 */
public byte readByte()
  throws IOException
{
 stream.read(buf1);
 return buf1[0];
}
origin: com.vividsolutions/jts

private static String msgWithCoord(String msg, Coordinate pt) {
  if (pt != null)
    return msg + " [ " + WKTWriter.toPoint(pt) + " ]";
  return msg;
}
origin: com.vividsolutions/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: com.vividsolutions/jts

/**
 *  Same as <code>write</code>, but with newlines and spaces to make the
 *  well-known text more readable.
 *
 *@param  geometry  a <code>Geometry</code> to process
 */
public void writeFormatted(Geometry geometry, Writer writer)
 throws IOException
{
 writeFormatted(geometry, true, writer);
}
/**
origin: com.vividsolutions/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);
}
com.vividsolutions.jts.io

Most used classes

  • WKTReader
    Converts a geometry in Well-Known Text format to a Geometry.WKTReader supports extracting Geometry o
  • WKTWriter
    Writes the Well-Known Text representation of a Geometry. The Well-Known Text format is defined in th
  • 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
  • ParseException
    Thrown by a WKTReader when a parsing problem occurs.
  • GMLWriter,
  • ByteOrderDataInStream,
  • GMLReader,
  • ByteOrderValues,
  • OutputStreamOutStream,
  • GMLHandler,
  • InputStreamInStream,
  • OutStream,
  • InStream,
  • WKBHexFileReader,
  • WKTFileReader,
  • GeoJsonWriter,
  • GMLHandler$Handler,
  • GeometryStrategies$ParseStrategy
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now