mil.nga.geopackage.extension.GeometryExtensions Java Examples
The following examples show how to use
mil.nga.geopackage.extension.GeometryExtensions.
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: GeometryExtensionsTest.java From geopackage-android with MIT License | 5 votes |
/** * Test the is extension check */ @Test public void testIsExtension() { assertFalse(GeometryExtensions.isExtension(GeometryType.GEOMETRY)); assertFalse(GeometryExtensions.isExtension(GeometryType.POINT)); assertFalse(GeometryExtensions.isExtension(GeometryType.LINESTRING)); assertFalse(GeometryExtensions.isExtension(GeometryType.POLYGON)); assertFalse(GeometryExtensions.isExtension(GeometryType.MULTIPOINT)); assertFalse(GeometryExtensions .isExtension(GeometryType.MULTILINESTRING)); assertFalse(GeometryExtensions.isExtension(GeometryType.MULTIPOLYGON)); assertFalse(GeometryExtensions .isExtension(GeometryType.GEOMETRYCOLLECTION)); assertTrue(GeometryExtensions.isExtension(GeometryType.CIRCULARSTRING)); assertTrue(GeometryExtensions.isExtension(GeometryType.COMPOUNDCURVE)); assertTrue(GeometryExtensions.isExtension(GeometryType.CURVEPOLYGON)); assertTrue(GeometryExtensions.isExtension(GeometryType.MULTICURVE)); assertTrue(GeometryExtensions.isExtension(GeometryType.MULTISURFACE)); assertTrue(GeometryExtensions.isExtension(GeometryType.CURVE)); assertTrue(GeometryExtensions.isExtension(GeometryType.SURFACE)); assertTrue(GeometryExtensions .isExtension(GeometryType.POLYHEDRALSURFACE)); assertTrue(GeometryExtensions.isExtension(GeometryType.TIN)); assertTrue(GeometryExtensions.isExtension(GeometryType.TRIANGLE)); }
Example #2
Source File: GeoPackageExample.java From geopackage-android with MIT License | 5 votes |
private void validateExtensions(GeoPackage geoPackage, boolean has) throws SQLException { ExtensionsDao extensionsDao = geoPackage.getExtensionsDao(); TestCase.assertEquals(has && RTREE_SPATIAL_INDEX, new RTreeIndexExtension(geoPackage).has()); TestCase.assertEquals( has && (RELATED_TABLES_FEATURES || RELATED_TABLES_MEDIA || RELATED_TABLES_SIMPLE_ATTRIBUTES), new RelatedTablesExtension(geoPackage).has()); TestCase.assertEquals( has && COVERAGE_DATA, extensionsDao.isTableExists() && !extensionsDao.queryByExtension( CoverageData.EXTENSION_NAME).isEmpty()); TestCase.assertEquals(has && SCHEMA, new SchemaExtension(geoPackage).has()); TestCase.assertEquals(has && METADATA, new MetadataExtension(geoPackage).has()); TestCase.assertEquals( has && NON_LINEAR_GEOMETRY_TYPES, extensionsDao.isTableExists() && !extensionsDao .queryByExtension( GeometryExtensions .getExtensionName(GeometryType.CIRCULARSTRING)) .isEmpty()); TestCase.assertEquals(has && WEBP, extensionsDao.isTableExists() && !extensionsDao .queryByExtension(WebPExtension.EXTENSION_NAME) .isEmpty()); TestCase.assertEquals(has && CRS_WKT, new CrsWktExtension(geoPackage).has()); }
Example #3
Source File: GeoPackageGeometryData.java From geopackage-core-java with MIT License | 5 votes |
/** * Set the geometry. Updates the empty flag and if the geometry is not null, * the extended flag * * @param geometry * geometry */ public void setGeometry(Geometry geometry) { this.geometry = geometry; empty = geometry == null; if (geometry != null) { extended = GeometryExtensions.isNonStandard(geometry .getGeometryType()); } }
Example #4
Source File: GeometryExtensionsTest.java From geopackage-java with MIT License | 5 votes |
/** * Test the is extension check */ @Test public void testIsExtension() { assertFalse(GeometryExtensions.isExtension(GeometryType.GEOMETRY)); assertFalse(GeometryExtensions.isExtension(GeometryType.POINT)); assertFalse(GeometryExtensions.isExtension(GeometryType.LINESTRING)); assertFalse(GeometryExtensions.isExtension(GeometryType.POLYGON)); assertFalse(GeometryExtensions.isExtension(GeometryType.MULTIPOINT)); assertFalse(GeometryExtensions .isExtension(GeometryType.MULTILINESTRING)); assertFalse(GeometryExtensions.isExtension(GeometryType.MULTIPOLYGON)); assertFalse(GeometryExtensions .isExtension(GeometryType.GEOMETRYCOLLECTION)); assertTrue(GeometryExtensions.isExtension(GeometryType.CIRCULARSTRING)); assertTrue(GeometryExtensions.isExtension(GeometryType.COMPOUNDCURVE)); assertTrue(GeometryExtensions.isExtension(GeometryType.CURVEPOLYGON)); assertTrue(GeometryExtensions.isExtension(GeometryType.MULTICURVE)); assertTrue(GeometryExtensions.isExtension(GeometryType.MULTISURFACE)); assertTrue(GeometryExtensions.isExtension(GeometryType.CURVE)); assertTrue(GeometryExtensions.isExtension(GeometryType.SURFACE)); assertTrue(GeometryExtensions .isExtension(GeometryType.POLYHEDRALSURFACE)); assertTrue(GeometryExtensions.isExtension(GeometryType.TIN)); assertTrue(GeometryExtensions.isExtension(GeometryType.TRIANGLE)); }
Example #5
Source File: GeoPackageExample.java From geopackage-java with MIT License | 5 votes |
private void validateExtensions(GeoPackage geoPackage, boolean has) throws SQLException { ExtensionsDao extensionsDao = geoPackage.getExtensionsDao(); TestCase.assertEquals(has && RTREE_SPATIAL_INDEX, new RTreeIndexExtension(geoPackage).has()); TestCase.assertEquals( has && (RELATED_TABLES_FEATURES || RELATED_TABLES_MEDIA || RELATED_TABLES_SIMPLE_ATTRIBUTES), new RelatedTablesExtension(geoPackage).has()); TestCase.assertEquals(has && COVERAGE_DATA, extensionsDao.isTableExists() && !extensionsDao .queryByExtension(CoverageData.EXTENSION_NAME) .isEmpty()); TestCase.assertEquals(has && SCHEMA, new SchemaExtension(geoPackage).has()); TestCase.assertEquals(has && METADATA, new MetadataExtension(geoPackage).has()); TestCase.assertEquals(has && NON_LINEAR_GEOMETRY_TYPES, extensionsDao.isTableExists() && !extensionsDao .queryByExtension(GeometryExtensions .getExtensionName(GeometryType.CIRCULARSTRING)) .isEmpty()); TestCase.assertEquals(has && WEBP, extensionsDao.isTableExists() && !extensionsDao .queryByExtension(WebPExtension.EXTENSION_NAME) .isEmpty()); TestCase.assertEquals(has && CRS_WKT, new CrsWktExtension(geoPackage).has()); }
Example #6
Source File: GeometryExtensionsTest.java From geopackage-android with MIT License | 4 votes |
/** * Test the is GeoPackage extension check */ @Test public void testIsGeoPackageExtension() { assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.GEOMETRY)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.POINT)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.LINESTRING)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.POLYGON)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTIPOINT)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTILINESTRING)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTIPOLYGON)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.GEOMETRYCOLLECTION)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.CIRCULARSTRING)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.COMPOUNDCURVE)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.CURVEPOLYGON)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTICURVE)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTISURFACE)); assertTrue(GeometryExtensions.isGeoPackageExtension(GeometryType.CURVE)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.SURFACE)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.POLYHEDRALSURFACE)); assertFalse(GeometryExtensions.isGeoPackageExtension(GeometryType.TIN)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.TRIANGLE)); }
Example #7
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 #8
Source File: GeometryExtensionsTest.java From geopackage-java with MIT License | 4 votes |
/** * Test the is GeoPackage extension check */ @Test public void testIsGeoPackageExtension() { assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.GEOMETRY)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.POINT)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.LINESTRING)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.POLYGON)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTIPOINT)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTILINESTRING)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTIPOLYGON)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.GEOMETRYCOLLECTION)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.CIRCULARSTRING)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.COMPOUNDCURVE)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.CURVEPOLYGON)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTICURVE)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.MULTISURFACE)); assertTrue(GeometryExtensions.isGeoPackageExtension(GeometryType.CURVE)); assertTrue(GeometryExtensions .isGeoPackageExtension(GeometryType.SURFACE)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.POLYHEDRALSURFACE)); assertFalse(GeometryExtensions.isGeoPackageExtension(GeometryType.TIN)); assertFalse(GeometryExtensions .isGeoPackageExtension(GeometryType.TRIANGLE)); }
Example #9
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); }