mil.nga.sf.Polygon Java Examples
The following examples show how to use
mil.nga.sf.Polygon.
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: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 6 votes |
/** * Compare Polygon with Map Polygon * * @param converter * @param polygon * @param polygon2 */ private static void comparePolygonAndMapPolygon(GoogleMapShapeConverter converter, Polygon polygon, PolygonOptions polygon2) { List<LineString> rings = polygon.getRings(); List<LatLng> points = polygon2.getPoints(); List<List<LatLng>> holes = polygon2.getHoles(); TestCase.assertEquals(polygon.numRings(), 1 + holes.size()); LineString polygonRing = rings.get(0); compareLineStringAndLatLngs(converter, polygonRing, points); for (int i = 1; i < rings.size(); i++) { LineString ring = rings.get(i); List<LatLng> hole = holes.get(i - 1); compareLineStringAndLatLngs(converter, ring, hole); } }
Example #2
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 #3
Source File: DefaultFeatureTiles.java From geopackage-java with MIT License | 6 votes |
/** * Get the area of the polygon * * @param simplifyTolerance * simplify tolerance in meters * @param boundingBox * @param transform * @param lineString */ private Area getArea(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Polygon polygon) { Area area = null; for (LineString ring : polygon.getRings()) { Path2D path = getPath(simplifyTolerance, boundingBox, transform, ring); Area ringArea = new Area(path); if (area == null) { area = ringArea; } else { area.subtract(ringArea); } } return area; }
Example #4
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 6 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example #5
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 #6
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 6 votes |
/** * Test the PolyhedralSurface conversion * * @param converter * @param polyhedralSurface */ private static void convertMultiPolygon(GoogleMapShapeConverter converter, PolyhedralSurface polyhedralSurface) { MultiPolygonOptions mapPolygons = converter .toPolygons(polyhedralSurface); TestCase.assertNotNull(mapPolygons); TestCase.assertFalse(mapPolygons.getPolygonOptions().isEmpty()); List<Polygon> polygons = polyhedralSurface.getPolygons(); comparePolygonsAndMapPolygons(converter, polygons, mapPolygons.getPolygonOptions()); PolyhedralSurface polyhedralSurface2 = converter .toPolyhedralSurfaceWithOptions(mapPolygons); comparePolygons(polygons, polyhedralSurface.getPolygons()); }
Example #7
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 #8
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Test the Polygon conversion * * @param converter * @param polygon */ private static void convertPolygon(GoogleMapShapeConverter converter, Polygon polygon) { PolygonOptions polygonOptions = converter.toPolygon(polygon); TestCase.assertNotNull(polygonOptions); comparePolygonAndMapPolygon(converter, polygon, polygonOptions); Polygon polygon2 = converter.toPolygon(polygonOptions); comparePolygons(polygon, polygon2); }
Example #9
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Compare two lists of polygons * * @param polygons * @param polygons2 */ private static void comparePolygons(List<Polygon> polygons, List<Polygon> polygons2) { TestCase.assertEquals(polygons.size(), polygons2.size()); for (int i = 0; i < polygons.size(); i++) { comparePolygons(polygons.get(i), polygons2.get(i)); } }
Example #10
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Compare two Polygons * * @param polygon * @param polygon2 */ private static void comparePolygons(Polygon polygon, Polygon polygon2) { List<LineString> rings = polygon.getRings(); List<LineString> rings2 = polygon2.getRings(); TestCase.assertEquals(polygon.numRings(), polygon2.numRings()); for (int i = 0; i < polygon.numRings(); i++) { compareLineStrings(rings.get(i), rings2.get(i)); } }
Example #11
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Test the MultiPolygon conversion * * @param converter * @param multiPolygon */ private static void convertMultiPolygon(GoogleMapShapeConverter converter, MultiPolygon multiPolygon) { MultiPolygonOptions mapPolygons = converter.toPolygons(multiPolygon); TestCase.assertNotNull(mapPolygons); TestCase.assertFalse(mapPolygons.getPolygonOptions().isEmpty()); List<Polygon> polygons = multiPolygon.getPolygons(); comparePolygonsAndMapPolygons(converter, polygons, mapPolygons.getPolygonOptions()); MultiPolygon multiPolygon2 = converter .toMultiPolygonFromOptions(mapPolygons); comparePolygons(polygons, multiPolygon2.getPolygons()); }
Example #12
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Compare list of polygons with list of map polygons * * @param converter * @param polygons * @param mapPolygons */ private static void comparePolygonsAndMapPolygons(GoogleMapShapeConverter converter, List<Polygon> polygons, List<PolygonOptions> mapPolygons) { TestCase.assertEquals(polygons.size(), mapPolygons.size()); for (int i = 0; i < polygons.size(); i++) { comparePolygonAndMapPolygon(converter, polygons.get(i), mapPolygons.get(i)); } }
Example #13
Source File: FeatureUtils.java From geopackage-android with MIT License | 5 votes |
/** * Validate Multi Polygon * * @param topGeometry * @param multiPolygon */ private static void validateMultiPolygon(Geometry topGeometry, MultiPolygon multiPolygon) { TestCase.assertEquals(GeometryType.MULTIPOLYGON, multiPolygon.getGeometryType()); validateZAndM(topGeometry, multiPolygon); for (Polygon polygon : multiPolygon.getPolygons()) { validatePolygon(topGeometry, polygon); } }
Example #14
Source File: GeoPackageGeometryDataUtils.java From geopackage-android with MIT License | 5 votes |
/** * Compare the two polygons for equality * * @param expected * @param actual * @param delta */ private static void comparePolygon(Polygon expected, Polygon actual, double delta) { compareBaseGeometryAttributes(expected, actual); TestCase.assertEquals(expected.numRings(), actual.numRings()); for (int i = 0; i < expected.numRings(); i++) { compareLineString(expected.getRings().get(i), actual.getRings() .get(i), delta); } }
Example #15
Source File: MapUtils.java From mage-android with Apache License 2.0 | 5 votes |
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; }
Example #16
Source File: FeatureUtils.java From geopackage-java with MIT License | 5 votes |
/** * Validate Multi Polygon * * @param topGeometry * @param multiPolygon */ private static void validateMultiPolygon(Geometry topGeometry, MultiPolygon multiPolygon) { TestCase.assertEquals(GeometryType.MULTIPOLYGON, multiPolygon.getGeometryType()); validateZAndM(topGeometry, multiPolygon); for (Polygon polygon : multiPolygon.getPolygons()) { validatePolygon(topGeometry, polygon); } }
Example #17
Source File: GeoPackageGeometryDataUtils.java From geopackage-java with MIT License | 5 votes |
/** * Compare the two polygons for equality * * @param expected * @param actual * @param delta */ private static void comparePolygon(Polygon expected, Polygon actual, double delta) { compareBaseGeometryAttributes(expected, actual); TestCase.assertEquals(expected.numRings(), actual.numRings()); for (int i = 0; i < expected.numRings(); i++) { compareLineString(expected.getRings().get(i), actual.getRings() .get(i), delta); } }
Example #18
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example #19
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a {@link PolyhedralSurface} to a {@link MultiPolygonOptions} * * @param polyhedralSurface polyhedral surface * @return multi polygon options */ public MultiPolygonOptions toPolygons(PolyhedralSurface polyhedralSurface) { MultiPolygonOptions polygons = new MultiPolygonOptions(); for (Polygon polygon : polyhedralSurface.getPolygons()) { PolygonOptions polygonOptions = toPolygon(polygon); polygons.add(polygonOptions); } return polygons; }
Example #20
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a {@link MultiPolygon} to a {@link MultiPolygonOptions} * * @param multiPolygon multi polygon * @return multi polygon options */ public MultiPolygonOptions toPolygons(MultiPolygon multiPolygon) { MultiPolygonOptions polygons = new MultiPolygonOptions(); for (Polygon polygon : multiPolygon.getPolygons()) { PolygonOptions polygonOptions = toPolygon(polygon); polygons.add(polygonOptions); } return polygons; }
Example #21
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a list of {@link com.google.android.gms.maps.model.Polygon} to a * {@link MultiPolygon} * * @param polygonList polygon list * @param hasZ has z flag * @param hasM has m flag * @return multi polygon */ public MultiPolygon toMultiPolygon( List<com.google.android.gms.maps.model.Polygon> polygonList, boolean hasZ, boolean hasM) { MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM); for (com.google.android.gms.maps.model.Polygon mapPolygon : polygonList) { Polygon polygon = toPolygon(mapPolygon); multiPolygon.addPolygon(polygon); } return multiPolygon; }
Example #22
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a list of {@link Polygon} to a {@link MultiPolygon} * * @param polygonList polygon list * @param hasZ has z flag * @param hasM has m flag * @return multi polygon */ public MultiPolygon createMultiPolygon(List<Polygon> polygonList, boolean hasZ, boolean hasM) { MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM); for (Polygon polygon : polygonList) { multiPolygon.addPolygon(polygon); } return multiPolygon; }
Example #23
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a list of {@link PolygonOptions} to a {@link MultiPolygon} * * @param multiPolygonOptions multi polygon options * @param hasZ has z flag * @param hasM has m flag * @return multi polygon */ public MultiPolygon toMultiPolygonFromOptions( MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) { MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM); for (PolygonOptions mapPolygon : multiPolygonOptions .getPolygonOptions()) { Polygon polygon = toPolygon(mapPolygon); multiPolygon.addPolygon(polygon); } return multiPolygon; }
Example #24
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a list of {@link Polygon} to a {@link PolyhedralSurface} * * @param polygonList polygon list * @param hasZ has z flag * @param hasM has m flag * @return polyhedral surface */ public PolyhedralSurface toPolyhedralSurface( List<com.google.android.gms.maps.model.Polygon> polygonList, boolean hasZ, boolean hasM) { PolyhedralSurface polyhedralSurface = new PolyhedralSurface(hasZ, hasM); for (com.google.android.gms.maps.model.Polygon mapPolygon : polygonList) { Polygon polygon = toPolygon(mapPolygon); polyhedralSurface.addPolygon(polygon); } return polyhedralSurface; }
Example #25
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Add a Polygon to the map as markers * * @param shapeMarkers google map shape markers * @param map google map * @param polygonOptions polygon options * @param polygonMarkerOptions polygon marker options * @param polygonMarkerHoleOptions polygon marker hole options * @param globalPolygonOptions global polygon options * @return polygon markers */ public PolygonMarkers addPolygonToMapAsMarkers( GoogleMapShapeMarkers shapeMarkers, GoogleMap map, PolygonOptions polygonOptions, MarkerOptions polygonMarkerOptions, MarkerOptions polygonMarkerHoleOptions, PolygonOptions globalPolygonOptions) { PolygonMarkers polygonMarkers = new PolygonMarkers(this); if (globalPolygonOptions != null) { polygonOptions.fillColor(globalPolygonOptions.getFillColor()); polygonOptions.strokeColor(globalPolygonOptions.getStrokeColor()); polygonOptions.geodesic(globalPolygonOptions.isGeodesic()); polygonOptions.visible(globalPolygonOptions.isVisible()); polygonOptions.zIndex(globalPolygonOptions.getZIndex()); polygonOptions.strokeWidth(globalPolygonOptions.getStrokeWidth()); } com.google.android.gms.maps.model.Polygon polygon = addPolygonToMap( map, polygonOptions); polygonMarkers.setPolygon(polygon); List<Marker> markers = addPointsToMapAsMarkers(map, polygon.getPoints(), polygonMarkerOptions, true); polygonMarkers.setMarkers(markers); for (List<LatLng> holes : polygon.getHoles()) { List<Marker> holeMarkers = addPointsToMapAsMarkers(map, holes, polygonMarkerHoleOptions, true); PolygonHoleMarkers polygonHoleMarkers = new PolygonHoleMarkers( polygonMarkers); polygonHoleMarkers.setMarkers(holeMarkers); shapeMarkers.add(polygonHoleMarkers); polygonMarkers.addHole(polygonHoleMarkers); } return polygonMarkers; }
Example #26
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 5 votes |
/** * Convert a {@link MultiPolygonOptions} to a {@link PolyhedralSurface} * * @param multiPolygonOptions multi polygon options * @param hasZ has z flag * @param hasM has m flag * @return polyhedral surface */ public PolyhedralSurface toPolyhedralSurfaceWithOptions( MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) { PolyhedralSurface polyhedralSurface = new PolyhedralSurface(hasZ, hasM); for (PolygonOptions mapPolygon : multiPolygonOptions .getPolygonOptions()) { Polygon polygon = toPolygon(mapPolygon); polyhedralSurface.addPolygon(polygon); } return polyhedralSurface; }
Example #27
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 4 votes |
/** * Convert a {@link Geometry} to a Map shape and add it * * @param map google map * @param geometry geometry * @return google map shape */ @SuppressWarnings("unchecked") public GoogleMapShape addToMap(GoogleMap map, Geometry geometry) { GoogleMapShape shape = null; GeometryType geometryType = geometry.getGeometryType(); switch (geometryType) { case POINT: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MARKER, addLatLngToMap(map, toLatLng((Point) geometry))); break; case LINESTRING: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE, addPolylineToMap(map, toPolyline((LineString) geometry))); break; case POLYGON: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toPolygon((Polygon) geometry))); break; case MULTIPOINT: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_MARKER, addLatLngsToMap(map, toLatLngs((MultiPoint) geometry))); break; case MULTILINESTRING: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE, addPolylinesToMap(map, toPolylines((MultiLineString) geometry))); break; case MULTIPOLYGON: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((MultiPolygon) geometry))); break; case CIRCULARSTRING: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE, addPolylineToMap(map, toPolyline((CircularString) geometry))); break; case COMPOUNDCURVE: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE, addPolylinesToMap(map, toPolylines((CompoundCurve) geometry))); break; case CURVEPOLYGON: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toCurvePolygon((CurvePolygon) geometry))); break; case POLYHEDRALSURFACE: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((PolyhedralSurface) geometry))); break; case TIN: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((TIN) geometry))); break; case TRIANGLE: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toPolygon((Triangle) geometry))); break; case GEOMETRYCOLLECTION: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.COLLECTION, addToMap(map, (GeometryCollection<Geometry>) geometry)); break; default: throw new GeoPackageException("Unsupported Geometry Type: " + geometryType.getName()); } return shape; }
Example #28
Source File: GoogleMapShapeConverterUtils.java From geopackage-android-map with MIT License | 4 votes |
/** * Test shapes * * @param geoPackage * @throws SQLException */ public static void testShapes(GeoPackage geoPackage) throws SQLException { GeometryColumnsDao geometryColumnsDao = geoPackage .getGeometryColumnsDao(); if (geometryColumnsDao.isTableExists()) { List<GeometryColumns> results = geometryColumnsDao.queryForAll(); for (GeometryColumns geometryColumns : results) { FeatureDao dao = geoPackage.getFeatureDao(geometryColumns); GoogleMapShapeConverter converter = new GoogleMapShapeConverter( dao.getProjection()); converter.setExteriorOrientation(null); converter.setHoleOrientation(null); // Query for all FeatureCursor cursor = dao.queryForAll(); while (cursor.moveToNext()) { FeatureRow featureRow = cursor.getRow(); GeoPackageGeometryData geometryData = featureRow .getGeometry(); if (geometryData != null) { Geometry geometry = geometryData.getGeometry(); GeometryType geometryType = geometry.getGeometryType(); switch (geometryType) { case POINT: convertPoint(converter, (Point) geometry); break; case LINESTRING: convertLineString(converter, (LineString) geometry); break; case POLYGON: convertPolygon(converter, (Polygon) geometry); break; case MULTIPOINT: convertMultiPoint(converter, (MultiPoint) geometry); break; case MULTILINESTRING: convertMultiLineString(converter, (MultiLineString) geometry); break; case MULTIPOLYGON: convertMultiPolygon(converter, (MultiPolygon) geometry); break; case CIRCULARSTRING: convertLineString(converter, (CircularString) geometry); break; case COMPOUNDCURVE: convertCompoundCurve(converter, (CompoundCurve) geometry); break; case POLYHEDRALSURFACE: convertMultiPolygon(converter, (PolyhedralSurface) geometry); break; case TIN: convertMultiPolygon(converter, (TIN) geometry); break; case TRIANGLE: convertPolygon(converter, (Triangle) geometry); break; default: } } } cursor.close(); } } }
Example #29
Source File: FeatureUtils.java From geopackage-java with MIT License | 4 votes |
/** * Validate the geometry * * @param geometryType * @param geometry */ private static void validateGeometry(GeometryType geometryType, Geometry geometry) { switch (geometryType) { case POINT: TestCase.assertTrue(geometry instanceof Point); Point point = (Point) geometry; validatePoint(point, point); break; case LINESTRING: TestCase.assertTrue(geometry instanceof LineString); LineString lineString = (LineString) geometry; validateLineString(lineString, lineString); break; case POLYGON: TestCase.assertTrue(geometry instanceof Polygon); Polygon polygon = (Polygon) geometry; validatePolygon(polygon, polygon); break; case MULTIPOINT: TestCase.assertTrue(geometry instanceof MultiPoint); MultiPoint multiPoint = (MultiPoint) geometry; validateMultiPoint(multiPoint, multiPoint); break; case MULTILINESTRING: TestCase.assertTrue(geometry instanceof MultiLineString); MultiLineString multiLineString = (MultiLineString) geometry; validateMultiLineString(multiLineString, multiLineString); break; case MULTIPOLYGON: TestCase.assertTrue(geometry instanceof MultiPolygon); MultiPolygon multiPolygon = (MultiPolygon) geometry; validateMultiPolygon(multiPolygon, multiPolygon); break; case GEOMETRYCOLLECTION: TestCase.assertTrue(geometry instanceof GeometryCollection); GeometryCollection<?> geometryCollection = (GeometryCollection<?>) geometry; validateGeometryCollection(geometryCollection, geometryCollection); break; default: } }
Example #30
Source File: GeoPackageGeometryDataUtils.java From geopackage-android with MIT License | 4 votes |
/** * Compare two geometries and verify they are equal * * @param expected * @param actual * @param delta */ public static void compareGeometries(Geometry expected, Geometry actual, double delta) { if (expected == null) { TestCase.assertNull(actual); } else { TestCase.assertNotNull(actual); GeometryType geometryType = expected.getGeometryType(); switch (geometryType) { case GEOMETRY: TestCase.fail("Unexpected Geometry Type of " + geometryType.name() + " which is abstract"); case POINT: comparePoint((Point) expected, (Point) actual, delta); break; case LINESTRING: compareLineString((LineString) expected, (LineString) actual, delta); break; case POLYGON: comparePolygon((Polygon) expected, (Polygon) actual, delta); break; case MULTIPOINT: compareMultiPoint((MultiPoint) expected, (MultiPoint) actual, delta); break; case MULTILINESTRING: compareMultiLineString((MultiLineString) expected, (MultiLineString) actual, delta); break; case MULTIPOLYGON: compareMultiPolygon((MultiPolygon) expected, (MultiPolygon) actual, delta); break; case GEOMETRYCOLLECTION: compareGeometryCollection((GeometryCollection<?>) expected, (GeometryCollection<?>) actual, delta); break; case CIRCULARSTRING: compareCircularString((CircularString) expected, (CircularString) actual, delta); break; case COMPOUNDCURVE: compareCompoundCurve((CompoundCurve) expected, (CompoundCurve) actual, delta); break; case CURVEPOLYGON: compareCurvePolygon((CurvePolygon<?>) expected, (CurvePolygon<?>) actual, delta); break; case MULTICURVE: TestCase.fail("Unexpected Geometry Type of " + geometryType.name() + " which is abstract"); case MULTISURFACE: TestCase.fail("Unexpected Geometry Type of " + geometryType.name() + " which is abstract"); case CURVE: TestCase.fail("Unexpected Geometry Type of " + geometryType.name() + " which is abstract"); case SURFACE: TestCase.fail("Unexpected Geometry Type of " + geometryType.name() + " which is abstract"); case POLYHEDRALSURFACE: comparePolyhedralSurface((PolyhedralSurface) expected, (PolyhedralSurface) actual, delta); break; case TIN: compareTIN((TIN) expected, (TIN) actual, delta); break; case TRIANGLE: compareTriangle((Triangle) expected, (Triangle) actual, delta); break; default: throw new GeoPackageException("Geometry Type not supported: " + geometryType); } } }