• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WKBWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.vividsolutions.jts.io.WKBWriter的典型用法代码示例。如果您正苦于以下问题:Java WKBWriter类的具体用法?Java WKBWriter怎么用?Java WKBWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WKBWriter类属于com.vividsolutions.jts.io包,在下文中一共展示了WKBWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
	}

}
 
开发者ID:GIScience,项目名称:osmgpxinclinecalculator,代码行数:20,代码来源:GPSDataSource.java


示例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;
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:20,代码来源:MySQLDatabaseMeta.java


示例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;
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:20,代码来源:OracleDatabaseMeta.java


示例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();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:17,代码来源:SpatialQuery.java


示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:14,代码来源:PostgreSQLLocationsDataProvider.java


示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:11,代码来源:PostgresSQLStatisticsProvider.java


示例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);

}
 
开发者ID:GIScience,项目名称:osmgpxmapmatcher,代码行数:14,代码来源:MapMatcher.java


示例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);
  }
 
开发者ID:kenweezy,项目名称:teiid,代码行数:12,代码来源:TestGeometry.java


示例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);
	}
 
开发者ID:GIScience,项目名称:osmgpxpreprocessor,代码行数:35,代码来源:PGSqlWriter.java


示例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);
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:8,代码来源:ValueMeta.java


示例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);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:8,代码来源:ShapeBlobSerializer.java


示例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();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:14,代码来源:RasterFootprintStatistics.java


示例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);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:21,代码来源:GeometryUtils.java


示例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))));
}
 
开发者ID:chemickypes,项目名称:searchgpspath,代码行数:39,代码来源:Way.java


示例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));
}
 
开发者ID:chemickypes,项目名称:searchgpspath,代码行数:10,代码来源:Way.java


示例16: write

import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
/**
 * @see org.geotools.data.jdbc.attributeio.AttributeIO#write(java.sql.PreparedStatement, int, java.lang.Object)
 * @TODO fix for wkt
 */
public void write(PreparedStatement ps, int position, Object value) throws IOException {
    try {
        if(value == null) {
            ps.setNull(position, Types.OTHER);
        } else {
            ps.setBytes( position, new WKBWriter().write( (Geometry)value ));
        }
    } catch (SQLException e) {
        throw new DataSourceException("SQL exception occurred while reading the geometry.", e);
    }

}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:17,代码来源:WKTAttributeIO.java


示例17: convertToWKB

import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
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);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:7,代码来源:ValueGeometry.java


示例18: publish

import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public void publish(DmlEvent event) {

		String metadata = extractMetadata(event);
		String changedTableSchema = event.getSchemaName();
		String changedTableName = event.getTableName();
		String type = event.getType().toString();
		Long transactionId = event.getTransactionId();
		PGobject timestamp = getTimestamp(event);
		PGobject oldjson = getJsonOldValues(event);
		PGobject newjson = getJsonNewValues(event);
		
		Object[] params;
		String sql;
		int[] types;
		
		Envelope envelope = event.getEnvelope();
		if (! envelope.isNull()) {
			
			//expand if necessasry
			if (envelope.getHeight() < minSize  && envelope.getWidth() < minSize) {
				envelope.expandBy(bufferSize);
			}
			
			//Transform Bounding Box of the change into WKB
			
			GeometryFactory geomFactory = new GeometryFactory(new PrecisionModel(), epsgCode);
			WKBWriter wkbWriter = new WKBWriter(2, true);
			byte[] wkb = wkbWriter.write(geomFactory.toGeometry(envelope));
			params = new Object[]{wkb, type, changedTableSchema, changedTableName, transactionId, timestamp, metadata, oldjson, newjson};
			types = new int[] {Types.BINARY, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.OTHER};
			sql = "INSERT INTO "+schemaname + "." + tableName + "("+regionColumnName
				+", "+transactionTypeColumnName + ", "+schemaColumnName+", "+tableColumnName+", "+txIdColumnName
				+", "+commitTimestampColumnName+", "+metadataColumnName+", "+jsonOldValuesColumnName+", "+jsonNewValuesColumName
				+") VALUES (?,?,?,?,?,?,?,?,?)";
		}
		else {
			//geometry is null, do not include it in SQL insert statement
			params = new Object[]{type, changedTableSchema, changedTableName, transactionId, timestamp, metadata, oldjson, newjson};
			types = new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.OTHER};
			sql = "INSERT INTO "+schemaname + "." + tableName + "("
					+transactionTypeColumnName + ", "+schemaColumnName+", "+tableColumnName+", "+txIdColumnName
					+", "+commitTimestampColumnName+", "+metadataColumnName+", "+jsonOldValuesColumnName+", "+jsonNewValuesColumName
					+") VALUES (?,?,?,?,?,?,?,?)";
		}
		template.update(sql, params,types);
	}
 
开发者ID:sebastian-r-schmidt,项目名称:logicaldecoding,代码行数:47,代码来源:TrackTablePublisher.java


示例19: asBinary

import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public byte[] asBinary(T shape) {
  WKBWriter writer = new WKBWriter();
  Geometry geom = SPATIAL_CONTEXT.getGeometryFrom(shape);
  return writer.write(geom);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:6,代码来源:OShapeBuilder.java


示例20: getGeometryType

import com.vividsolutions.jts.io.WKBWriter; //导入依赖的package包/类
public static GeometryType getGeometryType(Geometry jtsGeom, int srid) {
    WKBWriter writer = new WKBWriter();
    byte[] bytes = writer.write(jtsGeom);
    return new GeometryType(bytes, srid);        
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:6,代码来源:GeometryUtils.java



注:本文中的com.vividsolutions.jts.io.WKBWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SVGBuilder类代码示例发布时间:2022-05-21
下一篇:
Java Field类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap