本文整理汇总了Java中mil.nga.wkb.geom.Point.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getY方法的具体用法?Java Point.getY怎么用?Java Point.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.wkb.geom.Point
的用法示例。
在下文中一共展示了Point.getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkIfRectangleAndFindSide
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Check if the points form a rectangle and return if the side one has the same x
*
* @param points points
* @return null if not a rectangle, true if same x side 1, false if same y side 1
*/
public static Boolean checkIfRectangleAndFindSide(List<Point> points) {
Boolean sameXSide1 = null;
int size = points.size();
if (size == 4 || size == 5) {
Point point1 = points.get(0);
Point lastPoint = points.get(points.size() - 1);
boolean closed = point1.getX() == lastPoint.getX() && point1.getY() == lastPoint.getY();
if ((closed && size == 5) || (!closed && size == 4)) {
Point point2 = points.get(1);
Point point3 = points.get(2);
Point point4 = points.get(3);
if (point1.getX() == point2.getX() && point2.getY() == point3.getY()) {
if (point1.getY() == point4.getY() && point3.getX() == point4.getX()) {
sameXSide1 = true;
}
} else if (point1.getY() == point2.getY() && point2.getX() == point3.getX()) {
if (point1.getX() == point4.getX() && point3.getY() == point4.getY()) {
sameXSide1 = false;
}
}
}
}
return sameXSide1;
}
示例2: updateIfRectangle
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Check if the points form a rectangle and update
*
* @param points points
*/
private void updateIfRectangle(List<Point> points) {
int size = points.size();
if (size == 4 || size == 5) {
Point point1 = points.get(0);
Point lastPoint = points.get(points.size() - 1);
boolean closed = point1.getX() == lastPoint.getX() && point1.getY() == lastPoint.getY();
if ((closed && size == 5) || (!closed && size == 4)) {
Point point2 = points.get(1);
Point point3 = points.get(2);
Point point4 = points.get(3);
if (point1.getX() == point2.getX() && point2.getY() == point3.getY()) {
if (point1.getY() == point4.getY() && point3.getX() == point4.getX()) {
isRectangle = true;
rectangleSameXSide1 = true;
}
} else if (point1.getY() == point2.getY() && point2.getX() == point3.getX()) {
if (point1.getX() == point4.getX() && point3.getY() == point4.getY()) {
isRectangle = true;
rectangleSameXSide1 = false;
}
}
}
}
}
示例3: add
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Add or subtract a line string to or from the centroid total
*
* @param positive
* true if an addition, false if a subtraction
* @param lineString
* line string
*/
private void add(boolean positive, LineString lineString) {
List<Point> points = lineString.getPoints();
Point firstPoint = points.get(0);
if (base == null) {
base = firstPoint;
}
for (int i = 0; i < points.size() - 1; i++) {
Point point = points.get(i);
Point nextPoint = points.get(i + 1);
addTriangle(positive, base, point, nextPoint);
}
Point lastPoint = points.get(points.size() - 1);
if (firstPoint.getX() != lastPoint.getX()
|| firstPoint.getY() != lastPoint.getY()) {
addTriangle(positive, base, lastPoint, firstPoint);
}
}
示例4: doInBackground
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
CloseableIterator<Location> iterator = null;
try {
iterator = iterator();
while (iterator.hasNext() && !isCancelled()) {
Location location = iterator.current();
User user = location.getUser();
if (user == null) {
continue;
}
Point point = GeometryUtils.getCentroid(location.getGeometry());
LatLng latLng = new LatLng(point.getY(), point.getX());
MarkerOptions options = new MarkerOptions().position(latLng).icon(LocationBitmapFactory.bitmapDescriptor(context, location, user));
publishProgress(new Pair<>(options, new Pair<>(location, user)));
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (iterator != null) {
iterator.closeQuietly();
}
}
return null;
}
示例5: polygonHasKinks
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
public static boolean polygonHasKinks(Polygon polygon) {
for (LineString line1 : polygon.getRings()) {
Point lastPoint = line1.getPoints().get(line1.numPoints() - 1);
for (LineString line2 : polygon.getRings()) {
for (int i = 0; i < line1.numPoints() - 1; i++) {
Point point1 = line1.getPoints().get(i);
Point nextPoint1 = line1.getPoints().get(i + 1);
for (int k = i; k < line2.numPoints() - 1; k++) {
Point point2 = line2.getPoints().get(k);
Point nextPoint2 = line2.getPoints().get(k + 1);
if (line1 != line2) {
continue;
}
if (Math.abs(i - k) == 1) {
continue;
}
if (i == 0 && k == line1.numPoints() - 2 && point1.getX() == lastPoint.getX() && point1.getY() == lastPoint.getY()) {
continue;
}
boolean intersects = intersects(point1, nextPoint1, point2, nextPoint2);
if (intersects) {
return true;
}
}
}
}
}
return false;
}
示例6: intersects
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
private static boolean intersects(Point point1Start, Point point1End, Point point2Start, Point point2End) {
double q =
//Distance between the lines' starting rows times line2's horizontal length
(point1Start.getY() - point2Start.getY()) * (point2End.getX() - point2Start.getX())
//Distance between the lines' starting columns times line2's vertical length
- (point1Start.getX() - point2Start.getX()) * (point2End.getY() - point2Start.getY());
double d =
//Line 1's horizontal length times line 2's vertical length
(point1End.getX() - point1Start.getX()) * (point2End.getY() - point2Start.getY())
//Line 1's vertical length times line 2's horizontal length
- (point1End.getY() - point1Start.getY()) * (point2End.getX() - point2Start.getX());
if (d == 0) {
return false;
}
double r = q / d;
q =
//Distance between the lines' starting rows times line 1's horizontal length
(point1Start.getY() - point2Start.getY()) * (point1End.getX() - point1Start.getX())
//Distance between the lines' starting columns times line 1's vertical length
- (point1Start.getX() - point2Start.getX()) * (point1End.getY() - point1Start.getY());
double s = q / d;
if( r < 0 || r > 1 || s < 0 || s > 1 ) {
return false;
}
return true;
}
示例7: onMarkerClick
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
@Override
public boolean onMarkerClick(Marker marker) {
Pair<Location, User> pair = markerIdToPair.get(marker.getId());
if (pair == null) {
return false;
}
Location location = pair.first;
User user = pair.second;
final Geometry g = location.getGeometry();
if (g != null) {
Point point = GeometryUtils.getCentroid(g);
LatLng latLng = new LatLng(point.getY(), point.getX());
LocationProperty accuracyProperty = location.getPropertiesMap().get("accuracy");
if (accuracyProperty != null && !accuracyProperty.getValue().toString().trim().isEmpty()) {
try {
Float accuracy = Float.valueOf(accuracyProperty.getValue().toString());
if (clickedAccuracyCircle != null) {
clickedAccuracyCircle.remove();
}
clickedAccuracyCircle = map.addCircle(new CircleOptions().center(latLng).radius(accuracy).fillColor(0x1D43b0ff).strokeColor(0x620069cc).strokeWidth(1.0f));
clickedAccuracyCircleUserId = user.getId();
} catch (NumberFormatException nfe) {
Log.e(LOG_NAME, "Problem adding accuracy circle to the map.", nfe);
}
}
}
map.setInfoWindowAdapter(infoWindowAdapter);
// make sure to set the Anchor after this call as well, because the size of the icon might have changed
marker.setIcon(LocationBitmapFactory.bitmapDescriptor(context, location, user));
marker.setAnchor(0.5f, 1.0f);
marker.showInfoWindow();
return true;
}
示例8: doInBackground
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Location... locations) {
for (Location location : locations) {
User user = location.getUser();
if (user == null) {
continue;
}
boolean passesFilter = true;
for (Filter filter : filters) {
passesFilter = filter.passesFilter(location);
if (!passesFilter) {
break;
}
}
if (passesFilter) {
Point point = GeometryUtils.getCentroid(location.getGeometry());
LatLng latLng = new LatLng(point.getY(), point.getX());
MarkerOptions options = new MarkerOptions().position(latLng).icon(LocationBitmapFactory.bitmapDescriptor(context, location, user));
publishProgress(new Pair<>(options, new Pair<>(location, user)));
}
}
return null;
}
示例9: onMapReady
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
@Override
public void onMapReady(final GoogleMap map) {
ObservationLocation location = getIntent().getParcelableExtra(ObservationEditActivity.LOCATION);
Point centroid = location.getCentroid();
LatLng latLng = new LatLng(centroid.getY(), centroid.getX());
float zoom = getIntent().getFloatExtra(ObservationEditActivity.INITIAL_ZOOM, 0);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
}
示例10: add
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Add points to the centroid total
*
* @param points
* points
*/
private void add(List<Point> points) {
for (int i = 0; i < points.size() - 1; i++) {
Point point = points.get(i);
Point nextPoint = points.get(i + 1);
double length = GeometryUtils.distance(point, nextPoint);
totalLength += length;
double midX = (point.getX() + nextPoint.getX()) / 2;
sum.setX(sum.getX() + (length * midX));
double midY = (point.getY() + nextPoint.getY()) / 2;
sum.setY(sum.getY() + (length * midY));
}
}
示例11: perpendicularDistance
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Calculate the perpendicular distance between the point and the line
* represented by the start and end points. Points should be in a meters
* unit type projection.
*
* @param point
* point
* @param lineStart
* point representing the line start
* @param lineEnd
* point representing the line end
* @return distance in meters
* @since 1.0.4
*/
public static double perpendicularDistance(Point point, Point lineStart,
Point lineEnd) {
double x = point.getX();
double y = point.getY();
double startX = lineStart.getX();
double startY = lineStart.getY();
double endX = lineEnd.getX();
double endY = lineEnd.getY();
double vX = endX - startX;
double vY = endY - startY;
double wX = x - startX;
double wY = y - startY;
double c1 = wX * vX + wY * vY;
double c2 = vX * vX + vY * vY;
double x2;
double y2;
if (c1 <= 0) {
x2 = startX;
y2 = startY;
} else if (c2 <= c1) {
x2 = endX;
y2 = endY;
} else {
double b = c1 / c2;
x2 = startX + b * vX;
y2 = startY + b * vY;
}
double distance = Math.sqrt(Math.pow(x2 - x, 2) + Math.pow(y2 - y, 2));
return distance;
}
示例12: getPosition
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
@Override
public LatLng getPosition() {
Point point = GeometryUtils.getCentroid(observation.getGeometry());
return new LatLng(point.getY(), point.getX());
}
示例13: getFirstLatLng
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Get the first point from the geometry as a {@link LatLng}
*
* @return lat lng
*/
public LatLng getFirstLatLng() {
Point point = getFirstPoint();
LatLng latLng = new LatLng(point.getY(), point.getX());
return latLng;
}
示例14: getCentroidLatLng
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Get the geometry centroid as a LatLng
*
* @return centroid point lat lng
*/
public LatLng getCentroidLatLng() {
Point point = GeometryUtils.getCentroid(geometry);
LatLng latLng = new LatLng(point.getY(), point.getX());
return latLng;
}
示例15: addPointMessage
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Add Point
*
* @param envelope
* @param point
*/
private static void addPointMessage(GeometryEnvelope envelope, Point point) {
updateHasZandM(envelope, point);
double x = point.getX();
double y = point.getY();
if (x < envelope.getMinX()) {
envelope.setMinX(x);
}
if (x > envelope.getMaxX()) {
envelope.setMaxX(x);
}
if (y < envelope.getMinY()) {
envelope.setMinY(y);
}
if (y > envelope.getMaxY()) {
envelope.setMaxY(y);
}
if (point.hasZ()) {
Double z = point.getZ();
if (z != null) {
if (envelope.getMinZ() == null || z < envelope.getMinZ()) {
envelope.setMinZ(z);
}
if (envelope.getMaxZ() == null || z > envelope.getMaxZ()) {
envelope.setMaxZ(z);
}
}
}
if (point.hasM()) {
Double m = point.getM();
if (m != null) {
if (envelope.getMinM() == null || m < envelope.getMinM()) {
envelope.setMinM(m);
}
if (envelope.getMaxM() == null || m > envelope.getMaxM()) {
envelope.setMaxM(m);
}
}
}
}