org.locationtech.jts.geom.Geometry.toString()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中org.locationtech.jts.geom.Geometry.toString()方法的一些代码示例,展示了Geometry.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.toString()方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:toString

Geometry.toString介绍

暂无

代码示例

代码示例来源:origin: geoserver/geoserver

  1. object = transformer.transform(geometry);
  2. } catch (TransformException e) {
  3. String msg = "Error occured transforming " + geometry.toString();
  4. throw (IOException) new IOException(msg).initCause(e);

代码示例来源:origin: geotools/geotools

  1. public static String toWKT(Geometry arg0) {
  2. if (arg0 == null) return null;
  3. Geometry _this = arg0;
  4. return _this.toString();
  5. }

代码示例来源:origin: locationtech/spatial4j

  1. @Override
  2. public String toString() {
  3. return geom.toString();
  4. }

代码示例来源:origin: geotools/geotools

  1. public String toString() {
  2. return geometry.toString();
  3. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Gets geometry.
  3. *
  4. * @param geometry The geometry from the filter.
  5. * @throws IllegalFilterException If there are problems creating expression.
  6. */
  7. public void geometry(Geometry geometry) throws IllegalFilterException {
  8. // Sets the geometry for the expression, as appropriate
  9. LOGGER.finer("got geometry: " + geometry.toString());
  10. // if(curExprssn.getType()==ExpressionDefault.LITERAL_GEOMETRY){
  11. // LOGGER.finer("got geometry: ");
  12. curExprssn = new LiteralExpressionImpl();
  13. ((LiteralExpressionImpl) curExprssn).setValue(geometry);
  14. LOGGER.finer("set expression: " + curExprssn.toString());
  15. currentState = "complete";
  16. LOGGER.finer("set current state: " + currentState);
  17. // }
  18. }

代码示例来源:origin: geotools/geotools

  1. SimpleFeature reproject(SimpleFeature feature) throws IOException {
  2. List<Object> attributes = feature.getAttributes();
  3. for (int i = 0; i < attributes.size(); i++) {
  4. Object object = attributes.get(i);
  5. if (object instanceof Geometry) {
  6. // do the transformation
  7. Geometry geometry = (Geometry) object;
  8. try {
  9. attributes.set(i, tx.transform(geometry));
  10. } catch (TransformException e) {
  11. String msg = "Error occured transforming " + geometry.toString();
  12. throw (IOException) new IOException(msg).initCause(e);
  13. }
  14. }
  15. }
  16. try {
  17. return SimpleFeatureBuilder.build(schema, attributes, feature.getID());
  18. } catch (IllegalAttributeException e) {
  19. String msg = "Error creating reprojeced feature";
  20. throw (IOException) new IOException(msg).initCause(e);
  21. }
  22. }

代码示例来源:origin: geotools/geotools

  1. SimpleFeature reproject(SimpleFeature feature) throws IOException {
  2. List<Object> attributes = feature.getAttributes();
  3. for (int i = 0; i < attributes.size(); i++) {
  4. Object object = attributes.get(i);
  5. if (object instanceof Geometry) {
  6. // do the transformation
  7. Geometry geometry = (Geometry) object;
  8. try {
  9. attributes.set(i, tx.transform(geometry));
  10. } catch (TransformException e) {
  11. String msg = "Error occured transforming " + geometry.toString();
  12. throw (IOException) new IOException(msg).initCause(e);
  13. }
  14. }
  15. }
  16. try {
  17. return SimpleFeatureBuilder.build(schema, attributes, feature.getID());
  18. } catch (IllegalAttributeException e) {
  19. String msg = "Error creating reprojeced feature";
  20. throw (IOException) new IOException(msg).initCause(e);
  21. }
  22. }
  23. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Recieves a geometry from its child filter.
  3. *
  4. * @param geometry The geometry from the filter.
  5. * @throws RuntimeException if the filterFactory can't handle the geometry
  6. * @task REVISIT: can we throw another exception?
  7. */
  8. public void geometry(Geometry geometry) throws RuntimeException {
  9. // Sends the geometry to the expression
  10. try {
  11. LOGGER.finer("got geometry: " + geometry);
  12. expressionFactory.geometry(geometry);
  13. if (expressionFactory.isReady()) {
  14. LOGGER.finer("expression factory made expression and sent " + "to filter factory");
  15. filterFactory.expression(expressionFactory.create());
  16. }
  17. } catch (IllegalFilterException ife) {
  18. LOGGER.finer("Had problems adding geometry: " + geometry.toString());
  19. throw new RuntimeException("problem adding geometry to filter ", ife);
  20. }
  21. }

代码示例来源:origin: locationtech/jts

  1. public String toString()
  2. {
  3. return baseGeom.toString();
  4. }
  5. }

代码示例来源:origin: locationtech/geowave

  1. @Override
  2. public String toString() {
  3. return "DBScanClusterList [clusterGeo="
  4. + (clusterGeo == null ? "null" : clusterGeo.toString())
  5. + ", id="
  6. + id
  7. + "]";
  8. }
  9. }

代码示例来源:origin: orbisgis/h2gis

  1. public String toString() {
  2. return this.geom.toString();
  3. }

代码示例来源:origin: postgis/postgis-java

  1. public String toString() {
  2. return geom.toString();
  3. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public void encode(Geometry geometry, AttributesImpl atts, GMLWriter handler) throws Exception {
  3. if (geometry instanceof LineString) {
  4. LineStringEncoder lineString =
  5. new LineStringEncoder(encoder, LineStringEncoder.LINE_STRING);
  6. lineString.encode((LineString) geometry, atts, handler);
  7. } else if (geometry instanceof Point) {
  8. PointEncoder pt = new PointEncoder(encoder, gmlPrefix == null ? "gml" : gmlPrefix);
  9. pt.encode((Point) geometry, atts, handler);
  10. } else if (geometry instanceof Polygon) {
  11. PolygonEncoder polygon = new PolygonEncoder(encoder, gmlPrefix);
  12. polygon.encode((Polygon) geometry, atts, handler);
  13. } else if (geometry instanceof MultiLineString) {
  14. MultiLineStringEncoder multiLineString = new MultiLineStringEncoder(encoder, gmlPrefix);
  15. multiLineString.encode((MultiLineString) geometry, atts, handler);
  16. } else if (geometry instanceof MultiPoint) {
  17. MultiPointEncoder multiPoint = new MultiPointEncoder(encoder, gmlPrefix);
  18. multiPoint.encode((MultiPoint) geometry, atts, handler);
  19. } else if (geometry instanceof MultiPolygon) {
  20. MultiPolygonEncoder multiPolygon = new MultiPolygonEncoder(encoder, gmlPrefix);
  21. multiPolygon.encode((MultiPolygon) geometry, atts, handler);
  22. } else if (geometry instanceof LinearRing) {
  23. LinearRingEncoder linearRing = new LinearRingEncoder(encoder, gmlPrefix);
  24. linearRing.encode((LinearRing) geometry, atts, handler);
  25. } else {
  26. throw new Exception("Unsupported geometry " + geometry.toString());
  27. }
  28. }
  29. }

代码示例来源:origin: geotools/geotools

  1. curve.encode((LineString) geometry, atts, handler, parentId);
  2. } else {
  3. throw new Exception("Unsupported geometry " + geometry.toString());

代码示例来源:origin: org.locationtech.geomesa/geomesa-cqengine

  1. public String toString() {
  2. return "intersects(" +
  3. this.attribute.getAttributeName() +
  4. ", " +
  5. this.value.toString() +
  6. ")";
  7. }

代码示例来源:origin: locationtech/jts

  1. void rbWKT_actionPerformed(ActionEvent e) {
  2. writeView(
  3. test.getGeometry(0) == null ? null : test.getGeometry(0).toString(),
  4. test.getGeometry(1) == null ? null :test.getGeometry(1).toString(),
  5. test.getResult() == null ? null :test.getResult().toString()
  6. );
  7. }

代码示例来源:origin: locationtech/jts

  1. private String convertToWKT(Geometry g, boolean isFormatted)
  2. {
  3. if (g == null) return "";
  4. if (! isFormatted)
  5. return g.toString();
  6. WKTWriter writer = new WKTWriter();
  7. writer.setFormatted(isFormatted);
  8. writer.setMaxCoordinatesPerLine(5);
  9. return writer.write(g);
  10. }

代码示例来源:origin: locationtech/jts

  1. public void testNoding() throws Exception {
  2. Geometry a = reader.read("LINESTRING(0 0, 100 100)");
  3. Geometry b = reader.read("LINESTRING(0 100, 100 0)");
  4. List lineStrings = Arrays.asList(new Object[] {a, b});
  5. Geometry nodedLineStrings = (LineString) lineStrings.get(0);
  6. for (int i = 1; i < lineStrings.size(); i++) {
  7. nodedLineStrings = nodedLineStrings.union((LineString)lineStrings.get(i));
  8. }
  9. assertEquals("MULTILINESTRING ((0 0, 50 50), (50 50, 100 100), (0 100, 50 50), (50 50, 100 0))", nodedLineStrings.toString());
  10. }

代码示例来源:origin: locationtech/jts

  1. public void testQuickPolygonUnion() throws Exception {
  2. Geometry a = reader.read("POLYGON((0 0, 100 0, 100 100, 0 100, 0 0))");
  3. Geometry b = reader.read("POLYGON((50 50, 150 50, 150 150, 50 150, 50 50))");
  4. Geometry[] polygons = new Geometry[] {a, b};
  5. GeometryCollection polygonCollection = new GeometryFactory().createGeometryCollection(polygons);
  6. Geometry union = polygonCollection.buffer(0);
  7. System.out.println(union);
  8. assertEquals("POLYGON ((0 0, 0 100, 50 100, 50 150, 150 150, 150 50, 100 50, 100 0, 0 0))", union.toString());
  9. }

代码示例来源:origin: locationtech/jts

  1. public void test6() throws Exception {
  2. WKTReader reader = new WKTReader(new GeometryFactory(new PrecisionModel(1), 0));
  3. Geometry actualGeometry = reader.read("MULTIPOINT (0 0, 5 1, 10 0)").convexHull();
  4. Geometry expectedGeometry = reader.read("POLYGON ((0 0, 5 1, 10 0, 0 0))");
  5. assertEquals(expectedGeometry.toString(), actualGeometry.toString());
  6. }

相关文章