Java Code Examples for com.vividsolutions.jts.geom.Geometry#getSRID()

The following examples show how to use com.vividsolutions.jts.geom.Geometry#getSRID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoWaveIndexerSfTest.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * JTS library conversion from geometry to GML.
 * @param geo base Geometry gets delegated
 * @return String gml encoding of the geomoetry
 */
private static String geoToGmlUseJtsLib(final Geometry geo) {
    final int srid = geo.getSRID();
    final GMLWriter gmlWriter = new GMLWriter();
    gmlWriter.setNamespace(false);
    gmlWriter.setPrefix(null);

    if (srid != -1 || srid != 0) {
        gmlWriter.setSrsName("EPSG:" + geo.getSRID());
    }
    final String gml = gmlWriter.write(geo);
    // Hack to replace a gml 2.0 deprecated element in the Polygon.
    // It should tolerate this as it does other depreciated elements like <gml:coordinates>.
    return gml.replace("outerBoundaryIs", "exterior");
}
 
Example 2
Source File: GeoIndexerSfTest.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * JTS library conversion from geometry to GML.
 * @param geo base Geometry gets delegated
 * @return String gml encoding of the geomoetry
 */
private static String geoToGmlUseJtsLib(final Geometry geo) {
    final int srid = geo.getSRID();
    final GMLWriter gmlWriter = new GMLWriter();
    gmlWriter.setNamespace(false);
    gmlWriter.setPrefix(null);

    if (srid != -1 || srid != 0) {
        gmlWriter.setSrsName("EPSG:" + geo.getSRID());
    }
    final String gml = gmlWriter.write(geo);
    // Hack to replace a gml 2.0 deprecated element in the Polygon.
    // It should tolerate this as it does other depreciated elements like <gml:coordinates>.
    return gml.replace("outerBoundaryIs", "exterior");
}
 
Example 3
Source File: WKBTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
void runGeometry(Geometry g, int dimension, int byteOrder, boolean toHex, int srid)
    throws IOException, ParseException
{
  boolean includeSRID = false;
  if (srid >= 0) {
    includeSRID = true;
    g.setSRID(srid);
  }
  
  WKBWriter wkbWriter = new WKBWriter(dimension, byteOrder, includeSRID);
  byte[] wkb = wkbWriter.write(g);
  String wkbHex = null;
  if (toHex)
    wkbHex = WKBWriter.toHex(wkb);

  if (toHex)
    wkb = WKBReader.hexToBytes(wkbHex);
  Geometry g2 = wkbReader.read(wkb);

  CoordinateSequenceComparator comp = (dimension == 2) ? comp2 : comp3;
  boolean isEqual = (g.compareTo(g2, comp) == 0);
  assertTrue(isEqual);
  
  if (includeSRID) {
    boolean isSRIDEqual = g.getSRID() == g2.getSRID();
    assertTrue(isSRIDEqual);
  }
}
 
Example 4
Source File: HsqlGeometryUserType.java    From geomajas-project-server with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Converts a JTS <code>Geometry</code> to a native geometry object.
 * 
 * @param jtsGeom
 *            JTS Geometry to convert
 * @param connection
 *            the current database connection
 * @return native database geometry object corresponding to jtsGeom.
 */
public Object conv2DBGeometry(Geometry jtsGeom, Connection connection) {
	int srid = jtsGeom.getSRID();
	WKTWriter writer = new WKTWriter();
	String wkt = writer.write(jtsGeom);
	return srid + "|" + wkt;
}