本文整理了Java中org.locationtech.jts.geom.Geometry.getSRID()
方法的一些代码示例,展示了Geometry.getSRID()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getSRID()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称: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: hibernate/hibernate-orm
/**
* Two geometries are equal iff both have the same SRID, or both are unknown (i.e. a SRID of 0 or -1).
*
* @param geom1
* @param geom2
*
* @return
*/
private boolean equalSRID(Geometry geom1, Geometry geom2) {
return geom1.getSRID() == geom2.getSRID() ||
( geom1.getSRID() < 1 && geom2.getSRID() < 1 );
}
代码示例来源:origin: com.h2database/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: geotools/geotools
public int getSRID() {
return geometry.getSRID();
}
代码示例来源:origin: geotools/geotools
/**
* Returns geometry SRID.
*
* <p>SRID code representing Spatial Reference System. SRID number used must be defined in the
* Oracle MDSYS.CS_SRS table.
*
* <p><code>SRID_NULL</code>represents lack of coordinate system.
*
* @param geom Geometry SRID Number (JTS14 uses GeometryFactor.getSRID() )
* @return <code>SRID</code> for provided geom
*/
public static int SRID(Geometry geom) {
return geom.getSRID();
}
代码示例来源:origin: geotools/geotools
/**
* Used to convert double[] to SDO_ODINATE_ARRAY.
*
* <p>Will return <code>null</code> as an empty <code>SDO_GEOMETRY</code>
*
* @param geom Map to be represented as a STRUCT
* @return STRUCT representing provided Map
* @see net.refractions.jspatial.Converter#toDataType(java.lang.Object)
*/
public STRUCT toSDO(Geometry geom) throws SQLException {
return toSDO(geom, geom.getSRID());
}
代码示例来源:origin: geotools/geotools
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: geotools/geotools
/**
* Returns the spatial reference identifier for the geometry.
*
* <p>This method will return -1 if <tt>wkb</tt> is <code>null</code>.
*
* @param wkb The geometry.
* @return The srid.
*/
public static int GetSRID(byte[] wkb) {
if (wkb == null) {
return -1;
}
return fromWKB(wkb).getSRID();
}
代码示例来源:origin: geotools/geotools
@Override
public Object visit(Literal expression, Object extraData) {
Object value = expression.getValue();
if (value instanceof Geometry) {
Geometry g = (Geometry) value;
if (g.getUserData() instanceof CoordinateReferenceSystem) {
return g.getUserData();
} else if (g.getSRID() > 0) {
try {
return CRS.decode("EPSG:" + g.getSRID());
} catch (Exception e) {
return null;
}
}
}
return null;
}
代码示例来源:origin: geotools/geotools
private static byte[] toWKB(Geometry g) {
try {
WKBWriter w = new WKBWriter();
// write the geometry
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
w.write(g, new OutputStreamOutStream(bytes));
// supplement it with the srid
int srid = g.getSRID();
bytes.write((byte) (srid >>> 24));
bytes.write((byte) (srid >> 16 & 0xff));
bytes.write((byte) (srid >> 8 & 0xff));
bytes.write((byte) (srid & 0xff));
return bytes.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
//
代码示例来源:origin: geotools/geotools
if (userData != null && userData instanceof String) {
srsName = (String) userData;
} else if (geom.getSRID() > 0) {
srsName = "EPSG:" + geom.getSRID();
代码示例来源:origin: geotools/geotools
/**
* Looks up the geometry srs by trying a number of heuristics. Returns -1 if all attempts at
* guessing the srid failed.
*/
protected int getGeometrySRID(Geometry g, AttributeDescriptor descriptor) throws IOException {
int srid = getDescriptorSRID(descriptor);
if (g == null) {
return srid;
}
// check for srid in the jts geometry then
if (srid <= 0 && g.getSRID() > 0) {
srid = g.getSRID();
}
// check if the geometry has anything
if (srid <= 0 && g.getUserData() instanceof CoordinateReferenceSystem) {
// check for crs object
CoordinateReferenceSystem crs = (CoordinateReferenceSystem) g.getUserData();
try {
Integer candidate = CRS.lookupEpsgCode(crs, false);
if (candidate != null) srid = candidate;
} catch (Exception e) {
// ok, we tried...
}
}
return srid;
}
代码示例来源:origin: geotools/geotools
private CoordinateReferenceSystem evaluateCRS(SimpleFeature originalFeature) {
SimpleFeatureType originalSchema = originalFeature.getFeatureType();
CoordinateReferenceSystem computedCRS = evaluateCRS(originalSchema);
if (computedCRS == null) {
// all right, let's try the sample feature then
Geometry g = expression.evaluate(originalFeature, Geometry.class);
if (g != null && g.getUserData() instanceof CoordinateReferenceSystem) {
computedCRS = (CoordinateReferenceSystem) g.getUserData();
} else {
try {
computedCRS = CRS.decode("EPSG:" + g.getSRID());
} catch (Exception e) {
return null;
}
}
}
return computedCRS;
}
代码示例来源:origin: geotools/geotools
if (crs == null && geometry.getSRID() > 0) {
try {
crs = CRS.decode("EPSG:" + geometry.getSRID());
} catch (Exception e) {
代码示例来源:origin: org.n52.arctic-sea/shetland
@Override
public void setGeometry(final Geometry geometry) throws InvalidSridException {
if (geometry != null && geometry.getSRID() == 0) {
throw new InvalidSridException(0);
}
this.geometry = geometry;
}
代码示例来源:origin: org.n52.arctic-sea/shetland
public int getSRID() {
if (this.envelope != null) {
return envelope.getSrid();
} else if (this.geometry != null) {
return this.geometry.getSRID();
} else {
return -1;
}
}
代码示例来源:origin: geotools/geotools
h.setVersion((byte) 0);
h.setFlags(flags);
h.setSrid(g.getSRID());
if (config.isWriteEnvelope()) {
h.setEnvelope(g.getEnvelopeInternal());
ByteOrderValues.putInt(g.getSRID(), buf, order);
out.write(buf, 4);
代码示例来源:origin: locationtech/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.n52.arctic-sea/shetland
public static GeometryFactory getGeometryFactory(Geometry geometry) {
if (geometry.getFactory().getSRID() > 0 || geometry.getSRID() == 0) {
return geometry.getFactory();
} else {
return getGeometryFactoryForSRID(geometry.getSRID());
}
}
代码示例来源:origin: org.geoserver.geofence/geofence-model-internal
@Override
public MultiPolygon unmarshal(String val) throws ParseException {
WKTReader wktReader = new WKTReader();
Geometry the_geom = wktReader.read(val);
if (the_geom.getSRID() == 0)
the_geom.setSRID(4326);
try {
return (MultiPolygon) the_geom;
} catch (ClassCastException e) {
throw new ParseException("WKT val is a " + the_geom.getClass().getName());
}
}
代码示例来源:origin: locationtech/jts
private void checkCopy(final Geometry g) {
int SRID = 123;
g.setSRID(SRID );
Object DATA = new Integer(999);
g.setUserData(DATA);
Geometry copy = g.copy();
assertEquals(g.getSRID(), copy.getSRID());
assertEquals(g.getUserData(), copy.getUserData());
//TODO: use a test which checks all ordinates of CoordinateSequences
assertTrue( g.equalsExact(copy) );
}
}
内容来源于网络,如有侵权,请联系作者删除!