当前位置: 首页>>代码示例>>Java>>正文


Java OGCGeometry.fromBinary方法代码示例

本文整理汇总了Java中com.esri.core.geometry.ogc.OGCGeometry.fromBinary方法的典型用法代码示例。如果您正苦于以下问题:Java OGCGeometry.fromBinary方法的具体用法?Java OGCGeometry.fromBinary怎么用?Java OGCGeometry.fromBinary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.esri.core.geometry.ogc.OGCGeometry的用法示例。


在下文中一共展示了OGCGeometry.fromBinary方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			String gType = ogcObj.geometryType();
			if (gType.equals("MultiLineString") || gType.equals("LineString")) {
				return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
			} else {
				LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTILINESTRING, GeometryUtils.OGCType.UNKNOWN);
				return null;
			}
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:25,代码来源:ST_MLineFromWKB.java

示例2: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			String gType = ogcObj.geometryType();
			if (gType.equals("MultiPoint") || gType.equals("Point")) {
				return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
			} else {
				LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.OGCType.UNKNOWN);
				return null;
			}
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:25,代码来源:ST_MPointFromWKB.java

示例3: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			if (ogcObj.geometryType().equals("LineString")) {
				return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
			} else {
				LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.OGCType.UNKNOWN);
				return null;
			}
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:24,代码来源:ST_LineFromWKB.java

示例4: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			String gType = ogcObj.geometryType();
			if (gType.equals("MultiPolygon") || gType.equals("Polygon")) {
				return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
			} else {
				LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOLYGON, GeometryUtils.OGCType.UNKNOWN);
				return null;
			}
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:25,代码来源:ST_MPolyFromWKB.java

示例5: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:19,代码来源:ST_GeomFromWKB.java

示例6: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			if (ogcObj.geometryType().equals("Polygon")) {
				return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
			} else {
				LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POLYGON, GeometryUtils.OGCType.UNKNOWN);
				return null;
			}
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:24,代码来源:ST_PolyFromWKB.java

示例7: evaluate

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException {

		try {
			SpatialReference spatialReference = null;
			if (wkid != GeometryUtils.WKID_UNKNOWN) {
				spatialReference = SpatialReference.create(wkid);
			}
			byte [] byteArr = wkb.getBytes();
            ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
			byteBuf.put(byteArr);
			OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf);
			ogcObj.setSpatialReference(spatialReference);
			if (ogcObj.geometryType().equals("Point")) {
				return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
			} else {
				LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.OGCType.UNKNOWN);
				return null;
			}
		} catch (Exception e) {  // IllegalArgumentException, GeometryException
			LOG.error(e.getMessage());
			return null;
		}
	}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:24,代码来源:ST_PointFromWKB.java

示例8: testGeometryCollection

import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Test
public void testGeometryCollection() throws Exception {
	OGCGeometry g = OGCGeometry
			.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
	assertTrue(g.geometryType().equals("GeometryCollection"));
	OGCConcreteGeometryCollection gc = (OGCConcreteGeometryCollection) g;
	assertTrue(gc.numGeometries() == 5);
	assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
	assertTrue(gc.geometryN(1).geometryType().equals("Point"));
	assertTrue(gc.geometryN(2).geometryType().equals("LineString"));
	assertTrue(gc.geometryN(3).geometryType().equals("MultiPolygon"));
	assertTrue(gc.geometryN(4).geometryType().equals("MultiLineString"));

	g = OGCGeometry
			.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
	assertTrue(g.geometryType().equals("GeometryCollection"));
	gc = (OGCConcreteGeometryCollection) g;
	assertTrue(gc.numGeometries() == 7);
	assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
	assertTrue(gc.geometryN(1).geometryType().equals("Point"));
	assertTrue(gc.geometryN(2).geometryType().equals("GeometryCollection"));
	assertTrue(gc.geometryN(3).geometryType().equals("LineString"));
	assertTrue(gc.geometryN(4).geometryType().equals("GeometryCollection"));
	assertTrue(gc.geometryN(5).geometryType().equals("MultiPolygon"));
	assertTrue(gc.geometryN(6).geometryType().equals("MultiLineString"));

	OGCConcreteGeometryCollection gc2 = (OGCConcreteGeometryCollection) gc
			.geometryN(4);
	assertTrue(gc2.numGeometries() == 6);
	assertTrue(gc2.geometryN(0).geometryType().equals("Polygon"));
	assertTrue(gc2.geometryN(1).geometryType().equals("Point"));
	assertTrue(gc2.geometryN(2).geometryType().equals("LineString"));
	assertTrue(gc2.geometryN(3).geometryType().equals("MultiPolygon"));
	assertTrue(gc2.geometryN(4).geometryType().equals("MultiLineString"));
	assertTrue(gc2.geometryN(5).geometryType().equals("MultiPoint"));

	ByteBuffer wkbBuffer = g.asBinary();
	g = OGCGeometry.fromBinary(wkbBuffer);

	assertTrue(g.geometryType().equals("GeometryCollection"));
	gc = (OGCConcreteGeometryCollection) g;
	assertTrue(gc.numGeometries() == 7);
	assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
	assertTrue(gc.geometryN(1).geometryType().equals("Point"));
	assertTrue(gc.geometryN(2).geometryType().equals("GeometryCollection"));
	assertTrue(gc.geometryN(3).geometryType().equals("LineString"));
	assertTrue(gc.geometryN(4).geometryType().equals("GeometryCollection"));
	assertTrue(gc.geometryN(5).geometryType().equals("MultiPolygon"));
	assertTrue(gc.geometryN(6).geometryType().equals("MultiLineString"));

	gc2 = (OGCConcreteGeometryCollection) gc.geometryN(4);
	assertTrue(gc2.numGeometries() == 6);
	assertTrue(gc2.geometryN(0).geometryType().equals("Polygon"));
	assertTrue(gc2.geometryN(1).geometryType().equals("Point"));
	assertTrue(gc2.geometryN(2).geometryType().equals("LineString"));
	assertTrue(gc2.geometryN(3).geometryType().equals("MultiPolygon"));
	assertTrue(gc2.geometryN(4).geometryType().equals("MultiLineString"));
	assertTrue(gc2.geometryN(5).geometryType().equals("MultiPoint"));

	String wktString = g.asText();
	assertTrue(wktString
			.equals("GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"));

	g = OGCGeometry
			.fromGeoJson("{\"type\" : \"GeometryCollection\", \"geometries\" : [{\"type\" : \"Polygon\", \"coordinates\" : []}, {\"type\" : \"Point\", \"coordinates\" : [1, 1]}, {\"type\" : \"GeometryCollection\", \"geometries\" : []}, {\"type\" : \"LineString\", \"coordinates\" : []}, {\"type\" : \"GeometryCollection\", \"geometries\" : [{\"type\": \"Polygon\", \"coordinates\" : []}, {\"type\" : \"Point\", \"coordinates\" : [1,1]}, {\"type\" : \"LineString\", \"coordinates\" : []}, {\"type\" : \"MultiPolygon\", \"coordinates\" : []}, {\"type\" : \"MultiLineString\", \"coordinates\" : []}, {\"type\" : \"MultiPoint\", \"coordinates\" : []}]}, {\"type\" : \"MultiPolygon\", \"coordinates\" : []}, {\"type\" : \"MultiLineString\", \"coordinates\" : []} ] }");

	wktString = g.asText();
	assertTrue(wktString
			.equals("GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"));
	
	assertTrue(g.equals((Object)OGCGeometry.fromText(wktString)));
	
	assertTrue(g.hashCode() == OGCGeometry.fromText(wktString).hashCode());

}
 
开发者ID:Esri,项目名称:geometry-api-java,代码行数:76,代码来源:TestOGC.java


注:本文中的com.esri.core.geometry.ogc.OGCGeometry.fromBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。