当前位置: 首页>>代码示例>>Java>>正文


Java Point.getX方法代码示例

本文整理汇总了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;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:31,代码来源:ObservationLocation.java

示例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;
                }
            }
        }
    }
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:30,代码来源:LocationEditActivity.java

示例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));
				}
			}
		}
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:30,代码来源:GeometryUtils.java

示例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);
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:26,代码来源:CentroidSurface.java

示例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;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:29,代码来源:LocationLoadTask.java

示例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;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:33,代码来源:MapUtils.java

示例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;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:37,代码来源:LocationMarkerCollection.java

示例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;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:28,代码来源:LocationTask.java

示例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));

}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:12,代码来源:ObservationFormPickerActivity.java

示例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));
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:21,代码来源:CentroidCurve.java

示例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));
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:17,代码来源:GeometryUtils.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:50,代码来源:GeometryUtils.java

示例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);
		}
	}

}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:55,代码来源:GeometryUtilsTest.java

示例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());
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:6,代码来源:ObservationClusterCollection.java

示例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;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:11,代码来源:ObservationLocation.java


注:本文中的mil.nga.wkb.geom.Point.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。