Tabnine Logo
Geometry.toText
Code IndexAdd Tabnine to your IDE (free)

How to use
toText
method
in
com.vividsolutions.jts.geom.Geometry

Best Java code snippets using com.vividsolutions.jts.geom.Geometry.toText (Showing top 20 results out of 531)

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: opentripplanner/OpenTripPlanner

public void findHull() {
  LOG.info("finding hull of graph...");
  LOG.debug("using only stops? {}", useOnlyStops);
  if (bufferMeters < prototypeRoutingRequest.maxWalkDistance)
    LOG.warn("geographic filter buffer is smaller than max walk distance, this will probably yield incorrect results.");
  Graph graph= graphService.getRouter(prototypeRoutingRequest.routerId).graph;
  List<Geometry> geometries = new ArrayList<Geometry>();
  for (Vertex v : graph.getVertices()) {
    if (useOnlyStops && ! (v instanceof TransitStop))
      continue;
    Point pt = gf.createPoint(v.getCoordinate());
    Geometry geom = crudeProjectedBuffer(pt, bufferMeters);
    geometries.add(geom);
  }
  Geometry multiGeom = gf.buildGeometry(geometries);
  LOG.info("unioning hull...");
  hull = multiGeom.union();
  LOG.trace("hull is {}", hull.toText());
  // may lead to false rejections
  // DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier();
}

origin: com.vividsolutions/jts

public String toString() {
 return toText();
}
origin: org.geotools/gt-main

  public Object convert(Object source, Class target) throws Exception {
    Geometry geometry = (Geometry) source;
    return geometry.toText();
  }
};
origin: org.geotools/gt2-main

  public Object convert(Object source, Class target) throws Exception {
    Geometry geometry = (Geometry) source;
    return geometry.toText();
  }
};
origin: DataSystemsLab/GeoSpark

  public void call(Geometry shape)
      throws Exception
  {
    System.out.println(shape.toText());
  }
};
origin: org.geotools.jdbc/gt-jdbc-sqlserver

@Override
public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql)
    throws IOException {
  
  if ( value == null ) {
    sql.append( "NULL");
    return;
  }
  
  sql.append( "geometry::STGeomFromText('").append( value.toText() ).append( "',").append( srid ).append(")");
}

origin: org.geogit/geogit-core

public boolean canBeAppliedOn(Optional<Geometry> obj) {
  String wkt = obj.isPresent() ? obj.get().toText() : "";
  Object[] res = diffMatchPatch.patch_apply(patches, wkt);
  boolean[] bool = (boolean[]) res[1];
  for (int i = 0; i < bool.length; i++) {
    if (!bool[i]) {
      return false;
    }
  }
  return true;
}
origin: eu.agrosense.spi/grid2afd

@Override
public void handleTZN(Geometry geometry, Double value, int n) {
  assert afdURI != null;
  Map<String, Object> map = new HashMap<>();
  map.put(TreatmentZone.PROP_NAME, "TZN-" + n);
  map.put(TreatmentZone.PROP_VALUE, value);
  map.put(TreatmentZone.PROP_GEOMETRY, geometry.toText());
  map.put(TreatmentZone.PROP_PARENT_URI, afdURI);
  store(ItemIdType.TZN, map);
  nTZN++;
}
origin: org.geotools.jdbc/gt-jdbc-h2

/**
 * Returns the Well Known Text of the geometry.
 */
public static String AsWKT( byte[] wkb ) {
  if ( wkb == null ) {
    return null;
  }
  
  return fromWKB(wkb).toText();
}
origin: org.locationtech.geogig/geogig-core

@Nullable
public Geometry applyOn(@Nullable Geometry obj) {
  Preconditions.checkState(canBeAppliedOn(obj));
  String wkt = obj == null ? "" : obj.toText();
  String res = (String) diffMatchPatch.patch_apply(patches, wkt)[0];
  if (!res.isEmpty()) {
    return (Geometry) TextValueSerializer.fromString(FieldType.forBinding(Geometry.class),
        res);
  }
  return null;
}
origin: com.spatial4j/spatial4j

@Override
public String toString(Shape shape) {
 //Note: this logic is from the defunct JtsShapeReadWriter
 if (shape instanceof JtsGeometry) {
  JtsGeometry jtsGeom = (JtsGeometry) shape;
  return jtsGeom.getGeom().toText();
 }
 //Note: doesn't handle ShapeCollection or BufferedLineString
 return super.toString(shape);
}
origin: com.spatial4j/spatial4j

 @Override
 public String toString(Shape shape) {
  if (shape instanceof JtsGeometry) {
   return ((JtsGeometry) shape).getGeom().toText();
  }
  return super.toString(shape);
 }
}
origin: org.jboss.teiid/teiid-engine

public static ClobType geometryToClob(GeometryType geometry, 
                   boolean withSrid) 
    throws FunctionExecutionException {
  Geometry jtsGeometry = getGeometry(geometry);
  int srid = jtsGeometry.getSRID();
  StringBuilder geomText = new StringBuilder(); 
  if (withSrid && srid != GeometryType.UNKNOWN_SRID) {
    geomText.append("SRID=").append(jtsGeometry.getSRID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
  }
  geomText.append(jtsGeometry.toText());
  return new ClobType(new ClobImpl(geomText.toString()));
}
origin: teiid/teiid

public static ClobType geometryToClob(AbstractGeospatialType geometry, 
                   boolean withSrid) 
    throws FunctionExecutionException {
  Geometry jtsGeometry = getGeometry(geometry);
  int srid = jtsGeometry.getSRID();
  StringBuilder geomText = new StringBuilder(); 
  if (withSrid && srid != GeometryType.UNKNOWN_SRID) {
    geomText.append("SRID=").append(jtsGeometry.getSRID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
  }
  geomText.append(jtsGeometry.toText());
  return new ClobType(new ClobImpl(geomText.toString()));
}
origin: org.geotools.jdbc/gt-jdbc-h2

@Override
protected void visitLiteralGeometry(Literal expression) throws IOException {
  Geometry g = (Geometry) evaluateLiteral(expression, Geometry.class);
  if (g instanceof LinearRing) {
    //WKT does not support linear rings
    g = g.getFactory().createLineString(((LinearRing) g).getCoordinateSequence());
  }
  out.write( "ST_GeomFromText('"+g.toText()+"', "+currentSRID+")");
}

origin: org.n52.series.db/entities

  @Override
  public String getValueAsString() {
    return isSetValue()
        ? getValue().getGeometry()
              .toText()
        : "";
  }
}
origin: io.jeo/jeo-sql

protected void encode(Geometry geo, Object obj) {
  int srid = srid(geo, obj);
  if (prepared) {
    sql.add("ST_GeomFromText(?,?)");
    args.add(new Pair<Object,Integer>(geo.toText(), Types.VARCHAR));
    args.add(new Pair<Object,Integer>(srid, Types.INTEGER));
  }
  else {
    sql.add("ST_GeomFromText(").str(geo.toText()).add(",").add(srid).add(")");
  }
}
origin: teiid/teiid

@Test public void testTransform() throws Exception {
  Geometry g0 = new WKTReader().read("POINT(426418.89 4957737.37)");
  Geometry g1 = GeometryTransformUtils.transform(g0,
      "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs", // EPSG:32632
      "+proj=longlat +datum=WGS84 +no_defs" // EPSG:4326
  );
  assertEquals("POINT (8.07013599546795 44.76924401481436)", g1.toText());
}

origin: senbox-org/snap-desktop

@Test
public void testGetRegion_WithSpecifiedRegion() throws Exception {
  final BinningFormModel binningFormModel = new BinningFormModel();
  binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_BOUNDS, true);
  binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_NORTH_BOUND, 50.0);
  binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_EAST_BOUND, 15.0);
  binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_WEST_BOUND, 10.0);
  binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_SOUTH_BOUND, 40.0);
  assertEquals("POLYGON ((10 40, 10 50, 15 50, 15 40, 10 40))", binningFormModel.getRegion().toText());
}
com.vividsolutions.jts.geomGeometrytoText

Javadoc

Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text format, see the OpenGIS Simple Features Specification.

Popular methods of Geometry

  • getEnvelopeInternal
    Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
  • getCoordinates
    Returns an array containing the values of all the vertices for this geometry. If the geometry is a c
  • isEmpty
    Tests whether the set of points covered by this Geometry is empty.
  • getCentroid
    Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of componen
  • getGeometryN
    Returns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).
  • getNumGeometries
    Returns the number of Geometrys in a GeometryCollection(or 1, if the geometry is not a collection).
  • getFactory
    Gets the factory which contains the context in which this geometry was created.
  • getGeometryType
    Returns the name of this Geometry's actual class.
  • getSRID
    Returns the ID of the Spatial Reference System used by the Geometry. JTS supports Spatial Reference
  • getCoordinate
    Returns a vertex of this Geometry (usually, but not necessarily, the first one). The returned coordi
  • intersection
    Computes a Geometry representing the point-set which is common to both this Geometry and the other
  • buffer
    Computes a buffer area around this geometry having the given width and with a specified accuracy of
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply,
  • getLength

Popular in Java

  • Updating database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • startActivity (Activity)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Table (org.hibernate.mapping)
    A relational table
  • Github Copilot alternatives
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