本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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());
}