本文整理汇总了Java中com.esri.core.geometry.ogc.OGCGeometry.getEsriGeometry方法的典型用法代码示例。如果您正苦于以下问题:Java OGCGeometry.getEsriGeometry方法的具体用法?Java OGCGeometry.getEsriGeometry怎么用?Java OGCGeometry.getEsriGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esri.core.geometry.ogc.OGCGeometry
的用法示例。
在下文中一共展示了OGCGeometry.getEsriGeometry方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public Text evaluate(BytesWritable geomref){
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
Geometry esriGeom = ogcGeometry.getEsriGeometry();
int wkid = GeometryUtils.getWKID(geomref);
return new Text(GeometryEngine.geometryToJson(wkid, esriGeom));
}
示例2: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
try {
// Get Esri shape representation
Geometry esriGeometry = ogcGeometry.getEsriGeometry();
byte[] esriShape = GeometryEngine.geometryToEsriShape(esriGeometry);
return new BytesWritable(esriShape);
} catch (Exception e){
LOG.error(e.getMessage());
return null;
}
}
示例3: testGeomFromLineShape
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Test
public void testGeomFromLineShape() throws UDFArgumentException {
Polyline line = createLine();
byte[] esriShape = GeometryEngine.geometryToEsriShape(line);
assertNotNull("The shape must not be null!", esriShape);
BytesWritable shapeAsWritable = new BytesWritable(esriShape);
assertNotNull("The shape writable must not be null!", shapeAsWritable);
final int wkid = 4326;
ST_GeomFromShape fromShape = new ST_GeomFromShape();
BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid);
assertNotNull("The geometry writable must not be null!", geometryAsWritable);
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable);
assertNotNull("The OGC geometry must not be null!", ogcGeometry);
Geometry esriGeometry = ogcGeometry.getEsriGeometry();
assertNotNull("The Esri geometry must not be null!", esriGeometry);
assertTrue("The geometries are different!",
GeometryEngine.equals(line, esriGeometry, SpatialReference.create(wkid)));
}
示例4: testGeomFromPolylineShape
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Test
public void testGeomFromPolylineShape() throws UDFArgumentException {
Polyline line = createPolyline();
byte[] esriShape = GeometryEngine.geometryToEsriShape(line);
assertNotNull("The shape must not be null!", esriShape);
BytesWritable shapeAsWritable = new BytesWritable(esriShape);
assertNotNull("The shape writable must not be null!", shapeAsWritable);
final int wkid = 4326;
ST_GeomFromShape fromShape = new ST_GeomFromShape();
BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid);
assertNotNull("The geometry writable must not be null!", geometryAsWritable);
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable);
assertNotNull("The OGC geometry must not be null!", ogcGeometry);
Geometry esriGeometry = ogcGeometry.getEsriGeometry();
assertNotNull("The Esri geometry must not be null!", esriGeometry);
assertTrue("The geometries are different!",
GeometryEngine.equals(line, esriGeometry, SpatialReference.create(wkid)));
}
示例5: testGeomFromPolygonShape
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Test
public void testGeomFromPolygonShape() throws UDFArgumentException {
Polygon polygon = createPolygon();
byte[] esriShape = GeometryEngine.geometryToEsriShape(polygon);
assertNotNull("The shape must not be null!", esriShape);
BytesWritable shapeAsWritable = new BytesWritable(esriShape);
assertNotNull("The shape writable must not be null!", shapeAsWritable);
final int wkid = 4326;
ST_GeomFromShape fromShape = new ST_GeomFromShape();
BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid);
assertNotNull("The geometry writable must not be null!", geometryAsWritable);
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable);
assertNotNull("The OGC geometry must not be null!", ogcGeometry);
Geometry esriGeometry = ogcGeometry.getEsriGeometry();
assertNotNull("The Esri geometry must not be null!", esriGeometry);
assertTrue("The geometries are different!",
GeometryEngine.equals(polygon, esriGeometry, SpatialReference.create(wkid)));
}
示例6: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BooleanWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0) {
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
try {
switch(GeometryUtils.getType(geomref)) {
case ST_LINESTRING:
case ST_MULTILINESTRING:
MultiPath lines = (MultiPath)(ogcGeometry.getEsriGeometry());
int nPaths = lines.getPathCount();
boolean rslt = true;
for (int ix = 0; rslt && ix < nPaths; ix++) {
Point p0 = lines.getPoint(lines.getPathStart(ix));
Point pf = lines.getPoint(lines.getPathEnd(ix)-1);
rslt = rslt && pf.equals(p0); // no tolerance - OGC
}
resultBoolean.set(rslt);
return resultBoolean;
default: // ST_IsClosed gives ERROR on Point or Polygon, on Postgres/Oracle
LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.getType(geomref));
return null;
}
} catch (Exception e) {
LogUtils.Log_InternalError(LOG, "ST_IsClosed" + e);
return null;
}
}
示例7: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public IntWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0) {
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
Geometry esriGeom = ogcGeometry.getEsriGeometry();
switch(esriGeom.getType()) {
case Point:
resultInt.set(esriGeom.isEmpty() ? 0 : 1);
break;
case MultiPoint:
resultInt.set(((MultiPoint)(esriGeom)).getPointCount());
break;
case Polygon:
Polygon polygon = (Polygon)(esriGeom);
resultInt.set(polygon.getPointCount() + polygon.getPathCount());
break;
default:
resultInt.set(((MultiPath)(esriGeom)).getPointCount());
break;
}
return resultInt;
}
示例8: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BooleanWritable evaluate(BytesWritable geometryref1, BytesWritable geometryref2)
{
if (geometryref1 == null || geometryref2 == null ||
geometryref1.getLength() == 0 || geometryref2.getLength() == 0) {
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
if (!GeometryUtils.compareSpatialReferences(geometryref1, geometryref2)) {
LogUtils.Log_SRIDMismatch(LOG, geometryref1, geometryref2);
return null;
}
OGCGeometry ogcGeom1 = GeometryUtils.geometryFromEsriShape(geometryref1);
OGCGeometry ogcGeom2 = GeometryUtils.geometryFromEsriShape(geometryref2);
if (ogcGeom1 == null || ogcGeom2 == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
Geometry geometry1 = ogcGeom1.getEsriGeometry();
Geometry geometry2 = ogcGeom2.getEsriGeometry();
Envelope env1 = new Envelope(), env2 = new Envelope();
geometry1.queryEnvelope(env1);
geometry2.queryEnvelope(env2);
resultBoolean.set(env1.isIntersecting(env2));
return resultBoolean;
}
示例9: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
/**
* Return the last point of the ST_Linestring.
* @param geomref hive geometry bytes
* @return byte-reference of the last ST_Point
*/
public BytesWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
if (GeometryUtils.getType(geomref) == GeometryUtils.OGCType.ST_LINESTRING) {
MultiPath lines = (MultiPath)(ogcGeometry.getEsriGeometry());
int wkid = GeometryUtils.getWKID(geomref);
SpatialReference spatialReference = null;
if (wkid != GeometryUtils.WKID_UNKNOWN) {
spatialReference = SpatialReference.create(wkid);
}
return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(lines.getPoint(lines.getPointCount()-1),
spatialReference));
} else {
LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.getType(geomref));
return null;
}
}
示例10: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
/**
* Return the first point of the ST_Linestring.
* @param geomref hive geometry bytes
* @return byte-reference of the first ST_Point
*/
public BytesWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
if (GeometryUtils.getType(geomref) == GeometryUtils.OGCType.ST_LINESTRING) {
MultiPath lines = (MultiPath)(ogcGeometry.getEsriGeometry());
int wkid = GeometryUtils.getWKID(geomref);
SpatialReference spatialReference = null;
if (wkid != GeometryUtils.WKID_UNKNOWN) {
spatialReference = SpatialReference.create(wkid);
}
return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(lines.getPoint(0),
spatialReference));
} else {
LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.getType(geomref));
return null;
}
}
示例11: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate (BytesWritable ... geomrefs){
// validate arguments
if (geomrefs == null || geomrefs.length < 2){
LogUtils.Log_VariableArgumentLength(LOG);
}
int firstWKID = 0;
SpatialReference spatialRef = null;
// validate spatial references and geometries first
for (int i=0;i<geomrefs.length; i++){
BytesWritable geomref = geomrefs[i];
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
if (i==0){
firstWKID = GeometryUtils.getWKID(geomref);
if (firstWKID != GeometryUtils.WKID_UNKNOWN) {
spatialRef = SpatialReference.create(firstWKID);
}
} else if (firstWKID != GeometryUtils.getWKID(geomref)){
LogUtils.Log_SRIDMismatch(LOG, geomrefs[0], geomref);
return null;
}
}
// now build geometry array to pass to GeometryEngine.union
Geometry [] geomsToUnion = new Geometry[geomrefs.length];
for (int i=0;i<geomrefs.length;i++){
//HiveGeometry hiveGeometry = GeometryUtils.geometryFromEsriShape(geomrefs[i]);
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomrefs[i]);
// if (i==0){ // get from ogcGeometry rather than re-create above?
// spatialRef = hiveGeometry.spatialReference;
// }
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
geomsToUnion[i] = ogcGeometry.getEsriGeometry();
}
try {
Geometry unioned = GeometryEngine.union(geomsToUnion, spatialRef);
// we have to infer the type of the differenced geometry because we don't know
// if it's going to end up as a single or multi-part geometry
OGCType inferredType = GeometryUtils.getInferredOGCType(unioned);
return GeometryUtils.geometryToEsriShapeBytesWritable(unioned, firstWKID, inferredType);
} catch (Exception e){
LogUtils.Log_ExceptionThrown(LOG, "GeometryEngine.union", e);
return null;
}
}
示例12: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public DoubleWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0) {
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
int WGS84 = 4326;
if (GeometryUtils.getWKID(geomref) != WGS84) {
LogUtils.Log_SRIDMismatch(LOG, geomref, WGS84);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
Geometry esriGeom = ogcGeometry.getEsriGeometry();
switch(esriGeom.getType()) {
case Point:
case MultiPoint:
resultDouble.set(0.);
break;
default:
MultiPath lines = (MultiPath)(esriGeom);
int nPath = lines.getPathCount();
double length = 0.;
for (int ix = 0; ix < nPath; ix++) {
int curPt = lines.getPathStart(ix);
int pastPt = lines.getPathEnd(ix);
Point fromPt = lines.getPoint(curPt);
Point toPt = null;
for (int vx = curPt+1; vx < pastPt; vx++) {
toPt = lines.getPoint(vx);
length += GeometryEngine.geodesicDistanceOnWGS84(fromPt, toPt);
fromPt = toPt;
}
}
resultDouble.set(length);
break;
}
return resultDouble;
}
示例13: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
public BytesWritable evaluate (BytesWritable ... geomrefs){
// validate arguments
if (geomrefs == null || geomrefs.length < 1){
// LogUtils.Log_VariableArgumentLength(LOG);
return null;
}
int firstWKID = 0;
// validate spatial references and geometries first
for (int i=0;i<geomrefs.length; i++){
BytesWritable geomref = geomrefs[i];
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
if (i==0){
firstWKID = GeometryUtils.getWKID(geomref);
} else if (firstWKID != GeometryUtils.getWKID(geomref)){
LogUtils.Log_SRIDMismatch(LOG, geomrefs[0], geomref);
return null;
}
}
// now build geometry array to pass to GeometryEngine.union
Geometry [] geomsToProcess = new Geometry[geomrefs.length];
for (int i=0;i<geomrefs.length;i++){
//HiveGeometry hiveGeometry = GeometryUtils.geometryFromEsriShape(geomrefs[i]);
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomrefs[i]);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
geomsToProcess[i] = ogcGeometry.getEsriGeometry();
}
try {
Geometry [] geomResult = GeometryEngine.convexHull(geomsToProcess, true);
if (geomResult.length != 1){
return null;
}
Geometry merged = geomResult[0];
// we have to infer the type of the differenced geometry because we don't know
// if it's going to end up as a single or multi-part geometry
OGCType inferredType = GeometryUtils.getInferredOGCType(merged);
return GeometryUtils.geometryToEsriShapeBytesWritable(merged, firstWKID, inferredType);
} catch (Exception e){
LogUtils.Log_ExceptionThrown(LOG, "GeometryEngine.convexHull", e);
return null;
}
}