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

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

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

Geometry.getSRID介绍

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

JTS supports Spatial Reference System information in the simple way defined in the SFS. A Spatial Reference System ID (SRID) is present in each Geometry object. Geometry provides basic accessor operations for this field, but no others. The SRID is represented as an integer.
[中]返回Geometry使用的空间参照系统的ID。
JTS以SFS中定义的简单方式支持空间参考系统信息。每个Geometry对象中都有一个空间参考系统ID(SRID)。Geometry提供此字段的基本访问器操作,但不提供其他操作。SRID表示为一个整数。

代码示例

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

private void writeGeometryType(int geometryType, Geometry g, OutStream os)
  throws IOException
{
 int flag3D = (outputDimension == 3) ? 0x80000000 : 0;
 int typeInt = geometryType | flag3D;
 typeInt |= includeSRID ? 0x20000000 : 0;
 writeInt(typeInt, os);
 if (includeSRID) {
   writeInt(g.getSRID(), os);
 }
}

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

public int getSRID(int def) {
  int ret = value.getSRID();
  if (ret <= 0)
    ret = def;
  return ret;
}

代码示例来源:origin: org.gvnix/org.gvnix.jpa.geo

private String getSRID(Geometry geom) {
  int srid = geom.getSRID();
  if (srid != 0) {
    // Include SRID in wkt
    return "SRID=".concat(String.valueOf(srid)).concat(";");
  }
  return "";
}

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

private void initCRS(Geometry g) {
    // see if we have a native CRS in the mix
    if(crs == null && g.getUserData() instanceof CoordinateReferenceSystem) {
      crs = (CoordinateReferenceSystem) g.getUserData();
    }
    if(srid == -1 && g.getSRID() > 0) {
      srid = g.getSRID();
    }
  }
}

代码示例来源:origin: org.n52.shetland/shetland

public int getSRID() {
  if (this.envelope != null) {
    return envelope.getSrid();
  } else if (this.geometry != null) {
    return this.geometry.getSRID();
  } else {
    return -1;
  }
}

代码示例来源: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: org.jvnet.ogc/ogc-tools-gml-jts

public void convert(Geometry source, SRSReferenceGroup target) {
 Validate.notNull(source);
 Validate.notNull(target);
 if (source.getUserData() instanceof String) {
  target.setSrsName((String) source.getUserData());
 }
 else if (source.getSRID() != 0) {
  target.setSrsName(MessageFormat.format(this.sridPattern, source.getSRID()));
 }
}

代码示例来源: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.n52.shetland/shetland

public static GeometryFactory getGeometryFactory(Geometry geometry) {
  if (geometry.getFactory().getSRID() > 0 || geometry.getSRID() == 0) {
    return geometry.getFactory();
  } else {
    return getGeometryFactoryForSRID(geometry.getSRID());
  }
}

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

private void writeGeometryType(int geometryType, Geometry g, OutStream os)
  throws IOException
{
 int flag3D = (outputDimension == 3) ? 0x80000000 : 0;
 int typeInt = geometryType | flag3D;
 typeInt |= includeSRID ? 0x20000000 : 0;
 writeInt(typeInt, os);
 if (includeSRID) {
   writeInt(g.getSRID(), os);
 }
}

代码示例来源:origin: org.n52.sensorweb/timeseries-series-dao

private Geometry transformGeometry(FeatureEntity featureEntity, Geometry geometry) throws TransformException, FactoryException {
  try {
    String fromCrs = "EPSG:" + geometry.getSRID();
    return crsUtil.transformOuterToInner(geometry, fromCrs);
  }
  catch (FactoryException e) {
    LOGGER.info("Unable to create CRS factory for station/feature: {}" + featureEntity.getDomainId());
    return crsUtil.transformOuterToInner(geometry, CRSUtils.DEFAULT_CRS);
  }
}

代码示例来源:origin: BaseXdb/basex

@Override
 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
  return Uri.uri(token(checkGeo(0, qc).getSRID()));
 }
}

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

public static Geospatial convertToODataValue(InputStream wkb, boolean includesSrid) 
    throws FunctionExecutionException {
  Geometry g = GeometryUtils.getGeometry(wkb, null, includesSrid);
  JTS2OlingoBridge bridge = new JTS2OlingoBridge(Dimension.GEOMETRY, includesSrid?SRID.valueOf(String.valueOf(g.getSRID())):null);
  return bridge.convert(g);
}

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

public static GeographyType getGeographyType(Geometry geom) {
  byte[] bytes = getBytes(geom, true);
  GeographyType result = new GeographyType(bytes, geom.getSRID());
  result.setGeoCache(geom);
  return result;
}

代码示例来源:origin: org.n52.series.db/entities

public OfferingEntity setGeometry(Geometry geometry) {
  this.geometryEntity = new GeometryEntity();
  this.geometryEntity.setGeometry(geometry);
  this.geometryEntity.setSrid(geometry.getSRID());
  return this;
}

代码示例来源:origin: org.wowtools/h2

private static byte[] convertToWKB(Geometry g) {
  boolean includeSRID = g.getSRID() != 0;
  int dimensionCount = getDimensionCount(g);
  WKBWriter writer = new WKBWriter(dimensionCount, includeSRID);
  return writer.write(g);
}

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

public static GeographyType getGeographyType(Geometry geom) {
  byte[] bytes = getBytes(geom, true);
  GeographyType result = new GeographyType(bytes, geom.getSRID());
  result.setGeoCache(geom);
  return result;
}

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

public static Geospatial convertToODataValue(InputStream wkb, boolean includesSrid) 
    throws FunctionExecutionException {
  Geometry g = GeometryUtils.getGeometry(wkb, null, includesSrid);
  JTS2OlingoBridge bridge = new JTS2OlingoBridge(Dimension.GEOMETRY, includesSrid?SRID.valueOf(String.valueOf(g.getSRID())):null);
  return bridge.convert(g);
}

代码示例来源:origin: com.eventsourcing/h2

private static byte[] convertToWKB(Geometry g) {
  boolean includeSRID = g.getSRID() != 0;
  int dimensionCount = getDimensionCount(g);
  WKBWriter writer = new WKBWriter(dimensionCount, includeSRID);
  return writer.write(g);
}

代码示例来源: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;
}

相关文章