本文整理了Java中com.esri.core.geometry.Geometry
类的一些代码示例,展示了Geometry
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry
类的具体详情如下:
包路径:com.esri.core.geometry.Geometry
类名称:Geometry
[英]Common properties and methods shared by all geometric objects. Geometries are objects that define a spatial location and and associated geometric shape.
[中]所有几何对象共享的通用特性和方法。几何图形是定义空间位置和关联几何图形的对象。
代码示例来源:origin: prestodb/presto
public static Envelope getEnvelope(OGCGeometry ogcGeometry)
{
GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
Envelope overallEnvelope = new Envelope();
while (true) {
Geometry geometry = cursor.next();
if (geometry == null) {
return overallEnvelope;
}
Envelope envelope = new Envelope();
geometry.queryEnvelope(envelope);
overallEnvelope.merge(envelope);
}
}
代码示例来源:origin: prestodb/presto
private static OGCGeometry createFromEsriGeometry(Geometry geometry, boolean multiType)
Geometry.Type type = geometry.getType();
switch (type) {
case Polygon: {
if (geometry.isEmpty()) {
return new OGCPoint(new Point(), null);
代码示例来源:origin: prestodb/presto
@Description("Returns the 2D Euclidean area of a geometry")
@ScalarFunction("ST_Area")
@SqlType(DOUBLE)
public static double stArea(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
OGCGeometry geometry = deserialize(input);
// The Esri geometry library does not support area for geometry collections. We compute the area
// of collections by summing the area of the individual components.
GeometryType type = GeometryType.getForEsriGeometryType(geometry.geometryType());
if (type == GeometryType.GEOMETRY_COLLECTION) {
double area = 0.0;
GeometryCursor cursor = geometry.getEsriGeometryCursor();
while (true) {
com.esri.core.geometry.Geometry esriGeometry = cursor.next();
if (esriGeometry == null) {
return area;
}
area += esriGeometry.calculateArea2D();
}
}
return geometry.getEsriGeometry().calculateArea2D();
}
代码示例来源:origin: Esri/geometry-api-java
static boolean hasNonEmptyBoundary(Geometry geom,
ProgressTracker progress_tracker) {
if (geom.isEmpty())
return false;
Geometry.Type gt = geom.getType();
if (gt == Geometry.Type.Polygon) {
if (geom.calculateArea2D() == 0)
return false;
return true;
} else if (gt == Geometry.Type.Polyline) {
boolean[] b = new boolean[1];
b[0] = false;
calculatePolylineBoundary_(geom._getImpl(), progress_tracker, true,
b);
return b[0];
} else if (gt == Geometry.Type.Envelope) {
return true;
} else if (Geometry.isSegment(gt.value())) {
if (!((Segment) geom).isClosed()) {
return true;
}
return false;
} else if (Geometry.isPoint(gt.value())) {
return false;
}
return false;
}
代码示例来源:origin: Esri/geometry-api-java
private Geometry Generalize(Geometry geom) {
Geometry.Type gt = geom.getType();
if (Geometry.isPoint(gt.value()))
return geom;
if (gt == Geometry.Type.Envelope) {
Polygon poly = new Polygon(geom.getDescription());
poly.addEnvelope((Envelope) geom, false);
return Generalize(poly);
}
if (geom.isEmpty())
return geom;
MultiPath mp = (MultiPath) geom;
MultiPath dstmp = (MultiPath) geom.createInstance();
Line line = new Line();
for (int ipath = 0, npath = mp.getPathCount(); ipath < npath; ipath++) {
GeneralizePath((MultiPathImpl) mp._getImpl(), ipath,
(MultiPathImpl) dstmp._getImpl(), line);
}
return dstmp;
}
代码示例来源:origin: Esri/geometry-api-java
private Geometry bufferEnvelope_() {
Polygon polygon = new Polygon(m_geometry.getDescription());
if (m_distance <= 0) {
if (m_distance == 0)
polygon.addEnvelope((Envelope) (m_geometry), false);
else {
Envelope env = new Envelope();
m_geometry.queryEnvelope(env);
env.inflate(m_distance, m_distance);
polygon.addEnvelope(env, false);
}
return polygon;// nothing is easier than negative buffer on the
// envelope.
}
polygon.addEnvelope((Envelope) (m_geometry), false);
m_geometry = polygon;
return bufferConvexPath_(polygon, 0);
}
代码示例来源:origin: Esri/geometry-api-java
Geometry normalizeIntersectionOutput(Geometry geom, int GT_1, int GT_2) {
if (GT_1 == Geometry.GeometryType.Point
|| GT_2 == Geometry.GeometryType.Point) {
assert (geom.getType().value() == Geometry.GeometryType.Point);
}
if (GT_1 == Geometry.GeometryType.MultiPoint) {
if (geom.getType().value() == Geometry.GeometryType.Point) {
MultiPoint mp = new MultiPoint(geom.getDescription());
if (!geom.isEmpty())
mp.add((Point) geom);
return mp;
}
}
return geom;
}
代码示例来源:origin: Esri/geometry-api-java
int addGeometry(Geometry geometry) {
Geometry.Type gt = geometry.getType();
if (Geometry.isMultiPath(gt.value()))
return addMultiPath_((MultiPath) geometry);
if (gt == Geometry.Type.MultiPoint)
return addMultiPoint_((MultiPoint) geometry);
throw GeometryException.GeometryInternalError();
}
代码示例来源:origin: Esri/geometry-api-java
static Geometry _denormalizeGeometry(Geometry geom, Geometry geomA,
Geometry geomB) {
Geometry.Type gtA = geomA.getType();
Geometry.Type gtB = geomB.getType();
Geometry.Type gt = geom.getType();
if (gt == Geometry.Type.MultiPoint) {
if (gtA == Geometry.Type.Point || gtB == Geometry.Type.Point) {
MultiPoint mp = (MultiPoint) geom;
if (mp.getPointCount() <= 1) {
Point pt = new Point(geom.getDescription());
if (!mp.isEmpty())
mp.getPointByVal(0, pt);
return (Geometry) pt;
}
}
}
return geom;
}
代码示例来源:origin: prestodb/presto
@Description("Converts a Geometry object to a SphericalGeography object")
@ScalarFunction("to_spherical_geography")
@SqlType(SPHERICAL_GEOGRAPHY_TYPE_NAME)
public static Slice toSphericalGeography(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
// "every point in input is in range" <=> "the envelope of input is in range"
Envelope envelope = deserializeEnvelope(input);
if (envelope != null) {
checkLatitude(envelope.getYMin());
checkLatitude(envelope.getYMax());
checkLongitude(envelope.getXMin());
checkLongitude(envelope.getXMax());
}
OGCGeometry geometry = deserialize(input);
if (geometry.is3D()) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Cannot convert 3D geometry to a spherical geography");
}
GeometryCursor cursor = geometry.getEsriGeometryCursor();
while (true) {
com.esri.core.geometry.Geometry subGeometry = cursor.next();
if (subGeometry == null) {
break;
}
if (!GEOMETRY_TYPES_FOR_SPHERICAL_GEOGRAPHY.contains(subGeometry.getType())) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Cannot convert geometry of this type to spherical geography: " + subGeometry.getType());
}
}
return input;
}
代码示例来源:origin: prestodb/presto
@Description("Returns the length of a LineString or Multi-LineString using Euclidean measurement on a 2D plane (based on spatial ref) in projected units")
@ScalarFunction("ST_Length")
@SqlType(DOUBLE)
public static double stLength(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
OGCGeometry geometry = deserialize(input);
validateType("ST_Length", geometry, EnumSet.of(LINE_STRING, MULTI_LINE_STRING));
return geometry.getEsriGeometry().calculateLength2D();
}
代码示例来源:origin: Esri/geometry-api-java
@Override
public void copyTo(Geometry dst) {
if (getType() != dst.getType())
throw new IllegalArgumentException();
m_impl.copyTo((Geometry) dst._getImpl());
}
代码示例来源:origin: Esri/geometry-api-java
private static int get_vertex_count_(Geometry geom) {
int gt = geom.getType().value();
if (Geometry.isMultiVertex(gt)) {
return ((MultiVertexGeometry) geom).getPointCount();
} else if (gt == Geometry.GeometryType.Point) {
return 1;
} else if (gt == Geometry.GeometryType.Envelope) {
return 4;
} else if (Geometry.isSegment(gt)) {
return 2;
} else {
throw GeometryException.GeometryInternalError();
}
}
代码示例来源:origin: Esri/geometry-api-java
/**
* A shortcut for getDescription().hasAttribute()
* @param semantics The VertexDescription.Semantics to check.
* @return Return true if the attribute is present.
*/
public boolean hasAttribute(int semantics) {
return getDescription().hasAttribute(semantics);
}
代码示例来源:origin: Esri/geometry-api-java
static void testPointsOnLine2D(Geometry line, Point2D[] input_points,
int count, double tolerance, PolygonUtils.PiPResult[] test_results) {
Geometry.Type gt = line.getType();
if (gt == Geometry.Type.Polyline)
testPointsOnPolyline2D_((Polyline) line, input_points, count,
tolerance, test_results);
else if (Geometry.isSegment(gt.value())) {
testPointsOnSegment_((Segment) line, input_points, count,
tolerance, test_results);
} else
throw new GeometryException("Invalid call.");
}
代码示例来源:origin: prestodb/presto
public static int getPointCount(OGCGeometry ogcGeometry)
{
GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
int points = 0;
while (true) {
com.esri.core.geometry.Geometry geometry = cursor.next();
if (geometry == null) {
return points;
}
if (geometry.isEmpty()) {
continue;
}
if (geometry instanceof Point) {
points++;
}
else {
points += ((MultiVertexGeometry) geometry).getPointCount();
}
}
}
代码示例来源:origin: Esri/geometry-api-java
double calculate(/* const */Geometry geometryA, /* const */
Geometry geometryB) {
if (geometryA.isEmpty() || geometryB.isEmpty())
return NumberUtils.TheNaN;
geometryA.queryEnvelope2D(m_env2DgeometryA);
geometryB.queryEnvelope2D(m_env2DgeometryB);
return executeBruteForce_(geometryA, geometryB);
}
}
代码示例来源:origin: Esri/geometry-api-java
static Geometry execute(Geometry inputGeometry, double distance,
OperatorOffset.JoinType joins, double miterLimit, double tolerance,
ProgressTracker progressTracker) {
if (inputGeometry == null)
throw new IllegalArgumentException();
if (inputGeometry.getDimension() < 1)// can offset Polygons and
// Polylines only
throw new IllegalArgumentException();
if (distance == 0 || inputGeometry.isEmpty())
return inputGeometry;
ConstructOffset offset = new ConstructOffset(progressTracker);
offset.m_inputGeometry = inputGeometry;
offset.m_distance = distance;
offset.m_tolerance = tolerance;
offset.m_joins = joins;
offset.m_miterLimit = miterLimit;
return offset._ConstructOffset();
}
代码示例来源:origin: com.esri.geometry/esri-geometry-api
static boolean hasNonEmptyBoundary(Geometry geom,
ProgressTracker progress_tracker) {
if (geom.isEmpty())
return false;
Geometry.Type gt = geom.getType();
if (gt == Geometry.Type.Polygon) {
if (geom.calculateArea2D() == 0)
return false;
return true;
} else if (gt == Geometry.Type.Polyline) {
boolean[] b = new boolean[1];
b[0] = false;
calculatePolylineBoundary_(geom._getImpl(), progress_tracker, true,
b);
return b[0];
} else if (gt == Geometry.Type.Envelope) {
return true;
} else if (Geometry.isSegment(gt.value())) {
if (!((Segment) geom).isClosed()) {
return true;
}
return false;
} else if (Geometry.isPoint(gt.value())) {
return false;
}
return false;
}
代码示例来源:origin: com.esri.geometry/esri-geometry-api
private Geometry Generalize(Geometry geom) {
Geometry.Type gt = geom.getType();
if (Geometry.isPoint(gt.value()))
return geom;
if (gt == Geometry.Type.Envelope) {
Polygon poly = new Polygon(geom.getDescription());
poly.addEnvelope((Envelope) geom, false);
return Generalize(poly);
}
if (geom.isEmpty())
return geom;
MultiPath mp = (MultiPath) geom;
MultiPath dstmp = (MultiPath) geom.createInstance();
Line line = new Line();
for (int ipath = 0, npath = mp.getPathCount(); ipath < npath; ipath++) {
GeneralizePath((MultiPathImpl) mp._getImpl(), ipath,
(MultiPathImpl) dstmp._getImpl(), line);
}
return dstmp;
}
内容来源于网络,如有侵权,请联系作者删除!