mil.nga.sf.Point Java Examples
The following examples show how to use
mil.nga.sf.Point.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObservationLocation.java From mage-android with Apache License 2.0 | 6 votes |
/** * 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; }
Example #2
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 6 votes |
/** * Convert a {@link LineString} to a {@link PolylineOptions} * * @param lineString line string * @return polyline options */ public PolylineOptions toPolyline(LineString lineString) { PolylineOptions polylineOptions = new PolylineOptions(); Double z = null; // Try to simplify the number of points in the line string List<Point> points = simplifyPoints(lineString.getPoints()); for (Point point : points) { LatLng latLng = toLatLng(point); polylineOptions.add(latLng); if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); } } if (lineString.hasZ() && z != null) { polylineOptions.zIndex(z.floatValue()); } return polylineOptions; }
Example #3
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 6 votes |
/** * When the simplify tolerance is set, simplify the points to a similar * curve with fewer points. * * @param points ordered points * @return simplified points */ private List<Point> simplifyPoints(List<Point> points) { List<Point> simplifiedPoints = null; if (simplifyTolerance != null) { // Reproject to web mercator if not in meters if (projection != null && !projection.isUnit(Units.METRES)) { points = toWebMercator.transform(points); } // Simplify the points simplifiedPoints = GeometryUtils.simplifyPoints(points, simplifyTolerance); // Reproject back to the original projection if (projection != null && !projection.isUnit(Units.METRES)) { simplifiedPoints = fromWebMercator.transform(simplifiedPoints); } } else { simplifiedPoints = points; } return simplifiedPoints; }
Example #4
Source File: GeoPackagePerformance.java From geopackage-java with MIT License | 6 votes |
private static Geometry createGeometry() { Polygon polygon = new Polygon(); LineString ring = new LineString(); ring.addPoint(new Point(-104.802246, 39.720343)); ring.addPoint(new Point(-104.802246, 39.719753)); ring.addPoint(new Point(-104.802183, 39.719754)); ring.addPoint(new Point(-104.802184, 39.719719)); ring.addPoint(new Point(-104.802138, 39.719694)); ring.addPoint(new Point(-104.802097, 39.719691)); ring.addPoint(new Point(-104.802096, 39.719648)); ring.addPoint(new Point(-104.801646, 39.719648)); ring.addPoint(new Point(-104.801644, 39.719722)); ring.addPoint(new Point(-104.801550, 39.719723)); ring.addPoint(new Point(-104.801549, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720341)); ring.addPoint(new Point(-104.802246, 39.720343)); polygon.addRing(ring); return polygon; }
Example #5
Source File: TestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Create a random point * * @param hasZ * @param hasM * @return point */ public static Point createPoint(boolean hasZ, boolean hasM) { double x = Math.random() * 180.0 * (Math.random() < .5 ? 1 : -1); double y = Math.random() * ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE * (Math.random() < .5 ? 1 : -1); Point point = new Point(hasZ, hasM, x, y); if (hasZ) { double z = Math.random() * 1000.0; point.setZ(z); } if (hasM) { double m = Math.random() * 1000.0; point.setM(m); } return point; }
Example #6
Source File: GeoPackageGeometryDataUtils.java From geopackage-java with MIT License | 6 votes |
/** * Compare the two points for equality * * @param expected * @param actual */ private static void comparePoint(Point expected, Point actual, double delta) { compareBaseGeometryAttributes(expected, actual); TestCase.assertEquals(expected.getX(), actual.getX(), delta); TestCase.assertEquals(expected.getY(), actual.getY(), delta); if (expected.getZ() == null) { TestCase.assertEquals(expected.getZ(), actual.getZ()); } else { TestCase.assertEquals(expected.getZ(), actual.getZ(), delta); } if (expected.getM() == null) { TestCase.assertEquals(expected.getM(), actual.getM()); } else { TestCase.assertEquals(expected.getM(), actual.getM(), delta); } }
Example #7
Source File: FeatureUtils.java From geopackage-java with MIT License | 6 votes |
/** * Validate Point * * @param topGeometry * @param point */ private static void validatePoint(Geometry topGeometry, Point point) { TestCase.assertEquals(GeometryType.POINT, point.getGeometryType()); validateZAndM(topGeometry, point); if (topGeometry.hasZ()) { TestCase.assertNotNull(point.getZ()); } else { TestCase.assertNull(point.getZ()); } if (topGeometry.hasM()) { TestCase.assertNotNull(point.getM()); } else { TestCase.assertNull(point.getM()); } }
Example #8
Source File: UrlTileGeneratorUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test generating tiles with random bounds and zoomss * * @param geoPackage * @throws SQLException * @throws IOException */ public static void testGenerateTilesRandom(GeoPackage geoPackage) throws SQLException, IOException { for (int i = 0; i < 10; i++) { int minZoom = (int) (Math.random() * 3.0); int maxZoom = minZoom + ((int) (Math.random() * 3.0)); Point point1 = TestUtils.createPoint(false, false); Point point2 = TestUtils.createPoint(false, false); BoundingBox boundingBox = new BoundingBox(Math.min(point1.getX(), point2.getX()), Math.min(point1.getY(), point2.getY()), Math.max(point1.getX(), point2.getX()), Math.max( point1.getY(), point2.getY())); UrlTileGenerator tileGenerator = new UrlTileGenerator(geoPackage, TABLE_NAME + i, URL, minZoom, maxZoom, boundingBox, getProjection()); testGenerateTiles(tileGenerator); } }
Example #9
Source File: TestUtils.java From geopackage-android-map with MIT License | 6 votes |
/** * Create a random point * * @param hasZ * @param hasM * @return */ public static Point createPoint(boolean hasZ, boolean hasM) { double x = Math.random() * 180.0 * (Math.random() < .5 ? 1 : -1); double y = Math.random() * 90.0 * (Math.random() < .5 ? 1 : -1); Point point = new Point(hasZ, hasM, x, y); if (hasZ) { double z = Math.random() * 1000.0; point.setZ(z); } if (hasM) { double m = Math.random() * 1000.0; point.setM(m); } return point; }
Example #10
Source File: ObservationLoadTask.java From mage-android with Apache License 2.0 | 6 votes |
@Override protected Void doInBackground(Void... params ) { CloseableIterator<Observation> iterator = null; try { iterator = iterator(); while (iterator.hasNext() && !isCancelled()) { Observation o = iterator.current(); Geometry geometry = o.getGeometry(); Point centroid = GeometryUtils.getCentroid(geometry); MarkerOptions options = new MarkerOptions().position(new LatLng(centroid.getY(), centroid.getX())).icon(ObservationBitmapFactory.bitmapDescriptor(context, o)); publishProgress(new Pair<>(options, o)); } } catch (SQLException e) { e.printStackTrace(); } finally { if (iterator != null) { iterator.closeQuietly(); } } return null; }
Example #11
Source File: ObservationTask.java From mage-android with Apache License 2.0 | 6 votes |
@Override protected Void doInBackground(Observation... observations) { for (Observation o : observations) { boolean passesFilter = true; for (Filter filter : filters) { passesFilter = filter.passesFilter(o); if (!passesFilter) { break; } } if (passesFilter) { Geometry geometry = o.getGeometry(); Point centroid = GeometryUtils.getCentroid(geometry); MarkerOptions options = new MarkerOptions().position(new LatLng(centroid.getY(), centroid.getX())).icon(ObservationBitmapFactory.bitmapDescriptor(context, o)); publishProgress(new Pair<>(options, o)); } } return null; }
Example #12
Source File: DefaultFeatureTiles.java From geopackage-android with MIT License | 6 votes |
/** * Add the linestring to the path * * @param simplifyTolerance simplify tolerance in meters * @param boundingBox bounding box * @param transform projection transform * @param path path * @param lineString line string */ private void addLineString(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, LineString lineString) { List<Point> points = lineString.getPoints(); if (points.size() >= 2) { // Try to simplify the number of points in the LineString points = simplifyPoints(simplifyTolerance, points); for (int i = 0; i < points.size(); i++) { Point point = points.get(i); Point webMercatorPoint = transform.transform(point); float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox, webMercatorPoint.getX()); float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox, webMercatorPoint.getY()); if (i == 0) { path.moveTo(x, y); } else { path.lineTo(x, y); } } } }
Example #13
Source File: DefaultFeatureTiles.java From geopackage-android with MIT License | 6 votes |
/** * Add the polygon on the canvas * * @param simplifyTolerance simplify tolerance in meters * @param boundingBox bounding box * @param transform projection transform * @param path path * @param polygon polygon */ private void addPolygon(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, Polygon polygon) { List<LineString> rings = polygon.getRings(); if (!rings.isEmpty()) { // Add the polygon points LineString polygonLineString = rings.get(0); List<Point> polygonPoints = polygonLineString.getPoints(); if (polygonPoints.size() >= 2) { addRing(simplifyTolerance, boundingBox, transform, path, polygonPoints); // Add the holes for (int i = 1; i < rings.size(); i++) { LineString holeLineString = rings.get(i); List<Point> holePoints = holeLineString.getPoints(); if (holePoints.size() >= 2) { addRing(simplifyTolerance, boundingBox, transform, path, holePoints); } } } } }
Example #14
Source File: DefaultFeatureTiles.java From geopackage-android with MIT License | 6 votes |
/** * Add a ring * * @param simplifyTolerance simplify tolerance in meters * @param boundingBox bounding box * @param transform projection transform * @param path path * @param points points */ private void addRing(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, List<Point> points) { // Try to simplify the number of points in the LineString points = simplifyPoints(simplifyTolerance, points); for (int i = 0; i < points.size(); i++) { Point point = points.get(i); Point webMercatorPoint = transform.transform(point); float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox, webMercatorPoint.getX()); float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox, webMercatorPoint.getY()); if (i == 0) { path.moveTo(x, y); } else { path.lineTo(x, y); } } path.close(); }
Example #15
Source File: FeatureUtils.java From geopackage-android with MIT License | 6 votes |
/** * Validate Point * * @param topGeometry * @param point */ private static void validatePoint(Geometry topGeometry, Point point) { TestCase.assertEquals(GeometryType.POINT, point.getGeometryType()); validateZAndM(topGeometry, point); if (topGeometry.hasZ()) { TestCase.assertNotNull(point.getZ()); } else { TestCase.assertNull(point.getZ()); } if (topGeometry.hasM()) { TestCase.assertNotNull(point.getM()); } else { TestCase.assertNull(point.getM()); } }
Example #16
Source File: GeoPackageGeometryDataUtils.java From geopackage-android with MIT License | 6 votes |
/** * Compare the two points for equality * * @param expected * @param actual */ private static void comparePoint(Point expected, Point actual, double delta) { compareBaseGeometryAttributes(expected, actual); TestCase.assertEquals(expected.getX(), actual.getX(), delta); TestCase.assertEquals(expected.getY(), actual.getY(), delta); if (expected.getZ() == null) { TestCase.assertEquals(expected.getZ(), actual.getZ()); } else { TestCase.assertEquals(expected.getZ(), actual.getZ(), delta); } if (expected.getM() == null) { TestCase.assertEquals(expected.getM(), actual.getM()); } else { TestCase.assertEquals(expected.getM(), actual.getM(), delta); } }
Example #17
Source File: TestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Create a random point * * @param hasZ * @param hasM * @return */ public static Point createPoint(boolean hasZ, boolean hasM) { double x = Math.random() * 180.0 * (Math.random() < .5 ? 1 : -1); double y = Math.random() * ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE * (Math.random() < .5 ? 1 : -1); Point point = new Point(hasZ, hasM, x, y); if (hasZ) { double z = Math.random() * 1000.0; point.setZ(z); } if (hasM) { double m = Math.random() * 1000.0; point.setM(m); } return point; }
Example #18
Source File: GeoPackagePerformance.java From geopackage-android with MIT License | 6 votes |
private static Geometry createGeometry() { Polygon polygon = new Polygon(); LineString ring = new LineString(); ring.addPoint(new Point(-104.802246, 39.720343)); ring.addPoint(new Point(-104.802246, 39.719753)); ring.addPoint(new Point(-104.802183, 39.719754)); ring.addPoint(new Point(-104.802184, 39.719719)); ring.addPoint(new Point(-104.802138, 39.719694)); ring.addPoint(new Point(-104.802097, 39.719691)); ring.addPoint(new Point(-104.802096, 39.719648)); ring.addPoint(new Point(-104.801646, 39.719648)); ring.addPoint(new Point(-104.801644, 39.719722)); ring.addPoint(new Point(-104.801550, 39.719723)); ring.addPoint(new Point(-104.801549, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720341)); ring.addPoint(new Point(-104.802246, 39.720343)); polygon.addRing(ring); return polygon; }
Example #19
Source File: DefaultFeatureTiles.java From geopackage-java with MIT License | 5 votes |
/** * Get the path of the line string * * @param simplifyTolerance * simplify tolerance in meters * @param boundingBox * @param transform * @param lineString */ private Path2D getPath(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, LineString lineString) { Path2D path = null; // Try to simplify the number of points in the LineString List<Point> lineStringPoints = simplifyPoints(simplifyTolerance, lineString.getPoints()); for (Point point : lineStringPoints) { Point projectedPoint = transform.transform(point); float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox, projectedPoint.getX()); float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox, projectedPoint.getY()); if (path == null) { path = new Path2D.Double(); path.moveTo(x, y); } else { path.lineTo(x, y); } } return path; }
Example #20
Source File: FeatureUtils.java From geopackage-java with MIT License | 5 votes |
/** * Validate Multi Point * * @param topGeometry * @param multiPoint */ private static void validateMultiPoint(Geometry topGeometry, MultiPoint multiPoint) { TestCase.assertEquals(GeometryType.MULTIPOINT, multiPoint.getGeometryType()); validateZAndM(topGeometry, multiPoint); for (Point point : multiPoint.getPoints()) { validatePoint(topGeometry, point); } }
Example #21
Source File: MapObservationManager.java From mage-android with Apache License 2.0 | 5 votes |
/** * Add an observation to the map as a marker or shape * * @param observation observation * @param markerOptions marker options * @param visible visible state * @return map observation */ public MapObservation addToMap(Observation observation, MarkerOptions markerOptions, boolean visible) { MapObservation observationShape = null; Geometry geometry = observation.getGeometry(); if (geometry.getGeometryType() == GeometryType.POINT) { Point point = GeometryUtils.getCentroid(geometry); if(markerOptions == null) { markerOptions = getMarkerOptions(observation, visible); markerOptions.position(new LatLng(point.getY(), point.getX())); } Marker marker = map.addMarker(markerOptions); observationShape = new MapMarkerObservation(observation, marker); } else { GoogleMapShapeConverter shapeConverter = new GoogleMapShapeConverter(); GoogleMapShape shape = shapeConverter.toShape(geometry); prepareShapeOptions(observation, shape, visible); GoogleMapShape mapShape = GoogleMapShapeConverter.addShapeToMap(map, shape); observationShape = MapShapeObservation.create(observation, mapShape); } return observationShape; }
Example #22
Source File: LocationTask.java From mage-android with Apache License 2.0 | 5 votes |
@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; }
Example #23
Source File: ObservationFormPickerActivity.java From mage-android with Apache License 2.0 | 5 votes |
@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)); }
Example #24
Source File: FeatureUtils.java From geopackage-java with MIT License | 5 votes |
/** * Validate an updated point * * @param point */ private static void validateUpdatedPoint(Point point) { TestCase.assertEquals(POINT_UPDATED_X, point.getX()); TestCase.assertEquals(POINT_UPDATED_Y, point.getY()); if (point.hasZ()) { TestCase.assertEquals(POINT_UPDATED_Z, point.getZ()); } if (point.hasM()) { TestCase.assertEquals(POINT_UPDATED_M, point.getM()); } }
Example #25
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 5 votes |
private static LineString getLineString(double[][] points) { LineString lineString = new LineString(false, false); for (int i = 0; i < points.length; i++) { Point point = new Point(false, false, points[i][0], points[i][1]); lineString.addPoint(point); } return lineString; }
Example #26
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 5 votes |
public static void setPoint(FeatureRow featureRow, double x, double y) { GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Point point = new Point(false, false, x, y); geomData.setGeometry(point); featureRow.setGeometry(geomData); }
Example #27
Source File: TransactionTest.java From geopackage-android with MIT License | 5 votes |
/** * Insert a row into the feature table * * @param featureDao feature dao */ private void insertRow(FeatureDao featureDao) { FeatureRow row = featureDao.newRow(); GeoPackageGeometryData geometry = new GeoPackageGeometryData( featureDao.getGeometryColumns().getSrsId()); geometry.setGeometry(new Point(0, 0)); row.setGeometry(geometry); featureDao.insert(row); }
Example #28
Source File: TransactionTest.java From geopackage-java with MIT License | 5 votes |
/** * Insert a row into the feature table * * @param featureDao * feature dao */ private void insertRow(FeatureDao featureDao) { FeatureRow row = featureDao.newRow(); GeoPackageGeometryData geometry = new GeoPackageGeometryData(featureDao .getGeometryColumns().getSrsId()); geometry.setGeometry(new Point(0, 0)); row.setGeometry(geometry); featureDao.insert(row); }
Example #29
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Transform a WGS84 point to the projection * * @param point WGS84 point * @return projection point */ public Point toProjection(Point point) { if (projection != null) { point = fromWgs84.transform(point); } return point; }
Example #30
Source File: LocationLoadTask.java From mage-android with Apache License 2.0 | 5 votes |
@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; }