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

Java WKBReader类代码示例

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

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



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

示例1: loadSplicedGeometries

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<Geometry> loadSplicedGeometries(final Collection<Long> zoneIds) {
    if (zoneIds.isEmpty()) {
        return emptyList();
    }

    final GeometryFactory geometryFactory = GISUtils.getGeometryFactory(GISUtils.SRID.ETRS_TM35FIN);
    final WKBReader wkbReader = new WKBReader(geometryFactory);
    final MapSqlParameterSource params = new MapSqlParameterSource()
            .addValue("chunkSize", 2048)
            .addValue("zoneIds", zoneIds);

    return namedParameterJdbcTemplate.query(
            "SELECT ST_AsBinary(ST_SubDivide(geom, :chunkSize)) AS geom FROM zone WHERE zone_id IN (:zoneIds)",
            params, (resultSet, i) -> {
                final byte[] wkb = resultSet.getBytes("geom");

                try {
                    return wkbReader.read(wkb);
                } catch (ParseException e) {
                    throw new RuntimeException(e);
                }
            });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:26,代码来源:GISZoneRepositoryImpl.java


示例2: convertToJTSGeometry

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public Geometry convertToJTSGeometry(ValueMetaInterface vmi, Object obj, Database db) {
	if (obj instanceof oracle.sql.STRUCT) {
		try {
			// Map Oracle's SRID with the EPSG-SRID or take a custom SRS from WKT
			int oracle_srid = JGeometry.load((STRUCT)obj).getSRID();
			// see bug 2845785; disabled reading of SRS metadata as temporary workaround,
			// meanwhile one must assign SRS manually using Set SRS step
			// TODO: review everything!
			// SRS epsg_srid = convertToEPSG_SRID(oracle_srid, db.getConnection());
			SRS epsg_srid = SRS.UNKNOWN;
			vmi.setGeometrySRS(epsg_srid);
			
			WKB wkb = new WKB(ByteOrder.BIG_ENDIAN);		// Create empty WKB representation
			byte[] b = wkb.fromSTRUCT( (STRUCT) obj );		// convert: Object -> STRUCT -> byte[]
			Geometry jtsGeom = (new WKBReader()).read(b);	// convert: byte[] -> JTS-Geometry
			jtsGeom.setSRID(epsg_srid.getSRID());			// set the SRID of the JTS-Geometry
			return jtsGeom;
		} catch (Exception e) {
			LOGGER.logError("GeoKettle", "Conversion from Oracle-geometry failed.");
			return null;
		}
	} else {
		LOGGER.logDetailed("GeoKettle", "No Oracle-geometry found to convert.");
		return null;
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:27,代码来源:OracleDatabaseMeta.java


示例3: fromBinary

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
@Override
public void fromBinary(
		final byte[] bytes ) {
	final ByteBuffer buf = super.binaryBuffer(bytes);
	final byte[] payload = buf.array();
	if (payload.length > 0) {
		try {
			footprint = new WKBReader().read(payload);
		}
		catch (final ParseException e) {
			LOGGER.warn(
					"Unable to parse WKB",
					e);
		}
	}
	else {
		footprint = null;
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:RasterFootprintStatistics.java


示例4: fromBinary

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
@Override
public void fromBinary(
		final byte[] bytes ) {
	final ByteBuffer buf = ByteBuffer.wrap(bytes);
	compareOp = CompareOperation.values()[buf.getInt()];
	nonSpatialCompareOp = BasicQueryCompareOperation.values()[buf.getInt()];

	final byte[] crsBinary = new byte[buf.getInt()];
	final byte[] superBinary = new byte[buf.getInt()];
	buf.get(crsBinary);
	crsCode = crsBinary.length > 0 ? StringUtils.stringFromBinary(crsBinary) : null;
	buf.get(superBinary);
	super.fromBinary(superBinary);
	final byte[] geometryBinary = new byte[bytes.length - superBinary.length - crsBinary.length - 16];
	buf.get(geometryBinary);
	try {
		queryGeometry = new WKBReader().read(geometryBinary);
	}
	catch (final ParseException e) {
		LOGGER.warn(
				"Unable to read query geometry as well-known binary",
				e);
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:25,代码来源:SpatialQuery.java


示例5: getGeometryNoCopy

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public Geometry getGeometryNoCopy() {
    if (geometry == null) {
        try {
            geometry = new WKBReader().read(bytes);
        } catch (ParseException ex) {
            throw DbException.convert(ex);
        }
    }
    return geometry;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:11,代码来源:ValueGeometry.java


示例6: readGeometries

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
private static List<Geometry> readGeometries(final String fileName) {
    try (final Reader reader = new FileReader(new File(fileName))) {
        final GeometryFactory geometryFactory = GISUtils.getGeometryFactory(GISUtils.SRID.ETRS_TM35FIN);
        final WKBReader wkbReader = new WKBReader(geometryFactory);
        final WKBHexFileReader wkbHexFileReader = new WKBHexFileReader(reader, wkbReader);
        return wkbHexFileReader.read();

    } catch (ParseException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:12,代码来源:UnionCli.java


示例7: doEvaluate

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
@Override
protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
    byte[] data = new byte[0];

    if (inputs.get(0).hasAnyValue()) {
        Object o = inputs.get(0).getObject();
        if (o instanceof BlobRef) {
            BlobRef blob;
            blob = (BlobRef) o;
            String mode = context.getQueryContext().getStore().getConfig().getProperty(AkBlob.RETURN_UNWRAPPED);
            if (mode.equalsIgnoreCase(AkBlob.UNWRAPPED)){
                data = blob.getBytes();
            }
            else {
                if (blob.isShortLob()) {
                    data = blob.getBytes();
                } else {
                    LobService ls = context.getQueryContext().getServiceManager().getServiceByClass(LobService.class);
                    data = ls.readBlob(context.getQueryContext().getSession(), blob.getId());
                }
            }
        } else if (o instanceof byte[]) {
            data = (byte[])o;
        }
    }
    
    WKBReader reader = (WKBReader)context.preptimeObjectAt(READER_CONTEXT_POS);
    try {
        Geometry geometry = reader.read(data);
        output.putObject(geometry);
    } catch(ParseException e) {
        throw new InvalidSpatialObjectException(e.getMessage());
    }
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:35,代码来源:GeoWKB.java


示例8: init

import com.vividsolutions.jts.io.WKBReader; //导入依赖的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


示例9: StreetDataSource

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public StreetDataSource(Connection con, Properties p) {
	this.con = con;
	this.p = p;
	wkbReader = new WKBReader();
	retrieveData();

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


示例10: Binary2Geometry

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public static Geometry Binary2Geometry(final byte[] geometryAsBytes) throws ParseException {
	final byte[] wkb = new byte[geometryAsBytes.length - 4];
	System.arraycopy(geometryAsBytes, 4, wkb, 0, wkb.length);
	final WKBReader wkbReader = new WKBReader();
	final Geometry geom = wkbReader.read(wkb);
	return geom;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:8,代码来源:SqlUtils.java


示例11: convertToJTSGeometry

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public Geometry convertToJTSGeometry(ValueMetaInterface vmi, Object o, Database db) {
	if (o instanceof byte[]) {
		try {
			// treat the values read from MySQL as byte stream
			InputStream inStream = new ByteArrayInputStream( (byte[]) o );
			if (inStream == null) {
				throw new IOException("Could not read from byte array!");
			}
			
			// read first 4 bytes that represent the SRID
			byte[] sridFromByteArray = new byte[4];
			inStream.read(sridFromByteArray);
			
			// Map MySQL's SRID with the EPSG-SRID or take a custom SRS from WKT
			int mysql_srid = ByteOrderValues.getInt(sridFromByteArray, ByteOrderValues.LITTLE_ENDIAN);
			SRS epsg_srid = convertToEPSG_SRID(mysql_srid, db.getConnection());
			vmi.setGeometrySRS(epsg_srid);
			
			// parse the rest of the byte array as WKB and convert to Geometry
			Geometry geom = new WKBReader().read( new InputStreamInStream(inStream) );
			geom.setSRID(epsg_srid.getSRID());
			return geom;
		} catch (Exception e) {
			LOGGER.logError("GeoKettle", "Conversion from MySQL-geometry failed.");
			return null;
		}
	} else {
		LOGGER.logDetailed("GeoKettle", "No MySQL-geometry found to convert");
		return null;
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:32,代码来源:MySQLDatabaseMeta.java


示例12: convertBinaryToGeometry

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
private Geometry convertBinaryToGeometry(byte[] binary) {
  	Geometry geom = null;
try {
	geom = new WKBReader().read(binary);
} catch (com.vividsolutions.jts.io.ParseException e) {
	// TODO: log error
	// e.printStackTrace();
}
  	return geom;
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:11,代码来源:ValueMeta.java


示例13: fromWkb

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public static Geometry fromWkb(ValueMetaInterface metaA, Object dataA) throws KettleValueException{
  	Geometry geom = null;
  	WKBReader wkbReader = new WKBReader();
      if (dataA==null || !metaA.isString()) 
      	return null;
      try {
	geom = wkbReader.read(WKBReader.hexToBytes(metaA.getString(dataA)));
	return geom;
} catch (ParseException e) {
	return null;
}
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:13,代码来源:ValueDataUtil.java


示例14: deserialize

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
@Override
public ShapeBlobCell deserialize(DataCellDataInput input) throws IOException {
	byte[] bytes = new byte[input.readInt()];

	input.readFully(bytes);

	try {
		return new ShapeBlobCell(new WKBReader().read(bytes));
	} catch (ParseException e) {
		throw new IOException(e.getMessage());
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:13,代码来源:ShapeBlobSerializer.java


示例15: writeGeom

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
static void writeGeom(long geomId,byte[]bjsonBytes, byte[] geomBytes, DataOutputStream dos) throws IOException {
	// check geometry is valid
	try {
		if(new WKBReader().read(geomBytes)==null){
			throw new RuntimeException();
		}			
	} catch (Exception e) {
		throw new RuntimeException("Trying to save corrupt geometry: geomId=" + geomId);
	}

	
	dos.writeLong(geomId);
	writeByteArray(bjsonBytes, dos);
	writeByteArray(geomBytes, dos);
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:16,代码来源:ROGWriterUtils.java


示例16: geometryFromBinary

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
/**
 * Converts a byte array as well-known binary to a JTS geometry
 *
 * @param binary
 *            The well known binary
 * @return The JTS geometry
 */
public static Geometry geometryFromBinary(
		final byte[] binary ) {
	try {
		return new WKBReader().read(binary);
	}
	catch (final ParseException e) {
		LOGGER.warn(
				"Unable to deserialize geometry data",
				e);
	}
	return null;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:GeometryUtils.java


示例17: convertWKBHex

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public Object convertWKBHex(Object obj) throws IOException, SQLException,
			ParseException {
		if (obj == null) return null;
		String hex = obj.toString();
		Geometry geom = wkbReader.read(WKBReader.hexToBytes(hex));
//		Geometry geom = wkbReader.read(new HexStringInStream(hex));
		return geom;
	}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:9,代码来源:PostgisRowMapper.java


示例18: onGeometryLoadingFinished

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
protected void onGeometryLoadingFinished(Cursor cursor) {
    try {
        if (cursor == null || cursor.getCount() == 0)
            return;

        Log.v(TAG, "Geometries loaded: " + cursor.getCount());

        final int colId = cursor.getColumnIndexOrThrow(mIdColumn);
        final int colGeom = cursor.getColumnIndexOrThrow(mGeomColumn);
        final int colName = cursor.getColumnIndex(mNameColumn);
        final WKBReader geomReader = new WKBReader();

        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            final long id = cursor.getLong(colId);
            final String name = (colName != -1) ? cursor.getString(colName) : null;
            final String key = createGeomKey(mLoaderId, id);
            if (mGeomKeys.contains(key))
                continue;

            Geometry geom;
            //Geometry geom = mGeomCache.getGeometry(key);
            //if (geom == null)
            //{
            try {
                final byte[] geomBlob = cursor.getBlob(colGeom);
                if (geomBlob == null) {
                    Log.e(TAG, "Malformed or null geometry with id=" + id + ", name=" + name + " in table " + mTable);
                    continue;
                }
                geom = geomReader.read(geomBlob);
                //mGeomCache.putGeometry(key, geom);
                addGeometry(geom, name);
            } catch (Exception ex) {
                Log.e(TAG, "Failed to parse geometry blob with id=" + id + ", name=" + name + " in table " + mTable);
                ex.printStackTrace();
            } finally {
                // Add the key even if geometry is broken just to prevent perpetual attempts to load it
                mGeomKeys.add(key);

                cursor.moveToNext();
            }
            //}
        }
    } catch (SQLiteException sqlEx) {
        Log.e(TAG, sqlEx.getMessage());
    } finally {
        Utils.closeSilently(cursor);
        final GeomLoader loader = getLoader();
        loader.gotoPhase(0, null);
    }
}
 
开发者ID:sevar83,项目名称:SpatiAtlas,代码行数:53,代码来源:MapFragment.java


示例19: finishPreptimePhase

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
@Override
public void finishPreptimePhase(TPreptimeContext context) {
    context.set(READER_CONTEXT_POS, new WKBReader());
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:5,代码来源:GeoWKB.java


示例20: read

import com.vividsolutions.jts.io.WKBReader; //导入依赖的package包/类
public static Geometry read(final byte[] b) throws IOException, ParseException {
	final WKBReader wkb = new WKBReader();
	final Geometry geom = wkb.read(b);
	return geom;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:6,代码来源:SqlUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java TableRegionModel类代码示例发布时间:2022-05-21
下一篇:
Java NotNullLazyValue类代码示例发布时间: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