本文整理汇总了Java中mil.nga.wkb.geom.Point.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getX方法的具体用法?Java Point.getX怎么用?Java Point.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.wkb.geom.Point
的用法示例。
在下文中一共展示了Point.getX方法的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: minimize
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Minimize the line string
*
* @param lineString
* line string
* @param maxX
* max positive x value in the geometry projection
*/
private static void minimize(LineString lineString, double maxX) {
List<Point> points = lineString.getPoints();
if (points.size() > 1) {
Point point = points.get(0);
for (int i = 1; i < points.size(); i++) {
Point nextPoint = points.get(i);
if (point.getX() < nextPoint.getX()) {
if (nextPoint.getX() - point.getX() > point.getX()
- nextPoint.getX() + (maxX * 2.0)) {
nextPoint.setX(nextPoint.getX() - (maxX * 2.0));
}
} else if (point.getX() > nextPoint.getX()) {
if (point.getX() - nextPoint.getX() > nextPoint.getX()
- point.getX() + (maxX * 2.0)) {
nextPoint.setX(nextPoint.getX() + (maxX * 2.0));
}
}
}
}
}
示例4: 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);
}
}
示例5: 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;
}
示例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: normalize
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
/**
* Normalize the point
*
* @param point
* point
* @param maxX
* max positive x value in the geometry projection
*/
private static void normalize(Point point, double maxX) {
if (point.getX() < -maxX) {
point.setX(point.getX() + (maxX * 2.0));
} else if (point.getX() > maxX) {
point.setX(point.getX() - (maxX * 2.0));
}
}
示例12: 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;
}
示例13: testCopyMinimizeAndNormalize
import mil.nga.wkb.geom.Point; //导入方法依赖的package包/类
@Test
public void testCopyMinimizeAndNormalize() {
Polygon polygon = new Polygon();
LineString ring = new LineString();
double random = Math.random();
if (random < .5) {
ring.addPoint(createPoint(90.0, 0.0, 90.0, 90.0));
ring.addPoint(createPoint(90.0, -90.0, 90.0, 90.0));
ring.addPoint(createPoint(-180.0, -90.0, 89.0, 90.0));
ring.addPoint(createPoint(-180.0, 0.0, 89.0, 90.0));
} else {
ring.addPoint(createPoint(-180.0, 0.0, 89.0, 90.0));
ring.addPoint(createPoint(-180.0, -90.0, 89.0, 90.0));
ring.addPoint(createPoint(90.0, -90.0, 90.0, 90.0));
ring.addPoint(createPoint(90.0, 0.0, 90.0, 90.0));
}
polygon.addRing(ring);
Polygon polygon2 = (Polygon) polygon.copy();
GeometryUtils.minimizeGeometry(polygon2, 180.0);
Polygon polygon3 = (Polygon) polygon2.copy();
GeometryUtils.normalizeGeometry(polygon3, 180.0);
List<Point> points = ring.getPoints();
LineString ring2 = polygon2.getRings().get(0);
List<Point> points2 = ring2.getPoints();
LineString ring3 = polygon3.getRings().get(0);
List<Point> points3 = ring3.getPoints();
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
Point point2 = points2.get(i);
Point point3 = points3.get(i);
TestCase.assertEquals(point.getY(), point2.getY(), .0000000001);
TestCase.assertEquals(point.getY(), point3.getY(), .0000000001);
TestCase.assertEquals(point.getX(), point3.getX(), .0000000001);
if (i < 2) {
TestCase.assertEquals(point.getX(), point2.getX(), .0000000001);
} else {
double point2Value = point2.getX();
if (random < .5) {
point2Value -= 360.0;
} else {
point2Value += 360.0;
}
TestCase.assertEquals(point.getX(), point2Value, .0000000001);
}
}
}
示例14: 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());
}
示例15: 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;
}