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.

Tuesday, June 17, 2008

AutoCAD to CITYGML

Hi All,

CITYGML is the concept of publish the 3d Data on to the web.
we have written a AutoLISP program to convert the AutoCAD data to CITYGML format.
Inputs required for this tool.
Closed 3d polylines. with elevations updated.
Here is the code...
(Defun c:CityGML () (vl-load-com) (setq selset (ssget (list (cons 0 "polyline")))) (if selset (progn (setq xmlpath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "Dwgname")) ".xml")) (setq xmlfile (open xmlpath "w"))
(write-line (Strcat "") xmlfile)
(write-line (strcat "http://www.citygml.org/citygml/1/0/0" (chr 34) " xmlns:gml=" (chr 34) "http://www.opengis.net/gml" (chr 34) " xmlns:xlink=" (chr 34) "http://www.w3.org/1999/xlink" (chr 34) " xmlns:xsi=" (chr 34) "http://www.w3.org/2001/XMLSchema-instance" (chr 34) " xsi:schemaLocation=" (chr 34) "http://www.citygml.org/citygml/1/0/0 http://www.citygml.org/citygml/1/0/0/CityGML.xsd" (chr 34) ">") xmlfile) (write-line "City Exporeted by Infotech" xmlfile)
(setq count 0) (setq setlen (sslength selset)) (while (<>\n \n \n \n \n ") xmlfile) (foreach extval extlist (CityGML_Write_Func xmlfile extval) ) (write-line (Strcat " \n \n \n \n \n ") xmlfile) ) ) (setq count (1+ count)) ) (write-line "
" xmlfile) (close xmlfile) ) ))
;;; ! *************************************************************************************************************************************************************************
(defun CityGML_Write_Func (xmlfile lstvals )
(write-line (strcat " \n \n \n \n ") xmlfile)
(setq prntvals (mapcar '(lambda(x) (mapcar '(lambda (y) (rtos y)) x)) lstvals)) (setq retvals (INFO-LIST->STRING (mapcar '(lambda (x) (INFO-LIST->STRING x " ")) prntvals) " "))
(write-line (strcat "\n " retvals "") xmlfile)
(write-line "\n
\n
\n
\n
\n
" xmlfile) )
;;; ! *************************************************************************************************************************************************************************



;;; ! *************************************************************************************************************************************************************************
(defun Genrate_Extrude (Ent) (setq retlist '()) (setq ptlist (Info-GetVertices Ent))
(command "pline" ) (apply 'command ptlist) (command "c") (setq lent (entlast))
(setq chkflag (Lwcl lent)) (if chkflag (setq ptlist (reverse ptlist)) )
(command "erase" lent "")
(setq retlist (append retlist (list ptlist))) ;; Top of Extrude ;; bottom of extrude....
(setq botlist '())
(foreach pt ptlist (setq npt (list (car pt) (cadr pt) 0.0)) (setq botlist (append botlist (list npt))) ) (setq retlist (append retlist (list botlist))) ;; bottom complete... ;; sides of extrude....
(setq sidelist '()) (setq ctr 0) (while (< ctr (- (length ptlist) 1)) (setq xpt (nth ctr ptlist)) (setq ypt (nth (1+ ctr) ptlist)) (setq dummylist '()) (setq dummylist (list (list (car xpt) (cadr xpt) 0.0) (list (car ypt) (cadr ypt) 0.0) ypt xpt (list (car xpt) (cadr xpt) 0.0) ) ) (setq sidelist (append sidelist (list dummylist))) (setq ctr (1+ ctr)) ) (setq retlist (append retlist sidelist)))
;;; ! *************************************************************************************************************************************************************************
;;; To return the vertices of the given entity
(defun Info-GetVertices (enty)
(cond ((and enty (setq obj (vlax-ename->vla-object enty)))
(setq objName (vla-get-objectname obj))
(cond ((and (= objName "AcDb3dPolyline")
(Setq coors (vla-get-coordinates obj))
(setq coors (vlax-variant-value coors))
(setq coors (vlax-safearray->list coors))
)
(setq retlst (INFO-CREATELISTSFROMTHELISTOFVALUES coors 3))
)
((and (= objName "AcDbPolyline")
(Setq coors (vla-get-coordinates obj))
(setq coors (vlax-variant-value coors))
(setq coors (vlax-safearray->list coors))
)
(setq retlst (INFO-CREATELISTSFROMTHELISTOFVALUES coors 2))
)
((setq eprp (entget enty))
(setq retlst '())
(while (or (setq vertex (assoc 10 eprp)) (setq vertex (assoc 11 eprp)))
(setq coors (cdr vertex))
(if (not (member coors retlst))
(setq retlst (append retlst (list coors)))
)
(setq eprp (vl-remove vertex eprp))
)
)
)
)
)
retlst
)
;;; ! *************************************************************************************************************************************************************************

;;; To Create the Lists From the List of Values with Specified number of Values
(defun Info-CreateListsFromTheListOfValues (listofValues NumVals)
(setq retVal '())
(setq cntr 1)
(setq coor '())
(cond ((= (rem (length listofValues) NumVals) 0)
(repeat (length listofValues)
(cond ((= cntr NumVals) (setq cntr 1) (setq coor (append coor (list (nth 0 listofValues)))))
((< cntr NumVals) (setq cntr (1+ cntr)) (setq coor (append coor (list (nth 0 listofValues)))))
)
(cond ((= (length coor) NumVals)
(if (not retVal)
(setq retVal (list coor))
(setq retVal (append retVal (list coor)))
)
(setq coor '())
)
)
(Setq listofValues (Cdr listofValues))
)
)
)
retVal
)
;;; ! *************************************************************************************************************************************************************************
(defun Info-List->String (listofValues DelimChar) (if (not DelimChar) (setq DelimChar ",") ) (if (not (setq chkval (vl-remove 'STR (mapcar 'type listofValues)))) (if listofValues (vl-string-trim DelimChar (apply 'strcat (mapcar (function (lambda (x) (strcat x DelimChar))) listofValues)) ) ) ))
;;; ! *************************************************************************************************************************************************************************
(defun Lwcl (ent / LW LST MAXP MINP) ; Writer Evgeniy Elpanov. (setq lw (vlax-ename->vla-object ent)) (vla-GetBoundingBox lw 'MinP 'MaxP) (setq minp (vlax-safearray->list minp) MaxP (vlax-safearray->list MaxP) lst (mapcar (function (lambda (x) (vlax-curve-getParamAtPoint lw (vlax-curve-getClosestPointTo lw x) ) ;_ vlax-curve-getParamAtPoint ) ;_ lambda ) ;_ function (list minp (list (car minp) (cadr MaxP)) MaxP (list (car MaxP) (cadr minp)) ) ;_ list ) ;_ mapcar ) ;_ setq (if (or (<= (car lst) (cadr lst) (caddr lst) (cadddr lst)) (<= (cadr lst) (caddr lst) (cadddr lst) (car lst)) (<= (caddr lst) (cadddr lst) (car lst) (cadr lst)) (<= (cadddr lst) (car lst) (cadr lst) (caddr lst)) ) ;_ or t ) ;_ if) ;_ defun
;;; ! *************************************************************************************************************************************************************************


use this and update your comments

Regards,
GIS Programmers.



Wednesday, May 28, 2008

Oracle Georaster

Hi Friends,
Here are the simple steps to insert the Raster image into Oracle(Oracle Georaster).
  • Make object table

create table Landsat7 (id number,name varchar2(45),georaster sdo_georaster);

  • Make raster data table

CREATE TABLE Landsat7_RDT OF SDO_RASTER (PRIMARY KEY(RASTERID, PYRAMIDLEVEL, BANDBLOCKNUMBER,ROWBLOCKNUMBER, COLUMNBLOCKNUMBER))LOB(RASTERBLOCK) STORE AS (NOCACHE NOLOGGING);· execute CREATEDMLTRIGGER on table Landsat7o EXECUTE SDO_GEOR_UTL.CREATEDMLTRIGGER('Landsat7','GEORASTER');

  • Set permissions

call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tif', 'read' );o call dbms_java.grant_permission('GEOSPATIAL','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tif', 'read' );o call dbms_java.grant_permission('PUBLIC','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tif', 'read' );o call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tfw', 'read' );o call dbms_java.grant_permission('GEOSPATIAL','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tfw', 'read' );o call dbms_java.grant_permission('PUBLIC','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tfw', 'read' );

  • Insert in the landsat7 Object Table.

INSERT INTO Landsat7 VALUES(1,'p174r037',SDO_GEOR.INIT('Landsat7_RDT'));·

  • Insert Geotiff with world file. (make Sure that images should be copied into the server. i.e C: means server C: Drive)

Declare

geo SDO_GEORASTER;

BEGINSELECT GEORASTER INTO geo FROM Landsat7 WHERE ID=1 FOR UPDATE;SDO_GEOR.IMPORTFROM(geo,'blocksize=(512,512)','TIFF','file','C:\oracle\raster\georaster_table.tif','WORLDFILE','file','C:\oracle\raster\georaster_table.tfw');UPDATE Landsat7 SET GEORASTER = geo WHERE ID=1;END;/

  • set SRID to georaster (WGS84 UTM zone 36)

DECLARE

geo sdo_georaster;

BEGIN

SELECT georaster INTO geo FROM Landsat7 WHERE id=1 FOR UPDATE;sdo_geor.setModelSRID(geo, 32636);UPDATE Landsat7 SET georaster = geo WHERE id=1;

END;

  • Set Extend
UPDATE Landsat7 cSET c.georaster.spatialExtent = sdo_geor.generateSpatialExtent(georaster)WHERE c.id = 1;COMMIT;
  • Compute Pyramide

DECLARE

geo sdo_georaster;

BEGIN

SELECT georaster INTO geo from landsat7 where id = 1 FOR UPDATE;sdo_geor.generatePyramid(geo, 'rLevel=5, resampling=NN');UPDATE landsat7 SET georaster = geo where id = 1;

COMMIT;

END;

  • Check Data and Metadata.


select count(*) from Landsat7;
select count(*) from Landsat7_RDT;
set long 10000;
select a.georaster.metadata from Landsat7 a;
SELECT t.id, sdo_geor.validategeoraster(t.georaster) isvalid from Landsat7 t order by id;

format the above code and use it... please let us know if you need any help.

Regards,
GIS Programmers.