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

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

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

Geometry.setSRID介绍

[英]Sets the ID of the Spatial Reference System used by the Geometry.

NOTE: This method should only be used for exceptional circumstances or for backwards compatibility. Normally the SRID should be set on the GeometryFactory used to create the geometry. SRIDs set using this method will not be propagated to geometries returned by constructive methods.
[中]设置Geometry使用的空间参照系统的ID。
注意:此方法仅适用于特殊情况或向后兼容性。通常,应在用于创建几何图形的GeometryFactory上设置SRID。使用此方法设置的SRID不会传播到构造方法返回的几何体。

代码示例

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

/**
 * Sets the SRID, if it was specified in the WKB
 *
 * @param g the geometry to update
 * @return the geometry with an updated SRID value, if required
 */
private Geometry setSRID(Geometry g, int SRID)
{
 if (SRID != 0)
  g.setSRID(SRID);
 return g;
}

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

/**
 * Sets the SRID, if it was specified in the WKB
 *
 * @param g the geometry to update
 * @return the geometry with an updated SRID value, if required
 */
private Geometry setSRID(Geometry g, int SRID)
{
 if (SRID != 0)
  g.setSRID(SRID);
 return g;
}

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

/**
 * Sets the SRID, if it was specified in the WKB
 *
 * @param g the geometry to update
 * @return the geometry with an updated SRID value, if required
 */
private Geometry setSRID(Geometry g)
{
 if (SRID != 0)
  g.setSRID(SRID);
 return g;
}

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

public void setSRID(int SRID) {
  geometry.setSRID(SRID);
}

代码示例来源:origin: org.geomajas.plugin/geomajas-layer-hibernate

private Geometry asGeometry(Object geometry) {
  if (geometry instanceof Geometry) {
    Geometry geom = (Geometry) geometry;
    geom.setSRID(srid);
    return geom;
  } else {
    throw new IllegalStateException("Cannot handle " + geometry + " as geometry.");
  }
}

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

/**
 * @param geometry Geometry instance
 * @return Geometry envelope
 */
public static Geometry getBoundary(Geometry geometry, int srid) {
  if(geometry==null) {
    return null;
  }
  Geometry geometryEnvelope = geometry.getBoundary();
  geometryEnvelope.setSRID(srid);
  return geometryEnvelope;
}

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

/**
 * @param geometry Geometry instance
 * @return Geometry envelope
 */
public static Geometry getBoundary(Geometry geometry, int srid) {
  if(geometry==null) {
    return null;
  }
  Geometry geometryEnvelope = geometry.getBoundary();
  geometryEnvelope.setSRID(srid);
  return geometryEnvelope;
}

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

/**
 * @param geometry Geometry instance
 * @return Geometry envelope
 */
public static Geometry getBoundary(Geometry geometry, int srid) {
  if(geometry==null) {
    return null;
  }
  Geometry geometryEnvelope = geometry.getBoundary();
  geometryEnvelope.setSRID(srid);
  return geometryEnvelope;
}

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

/**
 * @param geometry Geometry instance
 * @param srid input SRID
 * @return Geometry envelope
 */
public static Geometry getEnvelope(Geometry geometry, int srid) {
  if(geometry==null) {
    return null;
  }
  Geometry geometryEnvelope = geometry.getEnvelope();
  geometryEnvelope.setSRID(srid);
  return geometryEnvelope;
}

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

/**
 * @param geometry Geometry instance
 * @param srid input SRID
 * @return Geometry envelope
 */
public static Geometry getEnvelope(Geometry geometry, int srid) {
  if(geometry==null) {
    return null;
  }
  Geometry geometryEnvelope = geometry.getEnvelope();
  geometryEnvelope.setSRID(srid);
  return geometryEnvelope;
}

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

/**
 * @param geometry Geometry instance
 * @param srid input SRID
 * @return Geometry envelope
 */
public static Geometry getEnvelope(Geometry geometry, int srid) {
  if(geometry==null) {
    return null;
  }
  Geometry geometryEnvelope = geometry.getEnvelope();
  geometryEnvelope.setSRID(srid);
  return geometryEnvelope;
}

代码示例来源:origin: org.teiid/teiid-engine

public static GeometryType makeEnvelope(double xmin, double ymin,
    double xmax, double ymax, Integer srid) {
  Geometry geom = GEOMETRY_FACTORY.createPolygon(new Coordinate[] {new Coordinate(xmin, ymin), new Coordinate(xmin, ymax), new Coordinate(xmax, ymax), new Coordinate(xmax, ymin), new Coordinate(xmin, ymin)});
  if (srid != null) {
    geom.setSRID(srid);
  }
  return getGeometryType(geom);
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

public static GeometryType makeEnvelope(double xmin, double ymin,
    double xmax, double ymax, Integer srid) {
  Geometry geom = GEOMETRY_FACTORY.createPolygon(new Coordinate[] {new Coordinate(xmin, ymin), new Coordinate(xmin, ymax), new Coordinate(xmax, ymax), new Coordinate(xmax, ymin), new Coordinate(xmin, ymin)});
  if (srid != null) {
    geom.setSRID(srid);
  }
  return getGeometryType(geom);
}

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

public static GeometryType makeEnvelope(double xmin, double ymin,
    double xmax, double ymax, Integer srid) {
  Geometry geom = GEOMETRY_FACTORY.createPolygon(new Coordinate[] {new Coordinate(xmin, ymin), new Coordinate(xmin, ymax), new Coordinate(xmax, ymax), new Coordinate(xmax, ymin), new Coordinate(xmin, ymin)});
  if (srid != null) {
    geom.setSRID(srid);
  }
  return getGeometryType(geom);
}

代码示例来源:origin: matsim-org/matsim

/**
 * Allows to manually overwrite the coordinate reference system (e.g. if the
 * ZoneLayer is read from a shape file without crs information).
 * 
 * @param crs a coordinate reference system.
 */
public void overwriteCRS(CoordinateReferenceSystem crs) {
  this.crs = crs;
  this.srid = CRSUtils.getSRID(crs);
  for(Zone<?> zone : zones) {
    zone.getGeometry().setSRID(srid);
  }
}

代码示例来源:origin: org.teiid/teiid-engine

public static GeometryType getGeometryType(Geometry jtsGeom, int srid) {
  jtsGeom.setSRID(srid);
  byte[] bytes = getBytes(jtsGeom, true);
  GeometryType result = new GeometryType(bytes, srid);
  result.setGeoCache(jtsGeom);
  return result;
}

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

public static GeometryType getGeometryType(Geometry jtsGeom, int srid) {
  jtsGeom.setSRID(srid);
  byte[] bytes = getBytes(jtsGeom, true);
  GeometryType result = new GeometryType(bytes, srid);
  result.setGeoCache(jtsGeom);
  return result;
}

代码示例来源:origin: org.hibernatespatial/hibernate-spatial-postgis

private Geometry convertGeometryCollection(GeometryCollection collection) {
  org.postgis.Geometry[] geometries = collection.getGeometries();
  com.vividsolutions.jts.geom.Geometry[] jtsGeometries = new com.vividsolutions.jts.geom.Geometry[geometries.length];
  for (int i = 0; i < geometries.length; i++) {
    jtsGeometries[i] = convert2JTS(geometries[i]);
    //TODO  - refactor this so the following line is not necessary
    jtsGeometries[i].setSRID(0); // convert2JTS sets SRIDs, but constituent geometries in a collection must have srid  == 0 
  }
  com.vividsolutions.jts.geom.GeometryCollection jtsGCollection = getGeometryFactory()
      .createGeometryCollection(jtsGeometries);
  return jtsGCollection;
}

代码示例来源:origin: org.hibernatespatial/hibernate-spatial-postgis

private Geometry forceEmptyToGeometryCollection(Geometry jtsGeom) {
  Geometry forced = jtsGeom;
  if (forced.isEmpty()) {
    GeometryFactory factory = jtsGeom.getFactory();
    if (factory == null) {
      factory = HBSpatialExtension.getDefaultGeomFactory();
    }
    forced = factory.createGeometryCollection(null);
    forced.setSRID(jtsGeom.getSRID());
  }
  return forced;
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

public static GeometryType polygon(GeometryType geom, int srid) throws FunctionExecutionException {
  Geometry g = getGeometry(geom);
  if (!(g instanceof LineString)) {
    throw new FunctionExecutionException(QueryPlugin.Event.TEIID31207, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31207));
  }
  LineString ls = (LineString)g;
  Geometry result = GEOMETRY_FACTORY.createPolygon(ls.getCoordinateSequence());
  result.setSRID(srid);
  return getGeometryType(result);
}

相关文章