mil.nga.sf.CurvePolygon Java Examples
The following examples show how to use
mil.nga.sf.CurvePolygon.
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: GeoPackageGeometryDataUtils.java From geopackage-android with MIT License | 5 votes |
/** * Compare the two curve polygons for equality * * @param expected * @param actual * @param delta */ private static void compareCurvePolygon(CurvePolygon<?> expected, CurvePolygon<?> actual, double delta) { compareBaseGeometryAttributes(expected, actual); TestCase.assertEquals(expected.numRings(), actual.numRings()); for (int i = 0; i < expected.numRings(); i++) { compareGeometries(expected.getRings().get(i), actual.getRings() .get(i), delta); } }
Example #2
Source File: GeoPackageGeometryDataUtils.java From geopackage-java with MIT License | 5 votes |
/** * Compare the two curve polygons for equality * * @param expected * @param actual * @param delta */ private static void compareCurvePolygon(CurvePolygon<?> expected, CurvePolygon<?> actual, double delta) { compareBaseGeometryAttributes(expected, actual); TestCase.assertEquals(expected.numRings(), actual.numRings()); for (int i = 0; i < expected.numRings(); i++) { compareGeometries(expected.getRings().get(i), actual.getRings() .get(i), delta); } }
Example #3
Source File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 4 votes |
/** * Convert a {@link Geometry} to a Map shape * * @param geometry geometry * @return google map shape */ @SuppressWarnings("unchecked") public GoogleMapShape toShape(Geometry geometry) { GoogleMapShape shape = null; GeometryType geometryType = geometry.getGeometryType(); switch (geometryType) { case POINT: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.LAT_LNG, toLatLng((Point) geometry)); break; case LINESTRING: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE_OPTIONS, toPolyline((LineString) geometry)); break; case POLYGON: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON_OPTIONS, toPolygon((Polygon) geometry)); break; case MULTIPOINT: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_LAT_LNG, toLatLngs((MultiPoint) geometry)); break; case MULTILINESTRING: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE_OPTIONS, toPolylines((MultiLineString) geometry)); break; case MULTIPOLYGON: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON_OPTIONS, toPolygons((MultiPolygon) geometry)); break; case CIRCULARSTRING: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE_OPTIONS, toPolyline((CircularString) geometry)); break; case COMPOUNDCURVE: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE_OPTIONS, toPolylines((CompoundCurve) geometry)); break; case CURVEPOLYGON: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON_OPTIONS, toCurvePolygon((CurvePolygon) geometry)); break; case POLYHEDRALSURFACE: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON_OPTIONS, toPolygons((PolyhedralSurface) geometry)); break; case TIN: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON_OPTIONS, toPolygons((TIN) geometry)); break; case TRIANGLE: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON_OPTIONS, toPolygon((Triangle) geometry)); break; case GEOMETRYCOLLECTION: shape = new GoogleMapShape(geometryType, GoogleMapShapeType.COLLECTION, toShapes((GeometryCollection<Geometry>) geometry)); break; default: throw new GeoPackageException("Unsupported Geometry Type: " + geometryType.getName()); } return shape; }
Example #4
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 #5
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createNonLinearGeometryTypesExtension( GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); SpatialReferenceSystem srs = srsDao.getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, (long) ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); GeometryExtensions extensions = new GeometryExtensions(geoPackage); String tableName = "non_linear_geometries"; List<Geometry> geometries = new ArrayList<>(); List<String> geometryNames = new ArrayList<>(); CircularString circularString = new CircularString(); circularString.addPoint(new Point(-122.358, 47.653)); circularString.addPoint(new Point(-122.348, 47.649)); circularString.addPoint(new Point(-122.348, 47.658)); circularString.addPoint(new Point(-122.358, 47.658)); circularString.addPoint(new Point(-122.358, 47.653)); for (int i = GeometryCodes.getCode(GeometryType.CIRCULARSTRING); i <= GeometryCodes.getCode(GeometryType.SURFACE); i++) { GeometryType geometryType = GeometryCodes.getGeometryType(i); extensions.getOrCreate(tableName, GEOMETRY_COLUMN, geometryType); Geometry geometry = null; String name = geometryType.getName().toLowerCase(); switch (geometryType) { case CIRCULARSTRING: geometry = circularString; break; case COMPOUNDCURVE: CompoundCurve compoundCurve = new CompoundCurve(); compoundCurve.addLineString(circularString); geometry = compoundCurve; break; case CURVEPOLYGON: CurvePolygon<CircularString> curvePolygon = new CurvePolygon<>(); curvePolygon.addRing(circularString); geometry = curvePolygon; break; case MULTICURVE: MultiLineString multiCurve = new MultiLineString(); multiCurve.addLineString(circularString); geometry = multiCurve; break; case MULTISURFACE: MultiPolygon multiSurface = new MultiPolygon(); Polygon polygon = new Polygon(); polygon.addRing(circularString); multiSurface.addPolygon(polygon); geometry = multiSurface; break; case CURVE: CompoundCurve curve = new CompoundCurve(); curve.addLineString(circularString); geometry = curve; break; case SURFACE: CurvePolygon<CircularString> surface = new CurvePolygon<>(); surface.addRing(circularString); geometry = surface; break; default: throw new GeoPackageException("Unexpected Geometry Type: " + geometryType); } geometries.add(geometry); geometryNames.add(name); } createFeatures(geoPackage, srs, tableName, GeometryType.GEOMETRY, geometries, geometryNames); }
Example #6
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); } } }
Example #7
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createNonLinearGeometryTypesExtension( GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); SpatialReferenceSystem srs = srsDao.getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, (long) ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); GeometryExtensions extensions = new GeometryExtensions(geoPackage); String tableName = "non_linear_geometries"; List<Geometry> geometries = new ArrayList<>(); List<String> geometryNames = new ArrayList<>(); CircularString circularString = new CircularString(); circularString.addPoint(new Point(-122.358, 47.653)); circularString.addPoint(new Point(-122.348, 47.649)); circularString.addPoint(new Point(-122.348, 47.658)); circularString.addPoint(new Point(-122.358, 47.658)); circularString.addPoint(new Point(-122.358, 47.653)); for (int i = GeometryCodes .getCode(GeometryType.CIRCULARSTRING); i <= GeometryCodes .getCode(GeometryType.SURFACE); i++) { GeometryType geometryType = GeometryCodes.getGeometryType(i); extensions.getOrCreate(tableName, GEOMETRY_COLUMN, geometryType); Geometry geometry = null; String name = geometryType.getName().toLowerCase(); switch (geometryType) { case CIRCULARSTRING: geometry = circularString; break; case COMPOUNDCURVE: CompoundCurve compoundCurve = new CompoundCurve(); compoundCurve.addLineString(circularString); geometry = compoundCurve; break; case CURVEPOLYGON: CurvePolygon<CircularString> curvePolygon = new CurvePolygon<>(); curvePolygon.addRing(circularString); geometry = curvePolygon; break; case MULTICURVE: MultiLineString multiCurve = new MultiLineString(); multiCurve.addLineString(circularString); geometry = multiCurve; break; case MULTISURFACE: MultiPolygon multiSurface = new MultiPolygon(); Polygon polygon = new Polygon(); polygon.addRing(circularString); multiSurface.addPolygon(polygon); geometry = multiSurface; break; case CURVE: CompoundCurve curve = new CompoundCurve(); curve.addLineString(circularString); geometry = curve; break; case SURFACE: CurvePolygon<CircularString> surface = new CurvePolygon<>(); surface.addRing(circularString); geometry = surface; break; default: throw new GeoPackageException( "Unexpected Geometry Type: " + geometryType); } geometries.add(geometry); geometryNames.add(name); } createFeatures(geoPackage, srs, tableName, GeometryType.GEOMETRY, geometries, geometryNames); }
Example #8
Source File: GeoPackageGeometryDataUtils.java From geopackage-java 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); } } }