本文整理了Java中com.esri.core.geometry.Point.<init>()
方法的一些代码示例,展示了Point.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.<init>()
方法的具体详情如下:
包路径:com.esri.core.geometry.Point
类名称:Point
方法名:<init>
[英]Creates an empty 2D point.
[中]创建一个空的二维点。
代码示例来源: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: prestodb/presto
private static Point tileXYToLatitudeLongitude(int tileX, int tileY, int zoomLevel)
{
long mapSize = mapSize(zoomLevel);
double x = (clip(tileX * TILE_PIXELS, 0, mapSize) / mapSize) - 0.5;
double y = 0.5 - (clip(tileY * TILE_PIXELS, 0, mapSize) / mapSize);
double latitude = 90 - 360 * Math.atan(Math.exp(-y * 2 * Math.PI)) / Math.PI;
double longitude = 360 * x;
return new Point(longitude, latitude);
}
代码示例来源:origin: prestodb/presto
@Test
public void testSTEnvelopeAsPts()
{
assertEnvelopeAsPts("MULTIPOINT (1 2, 2 4, 3 6, 4 8)", new Point(1, 2), new Point(4, 8));
assertFunction("ST_EnvelopeAsPts(ST_GeometryFromText('LINESTRING EMPTY'))", new ArrayType(GEOMETRY), null);
assertEnvelopeAsPts("LINESTRING (1 1, 2 2, 1 3)", new Point(1, 1), new Point(2, 3));
assertEnvelopeAsPts("LINESTRING (8 4, 5 7)", new Point(5, 4), new Point(8, 7));
assertEnvelopeAsPts("MULTILINESTRING ((1 1, 5 1), (2 4, 4 4))", new Point(1, 1), new Point(5, 4));
assertEnvelopeAsPts("POLYGON ((1 1, 4 1, 1 4))", new Point(1, 1), new Point(4, 4));
assertEnvelopeAsPts("MULTIPOLYGON (((1 1, 1 3, 3 3, 3 1)), ((0 0, 0 2, 2 2, 2 0)))", new Point(0, 0), new Point(3, 3));
assertEnvelopeAsPts("GEOMETRYCOLLECTION (POINT (5 1), LINESTRING (3 4, 4 4))", new Point(3, 1), new Point(5, 4));
assertEnvelopeAsPts("POINT (1 2)", new Point(1, 2), new Point(1, 2));
}
代码示例来源:origin: apache/drill
public void eval() {
double lon = lonParam.value;
double lat = latParam.value;
com.esri.core.geometry.ogc.OGCPoint point = new com.esri.core.geometry.ogc.OGCPoint(
new com.esri.core.geometry.Point(lon, lat), com.esri.core.geometry.SpatialReference.create(4326));
java.nio.ByteBuffer pointBytes = point.asBinary();
out.buffer = buffer;
out.start = 0;
out.end = pointBytes.remaining();
buffer.setBytes(0, pointBytes);
}
}
代码示例来源:origin: prestodb/presto
private List<OGCGeometry> makeGeometries()
{
ImmutableList.Builder<OGCGeometry> geometries = ImmutableList.builder();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
geometries.add(new OGCPoint(new Point(-10 + i, -10 + j), null));
}
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
geometries.add(new OGCPoint(new Point(-10 + 2 * i, 2 * j), null));
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
geometries.add(new OGCPoint(new Point(2.5 * i, -10 + 2.5 * j), null));
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
geometries.add(new OGCPoint(new Point(5 * i, 5 * j), null));
}
}
return geometries.build();
}
代码示例来源:origin: prestodb/presto
corners.add(new Point(envelope.getXMin(), envelope.getYMin()));
corners.add(new Point(envelope.getXMin(), envelope.getYMax()));
corners.add(new Point(envelope.getXMax(), envelope.getYMin()));
corners.add(new Point(envelope.getXMax(), envelope.getYMax()));
代码示例来源:origin: prestodb/presto
private static Point computePointsCentroid(MultiVertexGeometry multiVertex)
{
double xSum = 0;
double ySum = 0;
for (int i = 0; i < multiVertex.getPointCount(); i++) {
Point point = multiVertex.getPoint(i);
xSum += point.getX();
ySum += point.getY();
}
return new Point(xSum / multiVertex.getPointCount(), ySum / multiVertex.getPointCount());
}
代码示例来源:origin: prestodb/presto
@Description("Returns the Geometry value that represents the point set intersection of two Geometries")
@ScalarFunction("ST_Intersection")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stIntersection(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right)
{
if (deserializeType(left) == GeometrySerializationType.ENVELOPE && deserializeType(right) == GeometrySerializationType.ENVELOPE) {
Envelope leftEnvelope = deserializeEnvelope(left);
Envelope rightEnvelope = deserializeEnvelope(right);
// Envelope#intersect updates leftEnvelope to the intersection of the two envelopes
if (!leftEnvelope.intersect(rightEnvelope)) {
return EMPTY_POLYGON;
}
Envelope intersection = leftEnvelope;
if (intersection.getXMin() == intersection.getXMax()) {
if (intersection.getYMin() == intersection.getYMax()) {
return serialize(createFromEsriGeometry(new Point(intersection.getXMin(), intersection.getXMax()), null));
}
return serialize(createFromEsriGeometry(new Polyline(new Point(intersection.getXMin(), intersection.getYMin()), new Point(intersection.getXMin(), intersection.getYMax())), null));
}
if (intersection.getYMin() == intersection.getYMax()) {
return serialize(createFromEsriGeometry(new Polyline(new Point(intersection.getXMin(), intersection.getYMin()), new Point(intersection.getXMax(), intersection.getYMin())), null));
}
return serialize(intersection);
}
OGCGeometry leftGeometry = deserialize(left);
OGCGeometry rightGeometry = deserialize(right);
verifySameSpatialReference(leftGeometry, rightGeometry);
return serialize(leftGeometry.intersection(rightGeometry));
}
代码示例来源:origin: prestodb/presto
@Description("Returns a Geometry type Point object with the given coordinate values")
@ScalarFunction("ST_Point")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stPoint(@SqlType(DOUBLE) double x, @SqlType(DOUBLE) double y)
{
OGCGeometry geometry = createFromEsriGeometry(new Point(x, y), null);
return serialize(geometry);
}
代码示例来源:origin: prestodb/presto
private static Point computeMultiPolygonCentroid(OGCMultiPolygon multiPolygon)
{
double xSum = 0;
double ySum = 0;
double weightSum = 0;
for (int i = 0; i < multiPolygon.numGeometries(); i++) {
Point centroid = computePolygonCentroid((Polygon) multiPolygon.geometryN(i).getEsriGeometry());
Polygon polygon = (Polygon) multiPolygon.geometryN(i).getEsriGeometry();
double weight = polygon.calculateArea2D();
weightSum += weight;
xSum += centroid.getX() * weight;
ySum += centroid.getY() * weight;
}
return new Point(xSum / weightSum, ySum / weightSum);
}
代码示例来源:origin: prestodb/presto
@SqlNullable
@Description("Returns the lower left and upper right corners of bounding rectangular polygon of a Geometry")
@ScalarFunction("ST_EnvelopeAsPts")
@SqlType("array(" + GEOMETRY_TYPE_NAME + ")")
public static Block stEnvelopeAsPts(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
Envelope envelope = deserializeEnvelope(input);
if (envelope == null) {
return null;
}
BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, 2);
Point lowerLeftCorner = new Point(envelope.getXMin(), envelope.getYMin());
Point upperRightCorner = new Point(envelope.getXMax(), envelope.getYMax());
GEOMETRY.writeSlice(blockBuilder, serialize(createFromEsriGeometry(lowerLeftCorner, null, false)));
GEOMETRY.writeSlice(blockBuilder, serialize(createFromEsriGeometry(upperRightCorner, null, false)));
return blockBuilder.build();
}
代码示例来源:origin: prestodb/presto
private static Point computeLineCentroid(Polyline polyline)
{
double xSum = 0;
double ySum = 0;
double weightSum = 0;
for (int i = 0; i < polyline.getPathCount(); i++) {
Point startPoint = polyline.getPoint(polyline.getPathStart(i));
Point endPoint = polyline.getPoint(polyline.getPathEnd(i) - 1);
double dx = endPoint.getX() - startPoint.getX();
double dy = endPoint.getY() - startPoint.getY();
double length = sqrt(dx * dx + dy * dy);
weightSum += length;
xSum += (startPoint.getX() + endPoint.getX()) * length / 2;
ySum += (startPoint.getY() + endPoint.getY()) * length / 2;
}
return new Point(xSum / weightSum, ySum / weightSum);
}
代码示例来源:origin: prestodb/presto
private static Point computePolygonCentroid(Polygon polygon)
{
int pathCount = polygon.getPathCount();
if (pathCount == 1) {
return getPolygonSansHolesCentroid(polygon);
}
double xSum = 0;
double ySum = 0;
double areaSum = 0;
for (int i = 0; i < pathCount; i++) {
int startIndex = polygon.getPathStart(i);
int endIndex = polygon.getPathEnd(i);
Polygon sansHoles = getSubPolygon(polygon, startIndex, endIndex);
Point centroid = getPolygonSansHolesCentroid(sansHoles);
double area = sansHoles.calculateArea2D();
xSum += centroid.getX() * area;
ySum += centroid.getY() * area;
areaSum += area;
}
return new Point(xSum / areaSum, ySum / areaSum);
}
代码示例来源:origin: prestodb/presto
if (!multiType && ((MultiPoint) geometry).getPointCount() <= 1) {
if (geometry.isEmpty()) {
return new OGCPoint(new Point(), null);
代码示例来源: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: apache/drill
new com.esri.core.geometry.Point(result.x, result.y), sr).asBinary();
} else {
com.esri.core.geometry.Geometry esriGeom = geomSrc.getEsriGeometry();
代码示例来源:origin: prestodb/presto
return serialize(createFromEsriGeometry(new Point(), geometry.getEsriSpatialReference()));
代码示例来源:origin: Esri/geometry-api-java
/**
* Returns the envelope's upper right corner point.
*
* @return Returns the upper right corner point.
*/
public Point getUpperRight() {
return new Point(m_envelope.getUpperRight());
}
代码示例来源:origin: Esri/geometry-api-java
/**
* Returns the envelope's lower right corner point.
*
* @return Returns the lower right corner point.
*/
public Point getLowerRight() {
return new Point(m_envelope.getLowerRight());
}
代码示例来源:origin: Esri/geometry-api-java
@Override
public OGCGeometry reduceFromMulti() {
int n = numGeometries();
if (n == 0) {
return new OGCPoint(new Point(multiPoint.getDescription()), esriSR);
}
if (n == 1) {
return geometryN(0);
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!