本文整理了Java中com.esri.core.geometry.Point
类的一些代码示例,展示了Point
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point
类的具体详情如下:
包路径:com.esri.core.geometry.Point
类名称:Point
[英]A Point is a zero-dimensional object that represents a specific (X,Y) location in a two-dimensional XY-Plane. In case of Geographic Coordinate Systems, the X coordinate is the longitude and the Y is the latitude.
[中]点是零维对象,表示二维XY平面中的特定(X,Y)位置。对于地理坐标系,X坐标是经度,Y坐标是纬度。
代码示例来源:origin: prestodb/presto
private static Point getPolygonSansHolesCentroid(Polygon polygon)
{
int pointCount = polygon.getPointCount();
double xSum = 0;
double ySum = 0;
double signedArea = 0;
for (int i = 0; i < pointCount; i++) {
Point current = polygon.getPoint(i);
Point next = polygon.getPoint((i + 1) % polygon.getPointCount());
double ladder = current.getX() * next.getY() - next.getX() * current.getY();
xSum += (current.getX() + next.getX()) * ladder;
ySum += (current.getY() + next.getY()) * ladder;
signedArea += ladder / 2;
}
return new Point(xSum / (signedArea * 6), ySum / (signedArea * 6));
}
代码示例来源:origin: prestodb/presto
@SqlNullable
@Description("Returns TRUE if the LineString or Multi-LineString's start and end points are coincident")
@ScalarFunction("ST_IsClosed")
@SqlType(BOOLEAN)
public static Boolean stIsClosed(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
OGCGeometry geometry = deserialize(input);
validateType("ST_IsClosed", geometry, EnumSet.of(LINE_STRING, MULTI_LINE_STRING));
MultiPath lines = (MultiPath) geometry.getEsriGeometry();
int pathCount = lines.getPathCount();
for (int i = 0; i < pathCount; i++) {
Point start = lines.getPoint(lines.getPathStart(i));
Point end = lines.getPoint(lines.getPathEnd(i) - 1);
if (!end.equals(start)) {
return false;
}
}
return true;
}
代码示例来源:origin: prestodb/presto
private static void writePoint(DynamicSliceOutput output, OGCGeometry geometry)
{
Geometry esriGeometry = geometry.getEsriGeometry();
verify(esriGeometry instanceof Point, "geometry is expected to be an instance of Point");
Point point = (Point) esriGeometry;
verify(!point.hasAttribute(VertexDescription.Semantics.Z) &&
!point.hasAttribute(VertexDescription.Semantics.M) &&
!point.hasAttribute(VertexDescription.Semantics.ID),
"Only 2D points with no ID nor M attribute are supported");
output.appendByte(GeometrySerializationType.POINT.code());
if (!point.isEmpty()) {
output.appendDouble(point.getX());
output.appendDouble(point.getY());
}
else {
output.appendDouble(NaN);
output.appendDouble(NaN);
}
}
代码示例来源:origin: prestodb/presto
private static boolean withinDistance(GreatCircleDistanceToPoint distanceFunction, double maxDistance, Point point)
{
return distanceFunction.distance(point.getY(), point.getX()) <= maxDistance;
}
代码示例来源:origin: prestodb/presto
private static OGCPoint readPoint(BasicSliceInput input)
{
double x = input.readDouble();
double y = input.readDouble();
Point point;
if (isNaN(x) || isNaN(y)) {
point = new Point();
}
else {
point = new Point(x, y);
}
return new OGCPoint(point, null);
}
代码示例来源:origin: Esri/geometry-api-java
static void exportPointToWkt(int export_flags, Point point,
StringBuilder string) {
int precision = 17 - (7 & (export_flags >> 13));
boolean b_export_zs = point.hasAttribute(VertexDescription.Semantics.Z)
&& (export_flags & WktExportFlags.wktExportStripZs) == 0;
boolean b_export_ms = point.hasAttribute(VertexDescription.Semantics.M)
&& (export_flags & WktExportFlags.wktExportStripMs) == 0;
double x = NumberUtils.TheNaN;
double y = NumberUtils.TheNaN;
double z = NumberUtils.TheNaN;
double m = NumberUtils.TheNaN;
if (!point.isEmpty()) {
x = point.getX();
y = point.getY();
if (b_export_zs)
z = point.getZ();
if (b_export_ms)
m = point.getM();
}
if ((export_flags & WktExportFlags.wktExportMultiPoint) != 0) {
multiPointTaggedTextFromPoint_(precision, b_export_zs, b_export_ms,
x, y, z, m, string);
} else {
pointTaggedText_(precision, b_export_zs, b_export_ms, x, y, z, m,
string);
}
}
代码示例来源:origin: apache/drill
new com.esri.core.geometry.Point(result.x, result.y), sr).asBinary();
} else {
com.esri.core.geometry.Geometry esriGeom = geomSrc.getEsriGeometry();
for (int i = 0; i < vertexGeom.getPointCount(); i++) {
com.esri.core.geometry.Point point = vertexGeom.getPoint(i);
result = transform.transform(new org.osgeo.proj4j.ProjCoordinate(point.getX(), point.getY()), result);
point.setXY(result.x, result.y);
vertexGeom.setPoint(i, point);
代码示例来源:origin: Esri/geometry-api-java
/**
* Checks if this envelope contains (covers) the specified point.
*
* @param p
* The Point to be tested for coverage.
* @return TRUE if this envelope contains (covers) the specified point.
*/
public boolean contains(Point p) {
if (p.isEmpty())
return false;
return m_envelope.contains(p.getX(), p.getY());
}
代码示例来源:origin: org.apache.sis.core/sis-feature
/**
* If the given point is an implementation of this library, returns its coordinate.
* Otherwise returns {@code null}. If non-null, the returned array may have a length of 2 or 3.
*/
@Override
final double[] tryGetCoordinate(final Object point) {
if (point instanceof Point) {
final Point pt = (Point) point;
final double z = pt.getZ();
final double[] coord;
if (Double.isNaN(z)) {
coord = new double[2];
} else {
coord = new double[3];
coord[2] = z;
}
coord[1] = pt.getY();
coord[0] = pt.getX();
return coord;
}
return null;
}
代码示例来源:origin: Esri/geometry-api-java
@Override
public Point getPoint(int index) {
if (index < 0 || index >= m_pointCount)
throw new IndexOutOfBoundsException();
_verifyAllStreams();
Point outPoint = new Point();
outPoint.assignVertexDescription(m_description);
if (outPoint.isEmpty())
outPoint._setToDefault();
for (int attributeIndex = 0; attributeIndex < m_description
.getAttributeCount(); attributeIndex++) {
int semantics = m_description.getSemantics(attributeIndex);
for (int icomp = 0, ncomp = VertexDescription
.getComponentCount(semantics); icomp < ncomp; icomp++) {
double v = m_vertexAttributes[attributeIndex].readAsDbl(ncomp
* index + icomp);
outPoint.setAttribute(semantics, icomp, v);
}
}
return outPoint;
}
代码示例来源:origin: Esri/geometry-api-java
protected void _initPathStartPoint() {
_touch();
if (m_moveToPoint == null)
m_moveToPoint = new Point(m_description);
else
m_moveToPoint.assignVertexDescription(m_description);
}
代码示例来源:origin: com.esri.geometry/esri-geometry-api
static boolean mergeVertices(Point pt_1, Point pt_2, double w_1,
int rank_1, double w_2, int rank_2, Point pt_res, double[] w_res,
int[] rank_res) {
assert (!pt_1.isEmpty() && !pt_2.isEmpty());
boolean res = pt_1.equals(pt_2);
if (rank_1 > rank_2) {
pt_res = pt_1;
if (w_res != null) {
rank_res[0] = rank_1;
w_res[0] = w_1;
}
return res;
} else if (rank_2 > rank_1) {
pt_res = pt_2;
if (w_res != null) {
rank_res[0] = rank_1;
w_res[0] = w_1;
}
return res;
}
pt_res = pt_1;
Point2D pt2d = new Point2D();
mergeVertices2D(pt_1.getXY(), pt_2.getXY(), w_1, rank_1, w_2, rank_2,
pt2d, w_res, rank_res);
pt_res.setXY(pt2d);
return res;
}
代码示例来源:origin: Qihoo360/Quicksql
/** Returns the x-value of the first coordinate of {@code geom}. */
public static Double ST_X(Geom geom) {
return geom.g() instanceof Point ? ((Point) geom.g()).getX() : null;
}
代码示例来源:origin: Qihoo360/Quicksql
/** Returns the y-value of the first coordinate of {@code geom}. */
public static Double ST_Y(Geom geom) {
return geom.g() instanceof Point ? ((Point) geom.g()).getY() : null;
}
代码示例来源:origin: Esri/geometry-api-java
@Override
public void setPoint(int index, Point src) {
if (index < 0 || index >= m_pointCount)
throw new IndexOutOfBoundsException();
Point point = src;
if (src.isEmpty())// can not assign an empty point to a multipoint
// vertex
throw new IllegalArgumentException();
_verifyAllStreams();// verify all allocated streams are of necessary
// size.
VertexDescription vdin = point.getDescription();
for (int attributeIndex = 0; attributeIndex < vdin.getAttributeCount(); attributeIndex++) {
int semantics = vdin.getSemantics(attributeIndex);
int ncomp = VertexDescription.getComponentCount(semantics);
for (int icomp = 0; icomp < ncomp; icomp++) {
double v = point.getAttributeAsDbl(semantics, icomp);
setAttribute(semantics, index, icomp, v);
}
}
}
代码示例来源:origin: Esri/geometry-api-java
static Point difference(Point point, Point point2, double tolerance) {
if (point.isEmpty())
return (Point) point.createInstance();
if (point2.isEmpty())
return point;
if (CrackAndCluster.non_empty_points_need_to_cluster(tolerance, point,
point2)) {
return (Point) point.createInstance();
}
return point;
}
代码示例来源:origin: Esri/geometry-api-java
@Override
public void replaceNaNs(int semantics, double value) {
addAttribute(semantics);
if (isEmpty())
return;
int ncomps = VertexDescription.getComponentCount(semantics);
for (int i = 0; i < ncomps; i++) {
double v = getAttributeAsDbl(semantics, i);
if (Double.isNaN(v))
setAttribute(semantics, i, value);
}
}
}
代码示例来源:origin: Esri/geometry-api-java
/**
* Constructs an envelope that covers the given point. The coordinates of
* the point are used to set the extent of the envelope.
*
* @param point The point that the envelope covers.
*/
public Envelope(Point point) {
m_description = VertexDescriptionDesignerImpl.getDefaultDescriptor2D();
m_envelope.setEmpty();
if (point.isEmpty())
return;
_setFromPoint(point);
}
代码示例来源:origin: com.esri.geometry/esri-geometry-api
public void startPath(Point point) {
if (point.isEmpty())
throw new IllegalArgumentException();// throw new
// IllegalArgumentException();
mergeVertexDescription(point.getDescription());
_initPathStartPoint();
point.copyTo(m_moveToPoint);
// TODO check MultiPathImpl.cpp comment
// "//the description will be merged later"
// assignVertexDescription(m_moveToPoint.getDescription());
m_bPathStarted = true;
}
代码示例来源:origin: Esri/geometry-api-java
public double Z() {
return point.getZ();
}
内容来源于网络,如有侵权,请联系作者删除!