mil.nga.geopackage.features.user.FeatureDao Java Examples

The following examples show how to use mil.nga.geopackage.features.user.FeatureDao. 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: FeatureTileUtils.java    From geopackage-android with MIT License 7 votes vote down vote up
/**
 * Create feature dao
 *
 * @return
 */
public static FeatureDao createFeatureDao(GeoPackage geoPackage) {

    BoundingBox boundingBox = new BoundingBox();

    GeometryColumns geometryColumns = new GeometryColumns();
    geometryColumns.setId(new TableColumnKey("feature_tiles",
            "geom"));
    geometryColumns.setGeometryType(GeometryType.GEOMETRY);
    geometryColumns.setZ((byte) 0);
    geometryColumns.setM((byte) 0);

    geoPackage.createFeatureTableWithMetadata(
            geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);

    FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns);

    return featureDao;
}
 
Example #2
Source File: FeatureTileUtils.java    From geopackage-android with MIT License 6 votes vote down vote up
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 #3
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(Contents contents) {

    if (contents == null) {
        throw new GeoPackageException("Non null "
                + Contents.class.getSimpleName()
                + " is required to create "
                + FeatureDao.class.getSimpleName());
    }

    GeometryColumns geometryColumns = contents.getGeometryColumns();
    if (geometryColumns == null) {
        throw new GeoPackageException("No "
                + GeometryColumns.class.getSimpleName() + " exists for "
                + Contents.class.getSimpleName() + " " + contents.getId());
    }

    return getFeatureDao(geometryColumns);
}
 
Example #4
Source File: GeoPackageTextOutput.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Build text from a feature table
 * 
 * @param table
 *            feature table
 * @return text
 */
public String featureTable(String table) {

	StringBuilder output = new StringBuilder();
	FeatureDao featureDao = geoPackage.getFeatureDao(table);
	output.append("Table Name: " + featureDao.getTableName());
	output.append("\nFeatures: " + featureDao.count());

	GeometryColumns geometryColumns = featureDao.getGeometryColumns();

	output.append("\n\nContents\n\n")
			.append(textOutput(geometryColumns.getContents()));

	output.append("\n\nGeometry Columns\n\n")
			.append(textOutput(geometryColumns));

	return output.toString();
}
 
Example #5
Source File: RTreeIndexExtension.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get a RTree Index Table DAO for the feature dao
 * 
 * @param featureDao
 *            feature DAO
 * @return RTree Index Table DAO
 * @since 3.1.0
 */
public RTreeIndexTableDao getTableDao(FeatureDao featureDao) {

	GeoPackageConnection connection = getGeoPackage().getConnection();
	UserCustomTable userCustomTable = getRTreeTable(featureDao.getTable());
	UserCustomDao userCustomDao = new UserCustomDao(geoPackage.getName(),
			connection, userCustomTable);

	return new RTreeIndexTableDao(this, userCustomDao, featureDao);
}
 
Example #6
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(GeometryColumns geometryColumns) {

    if (geometryColumns == null) {
        throw new GeoPackageException("Non null "
                + GeometryColumns.class.getSimpleName()
                + " is required to create "
                + FeatureDao.class.getSimpleName());
    }

    // Read the existing table and create the dao
    FeatureTableReader tableReader = new FeatureTableReader(geometryColumns);
    final FeatureTable featureTable = tableReader.readTable(database);
    featureTable.setContents(geometryColumns.getContents());
    FeatureDao dao = new FeatureDao(getName(), database, geometryColumns, featureTable);

    // Register the table name (with and without quotes) to wrap cursors with the feature cursor
    registerCursorWrapper(geometryColumns.getTableName(),
            new GeoPackageCursorWrapper() {

                @Override
                public Cursor wrapCursor(Cursor cursor) {
                    return new FeatureCursor(featureTable, cursor);
                }
            });

    // If the GeoPackage is writable and the feature table has a RTree Index
    // extension, drop the RTree triggers.  User defined functions are currently not supported.
    if (writable) {
        RTreeIndexExtension rtree = new RTreeIndexExtension(this);
        rtree.dropTriggers(featureTable);
    }

    return dao;
}
 
Example #7
Source File: FeatureIndexManager.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Constructor
 *
 * @param context    context
 * @param geoPackage GeoPackage
 * @param featureDao feature DAO
 */
public FeatureIndexManager(Context context, GeoPackage geoPackage, FeatureDao featureDao) {
    this.featureDao = featureDao;
    featureTableIndex = new FeatureTableIndex(geoPackage, featureDao.copy());
    featureIndexer = new FeatureIndexer(context, featureDao.copy());
    RTreeIndexExtension rTreeExtension = new RTreeIndexExtension(geoPackage);
    rTreeIndexTableDao = rTreeExtension.getTableDao(featureDao.copy());
    manualFeatureQuery = new ManualFeatureQuery(featureDao.copy());

    // Set the default indexed check and query order
    indexLocationQueryOrder.add(FeatureIndexType.RTREE);
    indexLocationQueryOrder.add(FeatureIndexType.GEOPACKAGE);
    indexLocationQueryOrder.add(FeatureIndexType.METADATA);
}
 
Example #8
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(String tableName) {
    GeometryColumnsDao dao = getGeometryColumnsDao();
    List<GeometryColumns> geometryColumnsList;
    try {
        geometryColumnsList = dao.queryForEq(
                GeometryColumns.COLUMN_TABLE_NAME, tableName);
    } catch (SQLException e) {
        throw new GeoPackageException("Failed to retrieve "
                + FeatureDao.class.getSimpleName() + " for table name: "
                + tableName + ". Exception retrieving "
                + GeometryColumns.class.getSimpleName() + ".", e);
    }
    if (geometryColumnsList.isEmpty()) {
        throw new GeoPackageException(
                "No Feature Table exists for table name: " + tableName);
    } else if (geometryColumnsList.size() > 1) {
        // This shouldn't happen with the table name unique constraint on
        // geometry columns
        throw new GeoPackageException("Unexpected state. More than one "
                + GeometryColumns.class.getSimpleName()
                + " matched for table name: " + tableName + ", count: "
                + geometryColumnsList.size());
    }
    return getFeatureDao(geometryColumnsList.get(0));
}
 
Example #9
Source File: RTreeIndexTableDao.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Constructor
 *
 * @param rTree      RTree extension
 * @param dao        user custom data access object
 * @param featureDao feature DAO
 */
RTreeIndexTableDao(RTreeIndexExtension rTree, UserCustomDao dao,
                   FeatureDao featureDao) {
    super(dao, dao.getTable());
    this.rTree = rTree;
    this.featureDao = featureDao;
    this.projection = featureDao.getProjection();
    setUseBindings(true);
    featureDao.setUseBindings(true);
}
 
Example #10
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
public static long insertLine(FeatureDao featureDao, double[][] points) {
	FeatureRow featureRow = featureDao.newRow();
	GeoPackageGeometryData geomData = new GeoPackageGeometryData(
			ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
	LineString lineString = getLineString(points);
	geomData.setGeometry(lineString);
	featureRow.setGeometry(geomData);
	return featureDao.insert(featureRow);
}
 
Example #11
Source File: FeatureTileTableLinker.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Query for the feature tables linked to a tile table and return feature
 * DAOs to those tables
 *
 * @param tileTable tile table
 * @return feature DAOs
 */
public List<FeatureDao> getFeatureDaosForTileTable(String tileTable) {

    List<FeatureDao> featureDaos = new ArrayList<FeatureDao>();

    List<String> featureTables = getFeatureTablesForTileTable(tileTable);
    for (String featureTable : featureTables) {
        if (geoPackage.isFeatureTable(featureTable)) {
            FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
            featureDaos.add(featureDao);
        }
    }

    return featureDaos;
}
 
Example #12
Source File: FeaturePreview.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Draw a preview image
 * 
 * @return preview image
 */
public BufferedImage draw() {

	BufferedImage image = null;

	FeatureDao featureDao = featureTiles.getFeatureDao();
	String table = featureDao.getTableName();

	Projection webMercator = ProjectionFactory
			.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);

	BoundingBox boundingBox = geoPackage.getFeatureBoundingBox(webMercator,
			table, false);
	if (boundingBox == null) {
		boundingBox = geoPackage.getContentsBoundingBox(webMercator, table);
	}
	if (boundingBox == null && manual) {
		boundingBox = geoPackage.getFeatureBoundingBox(webMercator, table,
				manual);
	}
	if (boundingBox != null) {
		boundingBox = TileBoundingBoxUtils
				.boundWebMercatorBoundingBox(boundingBox);
		BoundingBox expandedBoundingBox = boundingBox
				.squareExpand(bufferPercentage);
		expandedBoundingBox = TileBoundingBoxUtils
				.boundWebMercatorBoundingBox(expandedBoundingBox);
		int zoom = TileBoundingBoxUtils.getZoomLevel(expandedBoundingBox);

		FeatureResultSet results = featureDao.query(
				columns.toArray(new String[] {}), where, whereArgs, null,
				null, null, limit != null ? limit.toString() : null);
		image = featureTiles.drawTile(zoom, expandedBoundingBox, results);
	}

	return image;
}
 
Example #13
Source File: FeaturePreview.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Constructor
 *
 * @param geoPackage   GeoPackage
 * @param featureTiles feature tiles
 */
public FeaturePreview(GeoPackage geoPackage, FeatureTiles featureTiles) {
    this.geoPackage = geoPackage;
    this.featureTiles = featureTiles;
    FeatureDao featureDao = featureTiles.getFeatureDao();
    columns.add(featureDao.getIdColumnName());
    columns.add(featureDao.getGeometryColumnName());
    where = CoreSQLUtils.quoteWrap(featureDao.getGeometryColumnName())
            + " IS NOT NULL";
}
 
Example #14
Source File: GeoPackageImpl.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(Contents contents) {

	if (contents == null) {
		throw new GeoPackageException("Non null "
				+ Contents.class.getSimpleName() + " is required to create "
				+ FeatureDao.class.getSimpleName());
	}

	GeometryColumns geometryColumns = null;
	try {
		geometryColumns = getGeometryColumnsDao()
				.queryForTableName(contents.getTableName());
	} catch (SQLException e) {
		throw new GeoPackageException("No "
				+ GeometryColumns.class.getSimpleName()
				+ " could be retrieved for "
				+ Contents.class.getSimpleName() + " " + contents.getId());
	}

	if (geometryColumns == null) {
		throw new GeoPackageException("No "
				+ GeometryColumns.class.getSimpleName() + " exists for "
				+ Contents.class.getSimpleName() + " " + contents.getId());
	}

	return getFeatureDao(geometryColumns);
}
 
Example #15
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
public static void insertFourPoints(FeatureDao featureDao, double x,
		double y) {
	insertPoint(featureDao, x, y);
	insertPoint(featureDao, x, -1 * y);
	insertPoint(featureDao, -1 * x, y);
	insertPoint(featureDao, -1 * x, -1 * y);
}
 
Example #16
Source File: TransactionTest.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Insert rows into the feature table
 *
 * @param featureDao feature dao
 * @param rows       number of rows
 */
private void insertRows(FeatureDao featureDao, int rows) {

    for (int count = 0; count < rows; count++) {
        insertRow(featureDao);
    }

}
 
Example #17
Source File: FeatureUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Test delete
 * 
 * @param geoPackage
 *            GeoPackage
 * @throws SQLException
 *             upon error
 */
public static void testDelete(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);
			TestCase.assertNotNull(dao);

			FeatureResultSet cursor = dao.queryForAll();
			int count = cursor.getCount();
			if (count > 0) {

				// Choose random feature
				int random = (int) (Math.random() * count);
				cursor.moveToPosition(random);

				FeatureRow featureRow = cursor.getRow();
				cursor.close();

				// Delete row
				TestCase.assertEquals(1, dao.delete(featureRow));

				// Verify deleted
				FeatureRow queryFeatureRow = dao.queryForIdRow(featureRow
						.getId());
				TestCase.assertNull(queryFeatureRow);
				cursor = dao.queryForAll();
				TestCase.assertEquals(count - 1, cursor.getCount());
				cursor.close();
			}
			cursor.close();
		}
	}
}
 
Example #18
Source File: GeoPackageExample.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void createFeatureTileLinkExtension(Context context, GeoPackage geoPackage)
        throws SQLException, IOException {

    List<String> featureTables = geoPackage.getFeatureTables();
    for (String featureTable : featureTables) {

        FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
        FeatureTiles featureTiles = new DefaultFeatureTiles(context, geoPackage, featureDao,
                context.getResources().getDisplayMetrics().density);

        BoundingBox boundingBox = featureDao.getBoundingBox();
        Projection projection = featureDao.getProjection();

        Projection requestProjection = ProjectionFactory
                .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);
        ProjectionTransform transform = projection
                .getTransformation(requestProjection);
        BoundingBox requestBoundingBox = boundingBox.transform(transform);

        int zoomLevel = TileBoundingBoxUtils
                .getZoomLevel(requestBoundingBox);
        zoomLevel = Math.max(zoomLevel, 8);
        zoomLevel = Math.min(zoomLevel, 19);

        int minZoom = zoomLevel - 8;
        int maxZoom = zoomLevel + 2;

        TileGenerator tileGenerator = new FeatureTileGenerator(context, geoPackage,
                featureTable + "_tiles", featureTiles, minZoom, maxZoom,
                requestBoundingBox, requestProjection);

        tileGenerator.generateTiles();
        featureTiles.close();
    }
}
 
Example #19
Source File: FeatureTilesTest.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Test feature tiles
 *
 * @throws java.sql.SQLException
 */
public void testFeatureTiles(boolean useIcon) throws SQLException {

    FeatureDao featureDao = FeatureTileUtils.createFeatureDao(geoPackage);

    int num = FeatureTileUtils.insertFeatures(geoPackage, featureDao);

    FeatureTiles featureTiles = FeatureTileUtils.createFeatureTiles(activity, geoPackage, featureDao, useIcon);

    try {
        FeatureIndexer indexer = new FeatureIndexer(activity, featureDao);
        try {
            indexer.index();
        } finally {
            indexer.close();
        }

        FeatureIndexManager indexManager = new FeatureIndexManager(activity, geoPackage, featureDao);
        featureTiles.setIndexManager(indexManager);

        indexManager.setIndexLocation(FeatureIndexType.GEOPACKAGE);
        int indexed = indexManager.index();
        assertEquals(num, indexed);

        createTiles(featureTiles, 0, 3);
    } finally {
        featureTiles.close();
    }
}
 
Example #20
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
public static void updateLastChange(GeoPackage geoPackage,
		FeatureDao featureDao) throws SQLException {
	Contents contents = featureDao.getGeometryColumns().getContents();
	contents.setLastChange(new Date());
	ContentsDao contentsDao = geoPackage.getContentsDao();
	contentsDao.update(contents);
}
 
Example #21
Source File: FeatureTileUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Insert features
 *
 * @param featureDao
 * @return number of features
 */
public static int insertFeatures(GeoPackage geoPackage, FeatureDao featureDao) throws SQLException {

    int count = 0;

    count += 5;
    insertPoint(featureDao, 0, 0);
    insertPoint(featureDao, 0, ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE - 1);
    insertPoint(featureDao, 0, ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE + 1);
    insertPoint(featureDao, -179, 0);
    insertPoint(featureDao, 179, 0);

    count += 4;
    insertFourPoints(featureDao, 179, ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE - 1);
    count += 4;
    insertFourPoints(featureDao, 90, 45);

    count += 4;
    insertFourLines(featureDao, new double[][]{{135.0, 67.5}, {90.0, 45.0}, {135.0, 45.0}});

    count += 4;
    insertFourPolygons(featureDao, new double[][]{{60.0, 35.0}, {65.0, 15.0}, {15.0, 20.0}, {20.0, 40.0}}, new double[][]{{50.0, 30.0}, {48.0, 22.0}, {30.0, 23.0}, {25.0, 34.0}});

    updateLastChange(geoPackage, featureDao);

    return count;
}
 
Example #22
Source File: FeatureTileUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Create a new feature tiles
 *
 * @return
 */
public static FeatureTiles createFeatureTiles(Context context, GeoPackage geoPackage, FeatureDao featureDao, boolean useIcon) {

    FeatureTiles featureTiles = new DefaultFeatureTiles(context, featureDao, context.getResources().getDisplayMetrics().density);

    Paint pointPaint = featureTiles.getPointPaint();
    if (useIcon) {
        Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), mil.nga.geopackage.test.R.drawable.ic_launcher);
        bitmap = Bitmap.createScaledBitmap(bitmap, 25, 25, false);
        FeatureTilePointIcon icon = new FeatureTilePointIcon(bitmap);
        featureTiles.setPointIcon(icon);
    } else {
        pointPaint.setColor(Color.BLUE);
    }

    Paint linePaint = featureTiles.getLinePaintCopy();
    linePaint.setColor(Color.GREEN);
    featureTiles.setLinePaint(linePaint);

    Paint polygonPaint = featureTiles.getPolygonPaintCopy();
    polygonPaint.setColor(Color.RED);
    featureTiles.setPolygonPaint(polygonPaint);

    featureTiles.setFillPolygon(true);
    Paint polygonFillPaint = featureTiles.getPolygonFillPaintCopy();
    polygonFillPaint.setColor(Color.RED);
    polygonFillPaint.setAlpha(50);
    featureTiles.setPolygonFillPaint(polygonFillPaint);

    featureTiles.calculateDrawOverlap();

    return featureTiles;
}
 
Example #23
Source File: FeatureIndexManager.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Constructor
 *
 * @param geoPackage
 *            GeoPackage
 * @param featureDao
 *            feature DAO
 */
public FeatureIndexManager(GeoPackage geoPackage, FeatureDao featureDao) {
	this.featureDao = featureDao;
	featureTableIndex = new FeatureTableIndex(geoPackage, featureDao);
	RTreeIndexExtension rTreeExtension = new RTreeIndexExtension(
			geoPackage);
	rTreeIndexTableDao = rTreeExtension.getTableDao(featureDao);
	manualFeatureQuery = new ManualFeatureQuery(featureDao);

	// Set the default indexed check and query order
	indexLocationQueryOrder.add(FeatureIndexType.RTREE);
	indexLocationQueryOrder.add(FeatureIndexType.GEOPACKAGE);
}
 
Example #24
Source File: FeatureIndexManagerUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void testTimedIndex(GeoPackage geoPackage,
		FeatureIndexType type, FeatureDao featureDao,
		List<FeatureIndexTestEnvelope> envelopes, double precision,
		boolean compareProjectionCounts, double projectionPrecision,
		boolean verbose) {
	testTimedIndex(geoPackage, type, featureDao, envelopes, precision,
			precision, compareProjectionCounts, projectionPrecision,
			verbose);
}
 
Example #25
Source File: IndexerTask.java    From geopackage-mapcache-android with MIT License 5 votes vote down vote up
/**
 * Index features
 *
 * @param activity
 * @param callback
 * @param database
 * @param tableName
 * @param indexLocation
 */
public static void indexFeatures(Activity activity, IIndexerTask callback,
                                 String database, String tableName,
                                 FeatureIndexType indexLocation) {

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);
    GeoPackage geoPackage = manager.open(database);

    FeatureDao featureDao = geoPackage.getFeatureDao(tableName);

    FeatureIndexManager indexer = new FeatureIndexManager(activity, geoPackage, featureDao);
    indexer.setIndexLocation(indexLocation);

    ProgressDialog progressDialog = new ProgressDialog(activity);
    final IndexerTask indexTask = new IndexerTask(activity,
            callback, progressDialog, geoPackage, indexer);

    int max = featureDao.count();
    indexTask.setMax(max);
    indexer.setProgress(indexTask);

    progressDialog.setMessage(activity
            .getString(R.string.geopackage_table_index_features_index_title)
            + ": "
            + geoPackage.getName() + " - " + tableName);
    progressDialog.setCancelable(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setMax(max);
    progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
            activity.getString(R.string.button_cancel_label),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    indexTask.cancel(true);
                }
            });

    indexTask.execute();
}
 
Example #26
Source File: FeatureTileTableLinker.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Query for the feature tables linked to a tile table and return feature
 * DAOs to those tables
 * 
 * @param tileTable
 *            tile table
 * @return feature DAOs
 */
public List<FeatureDao> getFeatureDaosForTileTable(String tileTable) {

	List<FeatureDao> featureDaos = new ArrayList<FeatureDao>();

	List<String> featureTables = getFeatureTablesForTileTable(tileTable);
	for (String featureTable : featureTables) {
		if (geoPackage.isFeatureTable(featureTable)) {
			FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
			featureDaos.add(featureDao);
		}
	}

	return featureDaos;
}
 
Example #27
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
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 #28
Source File: FeatureUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test update
 * 
 * @param geoPackage
 *            GeoPackage
 * @throws SQLException
 *             upon error
 */
public static void testUpdate(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);
			testUpdate(dao);

		}
	}

}
 
Example #29
Source File: FeatureTileUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
public static void insertFourPoints(FeatureDao featureDao, double x, double y) {
    insertPoint(featureDao, x, y);
    insertPoint(featureDao, x, -1 * y);
    insertPoint(featureDao, -1 * x, y);
    insertPoint(featureDao, -1 * x, -1 * y);
}
 
Example #30
Source File: TransactionTest.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test transactions on the User DAO
 * 
 * @throws SQLException
 *             upon error
 */
@Test
public void testUserDao() throws SQLException {

	final int rows = 500;
	final int chunkSize = 150;

	for (String featureTable : geoPackage.getFeatureTables()) {

		FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);

		testUserDao(featureDao, rows, false);
		testUserDao(featureDao, rows, true);

		testUserDaoShortcuts(featureDao, rows, false);
		testUserDaoShortcuts(featureDao, rows, true);

		testUserDaoShortcuts2(featureDao, rows, false);
		testUserDaoShortcuts2(featureDao, rows, true);

		testUserDaoChunks(featureDao, rows, chunkSize, false);
		testUserDaoChunks(featureDao, rows, chunkSize, true);

	}

}