Monday, March 16, 2009

Our New Blogs

Hi All,

In a Proceess of dividing of our blogs in diffrent technologies. we have started creating the new blogs..

  • ArcGIS Programming

http://indiaarcgis.blogspot.com/

  • Autodesk Programming

http://autocadprogramming.blogspot.com/

  • Bentley Programming

Coming soon....

Keep visiting our blogs and don't forget to post your comments

Regards,


Wednesday, February 25, 2009

More GIS

Hi All,

we want to split this blog into different segments, like

1. AutoDesk programming.
2. ArcGIS Programming.
3. Oracle Spatial.
4. Bentley programming.

Please post your comments and requirements in these areas.

Thank You,

Saturday, January 24, 2009

FDO Oracle Spatial .net

Hi All,
Today we are going to tell you abour accessing the oracle spatial data using FDO in .net
make all necessary settings for FDO as we described in the previous post.
Here is the code..

private static IProviderRegistry FDORegistry = FeatureAccessManager.GetProviderRegistry();
private IConnectionManager FDOManager = FeatureAccessManager.GetConnectionManager();
ProviderCollection pcol = FDORegistry.GetProviders();
private IConnection FDOConnection = FeatureAccessManager.GetConnectionManager().CreateConnection("Autodesk.Oracle.3.3");


public ConnectionState Constate;
string featureclsname;

  • Connect to Oracle using following function.

public FDOOracleClass(string username,string password,string servicename,string featureclassname)
{
FDOConnection.ConnectionInfo.ConnectionProperties.SetProperty("USERNAME", username);
FDOConnection.ConnectionInfo.ConnectionProperties.SetProperty("PASSWORD", password);
FDOConnection.ConnectionInfo.ConnectionProperties.SetProperty("SERVICE", servicename);
FDOConnection.ConnectionInfo.ConnectionProperties.SetProperty("DATASTORE", username);

featureclsname = featureclassname;

Constate = FDOConnection.Open();
}

  • Check the Connection state
    public ConnectionState CheckConnected
    {
    get
    {
    return Constate;
    }
    }

  • By using this function we can retrive the Geometry and required attributes...
    public GeometryCollection SelectAllQuery()
    {
    GeometryCollection Geo_Collection = new GeometryCollection();
    try
    {
    ISelect sel = (ISelect)FDOConnection.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Select);
    sel.SetFeatureClassName(featureclsname);
    // sel.LockType = OSGeo.FDO.Commands.Locking.LockType.LockType_Unsupported;

    // select column_name,table_name from user_tab_columns where data_type = 'SDO_GEOMETRY'
    IFeatureReader FDOReader = sel.Execute();
    FgfGeometryFactory gFac = new FgfGeometryFactory();
    while (FDOReader.ReadNext())
    {
    int wauid = FDOReader.GetInt16("TEST1");// Attribute field 1
    int Infuid = FDOReader.GetInt16("TEST2"); // Attribute field 2
    Byte[] Tmppts = FDOReader.GetGeometry("GEOM"); // name of geometry column
    Geo_Collection.Add(gFac.CreateGeometryFromFgf(Tmppts));
    }
    }
    catch(OSGeo.FDO.Common.Exception ex)
    {
    MessageBox.Show(ex.Message.ToString());
    }
    return Geo_Collection;
    }

if u want to know how to manipluate the geometry Please post you comment.

Thank You,

Tuesday, January 13, 2009

FDO-Shape file .Net


Hi All,

Today we are going to tell, how to connect and retrive the shape file information through FDO using .net.

Download the latest version of FDO providers from internet.

Extract and copy the dll in to your local machine.

Open the visual studio .net 2005

Create new c# windows application project.

Right click on the references and add the following dlls to your project from FDO Bin folder





Create a new class say “FDOShapeFileClass”
Below we have shown the code connect and read the shape file geometry


public class FDOShapeFileClass:IDisposable

{
private IProviderRegistry FDORegistry = FeatureAccessManager.GetProviderRegistry();
private IConnectionManager FDOManager = FeatureAccessManager.GetConnectionManager();
private IConnection FDOConnection = FeatureAccessManager.GetConnectionManager().CreateConnection("OSGeo.SHP.3.3"); // Replace the version of DLL your using…
public string OpenedFile;
public ConnectionState Constate;
public FDOShapeFileClass(string _ShapeFile)
{
OpenedFile = _ShapeFile;
FDOConnection.ConnectionInfo.ConnectionProperties.SetProperty("DefaultFileLocation", _ShapeFile);
Constate = FDOConnection.Open();

}

// To check the connection state of the Shape file…

public ConnectionState CheckConnected
{
get
{
return Constate;
}
}



// By using below function we can retrive the all geometry in the shape file at once..
// this function will return the Geomtrycollection… of the shape file.


public GeometryCollection SelectAllQuery()
{
ISelect sel = (ISelect)FDOConnection.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Select);
sel.SetFeatureClassName(System.IO.Path.GetFileNameWithoutExtension(OpenedFile));

IFeatureReader FDOReader = sel.Execute();
GeometryCollection Geo_Collection = new GeometryCollection();
FgfGeometryFactory GeoFac = new FgfGeometryFactory();
while (FDOReader.ReadNext())
{

Byte[] Tmppts = FDOReader.GetGeometry("Geometry");

IGeometry Geo = GeoFac.CreateGeometryFromFgf(Tmppts);
Geo_Collection.Add((IGeometry)Geo);
}
return Geo_Collection;
}

// By using this function we can the extents of shape file in the form of ipolygon.

public IPolygon GetExtents()
{
IPolygon retpolygon;
ISelectAggregates pselagree = (ISelectAggregates)FDOConnection.CreateCommand(CommandType.CommandType_SelectAggregates);
pselagree.SetFeatureClassName(System.IO.Path.GetFileNameWithoutExtension(OpenedFile));

IdentifierCollection props = pselagree.PropertyNames;
Expression exp = Expression.Parse("SpatialExtents(Geometry)");
ComputedIdentifier se = new ComputedIdentifier("Extents", exp);

props.Add(se);

IDataReader FDOReader = pselagree.Execute();
FgfGeometryFactory GeoFac = new FgfGeometryFactory();

FDOReader.ReadNext();
Byte[] Tmppts = FDOReader.GetGeometry("Extents");

IGeometry Geo = GeoFac.CreateGeometryFromFgf(Tmppts);

retpolygon = (IPolygon)Geo;

return retpolygon;

}

// we will give this function in the next post…

public void UpdateQuery()
{
throw new System.NotImplementedException();
}

public void DeleteQuery()
{
throw new System.NotImplementedException();
}

public void Dispose()
{
Close();
FDORegistry.Dispose();
FDOManager.Dispose();
FDOConnection.Dispose();
}

private void Close()
{
FDOConnection.Close();
}


Based on your feedback in the next post we will tell you how to use this retrived geometry in to your application.


Thank You,

Monday, January 12, 2009

ObjectArx-FDO

Hi All,

we are back....

if anybody intrested to learn how to build ObjectARX application with FDO, we will help you throgh our blog..

Please post ur replies....

Thank You.