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

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

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

Geometry.toString介绍

暂无

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

public static EncodedPolylineBean createEncodings(Geometry geometry) {
  if (geometry instanceof LineString) {
    LineString string = (LineString) geometry;
    Coordinate[] coordinates = string.getCoordinates();
    return createEncodings(new CoordinateList(coordinates));
  } else if (geometry instanceof MultiLineString) {
    MultiLineString mls = (MultiLineString) geometry;
    return createEncodings(new CoordinateList(mls.getCoordinates()));
  } else {
    throw new IllegalArgumentException(geometry.toString());
  }
}

代码示例来源:origin: com.vividsolutions/jts

public String toString()
 {
   return baseGeom.toString();
 }
}

代码示例来源:origin: org.geotools/gt-main

static public String toWKT(Geometry arg0)
{
   if (arg0 == null) return null;
   Geometry _this = arg0;
   return _this.toString();
}

代码示例来源:origin: com.vividsolutions/jts-core

public String toString()
 {
   return baseGeom.toString();
 }
}

代码示例来源:origin: org.geotools/gt2-main

static public String toWKT(Geometry arg0)
{
   Geometry _this = arg0;
   return _this.toString();
}

代码示例来源:origin: aseldawy/spatialhadoop2

@Override
public String toString() {
 return geom == null? "(empty)" : geom.toString();
}

代码示例来源:origin: com.spatial4j/spatial4j

@Override
public String toString() {
 return geom.toString();
}

代码示例来源:origin: harbby/presto-connectors

@Override
public String toString() {
 return geom.toString();
}

代码示例来源:origin: org.geotools/gt-render

public String toString() {
  return geometry.toString();
}

代码示例来源:origin: org.geotools/gt-main

public void geometry(Geometry geometry) {
    System.out.println("here is the geometry: " + geometry.toString());
  }
}

代码示例来源:origin: org.geotools/gt2-main

public void geometry(Geometry geometry) {
    System.out.println("here is the geometry: " + geometry.toString());
  }
}

代码示例来源:origin: FutureCitiesCatapult/TomboloDigitalConnector

private Map<String, Object> flattenSubject(List<Field> fields, Subject subject) {
  Map<String, Object> row = new HashMap<>();
  row.put("label", subject.getLabel());
  row.put("name", subject.getName());
  row.put("geometry", subject.getShape().toString());
  fields.stream().map(field -> getAttributeProperty(subject, field)).forEach(row::putAll);
  return row;
}

代码示例来源:origin: org.geotools/gt-main

/**
 * Gets geometry.
 *
 * @param geometry The geometry from the filter.
 *
 * @throws IllegalFilterException If there are problems creating
 *         expression.
 */
public void geometry(Geometry geometry) throws IllegalFilterException {
  // Sets the geometry for the expression, as appropriate
  LOGGER.finer("got geometry: " + geometry.toString());
  //if(curExprssn.getType()==ExpressionDefault.LITERAL_GEOMETRY){
  //LOGGER.finer("got geometry: ");
  curExprssn = ff.createLiteralExpression();
  ((LiteralExpression) curExprssn).setLiteral(geometry);
  LOGGER.finer("set expression: " + curExprssn.toString());
  currentState = "complete";
  LOGGER.finer("set current state: " + currentState);
  //        }
}

代码示例来源:origin: org.geotools/gt2-main

/**
 * Gets geometry.
 *
 * @param geometry The geometry from the filter.
 *
 * @throws IllegalFilterException If there are problems creating
 *         expression.
 */
public void geometry(Geometry geometry) throws IllegalFilterException {
  // Sets the geometry for the expression, as appropriate
  LOGGER.finer("got geometry: " + geometry.toString());
  //if(curExprssn.getType()==ExpressionDefault.LITERAL_GEOMETRY){
  //LOGGER.finer("got geometry: ");
  curExprssn = ff.createLiteralExpression();
  ((LiteralExpression) curExprssn).setLiteral(geometry);
  LOGGER.finer("set expression: " + curExprssn.toString());
  currentState = "complete";
  LOGGER.finer("set current state: " + currentState);
  //        }
}

代码示例来源:origin: org.geotools/gt-main

SimpleFeature reproject(SimpleFeature feature) throws IOException {
  List attributes = feature.getAttributes();
  for (int i = 0; i < attributes.size(); i++) {
    Object object = attributes.get(i);
    if (object instanceof Geometry) {
      // do the transformation
      Geometry geometry = (Geometry) object;
      try {
        attributes.set(i, tx.transform(geometry));
      } catch (TransformException e) {
        String msg = "Error occured transforming "
            + geometry.toString();
        throw (IOException) new IOException(msg).initCause(e);
      }
    }
  }
  try {
    return SimpleFeatureBuilder.build(schema, attributes, feature.getID());
  } catch (IllegalAttributeException e) {
    String msg = "Error creating reprojeced feature";
    throw (IOException) new IOException(msg).initCause(e);
  }
}

代码示例来源:origin: org.orbisgis/mapeditor

private ILayer createFenceLayer(Geometry g) {
    try(Connection connection = mc.getDataManager().getDataSource().getConnection();
      Statement st = connection.createStatement()) {
        boolean isH2 = JDBCUtilities.isH2DataBase(connection.getMetaData());
        String fenceLayer = getFenceLayerName(isH2);
        if(isH2) {
          st.execute("CREATE TABLE IF NOT EXISTS " + fenceLayer + " (THE_GEOM POLYGON)");
        } else {
          //PostGIS
          // TODO get SRID of the MapContext to build the fence
          st.execute("CREATE TABLE IF NOT EXISTS " + fenceLayer + " (THE_GEOM geometry(POLYGON,0))");
        }
        st.execute("DELETE FROM " + fenceLayer);
        st.execute("INSERT INTO " + fenceLayer + " VALUES (ST_PolyFromText('" + g.toString() + "', 0))");
        return mc.createLayer(fenceLayer);
    } catch (SQLException | LayerException e) {
        UILOGGER.error(i18n.tr("Cannot create fence layer"), e);
    }
    return null;
}

代码示例来源:origin: org.wikibrainapi/wikibrain-spatial

public static void printLatLonPrecisions(String args[]){
  try {
    // do basic setup
    Env env = EnvBuilder.envFromArgs(args);
    Configurator c = env.getConfigurator();
    SpatialDataDao sdDao = c.get(SpatialDataDao.class);
    String[] articleNames = new String[] {"Alaska","Minneapolis","California","Germany"};
    Language lang = Language.SIMPLE;
    String layerName = Layers.WIKIDATA;
    for (String articleName : articleNames){
      Geometry g = sdDao.getGeometry(articleName, lang, layerName, Precision.LatLonPrecision.HIGH);
      if (g != null){
        System.out.printf(":-) Found high-precision geometry for '%s' (%s) in layer '%s': %s\n", articleName, lang.toString(), layerName, g.toString());
      }else{
        System.out.printf(":-( Could not find high-precision geometry for '%s' (%s) in layer '%s'\n", articleName, lang.toString(), layerName);
      }
    }
  }catch(Exception e){
    e.printStackTrace();
  }
}

代码示例来源:origin: shilad/wikibrain

public static void printLatLonPrecisions(String args[]){
  try {
    // do basic setup
    Env env = EnvBuilder.envFromArgs(args);
    Configurator c = env.getConfigurator();
    SpatialDataDao sdDao = c.get(SpatialDataDao.class);
    String[] articleNames = new String[] {"Alaska","Minneapolis","California","Germany"};
    Language lang = Language.SIMPLE;
    String layerName = Layers.WIKIDATA;
    for (String articleName : articleNames){
      Geometry g = sdDao.getGeometry(articleName, lang, layerName, Precision.LatLonPrecision.HIGH);
      if (g != null){
        System.out.printf(":-) Found high-precision geometry for '%s' (%s) in layer '%s': %s\n", articleName, lang.toString(), layerName, g.toString());
      }else{
        System.out.printf(":-( Could not find high-precision geometry for '%s' (%s) in layer '%s'\n", articleName, lang.toString(), layerName);
      }
    }
  }catch(Exception e){
    e.printStackTrace();
  }
}

代码示例来源:origin: org.orbisgis/h2drivers

/**
 * Convert JTS geometry to a kml geometry representation.
 *
 * @param geometry
 * @param extrude
 * @param altitudeModeEnum
 * @param sb
 */
public static void toKMLGeometry(Geometry geometry, ExtrudeMode extrude, int altitudeModeEnum, StringBuilder sb) throws SQLException {
  if (geometry instanceof Point) {
    toKMLPoint((Point) geometry, extrude, altitudeModeEnum, sb);
  } else if (geometry instanceof LineString) {
    toKMLLineString((LineString) geometry, extrude, altitudeModeEnum, sb);
  } else if (geometry instanceof Polygon) {
    toKMLPolygon((Polygon) geometry, extrude, altitudeModeEnum, sb);
  } else if (geometry instanceof GeometryCollection) {
    toKMLMultiGeometry((GeometryCollection) geometry, extrude, altitudeModeEnum, sb);
  } else {
    throw new SQLException("This geometry type is not supported : " + geometry.toString());
  }
}

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

/**
 * Convert JTS geometry to a kml geometry representation.
 *
 * @param geometry
 * @param extrude
 * @param altitudeModeEnum
 * @param sb
 */
public static void toKMLGeometry(Geometry geometry, ExtrudeMode extrude, int altitudeModeEnum, StringBuilder sb) throws SQLException {
  if (geometry instanceof Point) {
    toKMLPoint((Point) geometry, extrude, altitudeModeEnum, sb);
  } else if (geometry instanceof LineString) {
    toKMLLineString((LineString) geometry, extrude, altitudeModeEnum, sb);
  } else if (geometry instanceof Polygon) {
    toKMLPolygon((Polygon) geometry, extrude, altitudeModeEnum, sb);
  } else if (geometry instanceof GeometryCollection) {
    toKMLMultiGeometry((GeometryCollection) geometry, extrude, altitudeModeEnum, sb);
  } else {
    throw new SQLException("This geometry type is not supported : " + geometry.toString());
  }
}

相关文章