|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gdal.ogr.Layer
public class Layer
This class represents a layer of simple features, with access methods.
The Layer class is a binding for the C++ OGRLayer class.
Method Summary | |
---|---|
int |
CommitTransaction()
For datasources which support transactions, CommitTransaction commits a transaction. |
int |
CreateFeature(Feature feature)
Create and write a new feature within a layer. |
int |
CreateField(FieldDefn field_def)
Create a new field on a layer. |
int |
CreateField(FieldDefn field_def,
int approx_ok)
Create a new field on a layer. |
void |
delete()
Deprecated. Do not do anything... |
int |
DeleteFeature(int fid)
Delete feature from layer. |
boolean |
equals(Object obj)
|
double[] |
GetExtent()
Fetch the extent of this layer. |
double[] |
GetExtent(boolean force)
Fetch the extent of this layer. |
int |
GetExtent(double[] extent,
int force)
Fetch the extent of this layer. |
Feature |
GetFeature(int fid)
Fetch a feature by its identifier. |
int |
GetFeatureCount()
Fetch the feature count in this layer. |
int |
GetFeatureCount(int force)
Fetch the feature count in this layer. |
long |
GetFeaturesRead()
Return the total number of features read. |
String |
GetFIDColumn()
Returns the name of the FID column. |
String |
GetGeometryColumn()
Returns the name of the geometry column. |
FeatureDefn |
GetLayerDefn()
Fetch the schema information for this layer. |
String |
GetName()
Return the layer name. |
Feature |
GetNextFeature()
Fetch the next available feature from this layer. |
int |
GetRefCount()
Fetch reference count. |
Geometry |
GetSpatialFilter()
Return the current spatial filter for this layer. |
SpatialReference |
GetSpatialRef()
Fetch the spatial reference system for this layer. |
int |
hashCode()
|
void |
ResetReading()
Reset feature reading to start on the first feature. |
int |
RollbackTransaction()
For datasources which support transactions, RollbackTransaction will roll back a datasource to its state before the start of the current transaction. |
int |
SetAttributeFilter(String filter_string)
Set a new attribute query. |
int |
SetFeature(Feature feature)
Rewrite an existing feature. |
int |
SetNextByIndex(int new_index)
Move read cursor to the new_index'th feature in the current resultset. |
void |
SetSpatialFilter(Geometry filter)
Set a new spatial filter. |
void |
SetSpatialFilterRect(double minx,
double miny,
double maxx,
double maxy)
Set a new rectangular spatial filter. |
int |
StartTransaction()
For datasources which support transactions, StartTransaction creates a transaction. |
int |
SyncToDisk()
Flush pending changes to disk. |
boolean |
TestCapability(String cap)
Test if this layer supported the named capability. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void delete()
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public double[] GetExtent(boolean force)
Depending on the drivers, the returned extent may or may not take the spatial filter into account. So it is safer to call GetExtent() without setting a spatial filter.
Layers without any geometry may return a null value just indicating that no meaningful extents could be collected.
force
- Flag indicating whether the extent should be computed even
if it is expensive
public double[] GetExtent()
GetExtent(boolean force)
public int GetRefCount()
public void SetSpatialFilter(Geometry filter)
Currently this test is may be inaccurately implemented, but it is guaranteed that all features who's envelope (as returned by Geometry.getEnvelope()) overlaps the envelope of the spatial filter will be returned. This can result in more shapes being returned that should strictly be the case.
This method makes an internal copy of the passed geometry. The passed geometry remains the responsibility of the caller, and may be safely destroyed.
For the time being the passed filter geometry should be in the same SRS as the layer (as returned by GetSpatialRef()). In the future this may be generalized.
filter
- the geometry to use as a filtering region. null may
be passed indicating that the current spatial filter should be cleared,
but no new one instituted.public void SetSpatialFilterRect(double minx, double miny, double maxx, double maxy)
The x/y values should be in the same coordinate system as the layer as a whole (as returned by GetSpatialRef()). Internally this method is normally implemented as creating a 5 vertex closed rectangular polygon and passing it to SetSpatialFilter(). It exists as a convenience.
The only way to clear a spatial filter set with this method is to call SetSpatialFilter(null).
minx
- the minimum X coordinate for the rectangular region.miny
- the minimum Y coordinate for the rectangular region.maxx
- the maximum X coordinate for the rectangular region.maxy
- the maximum Y coordinate for the rectangular region.public Geometry GetSpatialFilter()
public int SetAttributeFilter(String filter_string)
The query string should be in the format of an SQL WHERE clause. For instance "population > 1000000 and population < 5000000" where population is an attribute in the layer. The query format is a restricted form of SQL WHERE clause as defined "eq_format=restricted_where" about half way through this document:
Proposal 6.2: Capabilities MetadataNote that installing a query string will generally result in resetting the current reading position (ala ResetReading()).
filter_string
- query in restricted SQL WHERE format, or null to clear the
current query.
public void ResetReading()
public String GetName()
public String GetGeometryColumn()
public String GetFIDColumn()
public Feature GetFeature(int fid)
If this method returns a non-null feature, it is guaranteed that its feature id (Feature.GetFID()) will be the same as fid.
Use Layer.TestCapability(ogr.OLCRandomRead) to establish if this layer supports efficient random access reading via GetFeature(); however, the call should always work if the feature exists as a fallback implementation just scans all the features in the layer looking for the desired feature.
Sequential reads are generally considered interrupted by a GetFeature() call.
The returned feature will be properly handled by the Java garbage collector, but you can help it by explicitely calling the Feature.delete() method.
fid
- the feature id of the feature to read.
public Feature GetNextFeature()
This method implements sequential access to the features of a layer. The ResetReading() method can be used to start at the beginning again.
The returned feature will be properly handled by the Java garbage collector, but you can help it by explicitely calling the Feature.delete() method.
public int SetNextByIndex(int new_index)
Only in rare circumstances is SetNextByIndex() efficiently implemented. In all other cases the default implementation which calls ResetReading() and then calls GetNextFeature() nIndex times is used. To determine if fast seeking is available on the current layer use the TestCapability() method with a value of OLCFastSetNextByIndex.
new_index
- the index indicating how many steps into the result set
to seek.
public int SetFeature(Feature feature)
Use Layer.TestCapability(ogr.OLCRandomWrite) to establish if this layer supports random access writing via SetFeature().
feature
- the feature to write.
CreateFeature(Feature)
public int CreateFeature(Feature feature)
feature
- the feature to write to disk.
SetFeature(Feature)
public int DeleteFeature(int fid)
fid
- the feature id to be deleted from the layer
public int SyncToDisk()
Some layers do not implement this method, and will still return 0. The default implementation just returns 0. An error is only returned if an error occurs while attempting to flush to disk.
public FeatureDefn GetLayerDefn()
public int GetFeatureCount(int force)
The returned count takes the spatial filter into account.
force
- Flag indicating whether the count should be computed even
if it is expensive.
public int GetFeatureCount()
GetFeatureCount(int force)
public int GetExtent(double[] extent, int force)
Depending on the drivers, the returned extent may or may not take the spatial filter into account. So it is safer to call GetExtent() without setting a spatial filter.
Layers without any geometry may throw a RuntimeException just indicating that no meaningful extents could be collected.
extent
- an allocated array of 4 doubles in which the extent value will be returned.force
- Flag indicating whether the extent should be computed even
if it is expensive (1 for true, 0 for false).
public boolean TestCapability(String cap)
cap
- the name of the capability to test.
public int CreateField(FieldDefn field_def, int approx_ok)
field_def
- field definition to write to disk.approx_ok
- If 1, the field may be created in a slightly different
form depending on the limitations of the format driver.
public int CreateField(FieldDefn field_def)
CreateField(FieldDefn field_def, int approx_ok)
public int StartTransaction()
public int CommitTransaction()
public int RollbackTransaction()
public SpatialReference GetSpatialRef()
public long GetFeaturesRead()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |