本文整理汇总了Java中com.vividsolutions.jts.io.WKBWriter类的典型用法代码示例。如果您正苦于以下问题:Java WKBWriter类的具体用法?Java WKBWriter怎么用?Java WKBWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WKBWriter类属于com.vividsolutions.jts.io包,在下文中一共展示了WKBWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GPSDataSource
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public GPSDataSource(Connection con, Properties p) {
this.p = p;
wkbWriter = new WKBWriter(3, true);
try {
pst = con.prepareStatement("SELECT g." + p.getProperty("t_PpGpxIdCol") + ", g." + p.getProperty("t_PpGpxTrkIdCol") + ","
+ p.getProperty("t_PpGpxPartIdCol") + ", ST_ASGEOJSON(ST_INTERSECTION(g."
+ p.getProperty("t_PpGpxGeomCol") + ",ST_GeomFromEWKB(?))) as " + p.getProperty("t_PpGpxGeomCol")
+ ",ST_ASGEOJSON(ST_INTERSECTION(g." + p.getProperty("t_PpGpxGeomColSmoothed")
+ ",ST_GeomFromEWKB(?))) as " + p.getProperty("t_PpGpxGeomColSmoothed") + " FROM "
+ p.getProperty("t_mmName") + " sg LEFT JOIN " + p.getProperty("t_PpGpxName") + " g ON sg."
+ p.getProperty("t_mmGpxIdCol") + " = g." + p.getProperty("t_PpGpxIdCol") + " AND sg."
+ p.getProperty("t_mmTrkIdCol") + " = g." + p.getProperty("t_PpGpxTrkIdCol") + " WHERE sg."
+ p.getProperty("t_mmStreetIdCol") + "=? AND ST_INTERSECTS(g." + p.getProperty("t_PpGpxGeomCol")
+ ",ST_GeomFromEWKB(?));");
} catch (SQLException e) {
e.printStackTrace();
}
}
示例2: convertToObject
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public Object convertToObject(ValueMetaInterface vmi, Geometry geom, Database db) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try {
// Map the EPSG- (or custom-) SRID with MySQL's SRID.
int mysql_srid = convertToDBMS_SRID(vmi.getGeometrySRS(), db.getConnection());
// preserve SRID for MySQL in first 4 bytes, use little endian
byte[] sridInByteArray = new byte[4];
ByteOrderValues.putInt(mysql_srid, sridInByteArray, ByteOrderValues.LITTLE_ENDIAN);
outStream.write(sridInByteArray);
WKBWriter wkbWriter = new WKBWriter(2, ByteOrderValues.LITTLE_ENDIAN); // base 2, little endian
wkbWriter.write(geom, new OutputStreamOutStream(outStream)); // fill byte array with values from Geometry
return outStream.toByteArray();
} catch (Exception e) {
LOGGER.logError("GeoKettle", "Conversion to MySQL-geometry failed.");
return null;
}
}
示例3: convertToObject
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public Object convertToObject(ValueMetaInterface vmi, Geometry jtsGeom, Database db) {
WKBWriter wkbWriter = new WKBWriter();
byte[] b = wkbWriter.write(jtsGeom);
WKB wkb = new WKB(ByteOrder.BIG_ENDIAN);
try {
// Map the EPSG- (or custom-) SRID with Oracle's SRID.
// TODO: review this, probably has some of the same issues as when reading the SRID
int oracle_srid = convertToDBMS_SRID(vmi.getGeometrySRS(), db.getConnection());
STRUCT oracleStruct = wkb.toSTRUCT(b, db.getConnection()); // convert: byte[] --> STRUCT (using DB connection)
JGeometry oracleGeom = JGeometry.load(oracleStruct); // convert: STRUCT --> JGeometry
oracleGeom.setSRID(oracle_srid); // set the SRID
oracleStruct = JGeometry.store(db.getConnection(), oracleGeom); // convert: JGeometry --> STRUCT (using DB connection)
return oracleStruct;
} catch (Exception e) {
LOGGER.logError("GeoKettle", "Conversion to Oracle-geometry failed.");
return null;
}
}
示例4: toBinary
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
@Override
public byte[] toBinary() {
final byte[] crsBinary = isDefaultCrs(crsCode) ? new byte[0] : StringUtils.stringToBinary(crsCode);
final byte[] superBinary = super.toBinary();
final byte[] geometryBinary = new WKBWriter().write(queryGeometry);
final ByteBuffer buf = ByteBuffer.allocate(superBinary.length + geometryBinary.length + 16);
buf.putInt(compareOp.ordinal());
buf.putInt(nonSpatialCompareOp.ordinal());
buf.putInt(crsBinary.length);
buf.putInt(superBinary.length);
buf.put(crsBinary);
buf.put(superBinary);
buf.put(geometryBinary);
return buf.array();
}
示例5: geometryToWKB
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
private byte[] geometryToWKB(Geometry geom, Envelope bbox) throws IOException
{
if (geom == null)
geom = JTS.toGeometry(bbox);
WKBWriter wkbWriter = new WKBWriter();
ByteArrayOutputStream bytesStream = new ByteArrayOutputStream();
wkbWriter.write(geom, new OutputStreamOutStream(bytesStream));
byte[] geomBytes = bytesStream.toByteArray();
bytesStream.close();
return geomBytes;
}
示例6: geometryToWKB
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
private byte[] geometryToWKB(Geometry geom) throws IOException
{
WKBWriter wkbWriter = new WKBWriter();
ByteArrayOutputStream bytesStream = new ByteArrayOutputStream();
wkbWriter.write(geom, new OutputStreamOutStream(bytesStream));
byte[] geomBytes = bytesStream.toByteArray();
bytesStream.close();
return geomBytes;
}
示例7: init
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
/**
* This method initializes the MapMatcher. It checks whether all given
* database tables and their columns exist,
*/
public void init() {
// 1. check if table, rows and so on of input data exists.
checkInputdata();
// 2. init WKBReader and WKBWriter
wkbReader = new WKBReader();
wkbWriter = new WKBWriter(2, true);
}
示例8: testEwkb
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
@Test(expected=ExpressionEvaluationException.class) public void testEwkb() throws Exception {
WKBWriter writer = new WKBWriter(3, true);
GeometryFactory gf = new GeometryFactory();
Point point = gf.createPoint(new Coordinate(0, 0, 0));
point.setSRID(100);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.write(point, new OutputStreamOutStream(baos));
Expression ex1 = TestFunctionResolving.getExpression("ST_GeomFromBinary(X'"+new BinaryType(baos.toByteArray())+"', 8307)");
Evaluator.evaluate(ex1);
}
示例9: init
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public void init() {
Statement create = null;
try {
// for creation of databases
String tableName = p.getProperty("t_gpxName") + "_" + p.getProperty("dbPreProOutputSuffix");
create = con.createStatement();
create.addBatch("DROP TABLE IF EXISTS " + tableName + ";");
create.addBatch("CREATE TABLE "
+ tableName
+ " (\"gpx_id\" integer NOT NULL,\"trk_id\" integer NOT NULL, \"part_id\" integer NOT NULL, \"geom\" geometry NOT NULL, \"geom_smoothed\" geometry , CONSTRAINT \""
+ tableName + "_PK\" PRIMARY KEY (gpx_id, trk_id,part_id));");
create.addBatch("CREATE INDEX "+tableName+"_geomsmoothed_index ON "+tableName+" USING gist (geom_smoothed);");
create.addBatch("CREATE INDEX "+tableName+"_geom_index ON "+tableName+" USING gist (geom);");
create.executeBatch();
insert = con.prepareStatement("INSERT INTO " + tableName
+ " (\"gpx_id\",\"trk_id\", \"part_id\", \"geom\", \"geom_smoothed\") VALUES(?,?,?,ST_GeomFromEWKB(?),ST_GeomFromEWKB(?));");
} catch (SQLException e) {
e.printStackTrace();
SQLException e2 = e.getNextException();
e2.printStackTrace();
System.exit(1);
}
wkbWriter = new WKBWriter(3, true);
}
示例10: convertGeometryToBinary
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
private byte[] convertGeometryToBinary(Geometry geom)
{
if (geom==null) return null;
// defaults to big endian, 2-dimension representation:
WKBWriter wkbWriter = new WKBWriter();
return wkbWriter.write(geom);
}
示例11: serialize
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
@Override
public void serialize(ShapeBlobCell cell, DataCellDataOutput output) throws IOException {
byte[] bytes = new WKBWriter().write(cell.getShape());
output.writeInt(bytes.length);
output.write(bytes);
}
示例12: toBinary
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
@Override
public byte[] toBinary() {
byte[] bytes = null;
if (footprint == null) {
bytes = new byte[] {};
}
else {
bytes = new WKBWriter().write(footprint);
}
final ByteBuffer buf = super.binaryBuffer(bytes.length);
buf.put(bytes);
return buf.array();
}
示例13: geometryToBinary
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
/**
* Converts a JTS geometry to binary using JTS a Well Known Binary writer
*
* @param geometry
* The JTS geometry
* @return The binary representation of the geometry
*/
public static byte[] geometryToBinary(
final Geometry geometry ) {
int dimensions = DEFAULT_DIMENSIONALITY;
if (!geometry.isEmpty()) {
dimensions = Double.isNaN(geometry.getCoordinate().getOrdinate(
Coordinate.Z)) ? 2 : 3;
}
return new WKBWriter(
dimensions).write(geometry);
}
示例14: getWayMiddle
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public String getWayMiddle() {
double lenMiddle, distance, lineDistance;
GeometryFactory fac = new GeometryFactory();
OSMNode n1 = null, n2 = null;
lenMiddle = wayLength(nodes) / 2;
distance = 0d;
for (int i = 0; i < nodes.size() - 1; i++) {
n1 = nodes.get(i);
n2 = nodes.get(i + 1);
lineDistance = lineDistance(n1, n2);
if ((distance + lineDistance) > lenMiddle) {
distance = (lenMiddle - distance) / lineDistance;
break;
}
distance += lineDistance;
}
double lat = Double.parseDouble(n2.lat);
double lon = Double.parseDouble(n2.lon);
if (distance > 0.0d) {
distance = (1 / distance);
// Baseado na prova do ponto médio
lat = (Double.parseDouble(n2.lat) + (distance - 1) * Double.parseDouble(n1.lat)) / distance;
lon = (Double.parseDouble(n2.lon) + (distance - 1) * Double.parseDouble(n1.lon)) / distance;
}
return WKBWriter.bytesToHex(
new WKBWriter().write(fac.createPoint(new Coordinate(lon, lat))));
}
示例15: getShape
import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public String getShape() throws Exception {
MultiLineString mls;
// Precisa ser um MultiLineString
mls = new GeometryFactory().createMultiLineString(
new LineString[] { getLineString() });
return WKBWriter.bytesToHex(new WKBWriter().write(mls));
}