public final class

GeopackageFeatureTable

extends FeatureTable
java.lang.Object
   ↳ com.esri.core.table.FeatureTable
     ↳ com.esri.core.geodatabase.GeopackageFeatureTable

Class Overview

The GeopackageFeatureTable represents a feature table of a geopackage.

An instance is obtained using getGeopackageFeatureTable(String). The feature tables in a geopackage can be retrieved using getGeopackageFeatureTables().

It can be used to create a FeatureLayer that displays the features in this table.

Note: Geometries in GeopackageFeatureTables are only supported in WGS84 spatial reference.

Example:

 Geopackage geoPkg = new Geopackage("geopackage.gpkg");
 GeopackageFeatureTable featureTable = geoPkg.getGeopackageFeatureTable("validTableName");
 FeatureLayer featureLayer = new FeatureLayer(featureTable);
 mapView.addLayer(featureLayer);
 

Summary

Public Methods
long addFeature(Feature feature)
Adds the given feature to the table.
long[] addFeatures(List<Feature> features)
Adds the given features to the table.
boolean checkFeatureExists(long id)
Checks if a feature with the given ID exists in the table.
GeopackageFeature createNewFeature()
Creates a geopackage feature with null attributes and geometry.
GeopackageFeature createNewFeature(Map<String, Object> attributes, Geometry geometry)
Creates a geopackage feature with the given attributes and geometry.
void deleteFeature(long featureId)
Deletes the specified feature from the table.
void deleteFeatures(long[] featureId)
Deletes the specified features from the table.
boolean equals(Object obj)
String getCopyright()
Gets the copyright information.
Envelope getExtent()
Returns the extent of the GeopackageFeatureTable.
Feature getFeature(long id, SpatialReference outSR)
Retrieves the feature with the given ID from the table.
Feature getFeature(long id)
Retrieves the feature with the given ID from the table.
FeatureResult getFeatures(long[] ids)
Retrieves the features with the given IDs from the table.
Field getField(String fieldName)
Returns the Field object with the specified field name.
List<Field> getFields()
Returns all the Fields in the table.
Geometry.Type getGeometryType()
Gets the geometry type of the table.
Geopackage getGeopackage()
Gets the geopackage that this feature table comes from.
long getNumberOfFeatures()
Gets the number of features in the table.
String getObjectIdField()
Returns the field name used for the object ID.
SpatialReference getSpatialReference()
Returns the spatial reference that the geometries in this table are in.
String getTableName()
This returns the table name as defined by the table type.
boolean hasGeometry()
Always returns true.
int hashCode()
boolean isEditable()
Checks if the table can be edited.
Future<FeatureResult> queryFeatures(QueryParameters query, CallbackListener<FeatureResult> callback)
Queries the table using the given query parameters, and returns an iterator of features found by the query.
Future<long[]> queryIds(QueryParameters query, CallbackListener<long[]> callback)
Queries the table using the given query parameters, and returns an array of feature IDs found by the query.
String toString()
void updateFeature(long featureId, Geometry geometry)
Updates the geometry of the feature with the given ID in the table (leaves the feature attributes untouched).
void updateFeature(long featureId, Map<String, Object> attributes, Geometry geometry)
Updates the geometry and specified attributes of the feature with the given ID in the table.
void updateFeature(long featureId, Map<String, Object> attributes)
Updates the specified attributes of the feature with the given ID in the table (leaves the feature geometry untouched).
void updateFeature(long featureId, Feature feature)
Updates the feature specified by the unique feature ID.
void updateFeatures(long[] featureIds, List<Feature> features)
Updates the features specified by the array of feature IDs passed in.
Protected Methods
long getHandle()
Gets the handle.
int getTableIndex()
Gets the index of this table in the geopackage.
String toJson(Feature[] fs, boolean serializeGeometry, boolean asFeatures)
To json.
[Expand]
Inherited Methods
From class com.esri.core.table.FeatureTable
From class java.lang.Object

Public Methods

public long addFeature (Feature feature)

Adds the given feature to the table.

Parameters
feature Feature: the feature to add
Returns
long the unique ID of the added feature
Throws
TableException

public long[] addFeatures (List<Feature> features)

Adds the given features to the table.

Parameters
features List: the features to add
Returns
long[] an array of the unique IDs of the added features
Throws
TableException

public boolean checkFeatureExists (long id)

Checks if a feature with the given ID exists in the table.

Parameters
id long: the feature ID
Returns
boolean true if the feature exists, false otherwise

public GeopackageFeature createNewFeature ()

Creates a geopackage feature with null attributes and geometry.

Returns
GeopackageFeature the geopackage feature created
Throws
TableException if the feature does not conform to the table's schema

public GeopackageFeature createNewFeature (Map<String, Object> attributes, Geometry geometry)

Creates a geopackage feature with the given attributes and geometry.

Parameters
attributes Map: the feature's attributes
geometry Geometry: the feature's geometry
Returns
GeopackageFeature the geopackage feature created
Throws
TableException if the feature does not conform to the table's schema

public void deleteFeature (long featureId)

Deletes the specified feature from the table.

Parameters
featureId long: the feature's unique ID

public void deleteFeatures (long[] featureId)

Deletes the specified features from the table.

Parameters
featureId long: an array of feature IDs to delete

public boolean equals (Object obj)

Parameters
obj Object
Returns
boolean

public String getCopyright ()

Gets the copyright information.

Returns
String the copyright

public Envelope getExtent ()

Returns the extent of the GeopackageFeatureTable.

Note: Features can only be added to the GeopackageFeatureTable if they lie within this extent.

Returns
Envelope the extent of this GeopackageFeatureTable

public Feature getFeature (long id, SpatialReference outSR)

Retrieves the feature with the given ID from the table.

Parameters
id long: the feature's unique ID
outSR SpatialReference: the spatial reference of the returned feature
Returns
Feature the feature
Throws
TableException the table schema exception

public Feature getFeature (long id)

Retrieves the feature with the given ID from the table.

Parameters
id long: the feature's unique ID
Returns
Feature the feature retrieved, or null if the ID was invalid
Throws
TableException any error on retrieving the feature

public FeatureResult getFeatures (long[] ids)

Retrieves the features with the given IDs from the table.

Parameters
ids long: an array of feature IDs
Returns
FeatureResult an iterator for the features obtained from the IDs passed in

public Field getField (String fieldName)

Returns the Field object with the specified field name.

Parameters
fieldName String: the field name
Returns
Field the Field object

public List<Field> getFields ()

Returns all the Fields in the table.

Returns
List<Field> a list of Fields

public Geometry.Type getGeometryType ()

Gets the geometry type of the table. If the table contains more than 1 geometry type, return value is Geometry.Type.UNKNOWN. Features from tables with more than 1 geometry type cannot be rendered.

Returns
Geometry.Type the geometry type

public Geopackage getGeopackage ()

Gets the geopackage that this feature table comes from.

Returns
Geopackage the geopackage

public long getNumberOfFeatures ()

Gets the number of features in the table.

Returns
long the number of features

public String getObjectIdField ()

Returns the field name used for the object ID.

Returns
String the object ID field

public SpatialReference getSpatialReference ()

Returns the spatial reference that the geometries in this table are in.

Returns
SpatialReference the spatial reference

public String getTableName ()

This returns the table name as defined by the table type.

Returns
String the table name

public boolean hasGeometry ()

Always returns true.

Returns
boolean true

public int hashCode ()

Returns
int

public boolean isEditable ()

Checks if the table can be edited.

Returns
boolean true, if the table is editable

public Future<FeatureResult> queryFeatures (QueryParameters query, CallbackListener<FeatureResult> callback)

Queries the table using the given query parameters, and returns an iterator of features found by the query.

Parameters
query QueryParameters: the query parameters
callback CallbackListener: the callback with the iterator of features
Returns
Future<FeatureResult> the future with the iterator of features. The elements of the returned FeatureResult can be cast to
  • Feature for queries without statistics, or
  • to Map<String, Object> for queries with statistics.
Examples:
(1) Query without out-statistics
 
 QueryParameters query = new QueryParameters();
 query.setOutFields(new String[]{"*"});
 Future resultFuture = gdbFeatureTable.queryFeatures(query, new CallbackListener() {
   
   public void onError(Throwable e) {
     e.printStackTrace();
   }
   
   public void onCallback(FeatureResult featureIterator) {
     ...
   }
 });
 
 for (Object result : resultFuture.get()) {
   Feature feature = (Feature) result;
   // Map attrs = feature.getAttributes();
 }
 
 
(2) Query with out-statistics
 
 QueryParameters query = new QueryParameters();
 query.setOutStatistics(new OutStatistics[] {
   new OutStatistics(OutStatistics.Type.SUM, "ACRES", "SUM_ACRES")});

 Future resultFuture = 
   gdbFeatureTable.queryFeatures(query, new CallbackListener() {
   
   public void onError(Throwable e) {
     e.printStackTrace();
   }
   
   public void onCallback(FeatureResult featureIterator) {
     ...
   }
 });
    
 for (Object result : resultFuture.get()) {
   Map<String, Object> recordAsMap = (Map<String, Object>) result;
   double sumAcres = (Double) (recordAsMap.get("SUM_ACRES"));
 }
 
 

public Future<long[]> queryIds (QueryParameters query, CallbackListener<long[]> callback)

Queries the table using the given query parameters, and returns an array of feature IDs found by the query.

Parameters
query QueryParameters: the query parameters
callback CallbackListener: the callback with the array of feature IDs
Returns
Future<long[]> the future with the array of feature IDs

public String toString ()

Returns
String

public void updateFeature (long featureId, Geometry geometry)

Updates the geometry of the feature with the given ID in the table (leaves the feature attributes untouched).

Parameters
featureId long: the ID of the feature to update
geometry Geometry: the new geometry
Throws
TableException the table exception

public void updateFeature (long featureId, Map<String, Object> attributes, Geometry geometry)

Updates the geometry and specified attributes of the feature with the given ID in the table.

Parameters
featureId long: the ID of the feature to update
attributes Map: the attributes to update
geometry Geometry: the new geometry
Throws
TableException the table exception

public void updateFeature (long featureId, Map<String, Object> attributes)

Updates the specified attributes of the feature with the given ID in the table (leaves the feature geometry untouched).

Parameters
featureId long: the ID of the feature to update
attributes Map: the attributes to update
Throws
TableException the table exception

public void updateFeature (long featureId, Feature feature)

Updates the feature specified by the unique feature ID. To use this method, create a new feature with the properties you wish to update (such as geometry, certain attribute values), and pass in this feature.

Parameters
featureId long: the ID of the feature to update
feature Feature: the feature with the updated properties
Throws
TableException

public void updateFeatures (long[] featureIds, List<Feature> features)

Updates the features specified by the array of feature IDs passed in. To use this method, for each feature you wish to update, create a new feature with the properties to update (such as geometry, certain attribute values), and add it to the list of features in the same order as in the array of IDs.

Parameters
featureIds long: the IDs of features to update
features List: the features with the updated properties
Throws
TableException

Protected Methods

protected long getHandle ()

Gets the handle.

Returns
long the handle

protected int getTableIndex ()

Gets the index of this table in the geopackage.

Returns
int index of this table in the geopackage

protected String toJson (Feature[] fs, boolean serializeGeometry, boolean asFeatures)

To json.

Parameters
fs Feature: the fs
serializeGeometry boolean: the serialize geometry
asFeatures boolean: true if you want {features:[{}, {} , {}]} false it you want [{}, {}, {}]
Returns
String the string
Throws
Exception the exception