Provides access to members that create geometries from different inputs.
Members
Name | Description | |
---|---|---|
CreateEmptyGeometryByESRIType | Create an empty geometry of the specified Esri shape file type. | |
CreateEmptyGeometryByType | Creates an empty geometry of the specified ArcObjects geometry type. | |
CreateGeometry | Create a point, polyline, polygon, or multipoint from the specified shapefile format buffer. | |
CreateGeometryFromEnumerator | Creates a geometry bag containing references to geometries returned by the input geometry enumerator. | |
CreateGeometryFromWkb | Create a point, polyline, polygon, or multipoint from the specified OGIS WKB format buffer. | |
CreateGeometryFromWkbVariant | Create a point, polyline, polygon, or multipoint from the specified OGIS WKB format buffer. |
IGeometryFactory.CreateEmptyGeometryByESRIType Method
Create an empty geometry of the specified Esri shape file type.
Public Sub CreateEmptyGeometryByESRIType ( _
ByVal shapeType As esriShapeType, _
ByRef outGeometry As IGeometry _
)
public void CreateEmptyGeometryByESRIType (
esriShapeType shapeType,
ref IGeometry outGeometry
);
IGeometryFactory.CreateEmptyGeometryByType Method
Creates an empty geometry of the specified ArcObjects geometry type.
Public Sub CreateEmptyGeometryByType ( _
ByVal GeometryType As esriGeometryType, _
ByRef outGeometry As IGeometry _
)
public void CreateEmptyGeometryByType (
esriGeometryType GeometryType,
ref IGeometry outGeometry
);
IGeometryFactory.CreateGeometry Method
Create a point, polyline, polygon, or multipoint from the specified shapefile format buffer.
Public Sub CreateGeometry ( _
ByRef byteCountInOut As Integer, _
ByRef geometryInfo As Byte&, _
ByRef outGeometry As IGeometry _
)
public void CreateGeometry (
ref int byteCountInOut,
ref Byte& geometryInfo,
ref IGeometry outGeometry
);
IGeometryFactory.CreateGeometryFromEnumerator Method
Creates a geometry bag containing references to geometries returned by the input geometry enumerator.
Public Function CreateGeometryFromEnumerator ( _
ByVal geometries As IEnumGeometry _
) As IGeometry
public IGeometry CreateGeometryFromEnumerator (
IEnumGeometry geometries
);
IGeometryFactory.CreateGeometryFromWkb Method
Create a point, polyline, polygon, or multipoint from the specified OGIS WKB format buffer.
Public Sub CreateGeometryFromWkb ( _
ByRef byteCountInOut As Integer, _
ByRef geometryInfo As Byte&, _
ByRef outGeometry As IGeometry _
)
public void CreateGeometryFromWkb (
ref int byteCountInOut,
ref Byte& geometryInfo,
ref IGeometry outGeometry
);
IGeometryFactory.CreateGeometryFromWkbVariant Method
Create a point, polyline, polygon, or multipoint from the specified OGIS WKB format buffer.
Public Sub CreateGeometryFromWkbVariant ( _
ByVal wkb As Object, _
ByRef outGeometry As IGeometry, _
ByRef numBytesRead As Integer _
)
public void CreateGeometryFromWkbVariant (
object wkb,
ref IGeometry outGeometry,
ref int numBytesRead
);
private void CreateGeometryFromWkbVariant()
{
OleDbConnection connection = new OleDbConnection("Provider=ESRI.GeoDB.OLEDB.1;Data Source= C:\\basiceditdatabase.mdb;ExtendedProperties=workspacetype=esriDataSourcesGDB.AccessWorkspaceFactory.1;Geometry=WKB");
//create the command object with the sql query
OleDbCommand command = new OleDbCommand("select * from line_edit", connection);
try
{
connection.Open();
//create the datareader object to connect to table
OleDbDataReader reader = command.ExecuteReader();
//Iterate through the geodatabase and add new Geometries to to GeometryBag
IGeometryFactory2 factory = new GeometryEnvironmentClass();
IGeometryCollection geometryCollection = new GeometryBagClass();
IGeometry outGeometry;
int bytesRead;
object missing = Type.Missing;
while (reader.Read())
{
int shapeColumn = reader.GetOrdinal("SHAPE");
object byteArrayObject = reader.GetValue(shapeColumn);
//Re-create the geometry from the WKB data
factory.CreateGeometryFromWkbVariant(byteArrayObject, out outGeometry, out bytesRead);
if(outGeometry!= null)
{
//add the geometry to the geometryColection's end
geometryCollection.AddGeometry(outGeometry, ref missing, ref missing);
}
}
//don't forget to clean up
reader.Close();
connection.Close();
System.Windows.Forms.MessageBox.Show(geometryCollection.GeometryCount + " geomtries added");
}
//Some usual exception handling
catch (OleDbException e)
{
System.Windows.Forms.MessageBox.Show("Error: {0}", e.Errors[0].Message);
}
}
Dim pGFact As ESRI.ArcGIS.Geometry.IGeometryFactory
Dim pGeoEnv As ESRI.ArcGIS.Geometry.GeometryEnvironment
Dim pGeomCol As ESRI.ArcGIS.Geometry.IGeometryCollection
Dim pGeom As ESRI.ArcGIS.Geometry.IGeometry
Dim cBytesread As Long
Dim pEnvelope As ESRI.ArcGIS.Geometry.IEnvelope
Dim adors As ADODB.Recordset
Dim adocon As ADODB.Connection
Dim sConstring As String, sSQLstring As String
Dim WKBData As Object
pGeoEnv = New ESRI.ArcGIS.Geometry.GeometryEnvironment
pEnvelope = New ESRI.ArcGIS.Geometry.Envelope
pGFact = pGeoEnv
adors = New ADODB.Recordset
adocon = New ADODB.Connection
sConstring = "Provider=ESRI.GeoDB.OLEDB.1;" & "Data Source= d:\temp\us_states.mdb;" & "ExtendedProperties=workspacetype=esriDataSourcesGDB.AccessWorkspaceFactory.1;Geometry=WKB"
sSQLstring = "select * from us_states"
adocon.Open(sConstring)
adors.Open(sSQLstring, adocon, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic)
Do Until adors.EOF
pGeomCol = New ESRI.ArcGIS.Geometry.GeometryBag
WKBData = adors("Shape").Value
If IsNothing(WKBData) Then
adors.MoveNext()
Else
'++ Re-create the geometry from the WKB data
pGFact.CreateGeometryFromWkbVariant(WKBData, pGeom, cBytesread)
'++ Aggregate the geom envelopes
pEnvelope.Union(pGeom.Envelope)
pGeomCol.AddGeometry(pGeom)
adors.MoveNext()
End If
Loop
Classes that implement IGeometryFactory
Classes | Description |
---|---|
GeometryEnvironment | Provides a way of creating geometries from different inputs and setting/getting global variables for controlling behavior of geometry methods. |