Class VectorLayer
java.lang.Object
com.eco.bio7.gdal.VectorLayer
- All Implemented Interfaces:
AutoCloseable
A vector layer of a dataset (OGRLayer): its fields, features, extent and
coordinate system; filters (attributes, extent); new fields and features
(a layer of a dataset created or opened for writing). The result of SQL
(
GdalDataset.executeSql(String)) must be closed.-
Method Summary
Modifier and TypeMethodDescriptionlongaddFeature(Map<String, ?> attributes, String wkt) Adds a feature: the attributes by field name (numbers, strings, booleans or null; unknown names are an error), the geometry as WKT (in the coordinates of the layer; null: without geometry).voidAll features again (no spatial filter).voidclose()Releases the result of SQL (nothing to do for the other layers: they belong to their dataset).voidcreateField(String name, FieldType type) A new attribute field (before the features are added).double[]extent()The extent {minX, minY, maxX, maxY} (null if unknown).longThe number of features (counted if the format doesn't know it).features()All features (for large layers seeforEach(Consumer)).intfieldIndex(String name) The index of a field (-1 if it doesn't exist).The names of the attribute fields.voidReads the features one after the other (from the start of the layer).intThe type of the geometries (OGRwkbGeometryType: 1 point, 2 line string, 3 polygon, 4-6 multi..., 0 unknown).name()voidsetAttributeFilter(String where) Only the features of an attribute filter (an SQL WHERE clause, e.g.voidsetSpatialFilter(double minX, double minY, double maxX, double maxY) Only the features which intersect the rectangle (in the coordinates of the layer).The coordinate system (null if unknown).voidsync()Writes the changes to the file.toString()
-
Method Details
-
close
public void close()Releases the result of SQL (nothing to do for the other layers: they belong to their dataset).- Specified by:
closein interfaceAutoCloseable
-
setAttributeFilter
Only the features of an attribute filter (an SQL WHERE clause, e.g. "area > 1000 AND type = 'forest'"); null: all. Some drivers (e.g., GeoPackage) check the filter only when the features are read (an invalid filter: no features). -
setSpatialFilter
public void setSpatialFilter(double minX, double minY, double maxX, double maxY) Only the features which intersect the rectangle (in the coordinates of the layer). -
clearSpatialFilter
public void clearSpatialFilter()All features again (no spatial filter). -
createField
-
addFeature
-
sync
public void sync()Writes the changes to the file. -
fieldIndex
The index of a field (-1 if it doesn't exist). -
name
-
featureCount
public long featureCount()The number of features (counted if the format doesn't know it). -
fieldNames
-
geometryType
public int geometryType()The type of the geometries (OGRwkbGeometryType: 1 point, 2 line string, 3 polygon, 4-6 multi..., 0 unknown). -
spatialReference
The coordinate system (null if unknown). Close it after use. -
extent
public double[] extent()The extent {minX, minY, maxX, maxY} (null if unknown). -
features
All features (for large layers seeforEach(Consumer)). -
forEach
-
toString
-